pkcs11_protect_server 0.2.2 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 7a5fe3b3e7e2b4371955d63d571b32a889cb5cc4ded9c5f4407c7e248a77e373
4
+ data.tar.gz: 152bcff476fe55a9a288eff56341d1013492d2aad40b48283d6629ca06bb2bb2
5
+ SHA512:
6
+ metadata.gz: 260fdae7245c78b951906b3e586e64cbf038540f15833c376c49f1fa3f895fa51169aa30b63c1e7e2fafa8feb5701a68056362553cb0cec1ddddbf791130b168
7
+ data.tar.gz: da7604086b3b6145add4f76290c016bc959a8a18ed4f9dbdbbd82a60d589998271f1654d68f5fba780b3958a4d05cfa5fc37c912f6b4adba19ddae4f2aecb887
checksums.yaml.gz.sig ADDED
@@ -0,0 +1 @@
1
+ �����5���"����(V}2T�j��%�5�^W���|ַ=�z�p�if@Dk#7�.��;�*��n�����~��?5o�5Ǹ�vB:��F3�i��X�(Zn��m�&J5V�b�/u�6v�S
data.tar.gz.sig ADDED
@@ -0,0 +1 @@
1
+ Х�S��i���:@7��J1ی�gL�N:���U��Ö��*���&Ɔ�XI5DSI�3Z�V<�֣�ZB]*��l�����U���IVi��/�A1��Yhk$���aj]����!�{���A%���8#��.0�D��v�EK��3�ĭ�Vx��Y�z}�c*�f�rð��J1�SPڗ�/>�F0j<or֭�8�J�m����x�~ c
@@ -1,8 +1,8 @@
1
1
  = PKCS #11/Ruby Interface for Safenet Protect Server HSM
2
2
 
3
- * Homepage: http://github.com/larskanis/pkcs11
4
- * API documentation: http://pkcs11.rubyforge.org/pkcs11/
5
- * Safenet[http://www.safenet-inc.com] - Protect Server HSM
3
+ home :: http://github.com/larskanis/pkcs11
4
+ API documentation: http://pkcs11.rubyforge.org/pkcs11/
5
+ Safenet Protect Server HSM : http://www.safenet-inc.com
6
6
 
7
7
  This ruby gem is an add-on to ruby-pkcs11[http://github.com/larskanis/pkcs11] .
8
8
  It allowes to use Protect Server specific extensions, which are beyond the PKCS#11 standard.
data/Rakefile CHANGED
@@ -32,10 +32,9 @@ end
32
32
  hoe = Hoe.spec 'pkcs11_protect_server' do
33
33
  developer('Lars Kanis', 'kanis@comcard.de')
34
34
  extra_deps << ['pkcs11', "= #{pkcs11_version}"]
35
- extra_dev_deps << ['yard', '>= 0.6']
36
- extra_dev_deps << ['rake-compiler', '>= 0.7']
35
+ extra_dev_deps << ['yard', '~> 0.6']
36
+ extra_dev_deps << ['rake-compiler', '~> 0.7']
37
37
 
38
- self.url = 'http://github.com/larskanis/pkcs11'
39
38
  self.summary = 'Safenet-ProtectServer extensions for PKCS#11-Ruby'
40
39
  self.description = 'This module allows Ruby programs to use vendor extensions for Safenet Protect Server.'
41
40
  self.version = pkcs11_version
@@ -46,11 +45,9 @@ hoe = Hoe.spec 'pkcs11_protect_server' do
46
45
  spec_extras[:extensions] = 'ext/extconf.rb'
47
46
  spec_extras[:files] = File.read_utf("Manifest.txt").split(/\r?\n\r?/)
48
47
  spec_extras[:files] += GENERATED_FILES
49
- spec_extras[:has_rdoc] = 'yard'
48
+ spec_extras[:required_ruby_version] = '>= 2.2.0'
50
49
  end
51
50
 
52
- ENV['RUBY_CC_VERSION'] ||= '1.8.7:1.9.2'
53
-
54
51
  Rake::ExtensionTask.new('pkcs11_protect_server_ext', hoe.spec) do |ext|
55
52
  ext.ext_dir = 'ext'
56
53
  ext.cross_compile = true # enable cross compilation (requires cross compile toolchain)
@@ -61,7 +58,7 @@ end
61
58
 
62
59
  def copy_from_base_task(filename)
63
60
  file File.join('ext', filename) => File.join(RUBY_PKCS11_EXT_DIR, filename) do |t|
64
- cp t.prerequisites.first, t.name, :verbose=>true
61
+ cp t.prerequisites.first, t.name, verbose: true
65
62
  end
66
63
  end
67
64
 
@@ -71,16 +68,16 @@ copy_from_base_task 'pk11_version.h'
71
68
 
72
69
  file 'ext/extconf.rb' => ['ext/pk11s_struct_def.inc', 'ext/pk11s_const_def.inc', 'ext/pk11_struct_macros.h', 'ext/pk11_const_macros.h', 'ext/pk11_version.h']
73
70
  file 'ext/pk11s_struct_def.inc' => 'ext/generate_structs.rb' do
74
- sh "#{RbConfig::CONFIG['ruby_install_name']} ext/generate_structs.rb --def ext/pk11s_struct_def.inc --impl ext/pk11s_struct_impl.inc --doc ext/pk11s_struct.doc #{File.join(PROTECT_SERVER_SDK_DIR, 'include/ctvdef.h').inspect}"
71
+ sh "#{RbConfig::CONFIG['ruby_install_name']} -I../lib ext/generate_structs.rb --def ext/pk11s_struct_def.inc --impl ext/pk11s_struct_impl.inc --doc ext/pk11s_struct.doc #{File.join(PROTECT_SERVER_SDK_DIR, 'include/ctvdef.h').inspect}"
75
72
  end
76
73
  file 'ext/pk11s_struct_impl.inc' => 'ext/pk11s_struct_def.inc'
77
74
  file 'ext/pk11s_struct.doc' => 'ext/pk11s_struct_def.inc'
78
75
 
79
76
  file 'ext/pk11s_const_def.inc' => 'ext/generate_constants.rb' do
80
- sh "#{RbConfig::CONFIG['ruby_install_name']} ext/generate_constants.rb --const ext/pk11s_const_def.inc #{File.join(PROTECT_SERVER_SDK_DIR, 'include/ctvdef.h').inspect}"
77
+ sh "#{RbConfig::CONFIG['ruby_install_name']} -I../lib ext/generate_constants.rb --const ext/pk11s_const_def.inc #{File.join(PROTECT_SERVER_SDK_DIR, 'include/ctvdef.h').inspect}"
81
78
  end
82
79
  file 'ext/pk11s.c' => ['ext/pk11s_struct_def.inc', 'ext/pk11s_struct_impl.inc', 'ext/pk11s_const_def.inc']
83
80
 
84
- task :doc_files => 'ext/pk11s_struct.doc'
81
+ task doc_files: 'ext/pk11s_struct.doc'
85
82
 
86
83
  # vim: syntax=ruby
@@ -19,10 +19,10 @@ pkcs11_num2ulong(VALUE val)
19
19
  }
20
20
 
21
21
  static VALUE
22
- get_string(VALUE obj, off_t offset, size_t size)
22
+ get_string(VALUE obj, off_t offset, size_t size, rb_encoding *enc)
23
23
  {
24
24
  char *ptr = (char*)DATA_PTR(obj);
25
- return rb_str_new(ptr+offset, size);
25
+ return rb_enc_str_new(ptr+offset, size, enc);
26
26
  }
27
27
 
28
28
  static VALUE
@@ -86,7 +86,7 @@ set_ulong_ptr(VALUE obj, VALUE value, const char *name, off_t offset)
86
86
  *ptr = NULL_PTR;
87
87
  return value;
88
88
  }
89
- new_obj = Data_Make_Struct(rb_cInteger, CK_ULONG, 0, free, *ptr);
89
+ new_obj = Data_Make_Struct(rb_cData, CK_ULONG, 0, -1, *ptr);
90
90
  rb_iv_set(obj, name, new_obj);
91
91
  **ptr = NUM2ULONG(value);
92
92
  return value;
@@ -126,12 +126,12 @@ set_bool(VALUE obj, VALUE value, off_t offset)
126
126
  }
127
127
 
128
128
  static VALUE
129
- get_string_ptr(VALUE obj, const char *name, off_t offset)
129
+ get_string_ptr(VALUE obj, const char *name, off_t offset, rb_encoding *enc)
130
130
  {
131
131
  char *ptr = (char*)DATA_PTR(obj);
132
132
  char *p = *(char**)(ptr+offset);
133
133
  if (!p) return Qnil;
134
- return rb_str_new2(p);
134
+ return rb_enc_str_new_cstr(p, enc);
135
135
  }
136
136
 
137
137
  static VALUE
@@ -151,14 +151,14 @@ set_string_ptr(VALUE obj, VALUE value, const char *name, off_t offset)
151
151
  }
152
152
 
153
153
  static VALUE
154
- get_string_ptr_len(VALUE obj, const char *name, off_t offset, off_t offset_len)
154
+ get_string_ptr_len(VALUE obj, const char *name, off_t offset, off_t offset_len, rb_encoding *enc)
155
155
  {
156
156
  unsigned long l;
157
157
  char *ptr = (char*)DATA_PTR(obj);
158
158
  char *p = *(char**)(ptr+offset);
159
159
  if (!p) return Qnil;
160
160
  l = *(unsigned long*)(ptr+offset_len);
161
- return rb_str_new(p, l);
161
+ return rb_enc_str_new(p, l, enc);
162
162
  }
163
163
 
164
164
  static VALUE
@@ -290,9 +290,9 @@ static VALUE c##s;\
290
290
  static VALUE a##s##_members;\
291
291
  PKCS11_IMPLEMENT_ALLOCATOR(s);
292
292
 
293
- #define PKCS11_IMPLEMENT_STRING_ACCESSOR(s, f) \
293
+ #define PKCS11_IMPLEMENT_STRING_ACCESSOR(s, f, enco) \
294
294
  static VALUE c##s##_get_##f(VALUE o){ \
295
- return get_string(o, OFFSET_OF(s, f), SIZE_OF(s, f)); \
295
+ return get_string(o, OFFSET_OF(s, f), SIZE_OF(s, f), rb_##enco##_encoding()); \
296
296
  } \
297
297
  static VALUE c##s##_set_##f(VALUE o, VALUE v){ \
298
298
  return set_string(o, v, OFFSET_OF(s, f), SIZE_OF(s, f)); \
@@ -338,17 +338,17 @@ static VALUE c##s##_set_##f(VALUE o, VALUE v){ \
338
338
  return set_bool(o, v, OFFSET_OF(s, f)); \
339
339
  }
340
340
 
341
- #define PKCS11_IMPLEMENT_STRING_PTR_ACCESSOR(s, f) \
341
+ #define PKCS11_IMPLEMENT_STRING_PTR_ACCESSOR(s, f, enco) \
342
342
  static VALUE c##s##_get_##f(VALUE o){ \
343
- return get_string_ptr(o, #f, OFFSET_OF(s, f)); \
343
+ return get_string_ptr(o, #f, OFFSET_OF(s, f), rb_##enco##_encoding()); \
344
344
  } \
345
345
  static VALUE c##s##_set_##f(VALUE o, VALUE v){ \
346
346
  return set_string_ptr(o, v, #f, OFFSET_OF(s, f)); \
347
347
  }
348
348
 
349
- #define PKCS11_IMPLEMENT_STRING_PTR_LEN_ACCESSOR(s, f, l) \
349
+ #define PKCS11_IMPLEMENT_STRING_PTR_LEN_ACCESSOR(s, f, l, enco) \
350
350
  static VALUE c##s##_get_##f(VALUE o){ \
351
- return get_string_ptr_len(o, #f, OFFSET_OF(s, f), OFFSET_OF(s, l)); \
351
+ return get_string_ptr_len(o, #f, OFFSET_OF(s, f), OFFSET_OF(s, l), rb_##enco##_encoding()); \
352
352
  } \
353
353
  static VALUE c##s##_set_##f(VALUE o, VALUE v){ \
354
354
  return set_string_ptr_len(o, v, #f, OFFSET_OF(s, f), OFFSET_OF(s, l)); \
data/ext/pk11_version.h CHANGED
@@ -1,6 +1,6 @@
1
1
  #ifndef RUBY_PK11_VERSION_H
2
2
  #define RUBY_PK11_VERSION_H
3
3
 
4
- static const char *VERSION = "0.2.2";
4
+ static const char *VERSION = "0.3.0";
5
5
 
6
6
  #endif
data/ext/pk11s.c CHANGED
@@ -1,4 +1,5 @@
1
1
  #include <ruby.h>
2
+ #include <ruby/encoding.h>
2
3
 
3
4
  #if defined(_WIN32) || defined(__WIN32__) || defined(__CYGWIN__)
4
5
  #define _WINDOWS
data/ext/pk11s_struct.doc CHANGED
@@ -5,9 +5,9 @@ SIZEOF_STRUCT=Integer
5
5
  def to_s; end
6
6
  # @return [Array<String>] Attributes of this struct
7
7
  def members; end
8
- # @return [String] accessor for iv (max 8 bytes)
8
+ # @return [ASCII8BIT-String] accessor for iv (max 8 bytes)
9
9
  attr_accessor :iv
10
- # @return [String] accessor for data (max 8 bytes)
10
+ # @return [ASCII8BIT-String] accessor for data (max 8 bytes)
11
11
  attr_accessor :data
12
12
  end
13
13
  class PKCS11::ProtectServer::CK_DES2_CBC_PARAMS < PKCS11::ProtectServer::CStruct
@@ -17,9 +17,9 @@ SIZEOF_STRUCT=Integer
17
17
  def to_s; end
18
18
  # @return [Array<String>] Attributes of this struct
19
19
  def members; end
20
- # @return [String] accessor for iv (max 8 bytes)
20
+ # @return [ASCII8BIT-String] accessor for iv (max 8 bytes)
21
21
  attr_accessor :iv
22
- # @return [String] accessor for data (max 16 bytes)
22
+ # @return [ASCII8BIT-String] accessor for data (max 16 bytes)
23
23
  attr_accessor :data
24
24
  end
25
25
  class PKCS11::ProtectServer::CK_DES3_CBC_PARAMS < PKCS11::ProtectServer::CStruct
@@ -29,9 +29,9 @@ SIZEOF_STRUCT=Integer
29
29
  def to_s; end
30
30
  # @return [Array<String>] Attributes of this struct
31
31
  def members; end
32
- # @return [String] accessor for iv (max 8 bytes)
32
+ # @return [ASCII8BIT-String] accessor for iv (max 8 bytes)
33
33
  attr_accessor :iv
34
- # @return [String] accessor for data (max 24 bytes)
34
+ # @return [ASCII8BIT-String] accessor for data (max 24 bytes)
35
35
  attr_accessor :data
36
36
  end
37
37
  class PKCS11::ProtectServer::CK_TIMESTAMP_PARAMS < PKCS11::ProtectServer::CStruct
@@ -115,7 +115,7 @@ SIZEOF_STRUCT=Integer
115
115
  def to_s; end
116
116
  # @return [Array<String>] Attributes of this struct
117
117
  def members; end
118
- # @return [String, nil] accessor for prompt
118
+ # @return [USASCII-String, nil] accessor for prompt
119
119
  attr_accessor :prompt
120
120
  # @return [Boolean] Bool value
121
121
  attr_accessor :bMaskInput
@@ -129,7 +129,7 @@ SIZEOF_STRUCT=Integer
129
129
  def to_s; end
130
130
  # @return [Array<String>] Attributes of this struct
131
131
  def members; end
132
- # @return [String] accessor for peerId (max 16 bytes)
132
+ # @return [USASCII-String] accessor for peerId (max 16 bytes)
133
133
  attr_accessor :peerId
134
134
  end
135
135
  class PKCS11::ProtectServer::CK_SECRET_SHARE_PARAMS < PKCS11::ProtectServer::CStruct
@@ -151,9 +151,9 @@ SIZEOF_STRUCT=Integer
151
151
  def to_s; end
152
152
  # @return [Array<String>] Attributes of this struct
153
153
  def members; end
154
- # @return [String, nil] accessor for passwordAuthSafe and passwordAuthSafeLen
154
+ # @return [USASCII-String, nil] accessor for passwordAuthSafe and passwordAuthSafeLen
155
155
  attr_accessor :passwordAuthSafe
156
- # @return [String, nil] accessor for passwordHMAC and passwordHMACLen
156
+ # @return [USASCII-String, nil] accessor for passwordHMAC and passwordHMACLen
157
157
  attr_accessor :passwordHMAC
158
158
  # @return [Integer, PKCS11::Object] Object handle (CK_ULONG)
159
159
  attr_accessor :keyCert
@@ -173,9 +173,9 @@ def to_s; end
173
173
  def members; end
174
174
  # @return [Array<PKCS11::CK_ATTRIBUTE>] accessor for certAttr and certAttrCount
175
175
  attr_accessor :certAttr
176
- # @return [String, nil] accessor for passwordAuthSafe and passwordAuthSafeLen
176
+ # @return [USASCII-String, nil] accessor for passwordAuthSafe and passwordAuthSafeLen
177
177
  attr_accessor :passwordAuthSafe
178
- # @return [String, nil] accessor for passwordHMAC and passwordHMACLen
178
+ # @return [USASCII-String, nil] accessor for passwordHMAC and passwordHMACLen
179
179
  attr_accessor :passwordHMAC
180
180
  # @return [Integer, nil] accessor for hCertCount (CK_ULONG_PTR)
181
181
  attr_accessor :hCertCount
@@ -187,9 +187,9 @@ SIZEOF_STRUCT=Integer
187
187
  def to_s; end
188
188
  # @return [Array<String>] Attributes of this struct
189
189
  def members; end
190
- # @return [String, nil] accessor for pSharedData1
190
+ # @return [ASCII8BIT-String, nil] accessor for pSharedData1
191
191
  attr_accessor :pSharedData1
192
- # @return [String, nil] accessor for pSharedData2
192
+ # @return [ASCII8BIT-String, nil] accessor for pSharedData2
193
193
  attr_accessor :pSharedData2
194
194
  # @return [Integer] accessor for kdf (CK_ULONG)
195
195
  attr_accessor :kdf
@@ -1,14 +1,14 @@
1
1
  PKCS11_IMPLEMENT_STRUCT_WITH_ALLOCATOR(CK_DES_CBC_PARAMS);
2
- PKCS11_IMPLEMENT_STRING_ACCESSOR(CK_DES_CBC_PARAMS, iv);
3
- PKCS11_IMPLEMENT_STRING_ACCESSOR(CK_DES_CBC_PARAMS, data);
2
+ PKCS11_IMPLEMENT_STRING_ACCESSOR(CK_DES_CBC_PARAMS, iv, ascii8bit);
3
+ PKCS11_IMPLEMENT_STRING_ACCESSOR(CK_DES_CBC_PARAMS, data, ascii8bit);
4
4
 
5
5
  PKCS11_IMPLEMENT_STRUCT_WITH_ALLOCATOR(CK_DES2_CBC_PARAMS);
6
- PKCS11_IMPLEMENT_STRING_ACCESSOR(CK_DES2_CBC_PARAMS, iv);
7
- PKCS11_IMPLEMENT_STRING_ACCESSOR(CK_DES2_CBC_PARAMS, data);
6
+ PKCS11_IMPLEMENT_STRING_ACCESSOR(CK_DES2_CBC_PARAMS, iv, ascii8bit);
7
+ PKCS11_IMPLEMENT_STRING_ACCESSOR(CK_DES2_CBC_PARAMS, data, ascii8bit);
8
8
 
9
9
  PKCS11_IMPLEMENT_STRUCT_WITH_ALLOCATOR(CK_DES3_CBC_PARAMS);
10
- PKCS11_IMPLEMENT_STRING_ACCESSOR(CK_DES3_CBC_PARAMS, iv);
11
- PKCS11_IMPLEMENT_STRING_ACCESSOR(CK_DES3_CBC_PARAMS, data);
10
+ PKCS11_IMPLEMENT_STRING_ACCESSOR(CK_DES3_CBC_PARAMS, iv, ascii8bit);
11
+ PKCS11_IMPLEMENT_STRING_ACCESSOR(CK_DES3_CBC_PARAMS, data, ascii8bit);
12
12
 
13
13
  PKCS11_IMPLEMENT_STRUCT_WITH_ALLOCATOR(CK_TIMESTAMP_PARAMS);
14
14
  PKCS11_IMPLEMENT_BOOL_ACCESSOR(CK_TIMESTAMP_PARAMS, useMilliseconds);
@@ -36,22 +36,22 @@ PKCS11_IMPLEMENT_STRUCT_ACCESSOR(CK_PKCS_7_PARAMS, CK_MECH_AND_OBJECTS, encrypti
36
36
  PKCS11_IMPLEMENT_STRUCT_ACCESSOR(CK_PKCS_7_PARAMS, CK_ATTRIBUTES, extensions);
37
37
 
38
38
  PKCS11_IMPLEMENT_STRUCT_WITH_ALLOCATOR(CK_PP_LOAD_SECRET_PARAMS);
39
- PKCS11_IMPLEMENT_STRING_PTR_ACCESSOR(CK_PP_LOAD_SECRET_PARAMS, prompt);
39
+ PKCS11_IMPLEMENT_STRING_PTR_ACCESSOR(CK_PP_LOAD_SECRET_PARAMS, prompt, usascii);
40
40
  PKCS11_IMPLEMENT_BOOL_ACCESSOR(CK_PP_LOAD_SECRET_PARAMS, bMaskInput);
41
41
  PKCS11_IMPLEMENT_ULONG_ACCESSOR(CK_PP_LOAD_SECRET_PARAMS, cConvert);
42
42
  /* unimplemented attr CK_CHAR cTimeout */
43
43
  /* unimplemented attr CK_CHAR reserved */
44
44
 
45
45
  PKCS11_IMPLEMENT_STRUCT_WITH_ALLOCATOR(CK_REPLICATE_TOKEN_PARAMS);
46
- PKCS11_IMPLEMENT_STRING_ACCESSOR(CK_REPLICATE_TOKEN_PARAMS, peerId);
46
+ PKCS11_IMPLEMENT_STRING_ACCESSOR(CK_REPLICATE_TOKEN_PARAMS, peerId, usascii);
47
47
 
48
48
  PKCS11_IMPLEMENT_STRUCT_WITH_ALLOCATOR(CK_SECRET_SHARE_PARAMS);
49
49
  PKCS11_IMPLEMENT_ULONG_ACCESSOR(CK_SECRET_SHARE_PARAMS, n);
50
50
  PKCS11_IMPLEMENT_ULONG_ACCESSOR(CK_SECRET_SHARE_PARAMS, m);
51
51
 
52
52
  PKCS11_IMPLEMENT_STRUCT_WITH_ALLOCATOR(CK_PKCS12_PBE_EXPORT_PARAMS);
53
- PKCS11_IMPLEMENT_STRING_PTR_LEN_ACCESSOR(CK_PKCS12_PBE_EXPORT_PARAMS, passwordAuthSafe, passwordAuthSafeLen);
54
- PKCS11_IMPLEMENT_STRING_PTR_LEN_ACCESSOR(CK_PKCS12_PBE_EXPORT_PARAMS, passwordHMAC, passwordHMACLen);
53
+ PKCS11_IMPLEMENT_STRING_PTR_LEN_ACCESSOR(CK_PKCS12_PBE_EXPORT_PARAMS, passwordAuthSafe, passwordAuthSafeLen, usascii);
54
+ PKCS11_IMPLEMENT_STRING_PTR_LEN_ACCESSOR(CK_PKCS12_PBE_EXPORT_PARAMS, passwordHMAC, passwordHMACLen, usascii);
55
55
  PKCS11_IMPLEMENT_HANDLE_ACCESSOR(CK_PKCS12_PBE_EXPORT_PARAMS, keyCert);
56
56
  PKCS11_IMPLEMENT_ULONG_ACCESSOR(CK_PKCS12_PBE_EXPORT_PARAMS, safeBagKgMech);
57
57
  PKCS11_IMPLEMENT_ULONG_ACCESSOR(CK_PKCS12_PBE_EXPORT_PARAMS, safeContentKgMech);
@@ -59,14 +59,14 @@ PKCS11_IMPLEMENT_ULONG_ACCESSOR(CK_PKCS12_PBE_EXPORT_PARAMS, hmacKgMech);
59
59
 
60
60
  PKCS11_IMPLEMENT_STRUCT_WITH_ALLOCATOR(CK_PKCS12_PBE_IMPORT_PARAMS);
61
61
  PKCS11_IMPLEMENT_PKCS11_STRUCT_PTR_ARRAY_ACCESSOR(CK_PKCS12_PBE_IMPORT_PARAMS, CK_ATTRIBUTE, certAttr, certAttrCount);
62
- PKCS11_IMPLEMENT_STRING_PTR_LEN_ACCESSOR(CK_PKCS12_PBE_IMPORT_PARAMS, passwordAuthSafe, passwordAuthSafeLen);
63
- PKCS11_IMPLEMENT_STRING_PTR_LEN_ACCESSOR(CK_PKCS12_PBE_IMPORT_PARAMS, passwordHMAC, passwordHMACLen);
62
+ PKCS11_IMPLEMENT_STRING_PTR_LEN_ACCESSOR(CK_PKCS12_PBE_IMPORT_PARAMS, passwordAuthSafe, passwordAuthSafeLen, usascii);
63
+ PKCS11_IMPLEMENT_STRING_PTR_LEN_ACCESSOR(CK_PKCS12_PBE_IMPORT_PARAMS, passwordHMAC, passwordHMACLen, usascii);
64
64
  /* unimplemented attr CK_OBJECT_HANDLE_PTR hCert */
65
65
  PKCS11_IMPLEMENT_ULONG_PTR_ACCESSOR(CK_PKCS12_PBE_IMPORT_PARAMS, hCertCount);
66
66
 
67
67
  PKCS11_IMPLEMENT_STRUCT_WITH_ALLOCATOR(CK_ECIES_PARAMS);
68
- PKCS11_IMPLEMENT_STRING_PTR_ACCESSOR(CK_ECIES_PARAMS, pSharedData1);
69
- PKCS11_IMPLEMENT_STRING_PTR_ACCESSOR(CK_ECIES_PARAMS, pSharedData2);
68
+ PKCS11_IMPLEMENT_STRING_PTR_ACCESSOR(CK_ECIES_PARAMS, pSharedData1, ascii8bit);
69
+ PKCS11_IMPLEMENT_STRING_PTR_ACCESSOR(CK_ECIES_PARAMS, pSharedData2, ascii8bit);
70
70
  /* unimplemented attr CK_EC_DH_PRIMITIVE dhPrimitive */
71
71
  PKCS11_IMPLEMENT_ULONG_ACCESSOR(CK_ECIES_PARAMS, kdf);
72
72
  PKCS11_IMPLEMENT_ULONG_ACCESSOR(CK_ECIES_PARAMS, ulSharedDataLen1);
@@ -58,6 +58,15 @@ module ProtectServer
58
58
  #
59
59
  # See also PKCS11::Library#initialize[http://pkcs11.rubyforge.org/pkcs11/PKCS11/Library.html#initialize-instance_method] of pkcs11.gem
60
60
  def initialize(so_path = nil, args = {})
61
+ super(so_path, args)
62
+ end
63
+
64
+ def load_library(so_path)
65
+ @so_path = resolve_so_path(so_path)
66
+ super(@so_path)
67
+ end
68
+
69
+ def resolve_so_path(so_path)
61
70
  if [:sw, :hsm].include?(so_path)
62
71
  if RUBY_PLATFORM =~ /mswin|mingw/
63
72
  libctsw_so = "cryptoki.dll"
@@ -80,10 +89,9 @@ module ProtectServer
80
89
 
81
90
  raise "#{libctsw_so} not found - please install ProtectServer PTK-C or set ENV['CRYPTOKI_SO']" unless so_path
82
91
  end
83
-
84
- @so_path = so_path
85
- super(so_path, args)
92
+ return so_path
86
93
  end
94
+ private :resolve_so_path
87
95
 
88
96
  def vendor_const_get(name)
89
97
  return ProtectServer.const_get(name) if ProtectServer.const_defined?(name)
data/test/helper.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  def open_ctsw
2
- PKCS11::ProtectServer::Library.new(:sw, :flags=>0)
2
+ PKCS11::ProtectServer::Library.new(:sw, flags: 0)
3
3
  end
4
4
 
5
5
  def adjust_parity(data)
@@ -1,8 +1,8 @@
1
- require "test/unit"
1
+ require "minitest/autorun"
2
2
  require "pkcs11_protect_server"
3
3
  require "test/helper"
4
4
 
5
- class TestPkcs11ProtectServer < Test::Unit::TestCase
5
+ class TestPkcs11ProtectServer < Minitest::Test
6
6
  include PKCS11
7
7
 
8
8
  def test_CStruct
@@ -12,7 +12,7 @@ class TestPkcs11ProtectServer < Test::Unit::TestCase
12
12
  assert_match( /m=3/, s.inspect, 'There should be a n value in CK_SECRET_SHARE_PARAMS')
13
13
  assert_equal ["n", "m"], s.members, 'CK_SECRET_SHARE_PARAMS should contain some attributes'
14
14
  assert_equal [2, 3], s.values, 'values of CK_SECRET_SHARE_PARAMS'
15
- assert_equal( {:n=>2, :m=>3}, s.to_hash, 'CK_SECRET_SHARE_PARAMS as hash' )
15
+ assert_equal( {n: 2, m: 3}, s.to_hash, 'CK_SECRET_SHARE_PARAMS as hash' )
16
16
  end
17
17
 
18
18
  def test_CK_PKCS12_PBE_IMPORT_PARAMS
@@ -23,7 +23,7 @@ class TestPkcs11ProtectServer < Test::Unit::TestCase
23
23
  s.certAttr = [s1, s2]
24
24
  assert_equal [s1.to_hash, s2.to_hash], s.certAttr.map{|e| e.to_hash }
25
25
  GC.start
26
- assert_raise(ArgumentError){ s.certAttr = [s1, s2, nil] }
26
+ assert_raises(ArgumentError){ s.certAttr = [s1, s2, nil] }
27
27
  assert_equal [s1.to_hash, s2.to_hash], s.certAttr.map{|e| e.to_hash }
28
28
 
29
29
  s.certAttr = []
@@ -39,12 +39,21 @@ class TestPkcs11ProtectServer < Test::Unit::TestCase
39
39
  end
40
40
 
41
41
  def test_loading
42
- pk = PKCS11::ProtectServer::Library.new(:sw, :flags=>0)
42
+ pk = PKCS11::ProtectServer::Library.new(:sw, flags: 0)
43
43
  so_path = pk.so_path
44
44
  pk.close
45
45
  assert !so_path.empty?, "Used path shouldn't be empty"
46
46
 
47
- pk = PKCS11::ProtectServer::Library.new(so_path, :flags=>0)
47
+ pk = PKCS11::ProtectServer::Library.new(so_path, flags: 0)
48
+ pk.close
49
+ end
50
+
51
+ def test_loading2
52
+ pk = PKCS11::ProtectServer::Library.new
53
+ pk.load_library(:sw)
54
+ pk.C_GetFunctionList
55
+ pk.C_Initialize(flags: 0)
56
+ pk.info
48
57
  pk.close
49
58
  end
50
59
  end
@@ -1,8 +1,8 @@
1
- require "test/unit"
1
+ require "minitest/autorun"
2
2
  require "pkcs11_protect_server"
3
3
  require "test/helper"
4
4
 
5
- class TestPkcs11ProtectServerCrypt < Test::Unit::TestCase
5
+ class TestPkcs11ProtectServerCrypt < Minitest::Test
6
6
  include PKCS11
7
7
  attr_reader :slots
8
8
  attr_reader :slot
@@ -39,12 +39,12 @@ class TestPkcs11ProtectServerCrypt < Test::Unit::TestCase
39
39
  assert_equal CKS_RO_USER_FUNCTIONS, session.info.state, "Session should be in USER state"
40
40
 
41
41
  @secret_key = session.create_object(
42
- :CLASS=>CKO_SECRET_KEY,
43
- :KEY_TYPE=>CKK_DES2,
44
- :ENCRYPT=>true, :WRAP=>true, :DECRYPT=>true, :UNWRAP=>true, :TOKEN=>false, :DERIVE=>true,
45
- :USAGE_COUNT=>0, :EXPORTABLE=>true,
46
- :VALUE=>adjust_parity("0123456789abcdef"),
47
- :LABEL=>'test_secret_key')
42
+ CLASS: CKO_SECRET_KEY,
43
+ KEY_TYPE: CKK_DES2,
44
+ ENCRYPT: true, WRAP: true, DECRYPT: true, UNWRAP: true, TOKEN: false, DERIVE: true,
45
+ USAGE_COUNT: 0, EXPORTABLE: true,
46
+ VALUE: adjust_parity("0123456789abcdef"),
47
+ LABEL: 'test_secret_key')
48
48
  end
49
49
 
50
50
  def teardown
@@ -58,12 +58,12 @@ class TestPkcs11ProtectServerCrypt < Test::Unit::TestCase
58
58
  end
59
59
 
60
60
  def test_bad_parity
61
- assert_raise(ProtectServer::CKR_ET_NOT_ODD_PARITY) do
61
+ assert_raises(ProtectServer::CKR_ET_NOT_ODD_PARITY) do
62
62
  session.create_object(
63
- :CLASS=>CKO_SECRET_KEY,
64
- :KEY_TYPE=>CKK_DES2,
65
- :VALUE=>"0123456789abcdef",
66
- :LABEL=>'test_secret_key2')
63
+ CLASS: CKO_SECRET_KEY,
64
+ KEY_TYPE: CKK_DES2,
65
+ VALUE: "0123456789abcdef",
66
+ LABEL: 'test_secret_key2')
67
67
  end
68
68
  end
69
69
 
@@ -73,14 +73,14 @@ class TestPkcs11ProtectServerCrypt < Test::Unit::TestCase
73
73
  pa.iv = "2"*8
74
74
 
75
75
  new_key1 = session.derive_key( {ProtectServer::CKM_DES3_DERIVE_CBC => pa}, secret_key,
76
- :CLASS=>CKO_SECRET_KEY, :KEY_TYPE=>CKK_DES2, :ENCRYPT=>true, :DECRYPT=>true, :SENSITIVE=>false )
77
- assert_not_equal secret_key[:VALUE], new_key1[:VALUE], 'Derived key shouldn\'t have equal key value'
76
+ CLASS: CKO_SECRET_KEY, KEY_TYPE: CKK_DES2, ENCRYPT: true, DECRYPT: true, SENSITIVE: false )
77
+ refute_equal secret_key[:VALUE], new_key1[:VALUE], 'Derived key shouldn\'t have equal key value'
78
78
 
79
- new_key2 = session.derive_key( {:DES3_DERIVE_CBC => {:data=>"1"*16, :iv=>"2"*16}}, secret_key,
80
- :CLASS=>CKO_SECRET_KEY, :KEY_TYPE=>CKK_DES2, :ENCRYPT=>true, :DECRYPT=>true, :SENSITIVE=>false )
79
+ new_key2 = session.derive_key( {DES3_DERIVE_CBC: {data: "1"*16, iv: "2"*16}}, secret_key,
80
+ CLASS: CKO_SECRET_KEY, KEY_TYPE: CKK_DES2, ENCRYPT: true, DECRYPT: true, SENSITIVE: false )
81
81
  assert_equal new_key1[:VALUE], new_key2[:VALUE], 'Both derived key should be equal'
82
82
 
83
- encrypted_key_value = session.encrypt( {:DES3_CBC => "2"*8}, secret_key, "1"*16)
83
+ encrypted_key_value = session.encrypt( {DES3_CBC: "2"*8}, secret_key, "1"*16)
84
84
  encrypted_key_value = adjust_parity(encrypted_key_value)
85
85
  assert_equal new_key1[:VALUE], encrypted_key_value, 'Encrypted data should equal derived key value'
86
86
 
@@ -98,6 +98,6 @@ class TestPkcs11ProtectServerCrypt < Test::Unit::TestCase
98
98
  assert_equal 5, secret_key[:USAGE_COUNT], 'CKA_USAGE_COUNT should be usable'
99
99
 
100
100
  assert_equal false, secret_key[:IMPORT], 'CKA_IMPORT should default to false'
101
- assert_not_nil secret_key.attributes.find{|a| a.type==ProtectServer::CKA_EXPORT}, 'CKA_EXPORT should be returned for Object#attributes'
101
+ refute_nil secret_key.attributes.find{|a| a.type==ProtectServer::CKA_EXPORT}, 'CKA_EXPORT should be returned for Object#attributes'
102
102
  end
103
103
  end
metadata CHANGED
@@ -1,165 +1,169 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: pkcs11_protect_server
3
- version: !ruby/object:Gem::Version
4
- hash: 19
5
- prerelease:
6
- segments:
7
- - 0
8
- - 2
9
- - 2
10
- version: 0.2.2
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.3.0
11
5
  platform: ruby
12
- authors:
6
+ authors:
13
7
  - Lars Kanis
14
8
  autorequire:
15
9
  bindir: bin
16
- cert_chain: []
17
-
18
- date: 2011-12-12 00:00:00 Z
19
- dependencies:
20
- - !ruby/object:Gem::Dependency
10
+ cert_chain:
11
+ - |
12
+ -----BEGIN CERTIFICATE-----
13
+ MIIDPDCCAiSgAwIBAgIBBjANBgkqhkiG9w0BAQsFADBEMQ0wCwYDVQQDDARsYXJz
14
+ MR8wHQYKCZImiZPyLGQBGRYPZ3JlaXotcmVpbnNkb3JmMRIwEAYKCZImiZPyLGQB
15
+ GRYCZGUwHhcNMTkxMjAzMTkzNDA5WhcNMjAxMjAyMTkzNDA5WjBEMQ0wCwYDVQQD
16
+ DARsYXJzMR8wHQYKCZImiZPyLGQBGRYPZ3JlaXotcmVpbnNkb3JmMRIwEAYKCZIm
17
+ iZPyLGQBGRYCZGUwggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQDZb4Uv
18
+ RFJfRu/VEWiy3psh2jinETjiuBrL0NeRFGf8H7iU9+gx/DI/FFhfHGLrDeIskrJx
19
+ YIWDMmEjVO10UUdj7wu4ZhmU++0Cd7Kq9/TyP/shIP3IjqHjVLCnJ3P6f1cl5rxZ
20
+ gqo+d3BAoDrmPk0rtaf6QopwUw9RBiF8V4HqvpiY+ruJotP5UQDP4/lVOKvA8PI9
21
+ P0GmVbFBrbc7Zt5h78N3UyOK0u+nvOC23BvyHXzCtcFsXCoEkt+Wwh0RFqVZdnjM
22
+ LMO2vULHKKHDdX54K/sbVCj9pN9h1aotNzrEyo55zxn0G9PHg/G3P8nMvAXPkUTe
23
+ brhXrfCwWRvOXA4TAgMBAAGjOTA3MAkGA1UdEwQCMAAwCwYDVR0PBAQDAgSwMB0G
24
+ A1UdDgQWBBRAHK81igrXodaDj8a8/BIKsaZrETANBgkqhkiG9w0BAQsFAAOCAQEA
25
+ XDITkfRngYnc7MnDMd1XRSZqZKPvPFIk/ByhD4T5mHDAmOVV9Q4csAF9wAnYqLVG
26
+ XqetRpK47O55NHN7zG2RbE7ospqgNU4ToXM2KCZuGoGuV75RBf6kk498kcPuFBPq
27
+ FWzBIlr9Nat2NjwmEAvVf2UrmKl7rEDCQTkYCe9H5qkWtbneBASIfbVaw14yhosQ
28
+ 0fP+rf/XkPrhjfYMBd258JnTy32boRZQ018c/kX8myjnEZA6rTr6082ESHD3BTHj
29
+ D5uWyL3krcnTOgVS0jv7qSuxDjlvpHqvN1BNaw64Gf5TpqRDNM5r+hXhD8U339Ot
30
+ lrxBVhTTtOOm6AE6oziYmw==
31
+ -----END CERTIFICATE-----
32
+ date: 2019-12-05 00:00:00.000000000 Z
33
+ dependencies:
34
+ - !ruby/object:Gem::Dependency
21
35
  name: pkcs11
22
- prerelease: false
23
- requirement: &id001 !ruby/object:Gem::Requirement
24
- none: false
25
- requirements:
26
- - - "="
27
- - !ruby/object:Gem::Version
28
- hash: 19
29
- segments:
30
- - 0
31
- - 2
32
- - 2
33
- version: 0.2.2
36
+ requirement: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - '='
39
+ - !ruby/object:Gem::Version
40
+ version: 0.3.0
34
41
  type: :runtime
35
- version_requirements: *id001
36
- - !ruby/object:Gem::Dependency
37
- name: yard
38
42
  prerelease: false
39
- requirement: &id002 !ruby/object:Gem::Requirement
40
- none: false
41
- requirements:
42
- - - ">="
43
- - !ruby/object:Gem::Version
44
- hash: 7
45
- segments:
46
- - 0
47
- - 6
48
- version: "0.6"
43
+ version_requirements: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - '='
46
+ - !ruby/object:Gem::Version
47
+ version: 0.3.0
48
+ - !ruby/object:Gem::Dependency
49
+ name: yard
50
+ requirement: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '0.6'
49
55
  type: :development
50
- version_requirements: *id002
51
- - !ruby/object:Gem::Dependency
56
+ prerelease: false
57
+ version_requirements: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '0.6'
62
+ - !ruby/object:Gem::Dependency
52
63
  name: rake-compiler
64
+ requirement: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '0.7'
69
+ type: :development
53
70
  prerelease: false
54
- requirement: &id003 !ruby/object:Gem::Requirement
55
- none: false
56
- requirements:
71
+ version_requirements: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: '0.7'
76
+ - !ruby/object:Gem::Dependency
77
+ name: rdoc
78
+ requirement: !ruby/object:Gem::Requirement
79
+ requirements:
57
80
  - - ">="
58
- - !ruby/object:Gem::Version
59
- hash: 5
60
- segments:
61
- - 0
62
- - 7
63
- version: "0.7"
81
+ - !ruby/object:Gem::Version
82
+ version: '4.0'
83
+ - - "<"
84
+ - !ruby/object:Gem::Version
85
+ version: '7'
64
86
  type: :development
65
- version_requirements: *id003
66
- - !ruby/object:Gem::Dependency
67
- name: hoe
68
87
  prerelease: false
69
- requirement: &id004 !ruby/object:Gem::Requirement
70
- none: false
71
- requirements:
72
- - - ~>
73
- - !ruby/object:Gem::Version
74
- hash: 27
75
- segments:
76
- - 2
77
- - 12
78
- version: "2.12"
88
+ version_requirements: !ruby/object:Gem::Requirement
89
+ requirements:
90
+ - - ">="
91
+ - !ruby/object:Gem::Version
92
+ version: '4.0'
93
+ - - "<"
94
+ - !ruby/object:Gem::Version
95
+ version: '7'
96
+ - !ruby/object:Gem::Dependency
97
+ name: hoe
98
+ requirement: !ruby/object:Gem::Requirement
99
+ requirements:
100
+ - - "~>"
101
+ - !ruby/object:Gem::Version
102
+ version: '3.20'
79
103
  type: :development
80
- version_requirements: *id004
81
- - !ruby/object:Gem::Dependency
82
- name: rdoc
83
104
  prerelease: false
84
- requirement: &id005 !ruby/object:Gem::Requirement
85
- none: false
86
- requirements:
87
- - - ~>
88
- - !ruby/object:Gem::Version
89
- hash: 19
90
- segments:
91
- - 3
92
- - 10
93
- version: "3.10"
94
- type: :development
95
- version_requirements: *id005
96
- description: This module allows Ruby programs to use vendor extensions for Safenet Protect Server.
97
- email:
105
+ version_requirements: !ruby/object:Gem::Requirement
106
+ requirements:
107
+ - - "~>"
108
+ - !ruby/object:Gem::Version
109
+ version: '3.20'
110
+ description: This module allows Ruby programs to use vendor extensions for Safenet
111
+ Protect Server.
112
+ email:
98
113
  - kanis@comcard.de
99
114
  executables: []
100
-
101
- extensions:
115
+ extensions:
102
116
  - ext/extconf.rb
103
- extra_rdoc_files:
117
+ extra_rdoc_files:
104
118
  - Manifest.txt
105
119
  - README_PROTECT_SERVER.rdoc
106
120
  - ext/pk11s.c
107
- files:
108
- - .gemtest
109
- - .yardopts
121
+ files:
122
+ - ".gemtest"
123
+ - ".yardopts"
110
124
  - Manifest.txt
111
125
  - README_PROTECT_SERVER.rdoc
112
126
  - Rakefile
113
127
  - ext/extconf.rb
114
128
  - ext/generate_constants.rb
115
129
  - ext/generate_structs.rb
130
+ - ext/pk11_const_macros.h
131
+ - ext/pk11_struct_macros.h
132
+ - ext/pk11_version.h
116
133
  - ext/pk11s.c
134
+ - ext/pk11s_const_def.inc
135
+ - ext/pk11s_struct.doc
136
+ - ext/pk11s_struct_def.inc
137
+ - ext/pk11s_struct_impl.inc
117
138
  - lib/pkcs11_protect_server.rb
118
139
  - lib/pkcs11_protect_server/extensions.rb
119
140
  - test/helper.rb
120
141
  - test/test_pkcs11_protect_server.rb
121
142
  - test/test_pkcs11_protect_server_crypt.rb
122
- - ext/pk11s_struct_impl.inc
123
- - ext/pk11s_struct_def.inc
124
- - ext/pk11s_const_def.inc
125
- - ext/pk11s_struct.doc
126
- - ext/pk11_struct_macros.h
127
- - ext/pk11_const_macros.h
128
- - ext/pk11_version.h
129
143
  homepage: http://github.com/larskanis/pkcs11
130
- licenses: []
131
-
144
+ licenses:
145
+ - MIT
146
+ metadata:
147
+ homepage_uri: http://github.com/larskanis/pkcs11
132
148
  post_install_message:
133
- rdoc_options:
134
- - --main
149
+ rdoc_options:
150
+ - "--main"
135
151
  - README_PROTECT_SERVER.rdoc
136
- require_paths:
152
+ require_paths:
137
153
  - lib
138
- required_ruby_version: !ruby/object:Gem::Requirement
139
- none: false
140
- requirements:
154
+ required_ruby_version: !ruby/object:Gem::Requirement
155
+ requirements:
141
156
  - - ">="
142
- - !ruby/object:Gem::Version
143
- hash: 3
144
- segments:
145
- - 0
146
- version: "0"
147
- required_rubygems_version: !ruby/object:Gem::Requirement
148
- none: false
149
- requirements:
157
+ - !ruby/object:Gem::Version
158
+ version: 2.2.0
159
+ required_rubygems_version: !ruby/object:Gem::Requirement
160
+ requirements:
150
161
  - - ">="
151
- - !ruby/object:Gem::Version
152
- hash: 3
153
- segments:
154
- - 0
155
- version: "0"
162
+ - !ruby/object:Gem::Version
163
+ version: '0'
156
164
  requirements: []
157
-
158
- rubyforge_project: pkcs11_protect_server
159
- rubygems_version: 1.8.11
165
+ rubygems_version: 3.0.3
160
166
  signing_key:
161
- specification_version: 3
167
+ specification_version: 4
162
168
  summary: Safenet-ProtectServer extensions for PKCS#11-Ruby
163
- test_files:
164
- - test/test_pkcs11_protect_server.rb
165
- - test/test_pkcs11_protect_server_crypt.rb
169
+ test_files: []
metadata.gz.sig ADDED
@@ -0,0 +1,3 @@
1
+ .� V��,j��������r�x�WYs��c �$���YnD21P��Fr�Lch��&�1�ڕ�|'zP� ;Ԉp3���yP���6 ������+��q�)r=�I�J0��~e�q�ZL�5ї*�o�%�xҏ�
2
+ zJ������_s���H�O_D�)���&]`U=�*�j*�UX�� z���/�h�A�m��>o��P���:����mw�-*=Ӹ1��a�b�[i��D��<!��<MĶ�
3
+ �Ezm����9�'`