pkcs11_luna 0.3.4 → 0.4.0
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.
- checksums.yaml +4 -4
- checksums.yaml.gz.sig +0 -0
- data/ext/extconf.rb +1 -0
- data/ext/generate_constants.rb +3 -3
- data/ext/generate_structs.rb +1 -1
- data/ext/pk11_struct_macros.h +65 -16
- data/ext/pk11_version.h +1 -1
- data/ext/pk11l.c +50 -32
- data/ext/std_structs.rb +1 -1
- data/lib/pkcs11_luna/extensions.rb +3 -3
- data.tar.gz.sig +0 -0
- metadata +24 -24
- metadata.gz.sig +3 -3
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 4893d05a079040c1ac2d4cbae3fb2516284c8d8e33ffe7217ee5f5f1abcb4897
|
|
4
|
+
data.tar.gz: 16c6839104dd05d9b45b771accd5db685416cd18a5da4248686d64508801590f
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: e34db14604bb7d771223b03e57c23bd03922e7d5919780717fd2dd51e619db4e7455ee968c451b5a60fb2a9dceb8b210c149a19f0133dd029eb7938425b5316e
|
|
7
|
+
data.tar.gz: 5889f38a3420ae3c124f5fe3991d627bf3922af763c419e15ca876df50a06481cec67b159d4d6ea27707e259dd52581376b9eb1c26b1e232509193d659df78b0
|
checksums.yaml.gz.sig
CHANGED
|
Binary file
|
data/ext/extconf.rb
CHANGED
data/ext/generate_constants.rb
CHANGED
|
@@ -26,7 +26,7 @@ class ConstantParser
|
|
|
26
26
|
s.options = options
|
|
27
27
|
s.start!
|
|
28
28
|
end
|
|
29
|
-
|
|
29
|
+
|
|
30
30
|
ConstTemplate = Struct.new :regexp, :def
|
|
31
31
|
ConstGroups = [
|
|
32
32
|
ConstTemplate.new(/#define\s+(CKM_[A-Z_0-9]+)\s+(\w+)/, 'PKCS11_DEFINE_MECHANISM'),
|
|
@@ -38,11 +38,11 @@ class ConstantParser
|
|
|
38
38
|
def start!
|
|
39
39
|
File.open(options.const, "w") do |fd_const|
|
|
40
40
|
options.files.each do |file_h|
|
|
41
|
-
c_src =
|
|
41
|
+
c_src = File.read(file_h)
|
|
42
42
|
ConstGroups.each do |const_group|
|
|
43
43
|
c_src.scan(const_group.regexp) do
|
|
44
44
|
const_name, const_value = $1, $2
|
|
45
|
-
|
|
45
|
+
|
|
46
46
|
fd_const.puts "#{const_group.def}(#{const_name}); /* #{const_value} */"
|
|
47
47
|
end
|
|
48
48
|
end
|
data/ext/generate_structs.rb
CHANGED
|
@@ -56,7 +56,7 @@ class StructParser
|
|
|
56
56
|
def parse_files(files)
|
|
57
57
|
structs = []
|
|
58
58
|
files.each do |file_h|
|
|
59
|
-
c_src =
|
|
59
|
+
c_src = File.read(file_h)
|
|
60
60
|
c_src.scan(/struct\s+([A-Z_0-9]+)\s*\{(.*?)\}/m) do |struct|
|
|
61
61
|
struct_text = $2
|
|
62
62
|
struct = CStruct.new( $1, [] )
|
data/ext/pk11_struct_macros.h
CHANGED
|
@@ -77,7 +77,7 @@ get_ulong_ptr(VALUE obj, off_t offset)
|
|
|
77
77
|
}
|
|
78
78
|
|
|
79
79
|
static VALUE
|
|
80
|
-
set_ulong_ptr(VALUE obj, VALUE value, const char *name, off_t offset)
|
|
80
|
+
set_ulong_ptr(VALUE obj, VALUE value, const char *name, off_t offset, const rb_data_type_t *objtype)
|
|
81
81
|
{
|
|
82
82
|
VALUE new_obj;
|
|
83
83
|
CK_ULONG_PTR *ptr = (CK_ULONG_PTR *)((char*)DATA_PTR(obj) + offset);
|
|
@@ -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 =
|
|
89
|
+
new_obj = TypedData_Make_Struct(rb_cObject, CK_ULONG, objtype, *ptr);
|
|
90
90
|
rb_iv_set(obj, name, new_obj);
|
|
91
91
|
**ptr = NUM2ULONG(value);
|
|
92
92
|
return value;
|
|
@@ -180,10 +180,10 @@ set_string_ptr_len(VALUE obj, VALUE value, const char *name, off_t offset, off_t
|
|
|
180
180
|
}
|
|
181
181
|
|
|
182
182
|
static VALUE
|
|
183
|
-
get_struct_inline(VALUE obj, VALUE klass, const char *name, off_t offset)
|
|
183
|
+
get_struct_inline(VALUE obj, VALUE klass, const char *name, off_t offset, const rb_data_type_t *objtype)
|
|
184
184
|
{
|
|
185
185
|
char *ptr = (char*)DATA_PTR(obj) + offset;
|
|
186
|
-
VALUE inline_obj =
|
|
186
|
+
VALUE inline_obj = TypedData_Wrap_Struct(klass, objtype, ptr);
|
|
187
187
|
rb_iv_set(inline_obj, name, obj);
|
|
188
188
|
return inline_obj;
|
|
189
189
|
}
|
|
@@ -199,7 +199,7 @@ set_struct_inline(VALUE obj, VALUE klass, const char *struct_name, VALUE value,
|
|
|
199
199
|
}
|
|
200
200
|
|
|
201
201
|
static VALUE
|
|
202
|
-
get_struct_ptr(VALUE obj, VALUE klass, const char *name, off_t offset, int sizeofstruct)
|
|
202
|
+
get_struct_ptr(VALUE obj, VALUE klass, const char *name, off_t offset, int sizeofstruct, const rb_data_type_t *objtype)
|
|
203
203
|
{
|
|
204
204
|
char *ptr = (char*)DATA_PTR(obj);
|
|
205
205
|
char *p = *(char**)(ptr+offset);
|
|
@@ -208,7 +208,7 @@ get_struct_ptr(VALUE obj, VALUE klass, const char *name, off_t offset, int sizeo
|
|
|
208
208
|
if (!p) return Qnil;
|
|
209
209
|
mem = xmalloc(sizeofstruct);
|
|
210
210
|
memcpy(mem, p, sizeofstruct);
|
|
211
|
-
new_obj =
|
|
211
|
+
new_obj = TypedData_Wrap_Struct(klass, objtype, mem);
|
|
212
212
|
return new_obj;
|
|
213
213
|
}
|
|
214
214
|
|
|
@@ -229,7 +229,7 @@ set_struct_ptr(VALUE obj, VALUE klass, const char *struct_name, VALUE value, con
|
|
|
229
229
|
}
|
|
230
230
|
|
|
231
231
|
static VALUE
|
|
232
|
-
get_struct_ptr_array(VALUE obj, VALUE klass, off_t offset, off_t offset_len, int sizeofstruct)
|
|
232
|
+
get_struct_ptr_array(VALUE obj, VALUE klass, off_t offset, off_t offset_len, int sizeofstruct, const rb_data_type_t *objtype)
|
|
233
233
|
{
|
|
234
234
|
unsigned long i;
|
|
235
235
|
char *ptr = DATA_PTR(obj);
|
|
@@ -240,7 +240,7 @@ get_struct_ptr_array(VALUE obj, VALUE klass, off_t offset, off_t offset_len, int
|
|
|
240
240
|
VALUE new_obj;
|
|
241
241
|
void *mem = xmalloc(sizeofstruct);
|
|
242
242
|
memcpy(mem, p + sizeofstruct * i, sizeofstruct);
|
|
243
|
-
new_obj =
|
|
243
|
+
new_obj = TypedData_Wrap_Struct(klass, objtype, mem);
|
|
244
244
|
rb_ary_push(ary, new_obj);
|
|
245
245
|
}
|
|
246
246
|
return ary;
|
|
@@ -273,9 +273,15 @@ set_struct_ptr_array(VALUE obj, VALUE klass, const char *struct_name, VALUE valu
|
|
|
273
273
|
#define SIZE_OF(s, f) (sizeof(((s*)0)->f))
|
|
274
274
|
|
|
275
275
|
#define PKCS11_IMPLEMENT_ALLOCATOR(s) \
|
|
276
|
+
static const rb_data_type_t struct_##s##_obj_type = { \
|
|
277
|
+
"PKCS11::" #s, \
|
|
278
|
+
{0, RUBY_DEFAULT_FREE, 0,}, \
|
|
279
|
+
0, 0, \
|
|
280
|
+
RUBY_TYPED_FREE_IMMEDIATELY, \
|
|
281
|
+
}; \
|
|
276
282
|
static VALUE s##_s_alloc(VALUE self){ \
|
|
277
283
|
s *info; \
|
|
278
|
-
VALUE obj =
|
|
284
|
+
VALUE obj = TypedData_Make_Struct(self, s, &struct_##s##_obj_type, info); \
|
|
279
285
|
return obj; \
|
|
280
286
|
} \
|
|
281
287
|
static VALUE c##s##_to_s(VALUE self){ \
|
|
@@ -315,11 +321,18 @@ static VALUE c##s##_set_##f(VALUE o, VALUE v){ \
|
|
|
315
321
|
}
|
|
316
322
|
|
|
317
323
|
#define PKCS11_IMPLEMENT_ULONG_PTR_ACCESSOR(s, f) \
|
|
324
|
+
static const rb_data_type_t struct_##s##_##f##_obj_type = { \
|
|
325
|
+
"PKCS11::" #s "." #f, \
|
|
326
|
+
{0, RUBY_DEFAULT_FREE, 0,}, \
|
|
327
|
+
0, 0, \
|
|
328
|
+
RUBY_TYPED_FREE_IMMEDIATELY, \
|
|
329
|
+
}; \
|
|
330
|
+
\
|
|
318
331
|
static VALUE c##s##_get_##f(VALUE o){ \
|
|
319
332
|
return get_ulong_ptr(o, OFFSET_OF(s, f)); \
|
|
320
333
|
} \
|
|
321
334
|
static VALUE c##s##_set_##f(VALUE o, VALUE v){ \
|
|
322
|
-
return set_ulong_ptr(o, v, #f, OFFSET_OF(s, f)); \
|
|
335
|
+
return set_ulong_ptr(o, v, #f, OFFSET_OF(s, f), &struct_##s##_##f##_obj_type); \
|
|
323
336
|
}
|
|
324
337
|
|
|
325
338
|
#define PKCS11_IMPLEMENT_HANDLE_ACCESSOR(s, f) \
|
|
@@ -355,17 +368,29 @@ static VALUE c##s##_set_##f(VALUE o, VALUE v){ \
|
|
|
355
368
|
}
|
|
356
369
|
|
|
357
370
|
#define PKCS11_IMPLEMENT_STRUCT_ACCESSOR(s, k, f) \
|
|
371
|
+
static const rb_data_type_t struct_##s##_##f##_obj_type = { \
|
|
372
|
+
"PKCS11::" #s "." #f, \
|
|
373
|
+
{0, 0, 0,}, \
|
|
374
|
+
0, 0, \
|
|
375
|
+
RUBY_TYPED_FREE_IMMEDIATELY, \
|
|
376
|
+
}; \
|
|
358
377
|
static VALUE c##s##_get_##f(VALUE o){ \
|
|
359
|
-
return get_struct_inline(o, c##k, #f, OFFSET_OF(s, f)); \
|
|
378
|
+
return get_struct_inline(o, c##k, #f, OFFSET_OF(s, f), &struct_##s##_##f##_obj_type); \
|
|
360
379
|
} \
|
|
361
380
|
static VALUE c##s##_set_##f(VALUE o, VALUE v){ \
|
|
362
381
|
return set_struct_inline(o, c##k, #k, v, #f, OFFSET_OF(s, f), sizeof(k)); \
|
|
363
382
|
}
|
|
364
383
|
|
|
365
384
|
#define PKCS11_IMPLEMENT_PKCS11_STRUCT_ACCESSOR(s, k, f) \
|
|
385
|
+
static const rb_data_type_t struct_##s##_##f##_obj_type = { \
|
|
386
|
+
"PKCS11::" #s "." #f, \
|
|
387
|
+
{0, 0, 0,}, \
|
|
388
|
+
0, 0, \
|
|
389
|
+
RUBY_TYPED_FREE_IMMEDIATELY, \
|
|
390
|
+
}; \
|
|
366
391
|
static VALUE c##s##_get_##f(VALUE o){ \
|
|
367
392
|
VALUE klass = rb_const_get(rb_const_get(rb_cObject, rb_intern("PKCS11")), rb_intern(#k)); \
|
|
368
|
-
return get_struct_inline(o, klass, #f, OFFSET_OF(s, f)); \
|
|
393
|
+
return get_struct_inline(o, klass, #f, OFFSET_OF(s, f), &struct_##s##_##f##_obj_type); \
|
|
369
394
|
} \
|
|
370
395
|
static VALUE c##s##_set_##f(VALUE o, VALUE v){ \
|
|
371
396
|
VALUE klass = rb_const_get(rb_const_get(rb_cObject, rb_intern("PKCS11")), rb_intern(#k)); \
|
|
@@ -373,17 +398,29 @@ static VALUE c##s##_set_##f(VALUE o, VALUE v){ \
|
|
|
373
398
|
}
|
|
374
399
|
|
|
375
400
|
#define PKCS11_IMPLEMENT_STRUCT_PTR_ACCESSOR(s, k, f) \
|
|
401
|
+
static const rb_data_type_t struct_##s##_##f##_obj_type = { \
|
|
402
|
+
"PKCS11::" #s "." #f, \
|
|
403
|
+
{0, RUBY_DEFAULT_FREE, 0,}, \
|
|
404
|
+
0, 0, \
|
|
405
|
+
RUBY_TYPED_FREE_IMMEDIATELY, \
|
|
406
|
+
}; \
|
|
376
407
|
static VALUE c##s##_get_##f(VALUE o){ \
|
|
377
|
-
return get_struct_ptr(o, c##k, #f, OFFSET_OF(s, f), sizeof(k)); \
|
|
408
|
+
return get_struct_ptr(o, c##k, #f, OFFSET_OF(s, f), sizeof(k), &struct_##s##_##f##_obj_type); \
|
|
378
409
|
} \
|
|
379
410
|
static VALUE c##s##_set_##f(VALUE o, VALUE v){ \
|
|
380
411
|
return set_struct_ptr(o, c##k, #k, v, #f, OFFSET_OF(s, f)); \
|
|
381
412
|
}
|
|
382
413
|
|
|
383
414
|
#define PKCS11_IMPLEMENT_PKCS11_STRUCT_PTR_ACCESSOR(s, k, f) \
|
|
415
|
+
static const rb_data_type_t struct_##s##_##f##_obj_type = { \
|
|
416
|
+
"PKCS11::" #s "." #f, \
|
|
417
|
+
{0, RUBY_DEFAULT_FREE, 0,}, \
|
|
418
|
+
0, 0, \
|
|
419
|
+
RUBY_TYPED_FREE_IMMEDIATELY, \
|
|
420
|
+
}; \
|
|
384
421
|
static VALUE c##s##_get_##f(VALUE o){ \
|
|
385
422
|
VALUE klass = rb_const_get(rb_const_get(rb_cObject, rb_intern("PKCS11")), rb_intern(#k)); \
|
|
386
|
-
return get_struct_ptr(o, klass, #f, OFFSET_OF(s, f), sizeof(k)); \
|
|
423
|
+
return get_struct_ptr(o, klass, #f, OFFSET_OF(s, f), sizeof(k), &struct_##s##_##f##_obj_type); \
|
|
387
424
|
} \
|
|
388
425
|
static VALUE c##s##_set_##f(VALUE o, VALUE v){ \
|
|
389
426
|
VALUE klass = rb_const_get(rb_const_get(rb_cObject, rb_intern("PKCS11")), rb_intern(#k)); \
|
|
@@ -391,17 +428,29 @@ static VALUE c##s##_set_##f(VALUE o, VALUE v){ \
|
|
|
391
428
|
}
|
|
392
429
|
|
|
393
430
|
#define PKCS11_IMPLEMENT_STRUCT_PTR_ARRAY_ACCESSOR(s, k, f, l) \
|
|
431
|
+
static const rb_data_type_t struct_##s##_##f##_obj_type = { \
|
|
432
|
+
"PKCS11::" #s "." #f, \
|
|
433
|
+
{0, RUBY_DEFAULT_FREE, 0,}, \
|
|
434
|
+
0, 0, \
|
|
435
|
+
RUBY_TYPED_FREE_IMMEDIATELY, \
|
|
436
|
+
}; \
|
|
394
437
|
static VALUE c##s##_get_##f(VALUE o){ \
|
|
395
|
-
return get_struct_ptr_array(o, c##k, OFFSET_OF(s, f), OFFSET_OF(s, l), sizeof(k)); \
|
|
438
|
+
return get_struct_ptr_array(o, c##k, OFFSET_OF(s, f), OFFSET_OF(s, l), sizeof(k), &struct_##s##_##f##_obj_type); \
|
|
396
439
|
} \
|
|
397
440
|
static VALUE c##s##_set_##f(VALUE o, VALUE v){ \
|
|
398
441
|
return set_struct_ptr_array(o, c##k, #k, v, #f, OFFSET_OF(s, f), OFFSET_OF(s, l), sizeof(k)); \
|
|
399
442
|
}
|
|
400
443
|
|
|
401
444
|
#define PKCS11_IMPLEMENT_PKCS11_STRUCT_PTR_ARRAY_ACCESSOR(s, k, f, l) \
|
|
445
|
+
static const rb_data_type_t struct_##s##_##f##_obj_type = { \
|
|
446
|
+
"PKCS11::" #s "." #f, \
|
|
447
|
+
{0, RUBY_DEFAULT_FREE, 0,}, \
|
|
448
|
+
0, 0, \
|
|
449
|
+
RUBY_TYPED_FREE_IMMEDIATELY, \
|
|
450
|
+
}; \
|
|
402
451
|
static VALUE c##s##_get_##f(VALUE o){ \
|
|
403
452
|
VALUE klass = rb_const_get(rb_const_get(rb_cObject, rb_intern("PKCS11")), rb_intern(#k)); \
|
|
404
|
-
return get_struct_ptr_array(o, klass, OFFSET_OF(s, f), OFFSET_OF(s, l), sizeof(k)); \
|
|
453
|
+
return get_struct_ptr_array(o, klass, OFFSET_OF(s, f), OFFSET_OF(s, l), sizeof(k), &struct_##s##_##f##_obj_type); \
|
|
405
454
|
} \
|
|
406
455
|
static VALUE c##s##_set_##f(VALUE o, VALUE v){ \
|
|
407
456
|
VALUE klass = rb_const_get(rb_const_get(rb_cObject, rb_intern("PKCS11")), rb_intern(#k)); \
|
data/ext/pk11_version.h
CHANGED
data/ext/pk11l.c
CHANGED
|
@@ -18,6 +18,8 @@
|
|
|
18
18
|
#include <dlfcn.h>
|
|
19
19
|
#endif
|
|
20
20
|
|
|
21
|
+
#include "cryptoki_v2.h"
|
|
22
|
+
|
|
21
23
|
|
|
22
24
|
///////////////////////////////////////
|
|
23
25
|
|
|
@@ -55,11 +57,37 @@ static VALUE vRETURN_VALUES;
|
|
|
55
57
|
|
|
56
58
|
#define PKCS11_DEFINE_METHOD(name, args) \
|
|
57
59
|
rb_define_method(cPKCS11, #name, pkcs11_luna_##name, args);
|
|
58
|
-
|
|
60
|
+
|
|
61
|
+
typedef struct {
|
|
62
|
+
void *module;
|
|
63
|
+
CK_FUNCTION_LIST_PTR functions;
|
|
64
|
+
CK_SFNT_CA_FUNCTION_LIST_PTR sfnt_functions;
|
|
65
|
+
} pkcs11_luna_ctx;
|
|
66
|
+
|
|
67
|
+
static void
|
|
68
|
+
pkcs11_luna_ctx_free(void *_ptr)
|
|
69
|
+
{
|
|
70
|
+
pkcs11_luna_ctx *ctx = (pkcs11_luna_ctx *)_ptr;
|
|
71
|
+
free(ctx);
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
static size_t
|
|
75
|
+
pkcs11_luna_ctx_memsize(const void *_ptr)
|
|
76
|
+
{
|
|
77
|
+
return sizeof(pkcs11_luna_ctx);
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
static rb_data_type_t pkcs11_luna_ctx_type = {
|
|
81
|
+
"PKCS11::Luna::Library",
|
|
82
|
+
{0, pkcs11_luna_ctx_free, pkcs11_luna_ctx_memsize,},
|
|
83
|
+
0, 0,
|
|
84
|
+
RUBY_TYPED_FREE_IMMEDIATELY,
|
|
85
|
+
};
|
|
86
|
+
|
|
59
87
|
#define GetFunction(obj, name, sval) \
|
|
60
88
|
{ \
|
|
61
89
|
pkcs11_luna_ctx *ctx; \
|
|
62
|
-
|
|
90
|
+
TypedData_Get_Struct(obj, pkcs11_luna_ctx, &pkcs11_luna_ctx_type, ctx); \
|
|
63
91
|
if (!ctx->sfnt_functions) rb_raise(eLunaError, "no function list"); \
|
|
64
92
|
sval = (CK_##name)ctx->sfnt_functions->name; \
|
|
65
93
|
if (!sval) rb_raise(eLunaError, #name " is not supported."); \
|
|
@@ -74,24 +102,17 @@ static VALUE vRETURN_VALUES;
|
|
|
74
102
|
rv = params.retval; \
|
|
75
103
|
}
|
|
76
104
|
|
|
77
|
-
#include "cryptoki_v2.h"
|
|
78
|
-
|
|
79
105
|
#include "pk11_struct_macros.h"
|
|
80
106
|
#include "pk11_const_macros.h"
|
|
81
107
|
#include "pk11_version.h"
|
|
82
108
|
|
|
83
109
|
#include "pk11l_struct_impl.inc"
|
|
84
110
|
|
|
85
|
-
|
|
86
|
-
void *module;
|
|
87
|
-
CK_FUNCTION_LIST_PTR functions;
|
|
88
|
-
CK_SFNT_CA_FUNCTION_LIST_PTR sfnt_functions;
|
|
89
|
-
} pkcs11_luna_ctx;
|
|
90
|
-
|
|
111
|
+
NORETURN()
|
|
91
112
|
static void
|
|
92
|
-
pkcs11_luna_raise(VALUE self, CK_RV rv)
|
|
113
|
+
pkcs11_luna_raise(VALUE self, CK_RV rv, const char * const func)
|
|
93
114
|
{
|
|
94
|
-
rb_funcall(self, rb_intern("vendor_raise_on_return_value"),
|
|
115
|
+
rb_funcall(self, rb_intern("vendor_raise_on_return_value"), 2, ULONG2NUM(rv), rb_str_new_cstr(func));
|
|
95
116
|
rb_raise(eLunaError, "method vendor_raise_on_return_value should never return");
|
|
96
117
|
}
|
|
97
118
|
|
|
@@ -157,12 +178,6 @@ void * tbf_CA_LogExternal( void *data ){
|
|
|
157
178
|
|
|
158
179
|
|
|
159
180
|
|
|
160
|
-
static void
|
|
161
|
-
pkcs11_luna_ctx_free(pkcs11_luna_ctx *ctx)
|
|
162
|
-
{
|
|
163
|
-
free(ctx);
|
|
164
|
-
}
|
|
165
|
-
|
|
166
181
|
//NOTE: Code commented out as it was decided to only support standard pkcs11 initially.l
|
|
167
182
|
|
|
168
183
|
/*static VALUE
|
|
@@ -173,8 +188,8 @@ pkcs11_luna_CA_SetApplicationID(VALUE self, VALUE major, VALUE minor)
|
|
|
173
188
|
|
|
174
189
|
GetFunction(self, CA_SetApplicationID, func);
|
|
175
190
|
CallFunction(CA_SetApplicationID, func, rv, NUM2ULONG(major), NUM2ULONG(minor));
|
|
176
|
-
if(rv != CKR_OK)
|
|
177
|
-
pkcs11_luna_raise(self,rv);
|
|
191
|
+
if(rv != CKR_OK)
|
|
192
|
+
pkcs11_luna_raise(self, rv, "CA_SetApplicationID");
|
|
178
193
|
return self;
|
|
179
194
|
}
|
|
180
195
|
|
|
@@ -187,7 +202,7 @@ pkcs11_luna_CA_OpenApplicationID(VALUE self, VALUE slot_id, VALUE major, VALUE m
|
|
|
187
202
|
GetFunction(self, CA_OpenApplicationID, func);
|
|
188
203
|
CallFunction(CA_OpenApplicationID, func, rv, NUM2ULONG(slot_id), NUM2ULONG(major), NUM2ULONG(minor));
|
|
189
204
|
if(rv != CKR_OK)
|
|
190
|
-
pkcs11_luna_raise(self,rv);
|
|
205
|
+
pkcs11_luna_raise(self, rv, "CA_OpenApplicationID");
|
|
191
206
|
return self;
|
|
192
207
|
}
|
|
193
208
|
|
|
@@ -200,7 +215,7 @@ pkcs11_luna_CA_CloseApplicationID(VALUE self, VALUE slot_id, VALUE major, VALUE
|
|
|
200
215
|
GetFunction(self, CA_CloseApplicationID, func);
|
|
201
216
|
CallFunction(CA_CloseApplicationID, func, rv, NUM2ULONG(slot_id), NUM2ULONG(major), NUM2ULONG(minor));
|
|
202
217
|
if(rv != CKR_OK)
|
|
203
|
-
pkcs11_luna_raise(self,rv);
|
|
218
|
+
pkcs11_luna_raise(self, rv, "CA_CloseApplicationID");
|
|
204
219
|
return self;
|
|
205
220
|
}*/
|
|
206
221
|
|
|
@@ -212,7 +227,7 @@ pkcs11_luna_CA_LogExternal(VALUE self, VALUE slot_id, VALUE session, VALUE messa
|
|
|
212
227
|
GetFunction(self, CA_LogExternal, func);
|
|
213
228
|
CallFunction(CA_LogExternal, func, rv, NUM2HANDLE(slot_id), NUM2HANDLE(session),
|
|
214
229
|
(CK_CHAR_PTR)RSTRING_PTR(message), RSTRING_LEN(message));
|
|
215
|
-
if(rv != CKR_OK) pkcs11_luna_raise(self,rv);
|
|
230
|
+
if(rv != CKR_OK) pkcs11_luna_raise(self, rv, "CA_LogExternal");
|
|
216
231
|
|
|
217
232
|
return self;
|
|
218
233
|
}*/
|
|
@@ -232,7 +247,7 @@ pkcs11_luna_CA_GetFunctionList(VALUE self)
|
|
|
232
247
|
CK_RV rv;
|
|
233
248
|
CK_CA_GetFunctionList func;
|
|
234
249
|
|
|
235
|
-
|
|
250
|
+
TypedData_Get_Struct(self, pkcs11_luna_ctx, &pkcs11_luna_ctx_type, ctx);
|
|
236
251
|
#ifdef compile_for_windows
|
|
237
252
|
func = (CK_CA_GetFunctionList)GetProcAddress(ctx->module, "CA_GetFunctionList");
|
|
238
253
|
if(!func){
|
|
@@ -247,8 +262,8 @@ pkcs11_luna_CA_GetFunctionList(VALUE self)
|
|
|
247
262
|
if(!func) rb_raise(eLunaError, "%sHERE", dlerror());
|
|
248
263
|
#endif
|
|
249
264
|
CallFunction(CA_GetFunctionList, func, rv, &(ctx->sfnt_functions));
|
|
250
|
-
if (rv != CKR_OK)
|
|
251
|
-
pkcs11_luna_raise(self, rv);
|
|
265
|
+
if (rv != CKR_OK)
|
|
266
|
+
pkcs11_luna_raise(self, rv, "CA_GetFunctionList");
|
|
252
267
|
|
|
253
268
|
return self;
|
|
254
269
|
}
|
|
@@ -258,7 +273,7 @@ pkcs11_luna_s_alloc(VALUE self)
|
|
|
258
273
|
{
|
|
259
274
|
VALUE obj;
|
|
260
275
|
pkcs11_luna_ctx *ctx;
|
|
261
|
-
obj =
|
|
276
|
+
obj = TypedData_Make_Struct(self, pkcs11_luna_ctx, &pkcs11_luna_ctx_type, ctx);
|
|
262
277
|
return obj;
|
|
263
278
|
}
|
|
264
279
|
|
|
@@ -290,23 +305,26 @@ Init_pkcs11_luna_ext()
|
|
|
290
305
|
*
|
|
291
306
|
* Module to provide functionality for SafeNet's Luna HSMs */
|
|
292
307
|
mLuna = rb_define_module_under(mPKCS11, "Luna");
|
|
293
|
-
|
|
308
|
+
|
|
294
309
|
/* Document-class: PKCS11::Luna::Library
|
|
295
310
|
*
|
|
296
311
|
* Derived class for Luna Library */
|
|
297
312
|
cLibrary = rb_const_get(mPKCS11, rb_intern("Library"));
|
|
298
|
-
|
|
313
|
+
|
|
299
314
|
cPKCS11 = rb_define_class_under(mLuna, "Library", cLibrary);
|
|
300
|
-
|
|
315
|
+
|
|
316
|
+
/* fetch parent struct for correct type checks of pkcs11_luna_ctx_type */
|
|
317
|
+
pkcs11_luna_ctx_type.parent = (const rb_data_type_t*)RB_NUM2ULL( rb_const_get( cPKCS11, rb_intern("PKCS11_CTX_TYPE") ));
|
|
318
|
+
|
|
301
319
|
rb_define_alloc_func(cPKCS11, pkcs11_luna_s_alloc);
|
|
302
320
|
rb_define_method(cPKCS11, "initialize", pkcs11_luna_initialize, -1);
|
|
303
|
-
|
|
321
|
+
|
|
304
322
|
PKCS11_DEFINE_METHOD(CA_GetFunctionList, 0);
|
|
305
323
|
//PKCS11_DEFINE_METHOD(CA_LogExternal, 3);
|
|
306
324
|
//PKCS11_DEFINE_METHOD(CA_SetApplicationID, 2);
|
|
307
325
|
//PKCS11_DEFINE_METHOD(CA_OpenApplicationID, 3);
|
|
308
326
|
//PKCS11_DEFINE_METHOD(CA_CloseApplicationID, 3);
|
|
309
|
-
|
|
327
|
+
|
|
310
328
|
|
|
311
329
|
/* Library version */
|
|
312
330
|
rb_define_const( mLuna, "VERSION", rb_str_new2(VERSION) );
|
data/ext/std_structs.rb
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
PKCS11_STD_STRUCTS = [:
|
|
1
|
+
PKCS11_STD_STRUCTS = [:CK_MECHANISM, :CK_VERSION, :CK_INFO, :CK_SLOT_INFO, :CK_TOKEN_INFO, :CK_SESSION_INFO, :CK_DATE, :CK_MECHANISM_INFO, :CK_C_INITIALIZE_ARGS, :CK_RSA_PKCS_OAEP_PARAMS, :CK_RSA_PKCS_PSS_PARAMS, :CK_ECDH1_DERIVE_PARAMS, :CK_ECMQV_DERIVE_PARAMS, :CK_X9_42_DH1_DERIVE_PARAMS, :CK_X9_42_DH2_DERIVE_PARAMS, :CK_X9_42_MQV_DERIVE_PARAMS, :CK_KEA_DERIVE_PARAMS, :CK_RC2_CBC_PARAMS, :CK_RC2_MAC_GENERAL_PARAMS, :CK_RC5_PARAMS, :CK_RC5_CBC_PARAMS, :CK_RC5_MAC_GENERAL_PARAMS, :CK_DES_CBC_ENCRYPT_DATA_PARAMS, :CK_AES_CBC_ENCRYPT_DATA_PARAMS, :CK_SKIPJACK_PRIVATE_WRAP_PARAMS, :CStruct, :CK_ATTRIBUTE, :CK_SKIPJACK_RELAYX_PARAMS, :CK_PBE_PARAMS, :CK_KEY_WRAP_SET_OAEP_PARAMS, :CK_SSL3_RANDOM_DATA, :CK_SSL3_MASTER_KEY_DERIVE_PARAMS, :CK_SSL3_KEY_MAT_OUT, :CK_SSL3_KEY_MAT_PARAMS, :CK_WTLS_RANDOM_DATA, :CK_WTLS_MASTER_KEY_DERIVE_PARAMS, :CK_WTLS_PRF_PARAMS, :CK_WTLS_KEY_MAT_OUT, :CK_WTLS_KEY_MAT_PARAMS, :CK_CMS_SIG_PARAMS, :CK_KEY_DERIVATION_STRING_DATA, :CK_PKCS5_PBKD2_PARAMS, :CK_OTP_PARAM, :CK_OTP_PARAMS, :CK_OTP_SIGNATURE_INFO, :CK_KIP_PARAMS, :CK_AES_CTR_PARAMS, :CK_GCM_PARAMS, :CK_CCM_PARAMS, :CK_CAMELLIA_CBC_ENCRYPT_DATA_PARAMS, :CK_ARIA_CBC_ENCRYPT_DATA_PARAMS, :CK_DSA_PARAMETER_GEN_PARAM, :CK_ECDH_AES_KEY_WRAP_PARAMS, :CK_RSA_AES_KEY_WRAP_PARAMS, :CK_TLS12_MASTER_KEY_DERIVE_PARAMS, :CK_TLS12_KEY_MAT_PARAMS, :CK_TLS_KDF_PARAMS, :CK_TLS_MAC_PARAMS, :CK_GOSTR3410_DERIVE_PARAMS, :CK_GOSTR3410_KEY_WRAP_PARAMS]
|
|
@@ -112,12 +112,12 @@ module Luna
|
|
|
112
112
|
MechanismParameters[mech] || super
|
|
113
113
|
end
|
|
114
114
|
|
|
115
|
-
def vendor_raise_on_return_value(rv)
|
|
115
|
+
def vendor_raise_on_return_value(rv, func)
|
|
116
116
|
if ex=PKCS11::RETURN_VALUES[rv]
|
|
117
|
-
raise(ex, rv
|
|
117
|
+
raise(ex, "#{func} returned #{rv}")
|
|
118
118
|
end
|
|
119
119
|
if ex=Luna::RETURN_VALUES[rv]
|
|
120
|
-
raise(ex, rv
|
|
120
|
+
raise(ex, "#{func} returned #{rv}")
|
|
121
121
|
end
|
|
122
122
|
super
|
|
123
123
|
end
|
data.tar.gz.sig
CHANGED
|
Binary file
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: pkcs11_luna
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 0.4.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- SafeNet
|
|
@@ -10,26 +10,26 @@ bindir: bin
|
|
|
10
10
|
cert_chain:
|
|
11
11
|
- |
|
|
12
12
|
-----BEGIN CERTIFICATE-----
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
13
|
+
MIIDPDCCAiSgAwIBAgIBCTANBgkqhkiG9w0BAQsFADBEMQ0wCwYDVQQDDARsYXJz
|
|
14
|
+
MR8wHQYKCZImiZPyLGQBGRYPZ3JlaXotcmVpbnNkb3JmMRIwEAYKCZImiZPyLGQB
|
|
15
|
+
GRYCZGUwHhcNMjYwNDAxMTg0ODAwWhcNMjcwNDAxMTg0ODAwWjBEMQ0wCwYDVQQD
|
|
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
|
+
EjU6iOXhPs6VyCWOEzQvH0qFsS9bvSO6kAY/tiiM1GoMmrFf5aJcJwVGo5dUawAO
|
|
26
|
+
MtPRglzAXUg2PBjXMvdcbcmFVrx86WEtrpt4/VrRg+Sw10A5wwb/7gsmec7CPs5j
|
|
27
|
+
t40augLjTJVe2L+8vVEGXyhI33qGiQv6CFWrMhShdfRxLkEedCE/CS/xsbiOYidf
|
|
28
|
+
VeRnDP4Xd/mWfvi0E8t+OybXpljhmsElg/X9E3Ckr3I/U8xgtCUbfmWrGXXVG6+V
|
|
29
|
+
tJgAY1NWb91NFLi8hIuvg0jUtg6bVkw/m67U70Je/O+qMayhGi/lvdSicZL0y4Ly
|
|
30
|
+
lM5sbwRVBbcM4hV2A0XuHA==
|
|
31
31
|
-----END CERTIFICATE-----
|
|
32
|
-
date:
|
|
32
|
+
date: 2026-04-01 00:00:00.000000000 Z
|
|
33
33
|
dependencies:
|
|
34
34
|
- !ruby/object:Gem::Dependency
|
|
35
35
|
name: pkcs11
|
|
@@ -37,14 +37,14 @@ dependencies:
|
|
|
37
37
|
requirements:
|
|
38
38
|
- - '='
|
|
39
39
|
- !ruby/object:Gem::Version
|
|
40
|
-
version: 0.
|
|
40
|
+
version: 0.4.0
|
|
41
41
|
type: :runtime
|
|
42
42
|
prerelease: false
|
|
43
43
|
version_requirements: !ruby/object:Gem::Requirement
|
|
44
44
|
requirements:
|
|
45
45
|
- - '='
|
|
46
46
|
- !ruby/object:Gem::Version
|
|
47
|
-
version: 0.
|
|
47
|
+
version: 0.4.0
|
|
48
48
|
- !ruby/object:Gem::Dependency
|
|
49
49
|
name: yard
|
|
50
50
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -99,14 +99,14 @@ dependencies:
|
|
|
99
99
|
requirements:
|
|
100
100
|
- - "~>"
|
|
101
101
|
- !ruby/object:Gem::Version
|
|
102
|
-
version: '3.
|
|
102
|
+
version: '3.25'
|
|
103
103
|
type: :development
|
|
104
104
|
prerelease: false
|
|
105
105
|
version_requirements: !ruby/object:Gem::Requirement
|
|
106
106
|
requirements:
|
|
107
107
|
- - "~>"
|
|
108
108
|
- !ruby/object:Gem::Version
|
|
109
|
-
version: '3.
|
|
109
|
+
version: '3.25'
|
|
110
110
|
description: This module allows Ruby programs to use vendor extensions for SafeNet
|
|
111
111
|
Luna.
|
|
112
112
|
email:
|
metadata.gz.sig
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
|
|
2
|
-
]�
|
|
3
|
-
|
|
1
|
+
s�s�C�
|
|
2
|
+
X -(WZ��&rp�Y���r�%|�����&n@V
]�d�j���^c�?�(��g�O�k�^tA�����K�a�A�VS��9�S�x��:��%�^�i�\�� �5o�:�j�K�������Ş��E����"��U�Zj,� v�����$�ҷ ��
|
|
3
|
+
Umx*��b��8\D���H��.�_�<�c-O���5t���Vv���U|
|