pkcs11 0.1.0-x86-mingw32

Sign up to get free protection for your applications and to get access to all the features.
data/.autotest ADDED
@@ -0,0 +1,23 @@
1
+ # -*- ruby -*-
2
+
3
+ require 'autotest/restart'
4
+
5
+ # Autotest.add_hook :initialize do |at|
6
+ # at.extra_files << "../some/external/dependency.rb"
7
+ #
8
+ # at.libs << ":../some/external"
9
+ #
10
+ # at.add_exception 'vendor'
11
+ #
12
+ # at.add_mapping(/dependency.rb/) do |f, _|
13
+ # at.files_matching(/test_.*rb$/)
14
+ # end
15
+ #
16
+ # %w(TestA TestB).each do |klass|
17
+ # at.extra_class_map[klass] = "test/test_misc.rb"
18
+ # end
19
+ # end
20
+
21
+ # Autotest.add_hook :run_command do |at|
22
+ # system "rake build"
23
+ # end
data/History.txt ADDED
@@ -0,0 +1,3 @@
1
+ === 0.1.0 / 2010-05-03
2
+
3
+ * first rubygem version
data/MIT-LICENSE ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2008 Ryosuke Kutsuna <ryosuke@deer-n-horse.jp>
2
+ Copyright (c) 2008 GOTOU Yuuzou <gotoyuzo@notwork.org>
3
+ Copyright (c) 2010 Lars Kanis <kanis@comcard.de>
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/Manifest.txt ADDED
@@ -0,0 +1,34 @@
1
+ .autotest
2
+ History.txt
3
+ MIT-LICENSE
4
+ Manifest.txt
5
+ README.rdoc
6
+ Rakefile
7
+ ext/extconf.rb
8
+ ext/include/cryptoki.h
9
+ ext/include/ct-kip.h
10
+ ext/include/otp-pkcs11.h
11
+ ext/include/pkcs-11v2-20a3.h
12
+ ext/include/pkcs11.h
13
+ ext/include/pkcs11f.h
14
+ ext/include/pkcs11t.h
15
+ ext/pk11.c
16
+ ext/pk11.h
17
+ ext/pk11_const.c
18
+ lib/pkcs11.rb
19
+ lib/pkcs11/extensions.rb
20
+ lib/pkcs11/library.rb
21
+ lib/pkcs11/object.rb
22
+ lib/pkcs11/session.rb
23
+ lib/pkcs11/slot.rb
24
+ sample/firefox_certs.rb
25
+ sample/nssckbi.rb
26
+ test/fixtures/softokn/cert8.db
27
+ test/fixtures/softokn/key3.db
28
+ test/fixtures/softokn/secmod.db
29
+ test/helper.rb
30
+ test/test_pkcs11.rb
31
+ test/test_pkcs11_crypt.rb
32
+ test/test_pkcs11_object.rb
33
+ test/test_pkcs11_session.rb
34
+ test/test_pkcs11_slot.rb
data/README.rdoc ADDED
@@ -0,0 +1,156 @@
1
+ = PKCS #11/Ruby Interface
2
+
3
+ * Homepage: http://github.com/larskanis/pkcs11
4
+ * older SVN repository: http://coderepos.org/share/log/lang/ruby/pkcs11-ruby
5
+ * API documentation: http://pkcs11.rubyforge.org/pkcs11/
6
+
7
+ This module allows Ruby programs to interface with "RSA Security Inc.
8
+ PKCS #11 Cryptographic Token Interface (Cryptoki)".
9
+ PKCS #11 is the de-facto standard to access cryptographic devices.
10
+ You must have the PKCS #11 v2.20 implementation library installed in
11
+ order to use this module. Tested implementations of PKCS#11 librarys
12
+ include:
13
+ * OpenSC[http://www.opensc-project.org] supported Smart Cards
14
+ * Safenet[http://www.safenet-inc.com] - Protect Server HSMs
15
+ * Mozilla_Soft_Token[https://developer.mozilla.org/en/PKCS11] which comes with every firefox installation
16
+
17
+ This module works on the Unix like operating systems and win32.
18
+
19
+ == Installation
20
+
21
+ gem install pkcs11
22
+
23
+
24
+ == Usage
25
+ Cryptoki has a reputation to be complicated to implement and use.
26
+ While this seems to be true for C it isn't for Ruby.
27
+
28
+ PKCS11.open requires suitable PKCS #11 implementation as UN*X *.so file or Windows-DLL.
29
+
30
+ require "rubygems"
31
+ require "pkcs11"
32
+ include PKCS11
33
+
34
+ pkcs11 = PKCS11.open("/path/to/pkcs11.so")
35
+ p pkcs11.info
36
+ slot = pkcs11.active_slots.first
37
+ session = slot.open
38
+ session.login(:USER, "1234")
39
+ ...
40
+ session.logout
41
+ session.close
42
+
43
+ See PKCS11::Library for API documentation. See unit tests in the <tt>test</tt>
44
+ directory of the project or gem for further examples of the usage.
45
+
46
+ Detail information for the API specification is provided by RSA Security Inc.
47
+ Please refer the URL: http://www.rsa.com/rsalabs/node.asp?id=2133.
48
+
49
+
50
+ == Cross compiling for mswin32
51
+
52
+ Using rake-compiler a cross compiled pkcs11-gem can be build on a linux host for
53
+ the win32 platform. There are no runtime dependencies to any but the standard Windows DLLs.
54
+
55
+ Install mingw32. On a debian based system this should work:
56
+
57
+ apt-get install mingw32
58
+
59
+ On MacOS X, if you have MacPorts installed:
60
+
61
+ port install i386-mingw32-gcc
62
+
63
+ Install the rake-compiler:
64
+
65
+ gem install rake-compiler
66
+
67
+ Download and cross compile ruby for win32:
68
+
69
+ rake-compiler cross-ruby VERSION=1.8.6-p287
70
+
71
+ Download and cross compile pkcs11 for win32:
72
+
73
+ rake cross native gem
74
+
75
+ If everything works, there should be pkcs11-VERSION-x86-mswin32.gem in the pkg
76
+ directory.
77
+
78
+
79
+ == ToDo
80
+
81
+ * unit testing (with mozilla softoken)
82
+ * implement all functions/structs
83
+ * sample code
84
+
85
+ == Development Status
86
+
87
+ STATE FUNCTION NOTE
88
+ ------ --------------------- ----------------------------------------
89
+ N/A C_Initialize called in PKCS11#initialize("/path/to/pk11lib")
90
+ DONE C_Finalize called in GC
91
+ DONE C_GetInfo
92
+ N/A C_GetFunctionList internal use only
93
+ DONE C_GetSlotList
94
+ DONE C_GetSlotInfo
95
+ DONE C_GetTokenInfo
96
+ DONE C_GetMechanismList
97
+ DONE C_GetMechanismInfo
98
+ DONE C_InitToken
99
+ DONE C_InitPIN
100
+ DONE C_SetPIN
101
+ DONE C_OpenSession
102
+ DONE C_CloseSession
103
+ DONE C_CloseAllSessions
104
+ DONE C_GetSessionInfo
105
+ DONE C_GetOperationState
106
+ DONE C_SetOperationState
107
+ DONE C_Login
108
+ DONE C_Logout
109
+ DONE C_CreateObject
110
+ N/A C_CopyObject use C_GetAttributeValue and C_CreateObject
111
+ DONE C_DestroyObject
112
+ DONE C_GetObjectSize
113
+ DONE C_GetAttributeValue
114
+ DONE C_SetAttributeValue
115
+ DONE C_FindObjectsInit
116
+ DONE C_FindObjects
117
+ DONE C_FindObjectsFinal
118
+ DONE C_EncryptInit
119
+ DONE C_Encrypt
120
+ DONE C_EncryptUpdate
121
+ DONE C_EncryptFinal
122
+ DONE C_DecryptInit
123
+ DONE C_Decrypt
124
+ DONE C_DecryptUpdate
125
+ DONE C_DecryptFinal
126
+ DONE C_DigestInit
127
+ DONE C_Digest
128
+ DONE C_DigestUpdate
129
+ DONE C_DigestKey
130
+ DONE C_DigestFinal
131
+ DONE C_SignInit
132
+ DONE C_Sign
133
+ DONE C_SignUpdate
134
+ DONE C_SignFinal
135
+ DONE C_SignRecoverInit
136
+ DONE C_SignRecover
137
+ DONE C_VerifyInit
138
+ DONE C_Verify
139
+ DONE C_VerifyUpdate
140
+ DONE C_VerifyFinal
141
+ DONE C_VerifyRecoverInit
142
+ DONE C_VerifyRecover
143
+ DONE C_DigestEncryptUpdate
144
+ DONE C_DecryptDigestUpdate
145
+ DONE C_SignEncryptUpdate
146
+ DONE C_DecryptVerifyUpdate
147
+ DONE C_GenerateKey
148
+ DONE C_GenerateKeyPair
149
+ DONE C_WrapKey
150
+ DONE C_UnwrapKey
151
+ DONE C_DeriveKey
152
+ DONE C_SeedRandom
153
+ DONE C_GenerateRandom
154
+ N/A C_GetFunctionStatus legacy function
155
+ N/A C_CancelFunction legacy function
156
+ DONE C_WaitForSlotEvent
data/Rakefile ADDED
@@ -0,0 +1,36 @@
1
+ # -*- coding: utf-8 -*-
2
+ # -*- ruby -*-
3
+
4
+ require 'rubygems'
5
+ require 'hoe'
6
+ require 'rake/extensiontask'
7
+
8
+ hoe = Hoe.spec 'pkcs11' do
9
+ developer('Ryosuke Kutsuna', 'ryosuke@deer-n-horse.jp')
10
+ developer('GOTOU Yuuzou', 'gotoyuzo@notwork.org')
11
+ developer('Lars Kanis', 'kanis@comcard.de')
12
+ self.url = 'http://github.com/larskanis/pkcs11'
13
+
14
+ self.readme_file = 'README.rdoc'
15
+ self.extra_rdoc_files << self.readme_file << 'ext/pk11.c'
16
+ spec_extras[:extensions] = 'ext/extconf.rb'
17
+ end
18
+
19
+ ENV['RUBY_CC_VERSION'] = '1.8.6:1.9.1'
20
+
21
+ Rake::ExtensionTask.new('pkcs11_ext', hoe.spec) do |ext|
22
+ ext.ext_dir = 'ext'
23
+ ext.cross_compile = true # enable cross compilation (requires cross compile toolchain)
24
+ ext.cross_platform = ['i386-mswin32', 'i386-mingw32'] # forces the Windows platform instead of the default one
25
+ end
26
+
27
+ # RDoc-upload task for github (currently on rubyforge)
28
+ #
29
+ # require 'grancher/task'
30
+ # Grancher::Task.new do |g|
31
+ # g.branch = 'gh-pages' # alternatively, g.refspec = 'ghpages:/refs/heads/ghpages'
32
+ # g.push_to = 'origin'
33
+ # g.directory 'doc'
34
+ # end
35
+
36
+ # vim: syntax=ruby
data/ext/extconf.rb ADDED
@@ -0,0 +1,6 @@
1
+ require "mkmf"
2
+
3
+ basedir = File.dirname(__FILE__)
4
+ $CPPFLAGS += " -I \"#{basedir}/include\""
5
+ have_func("rb_str_set_len")
6
+ create_makefile("pkcs11_ext");
@@ -0,0 +1,66 @@
1
+ /* cryptoki.h include file for PKCS #11. */
2
+ /* $Revision: 1.4 $ */
3
+
4
+ /* License to copy and use this software is granted provided that it is
5
+ * identified as "RSA Security Inc. PKCS #11 Cryptographic Token Interface
6
+ * (Cryptoki)" in all material mentioning or referencing this software.
7
+
8
+ * License is also granted to make and use derivative works provided that
9
+ * such works are identified as "derived from the RSA Security Inc. PKCS #11
10
+ * Cryptographic Token Interface (Cryptoki)" in all material mentioning or
11
+ * referencing the derived work.
12
+
13
+ * RSA Security Inc. makes no representations concerning either the
14
+ * merchantability of this software or the suitability of this software for
15
+ * any particular purpose. It is provided "as is" without express or implied
16
+ * warranty of any kind.
17
+ */
18
+
19
+ /* This is a sample file containing the top level include directives
20
+ * for building Win32 Cryptoki libraries and applications.
21
+ */
22
+
23
+ #ifndef ___CRYPTOKI_H_INC___
24
+ #define ___CRYPTOKI_H_INC___
25
+
26
+ #pragma pack(push, cryptoki, 1)
27
+
28
+ /* Specifies that the function is a DLL entry point. */
29
+ #define CK_IMPORT_SPEC __declspec(dllimport)
30
+
31
+ /* Define CRYPTOKI_EXPORTS during the build of cryptoki libraries. Do
32
+ * not define it in applications.
33
+ */
34
+ #ifdef CRYPTOKI_EXPORTS
35
+ /* Specified that the function is an exported DLL entry point. */
36
+ #define CK_EXPORT_SPEC __declspec(dllexport)
37
+ #else
38
+ #define CK_EXPORT_SPEC CK_IMPORT_SPEC
39
+ #endif
40
+
41
+ /* Ensures the calling convention for Win32 builds */
42
+ #define CK_CALL_SPEC __cdecl
43
+
44
+ #define CK_PTR *
45
+
46
+ #define CK_DEFINE_FUNCTION(returnType, name) \
47
+ returnType CK_EXPORT_SPEC CK_CALL_SPEC name
48
+
49
+ #define CK_DECLARE_FUNCTION(returnType, name) \
50
+ returnType CK_EXPORT_SPEC CK_CALL_SPEC name
51
+
52
+ #define CK_DECLARE_FUNCTION_POINTER(returnType, name) \
53
+ returnType CK_IMPORT_SPEC (CK_CALL_SPEC CK_PTR name)
54
+
55
+ #define CK_CALLBACK_FUNCTION(returnType, name) \
56
+ returnType (CK_CALL_SPEC CK_PTR name)
57
+
58
+ #ifndef NULL_PTR
59
+ #define NULL_PTR 0
60
+ #endif
61
+
62
+ #include "pkcs11.h"
63
+
64
+ #pragma pack(pop, cryptoki)
65
+
66
+ #endif /* ___CRYPTOKI_H_INC___ */
@@ -0,0 +1,50 @@
1
+ /* ct-kip.h include file for the PKCS #11 Mechanisms for the
2
+ * Cryptographic Token Key Initialization Protocol OTPS document.
3
+ */
4
+
5
+ /* $Revision: 1.3 $ */
6
+
7
+ /* License to copy and use this software is granted provided that it is
8
+ * identified as "RSA Security Inc. Cryptographic Token Key Initialization
9
+ * Protocol (CT-KIP)" in all material mentioning or referencing this software.
10
+
11
+ * RSA Security Inc. makes no representations concerning either the
12
+ * merchantability of this software or the suitability of this software for
13
+ * any particular purpose. It is provided "as is" without express or implied
14
+ * warranty of any kind.
15
+ */
16
+
17
+ /* This file is preferably included after inclusion of pkcs11.h */
18
+
19
+ #ifndef _CT_KIP_H_
20
+ #define _CT_KIP_H_ 1
21
+
22
+ /* Are the definitions of this file already included in pkcs11t.h? */
23
+ #ifndef CKM_KIP_DERIVE
24
+
25
+ #ifdef __cplusplus
26
+ extern "C" {
27
+ #endif
28
+
29
+ /* Mechanism Identifiers */
30
+ #define CKM_KIP_DERIVE 0x00000510
31
+ #define CKM_KIP_WRAP 0x00000511
32
+ #define CKM_KIP_MAC 0x00000512
33
+
34
+ /* Structures */
35
+ typedef struct CK_KIP_PARAMS {
36
+ CK_MECHANISM_PTR pMechanism;
37
+ CK_OBJECT_HANDLE hKey;
38
+ CK_BYTE_PTR pSeed;
39
+ CK_ULONG ulSeedLen;
40
+ } CK_KIP_PARAMS;
41
+
42
+ typedef CK_KIP_PARAMS CK_PTR CK_KIP_PARAMS_PTR;
43
+
44
+ #ifdef __cplusplus
45
+ }
46
+ #endif
47
+
48
+ #endif
49
+
50
+ #endif
@@ -0,0 +1,125 @@
1
+ /* otp-pkcs11.h include file for the PKCS #11 Mechanisms for One-Time
2
+ Password Tokens OTPS document. */
3
+ /* $Revision: 1.6 $ */
4
+
5
+ /* License to copy and use this software is granted provided that it is
6
+ * identified as "RSA Security Inc. PKCS #11 Mechanisms for One-Time
7
+ * Password Tokens" in all material mentioning or referencing this software.
8
+ *
9
+ * RSA Security Inc. makes no representations concerning either the
10
+ * merchantability of this software or the suitability of this software for
11
+ * any particular purpose. It is provided "as is" without express or implied
12
+ * warranty of any kind.
13
+ */
14
+
15
+ /* This file is preferably included after inclusion of pkcs11.h */
16
+
17
+ #ifndef _OTP_PKCS11_H_
18
+ #define _OTP_PKCS11_H_ 1
19
+
20
+ /* Are the definitions of this file already included in pkcs11t.h? */
21
+ #ifndef CKO_OTP_KEY
22
+
23
+ #ifdef __cplusplus
24
+ extern "C" {
25
+ #endif
26
+
27
+ /* A.1 Object classes */
28
+ #define CKO_OTP_KEY 0x00000008
29
+
30
+ /* A.2 Key types */
31
+ #define CKK_SECURID 0x00000022
32
+ #define CKK_HOTP 0x00000023
33
+ #define CKK_ACTI 0x00000024
34
+
35
+ /* A.3 Mechanisms */
36
+ #define CKM_SECURID_KEY_GEN 0x00000280
37
+ #define CKM_SECURID 0x00000282
38
+ #define CKM_HOTP_KEY_GEN 0x00000290
39
+ #define CKM_HOTP 0x00000291
40
+ #define CKM_ACTI 0x000002A0
41
+ #define CKM_ACTI_KEY_GEN 0x000002A1
42
+
43
+ /* A.4 Attributes */
44
+ #define CKA_OTP_FORMAT 0x00000220
45
+ #define CKA_OTP_LENGTH 0x00000221
46
+ #define CKA_OTP_TIME_INTERVAL 0x00000222
47
+ #define CKA_OTP_USER_FRIENDLY_MODE 0x00000223
48
+ #define CKA_OTP_CHALLENGE_REQUIREMENT 0x00000224
49
+ #define CKA_OTP_TIME_REQUIREMENT 0x00000225
50
+ #define CKA_OTP_COUNTER_REQUIREMENT 0x00000226
51
+ #define CKA_OTP_PIN_REQUIREMENT 0x00000227
52
+ #define CKA_OTP_COUNTER 0x0000022E
53
+ #define CKA_OTP_TIME 0x0000022F
54
+ #define CKA_OTP_USER_IDENTIFIER 0x0000022A
55
+ #define CKA_OTP_SERVICE_IDENTIFIER 0x0000022B
56
+ #define CKA_OTP_SERVICE_LOGO 0x0000022C
57
+ #define CKA_OTP_SERVICE_LOGO_TYPE 0x0000022D
58
+
59
+ /* A.5 Attribute constants */
60
+ #define CK_OTP_FORMAT_DECIMAL 0
61
+ #define CK_OTP_FORMAT_HEXADECIMAL 1
62
+ #define CK_OTP_FORMAT_ALPHANUMERIC 2
63
+ #define CK_OTP_FORMAT_BINARY 3
64
+
65
+ #define CK_OTP_PARAM_IGNORED 0
66
+ #define CK_OTP_PARAM_OPTIONAL 1
67
+ #define CK_OTP_PARAM_MANDATORY 2
68
+
69
+ /* A.6 Other constants */
70
+ #define CK_OTP_VALUE 0
71
+ #define CK_OTP_PIN 1
72
+ #define CK_OTP_CHALLENGE 2
73
+ #define CK_OTP_TIME 3
74
+ #define CK_OTP_COUNTER 4
75
+ #define CK_OTP_FLAGS 5
76
+ #define CK_OTP_OUTPUT_LENGTH 6
77
+ #define CK_OTP_OUTPUT_FORMAT 7
78
+
79
+ #define CKF_NEXT_OTP 0x00000001
80
+ #define CKF_EXCLUDE_TIME 0x00000002
81
+ #define CKF_EXCLUDE_COUNTER 0x00000004
82
+ #define CKF_EXCLUDE_CHALLENGE 0x00000008
83
+ #define CKF_EXCLUDE_PIN 0x00000010
84
+ #define CKF_USER_FRIENDLY_OTP 0x00000020
85
+
86
+ /* A.7 Notifications */
87
+ #define CKN_OTP_CHANGED 1
88
+
89
+ /* A.8 Return values */
90
+ #define CKR_NEW_PIN_MODE 0x000001B0
91
+ #define CKR_NEXT_OTP 0x000001B1
92
+
93
+ /* Structs */
94
+ typedef CK_ULONG CK_OTP_PARAM_TYPE;
95
+ typedef CK_OTP_PARAM_TYPE CK_PARAM_TYPE; /* B/w compatibility */
96
+
97
+ typedef struct CK_OTP_PARAM {
98
+ CK_OTP_PARAM_TYPE type;
99
+ CK_VOID_PTR pValue;
100
+ CK_ULONG ulValueLen;
101
+ } CK_OTP_PARAM;
102
+
103
+ typedef CK_OTP_PARAM CK_PTR CK_OTP_PARAM_PTR;
104
+
105
+ typedef struct CK_OTP_PARAMS {
106
+ CK_OTP_PARAM_PTR pParams;
107
+ CK_ULONG ulCount;
108
+ } CK_OTP_PARAMS;
109
+
110
+ typedef CK_OTP_PARAMS CK_PTR CK_OTP_PARAMS_PTR;
111
+
112
+ typedef struct CK_OTP_SIGNATURE_INFO {
113
+ CK_OTP_PARAM_PTR pParams;
114
+ CK_ULONG ulCount;
115
+ } CK_OTP_SIGNATURE_INFO;
116
+
117
+ typedef CK_OTP_SIGNATURE_INFO CK_PTR CK_OTP_SIGNATURE_INFO_PTR;
118
+
119
+ #ifdef __cplusplus
120
+ }
121
+ #endif
122
+
123
+ #endif
124
+
125
+ #endif