pkcs11 0.2.0-x86-mswin32 → 0.2.1-x86-mswin32
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/.yardopts +1 -2
- data/History.txt +10 -0
- data/Manifest.txt +3 -0
- data/README.rdoc +31 -14
- data/Rakefile +6 -3
- data/ext/generate_constants.rb +57 -0
- data/ext/generate_structs.rb +173 -136
- data/ext/pk11.c +40 -367
- data/ext/pk11_const.c +205 -229
- data/ext/pk11_const_macros.h +37 -0
- data/ext/pk11_struct_def.inc +80 -82
- data/ext/pk11_struct_impl.inc +82 -84
- data/ext/pk11_struct_macros.h +423 -0
- data/lib/1.8/pkcs11_ext.so +0 -0
- data/lib/1.9/pkcs11_ext.so +0 -0
- data/lib/pkcs11/helper.rb +0 -9
- data/lib/pkcs11/slot.rb +1 -1
- data/test/test_pkcs11_crypt.rb +18 -1
- data/test/test_pkcs11_slot.rb +10 -1
- data/test/test_pkcs11_structs.rb +23 -4
- metadata +62 -25
data/test/test_pkcs11_crypt.rb
CHANGED
@@ -42,7 +42,7 @@ class TestPkcs11Crypt < Test::Unit::TestCase
|
|
42
42
|
$pkcs11
|
43
43
|
end
|
44
44
|
|
45
|
-
def
|
45
|
+
def test_endecrypt_rsa
|
46
46
|
plaintext1 = "secret text"
|
47
47
|
cryptogram = session.encrypt( :RSA_PKCS, rsa_pub_key, plaintext1)
|
48
48
|
assert cryptogram.length>10, 'The cryptogram should contain some data'
|
@@ -52,6 +52,23 @@ class TestPkcs11Crypt < Test::Unit::TestCase
|
|
52
52
|
assert_equal plaintext1, plaintext2, 'Decrypted plaintext should be the same'
|
53
53
|
end
|
54
54
|
|
55
|
+
def test_endecrypt_des
|
56
|
+
plaintext1 = "secret message "
|
57
|
+
cryptogram = session.encrypt( {:DES3_CBC_PAD=>"\0"*8}, secret_key, plaintext1)
|
58
|
+
assert_equal 16, cryptogram.length, 'The cryptogram should contain some data'
|
59
|
+
assert_not_equal cryptogram, plaintext1, 'The cryptogram should be different to plaintext'
|
60
|
+
|
61
|
+
cryptogram2 = ''
|
62
|
+
cryptogram2 << session.encrypt( {:DES3_CBC_PAD=>"\0"*8}, secret_key ) do |cipher|
|
63
|
+
cryptogram2 << cipher.update(plaintext1[0, 8])
|
64
|
+
cryptogram2 << cipher.update(plaintext1[8..-1])
|
65
|
+
end
|
66
|
+
assert_equal cryptogram, cryptogram2, "Encrypt with and w/o block should be lead to the same result"
|
67
|
+
|
68
|
+
plaintext2 = session.decrypt( {:DES3_CBC_PAD=>"\0"*8}, secret_key, cryptogram)
|
69
|
+
assert_equal plaintext1, plaintext2, 'Decrypted plaintext should be the same'
|
70
|
+
end
|
71
|
+
|
55
72
|
def test_sign_verify
|
56
73
|
plaintext = "important text"
|
57
74
|
signature = session.sign( :SHA1_RSA_PKCS, rsa_priv_key, plaintext)
|
data/test/test_pkcs11_slot.rb
CHANGED
@@ -44,11 +44,20 @@ class TestPkcs11Slot < Test::Unit::TestCase
|
|
44
44
|
assert_equal false, slot.mechanisms.empty?, 'There should be some mechanisms'
|
45
45
|
slot.mechanisms.each do |m|
|
46
46
|
info = slot.mechanism_info(m)
|
47
|
-
assert_equal CK_MECHANISM_INFO, info.class, 'Mechanism info should a CK_MECHANISM_INFO'
|
47
|
+
assert_equal CK_MECHANISM_INFO, info.class, 'Mechanism info should get a CK_MECHANISM_INFO'
|
48
48
|
assert info.inspect =~ /ulMaxKeySize=/, 'Mechanism info should tell about max key size'
|
49
49
|
end
|
50
50
|
end
|
51
51
|
|
52
|
+
def test_mechanism_info
|
53
|
+
info1 = slot.mechanism_info(:DES3_CBC)
|
54
|
+
assert_equal CK_MECHANISM_INFO, info1.class, 'Mechanism info should get a CK_MECHANISM_INFO'
|
55
|
+
assert info1.inspect =~ /ulMinKeySize=/, 'Mechanism info should tell about min key size'
|
56
|
+
|
57
|
+
info2 = slot.mechanism_info(CKM_DES3_CBC)
|
58
|
+
assert_equal info1.to_hash, info2.to_hash, 'Mechanism infos should be equal'
|
59
|
+
end
|
60
|
+
|
52
61
|
def test_session
|
53
62
|
flags = CKF_SERIAL_SESSION #| CKF_RW_SESSION
|
54
63
|
session = slot.open(flags){|_session|
|
data/test/test_pkcs11_structs.rb
CHANGED
@@ -4,7 +4,7 @@ require "test/helper"
|
|
4
4
|
|
5
5
|
class TestPkcs11Structs < Test::Unit::TestCase
|
6
6
|
include PKCS11
|
7
|
-
|
7
|
+
|
8
8
|
def setup
|
9
9
|
end
|
10
10
|
|
@@ -98,7 +98,7 @@ class TestPkcs11Structs < Test::Unit::TestCase
|
|
98
98
|
s.pServerRandom = nil
|
99
99
|
assert_nil s.pServerRandom
|
100
100
|
end
|
101
|
-
|
101
|
+
|
102
102
|
def test_STRUCT_PTR_ACCESSOR
|
103
103
|
s = CK_SSL3_KEY_MAT_PARAMS.new
|
104
104
|
assert_nil s.pReturnedKeyMaterial
|
@@ -122,13 +122,32 @@ class TestPkcs11Structs < Test::Unit::TestCase
|
|
122
122
|
assert_nil s.pulOutputLen
|
123
123
|
end
|
124
124
|
|
125
|
+
def test_STRUCT_ARRAY_ACCESSOR
|
126
|
+
s = CK_OTP_PARAMS.new
|
127
|
+
assert_equal [], s.pParams
|
128
|
+
s1 = CK_OTP_PARAM.new
|
129
|
+
s1.type = CK_OTP_VALUE
|
130
|
+
s1.pValue = "\0xyz"
|
131
|
+
s2 = CK_OTP_PARAM.new
|
132
|
+
s2.type = CK_OTP_PIN
|
133
|
+
s2.pValue = "1234"
|
134
|
+
s.pParams = [s1, s2]
|
135
|
+
assert_equal [s1.to_hash, s2.to_hash], s.pParams.map{|e| e.to_hash }
|
136
|
+
GC.start
|
137
|
+
assert_raise(ArgumentError){ s.pParams = [s1, s2, nil] }
|
138
|
+
assert_equal [s1.to_hash, s2.to_hash], s.pParams.map{|e| e.to_hash }
|
139
|
+
|
140
|
+
s.pParams = []
|
141
|
+
assert_equal [], s.pParams
|
142
|
+
end
|
143
|
+
|
125
144
|
def test_CStruct
|
126
145
|
s = CK_DATE.new
|
127
146
|
s.day, s.month, s.year = "31", "12", "2010"
|
128
147
|
|
129
148
|
assert s.inspect =~ /year="2010"/, 'There should be a year in CK_DATE'
|
130
|
-
assert_equal ["
|
131
|
-
assert_equal ["
|
149
|
+
assert_equal ["year", "month", "day"], s.members, 'CK_DATE should contain some attributes'
|
150
|
+
assert_equal ["2010", "12", "31"], s.values, 'values of CK_DATE'
|
132
151
|
assert_equal( {:day=>"31", :month=>"12", :year=>"2010"}, s.to_hash, 'CK_DATE as hash' )
|
133
152
|
end
|
134
153
|
end
|
metadata
CHANGED
@@ -1,7 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: pkcs11
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
|
4
|
+
hash: 21
|
5
|
+
prerelease:
|
6
|
+
segments:
|
7
|
+
- 0
|
8
|
+
- 2
|
9
|
+
- 1
|
10
|
+
version: 0.2.1
|
5
11
|
platform: x86-mswin32
|
6
12
|
authors:
|
7
13
|
- Ryosuke Kutsuna
|
@@ -11,49 +17,71 @@ autorequire:
|
|
11
17
|
bindir: bin
|
12
18
|
cert_chain: []
|
13
19
|
|
14
|
-
date: 2011-
|
20
|
+
date: 2011-04-20 00:00:00 +02:00
|
15
21
|
default_executable:
|
16
22
|
dependencies:
|
17
23
|
- !ruby/object:Gem::Dependency
|
18
24
|
name: rubyforge
|
19
|
-
|
20
|
-
|
21
|
-
|
25
|
+
prerelease: false
|
26
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
27
|
+
none: false
|
22
28
|
requirements:
|
23
29
|
- - ">="
|
24
30
|
- !ruby/object:Gem::Version
|
31
|
+
hash: 7
|
32
|
+
segments:
|
33
|
+
- 2
|
34
|
+
- 0
|
35
|
+
- 4
|
25
36
|
version: 2.0.4
|
26
|
-
|
37
|
+
type: :development
|
38
|
+
version_requirements: *id001
|
27
39
|
- !ruby/object:Gem::Dependency
|
28
40
|
name: yard
|
29
|
-
|
30
|
-
|
31
|
-
|
41
|
+
prerelease: false
|
42
|
+
requirement: &id002 !ruby/object:Gem::Requirement
|
43
|
+
none: false
|
32
44
|
requirements:
|
33
45
|
- - ">="
|
34
46
|
- !ruby/object:Gem::Version
|
47
|
+
hash: 7
|
48
|
+
segments:
|
49
|
+
- 0
|
50
|
+
- 6
|
35
51
|
version: "0.6"
|
36
|
-
|
52
|
+
type: :development
|
53
|
+
version_requirements: *id002
|
37
54
|
- !ruby/object:Gem::Dependency
|
38
55
|
name: rake-compiler
|
39
|
-
|
40
|
-
|
41
|
-
|
56
|
+
prerelease: false
|
57
|
+
requirement: &id003 !ruby/object:Gem::Requirement
|
58
|
+
none: false
|
42
59
|
requirements:
|
43
60
|
- - ">="
|
44
61
|
- !ruby/object:Gem::Version
|
62
|
+
hash: 5
|
63
|
+
segments:
|
64
|
+
- 0
|
65
|
+
- 7
|
45
66
|
version: "0.7"
|
46
|
-
|
67
|
+
type: :development
|
68
|
+
version_requirements: *id003
|
47
69
|
- !ruby/object:Gem::Dependency
|
48
70
|
name: hoe
|
49
|
-
|
50
|
-
|
51
|
-
|
71
|
+
prerelease: false
|
72
|
+
requirement: &id004 !ruby/object:Gem::Requirement
|
73
|
+
none: false
|
52
74
|
requirements:
|
53
75
|
- - ">="
|
54
76
|
- !ruby/object:Gem::Version
|
55
|
-
|
56
|
-
|
77
|
+
hash: 19
|
78
|
+
segments:
|
79
|
+
- 2
|
80
|
+
- 7
|
81
|
+
- 0
|
82
|
+
version: 2.7.0
|
83
|
+
type: :development
|
84
|
+
version_requirements: *id004
|
57
85
|
description: "This module allows Ruby programs to interface with \"RSA Security Inc. PKCS #11 Cryptographic Token Interface (Cryptoki)\"."
|
58
86
|
email:
|
59
87
|
- ryosuke@deer-n-horse.jp
|
@@ -77,6 +105,7 @@ files:
|
|
77
105
|
- README.rdoc
|
78
106
|
- Rakefile
|
79
107
|
- ext/extconf.rb
|
108
|
+
- ext/generate_constants.rb
|
80
109
|
- ext/generate_structs.rb
|
81
110
|
- ext/generate_thread_funcs.rb
|
82
111
|
- ext/include/cryptoki.h
|
@@ -89,6 +118,8 @@ files:
|
|
89
118
|
- ext/pk11.c
|
90
119
|
- ext/pk11.h
|
91
120
|
- ext/pk11_const.c
|
121
|
+
- ext/pk11_const_macros.h
|
122
|
+
- ext/pk11_struct_macros.h
|
92
123
|
- lib/pkcs11.rb
|
93
124
|
- lib/pkcs11/extensions.rb
|
94
125
|
- lib/pkcs11/helper.rb
|
@@ -127,29 +158,35 @@ rdoc_options:
|
|
127
158
|
require_paths:
|
128
159
|
- lib
|
129
160
|
required_ruby_version: !ruby/object:Gem::Requirement
|
161
|
+
none: false
|
130
162
|
requirements:
|
131
163
|
- - ">="
|
132
164
|
- !ruby/object:Gem::Version
|
165
|
+
hash: 3
|
166
|
+
segments:
|
167
|
+
- 0
|
133
168
|
version: "0"
|
134
|
-
version:
|
135
169
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
170
|
+
none: false
|
136
171
|
requirements:
|
137
172
|
- - ">="
|
138
173
|
- !ruby/object:Gem::Version
|
174
|
+
hash: 3
|
175
|
+
segments:
|
176
|
+
- 0
|
139
177
|
version: "0"
|
140
|
-
version:
|
141
178
|
requirements: []
|
142
179
|
|
143
180
|
rubyforge_project: pkcs11
|
144
|
-
rubygems_version: 1.
|
181
|
+
rubygems_version: 1.6.2
|
145
182
|
signing_key:
|
146
183
|
specification_version: 3
|
147
184
|
summary: PKCS#11 binding for Ruby
|
148
185
|
test_files:
|
149
|
-
- test/
|
186
|
+
- test/test_pkcs11_object.rb
|
150
187
|
- test/test_pkcs11_structs.rb
|
188
|
+
- test/test_pkcs11_thread.rb
|
151
189
|
- test/test_pkcs11_session.rb
|
152
190
|
- test/test_pkcs11_slot.rb
|
153
|
-
- test/test_pkcs11.rb
|
154
191
|
- test/test_pkcs11_crypt.rb
|
155
|
-
- test/
|
192
|
+
- test/test_pkcs11.rb
|