pkcs11 0.2.4-x64-mingw32
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.tar.gz.sig +0 -0
- data/.autotest +23 -0
- data/.gemtest +0 -0
- data/.yardopts +1 -0
- data/History.txt +57 -0
- data/MIT-LICENSE +22 -0
- data/Manifest.txt +57 -0
- data/README.rdoc +205 -0
- data/Rakefile +111 -0
- data/ext/extconf.rb +7 -0
- data/ext/generate_constants.rb +57 -0
- data/ext/generate_structs.rb +206 -0
- data/ext/generate_thread_funcs.rb +72 -0
- data/ext/include/cryptoki.h +66 -0
- data/ext/include/ct-kip.h +50 -0
- data/ext/include/otp-pkcs11.h +125 -0
- data/ext/include/pkcs-11v2-20a3.h +124 -0
- data/ext/include/pkcs11.h +299 -0
- data/ext/include/pkcs11f.h +912 -0
- data/ext/include/pkcs11t.h +1885 -0
- data/ext/pk11.c +1675 -0
- data/ext/pk11.h +81 -0
- data/ext/pk11_const.c +205 -0
- data/ext/pk11_const_def.inc +452 -0
- data/ext/pk11_const_macros.h +38 -0
- data/ext/pk11_struct.doc +792 -0
- data/ext/pk11_struct_def.inc +302 -0
- data/ext/pk11_struct_impl.inc +302 -0
- data/ext/pk11_struct_macros.h +435 -0
- data/ext/pk11_thread_funcs.c +411 -0
- data/ext/pk11_thread_funcs.h +482 -0
- data/ext/pk11_version.h +6 -0
- data/lib/2.0/pkcs11_ext.so +0 -0
- data/lib/pkcs11.rb +9 -0
- data/lib/pkcs11/extensions.rb +68 -0
- data/lib/pkcs11/helper.rb +144 -0
- data/lib/pkcs11/library.rb +140 -0
- data/lib/pkcs11/object.rb +171 -0
- data/lib/pkcs11/session.rb +765 -0
- data/lib/pkcs11/slot.rb +102 -0
- data/pkcs11_protect_server/Manifest.txt +14 -0
- data/pkcs11_protect_server/README_PROTECT_SERVER.rdoc +89 -0
- data/test/fixtures/softokn/cert8.db +0 -0
- data/test/fixtures/softokn/key3.db +0 -0
- data/test/fixtures/softokn/secmod.db +0 -0
- data/test/helper.rb +58 -0
- data/test/test_pkcs11.rb +71 -0
- data/test/test_pkcs11_crypt.rb +220 -0
- data/test/test_pkcs11_object.rb +122 -0
- data/test/test_pkcs11_session.rb +123 -0
- data/test/test_pkcs11_slot.rb +78 -0
- data/test/test_pkcs11_structs.rb +166 -0
- data/test/test_pkcs11_thread.rb +44 -0
- metadata +213 -0
- metadata.gz.sig +0 -0
data/ext/extconf.rb
ADDED
@@ -0,0 +1,57 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# Quick and dirty parser for PKCS#11 constants and
|
3
|
+
# generator for Ruby wrapper classes.
|
4
|
+
|
5
|
+
require 'optparse'
|
6
|
+
|
7
|
+
module PKCS11
|
8
|
+
class ConstantParser
|
9
|
+
|
10
|
+
attr_accessor :options
|
11
|
+
|
12
|
+
def self.run(argv)
|
13
|
+
s = self.new
|
14
|
+
options = Struct.new(:verbose, :const, :files).new
|
15
|
+
OptionParser.new(argv) do |opts|
|
16
|
+
opts.banner = "Usage: #{$0} [options] <header-file.h>*"
|
17
|
+
|
18
|
+
opts.on("-v", "--[no-]verbose", "Run verbosely", &options.method(:verbose=))
|
19
|
+
opts.on("--const FILE", "Write const implementations to this file", &options.method(:const=))
|
20
|
+
opts.on_tail("-h", "--help", "Show this message") do
|
21
|
+
puts opts
|
22
|
+
exit
|
23
|
+
end
|
24
|
+
end.parse!
|
25
|
+
options.files = argv
|
26
|
+
s.options = options
|
27
|
+
s.start!
|
28
|
+
end
|
29
|
+
|
30
|
+
ConstTemplate = Struct.new :regexp, :def
|
31
|
+
ConstGroups = [
|
32
|
+
ConstTemplate.new(/#define\s+(CKM_[A-Z_0-9]+)\s+(\w+)/, 'PKCS11_DEFINE_MECHANISM'),
|
33
|
+
ConstTemplate.new(/#define\s+(CKA_[A-Z_0-9]+)\s+(\w+)/, 'PKCS11_DEFINE_ATTRIBUTE'),
|
34
|
+
ConstTemplate.new(/#define\s+(CKO_[A-Z_0-9]+)\s+(\w+)/, 'PKCS11_DEFINE_OBJECT_CLASS'),
|
35
|
+
ConstTemplate.new(/#define\s+(CKR_[A-Z_0-9]+)\s+(\w+)/, 'PKCS11_DEFINE_RETURN_VALUE'),
|
36
|
+
]
|
37
|
+
|
38
|
+
def start!
|
39
|
+
File.open(options.const, "w") do |fd_const|
|
40
|
+
options.files.each do |file_h|
|
41
|
+
c_src = IO.read(file_h)
|
42
|
+
ConstGroups.each do |const_group|
|
43
|
+
c_src.scan(const_group.regexp) do
|
44
|
+
const_name, const_value = $1, $2
|
45
|
+
|
46
|
+
fd_const.puts "#{const_group.def}(#{const_name}); /* #{const_value} */"
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
if $0==__FILE__
|
56
|
+
PKCS11::ConstantParser.run(ARGV)
|
57
|
+
end
|
@@ -0,0 +1,206 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# Quick and dirty parser for PKCS#11 structs and
|
3
|
+
# generator for Ruby wrapper classes.
|
4
|
+
|
5
|
+
require 'optparse'
|
6
|
+
|
7
|
+
module PKCS11
|
8
|
+
class StructParser
|
9
|
+
|
10
|
+
attr_accessor :options
|
11
|
+
attr_accessor :structs
|
12
|
+
attr_accessor :structs_by_name
|
13
|
+
attr_accessor :std_structs_by_name
|
14
|
+
|
15
|
+
def self.run(argv)
|
16
|
+
s = self.new
|
17
|
+
options = Struct.new(:verbose, :def, :impl, :doc, :files).new
|
18
|
+
OptionParser.new(argv) do |opts|
|
19
|
+
opts.banner = "Usage: #{$0} [options] <header-file.h>*"
|
20
|
+
|
21
|
+
opts.on("-v", "--[no-]verbose", "Run verbosely", &options.method(:verbose=))
|
22
|
+
opts.on("--def FILE", "Write struct definitions to this file", &options.method(:def=))
|
23
|
+
opts.on("--impl FILE", "Write struct implementations to this file", &options.method(:impl=))
|
24
|
+
opts.on("--doc FILE", "Write documentation to this file", &options.method(:doc=))
|
25
|
+
opts.on_tail("-h", "--help", "Show this message") do
|
26
|
+
puts opts
|
27
|
+
exit
|
28
|
+
end
|
29
|
+
end.parse!
|
30
|
+
options.files = argv
|
31
|
+
s.options = options
|
32
|
+
s.start!
|
33
|
+
end
|
34
|
+
|
35
|
+
CStruct = Struct.new(:name, :attrs)
|
36
|
+
Attribute = Struct.new(:type, :name, :qual, :mark)
|
37
|
+
IgnoreStructs = %w[CK_ATTRIBUTE CK_MECHANISM]
|
38
|
+
OnlyAllocatorStructs = %w[CK_MECHANISM_INFO CK_C_INITIALIZE_ARGS CK_INFO CK_SLOT_INFO CK_TOKEN_INFO CK_SESSION_INFO]
|
39
|
+
|
40
|
+
def struct_module
|
41
|
+
'PKCS11'
|
42
|
+
end
|
43
|
+
|
44
|
+
class CStruct
|
45
|
+
def attr_by_sign(key)
|
46
|
+
attrs.find{|a| a.type+" "+a.name==key }
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
class Attribute
|
51
|
+
def type_noptr
|
52
|
+
type.gsub(/_PTR$/,'')
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
def parse_files(files)
|
57
|
+
structs = []
|
58
|
+
files.each do |file_h|
|
59
|
+
c_src = IO.read(file_h)
|
60
|
+
c_src.scan(/struct\s+([A-Z_0-9]+)\s*\{(.*?)\}/m) do |struct|
|
61
|
+
struct_text = $2
|
62
|
+
struct = CStruct.new( $1, [] )
|
63
|
+
|
64
|
+
struct_text.scan(/^\s+([A-Z_0-9]+)\s+([\w_]+)\s*(\[\s*(\d+)\s*\])?/) do |elem|
|
65
|
+
struct.attrs << Attribute.new($1, $2, $4)
|
66
|
+
end
|
67
|
+
structs << struct
|
68
|
+
end
|
69
|
+
end
|
70
|
+
return structs
|
71
|
+
end
|
72
|
+
|
73
|
+
def start!
|
74
|
+
@structs = parse_files(options.files)
|
75
|
+
@structs_by_name = @structs.inject({}){|sum, v| sum[v.name]=v; sum }
|
76
|
+
@std_structs_by_name = @structs_by_name.dup
|
77
|
+
|
78
|
+
write_files
|
79
|
+
end
|
80
|
+
|
81
|
+
def array_attribute_names; ['pParams']; end
|
82
|
+
|
83
|
+
def write_files
|
84
|
+
File.open(options.def, "w") do |fd_def|
|
85
|
+
File.open(options.impl, "w") do |fd_impl|
|
86
|
+
File.open(options.doc, "w") do |fd_doc|
|
87
|
+
structs.each do |struct|
|
88
|
+
next if IgnoreStructs.include?(struct.name)
|
89
|
+
|
90
|
+
if OnlyAllocatorStructs.include?(struct.name)
|
91
|
+
fd_impl.puts "PKCS11_IMPLEMENT_ALLOCATOR(#{struct.name});"
|
92
|
+
else
|
93
|
+
fd_impl.puts "PKCS11_IMPLEMENT_STRUCT_WITH_ALLOCATOR(#{struct.name});"
|
94
|
+
end
|
95
|
+
fd_def.puts "PKCS11_DEFINE_STRUCT(#{struct.name});"
|
96
|
+
fd_doc.puts"class #{struct_module}::#{struct.name} < #{struct_module}::CStruct"
|
97
|
+
fd_doc.puts"# Size of corresponding C struct in bytes\nSIZEOF_STRUCT=Integer"
|
98
|
+
fd_doc.puts"# @return [String] Binary copy of the C struct\ndef to_s; end"
|
99
|
+
fd_doc.puts"# @return [Array<String>] Attributes of this struct\ndef members; end"
|
100
|
+
|
101
|
+
# find attributes belonging together for array of struct
|
102
|
+
struct.attrs.select{|attr| structs_by_name[attr.type_noptr] || std_structs_by_name[attr.type_noptr] }.each do |attr|
|
103
|
+
if array_attribute_names.include?(attr.name) && (len_attr = struct.attr_by_sign("CK_ULONG ulCount") || struct.attr_by_sign("CK_ULONG count") || struct.attr_by_sign("CK_ULONG #{attr.name}Count"))
|
104
|
+
std_struct = "PKCS11_" if std_structs_by_name[attr.type_noptr]
|
105
|
+
fd_impl.puts "PKCS11_IMPLEMENT_#{std_struct}STRUCT_PTR_ARRAY_ACCESSOR(#{struct.name}, #{attr.type_noptr}, #{attr.name}, #{len_attr.name});"
|
106
|
+
fd_def.puts "PKCS11_DEFINE_MEMBER(#{struct.name}, #{attr.name});"
|
107
|
+
fd_doc.puts"# @return [Array<PKCS11::#{attr.type_noptr}>] accessor for #{attr.name} and #{len_attr.name}\nattr_accessor :#{attr.name}"
|
108
|
+
len_attr.mark = true
|
109
|
+
attr.mark = true
|
110
|
+
end
|
111
|
+
end
|
112
|
+
# find string attributes belonging together
|
113
|
+
struct.attrs.select{|attr| ['CK_BYTE_PTR', 'CK_VOID_PTR', 'CK_UTF8CHAR_PTR', 'CK_CHAR_PTR'].include?(attr.type) }.each do |attr|
|
114
|
+
if len_attr=struct.attr_by_sign("CK_ULONG #{attr.name.gsub(/^p([A-Z])/){ "ul"+$1 }}Len")
|
115
|
+
fd_impl.puts "PKCS11_IMPLEMENT_STRING_PTR_LEN_ACCESSOR(#{struct.name}, #{attr.name}, #{len_attr.name});"
|
116
|
+
fd_def.puts "PKCS11_DEFINE_MEMBER(#{struct.name}, #{attr.name});"
|
117
|
+
fd_doc.puts"# @return [String, nil] accessor for #{attr.name} and #{len_attr.name}\nattr_accessor :#{attr.name}"
|
118
|
+
len_attr.mark = true
|
119
|
+
elsif attr.name=='pData' && (len_attr = struct.attr_by_sign("CK_ULONG length") || struct.attr_by_sign("CK_ULONG ulLen"))
|
120
|
+
fd_impl.puts "PKCS11_IMPLEMENT_STRING_PTR_LEN_ACCESSOR(#{struct.name}, #{attr.name}, #{len_attr.name});"
|
121
|
+
fd_def.puts "PKCS11_DEFINE_MEMBER(#{struct.name}, #{attr.name});"
|
122
|
+
fd_doc.puts"# @return [String, nil] accessor for #{attr.name} and #{len_attr.name}\nattr_accessor :#{attr.name}"
|
123
|
+
len_attr.mark = true
|
124
|
+
else
|
125
|
+
fd_impl.puts "PKCS11_IMPLEMENT_STRING_PTR_ACCESSOR(#{struct.name}, #{attr.name});"
|
126
|
+
fd_def.puts "PKCS11_DEFINE_MEMBER(#{struct.name}, #{attr.name});"
|
127
|
+
fd_doc.puts"# @return [String, nil] accessor for #{attr.name}\nattr_accessor :#{attr.name}"
|
128
|
+
end
|
129
|
+
attr.mark = true
|
130
|
+
end
|
131
|
+
|
132
|
+
# standalone attributes
|
133
|
+
struct.attrs.reject{|a| a.mark }.each do |attr|
|
134
|
+
if attr.qual
|
135
|
+
# Attributes with qualifier
|
136
|
+
case attr.type
|
137
|
+
when 'CK_BYTE', 'CK_UTF8CHAR', 'CK_CHAR'
|
138
|
+
fd_impl.puts "PKCS11_IMPLEMENT_STRING_ACCESSOR(#{struct.name}, #{attr.name});"
|
139
|
+
fd_def.puts "PKCS11_DEFINE_MEMBER(#{struct.name}, #{attr.name});"
|
140
|
+
fd_doc.puts"# @return [String] accessor for #{attr.name} (max #{attr.qual} bytes)\nattr_accessor :#{attr.name}"
|
141
|
+
else
|
142
|
+
fd_impl.puts "/* unimplemented attr #{attr.type} #{attr.name} #{attr.qual} */"
|
143
|
+
fd_def.puts "/* unimplemented attr #{attr.type} #{attr.name} #{attr.qual} */"
|
144
|
+
end
|
145
|
+
else
|
146
|
+
case attr.type
|
147
|
+
when 'CK_BYTE'
|
148
|
+
fd_impl.puts "PKCS11_IMPLEMENT_BYTE_ACCESSOR(#{struct.name}, #{attr.name});"
|
149
|
+
fd_def.puts "PKCS11_DEFINE_MEMBER(#{struct.name}, #{attr.name});"
|
150
|
+
fd_doc.puts"# @return [Integer] accessor for #{attr.name} (CK_BYTE)\nattr_accessor :#{attr.name}"
|
151
|
+
when 'CK_ULONG', 'CK_FLAGS', 'CK_SLOT_ID', 'CK_STATE', /CK_[A-Z_0-9]+_TYPE/
|
152
|
+
fd_impl.puts "PKCS11_IMPLEMENT_ULONG_ACCESSOR(#{struct.name}, #{attr.name});"
|
153
|
+
fd_def.puts "PKCS11_DEFINE_MEMBER(#{struct.name}, #{attr.name});"
|
154
|
+
fd_doc.puts"# @return [Integer] accessor for #{attr.name} (CK_ULONG)\nattr_accessor :#{attr.name}"
|
155
|
+
when 'CK_OBJECT_HANDLE'
|
156
|
+
fd_impl.puts "PKCS11_IMPLEMENT_HANDLE_ACCESSOR(#{struct.name}, #{attr.name});"
|
157
|
+
fd_def.puts "PKCS11_DEFINE_MEMBER(#{struct.name}, #{attr.name});"
|
158
|
+
fd_doc.puts"# @return [Integer, PKCS11::Object] Object handle (CK_ULONG)\nattr_accessor :#{attr.name}"
|
159
|
+
when 'CK_BBOOL'
|
160
|
+
fd_impl.puts "PKCS11_IMPLEMENT_BOOL_ACCESSOR(#{struct.name}, #{attr.name});"
|
161
|
+
fd_def.puts "PKCS11_DEFINE_MEMBER(#{struct.name}, #{attr.name});"
|
162
|
+
fd_doc.puts"# @return [Boolean] Bool value\nattr_accessor :#{attr.name}"
|
163
|
+
when 'CK_ULONG_PTR'
|
164
|
+
fd_impl.puts "PKCS11_IMPLEMENT_ULONG_PTR_ACCESSOR(#{struct.name}, #{attr.name});"
|
165
|
+
fd_def.puts "PKCS11_DEFINE_MEMBER(#{struct.name}, #{attr.name});"
|
166
|
+
fd_doc.puts"# @return [Integer, nil] accessor for #{attr.name} (CK_ULONG_PTR)\nattr_accessor :#{attr.name}"
|
167
|
+
else
|
168
|
+
# Struct attributes
|
169
|
+
if structs_by_name[attr.type]
|
170
|
+
fd_impl.puts "PKCS11_IMPLEMENT_STRUCT_ACCESSOR(#{struct.name}, #{attr.type}, #{attr.name});"
|
171
|
+
fd_def.puts "PKCS11_DEFINE_MEMBER(#{struct.name}, #{attr.name});"
|
172
|
+
fd_doc.puts"# @return [#{struct_module}::#{attr.type}] inline struct\nattr_accessor :#{attr.name}"
|
173
|
+
elsif structs_by_name[attr.type_noptr]
|
174
|
+
fd_impl.puts "PKCS11_IMPLEMENT_STRUCT_PTR_ACCESSOR(#{struct.name}, #{attr.type_noptr}, #{attr.name});"
|
175
|
+
fd_def.puts "PKCS11_DEFINE_MEMBER(#{struct.name}, #{attr.name});"
|
176
|
+
fd_doc.puts"# @return [#{struct_module}::#{attr.type_noptr}, nil] pointer to struct\nattr_accessor :#{attr.name}"
|
177
|
+
elsif std_structs_by_name[attr.type]
|
178
|
+
fd_impl.puts "PKCS11_IMPLEMENT_PKCS11_STRUCT_ACCESSOR(#{struct.name}, #{attr.type}, #{attr.name});"
|
179
|
+
fd_def.puts "PKCS11_DEFINE_MEMBER(#{struct.name}, #{attr.name});"
|
180
|
+
fd_doc.puts"# @return [PKCS11::#{attr.type}] inline struct (see pkcs11.gem)\nattr_accessor :#{attr.name}"
|
181
|
+
elsif std_structs_by_name[attr.type_noptr]
|
182
|
+
fd_impl.puts "PKCS11_IMPLEMENT_PKCS11_STRUCT_PTR_ACCESSOR(#{struct.name}, #{attr.type_noptr}, #{attr.name});"
|
183
|
+
fd_def.puts "PKCS11_DEFINE_MEMBER(#{struct.name}, #{attr.name});"
|
184
|
+
fd_doc.puts"# @return [PKCS11::#{attr.type_noptr}, nil] pointer to struct (see pkcs11.gem)\nattr_accessor :#{attr.name}"
|
185
|
+
else
|
186
|
+
fd_impl.puts "/* unimplemented attr #{attr.type} #{attr.name} #{attr.qual} */"
|
187
|
+
fd_def.puts "/* unimplemented attr #{attr.type} #{attr.name} #{attr.qual} */"
|
188
|
+
end
|
189
|
+
end
|
190
|
+
end
|
191
|
+
end
|
192
|
+
|
193
|
+
fd_impl.puts
|
194
|
+
fd_def.puts
|
195
|
+
fd_doc.puts "end"
|
196
|
+
end
|
197
|
+
end
|
198
|
+
end
|
199
|
+
end
|
200
|
+
end
|
201
|
+
end
|
202
|
+
end
|
203
|
+
|
204
|
+
if $0==__FILE__
|
205
|
+
PKCS11::StructParser.run(ARGV)
|
206
|
+
end
|
@@ -0,0 +1,72 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# This quick and dirty parser for PKCS#11 functions generates
|
3
|
+
# wrapper functions for using rb_thread_blocking_region()
|
4
|
+
# of Ruby 1.9.
|
5
|
+
|
6
|
+
require 'optparse'
|
7
|
+
|
8
|
+
options = Struct.new(:verbose, :impl, :decl).new
|
9
|
+
OptionParser.new do |opts|
|
10
|
+
opts.banner = "Usage: #{$0} [options] <header-file.h>*"
|
11
|
+
|
12
|
+
opts.on("-v", "--[no-]verbose", "Run verbosely", &options.method(:verbose=))
|
13
|
+
opts.on("--decl FILE", "Write declarations to this file", &options.method(:decl=))
|
14
|
+
opts.on("--impl FILE", "Write implementations to this file", &options.method(:impl=))
|
15
|
+
opts.on_tail("-h", "--help", "Show this message") do
|
16
|
+
puts opts
|
17
|
+
exit
|
18
|
+
end
|
19
|
+
end.parse!
|
20
|
+
|
21
|
+
Attribute = Struct.new(:type, :name)
|
22
|
+
|
23
|
+
File.open(options.decl, "w") do |fd_decl|
|
24
|
+
File.open(options.impl, "w") do |fd_impl|
|
25
|
+
fd_decl.puts <<-EOT
|
26
|
+
#ifndef #{options.decl.gsub(/[^\w]/, "_").upcase}
|
27
|
+
#define #{options.decl.gsub(/[^\w]/, "_").upcase}
|
28
|
+
#include "pk11.h"
|
29
|
+
#ifdef HAVE_RB_THREAD_BLOCKING_REGION
|
30
|
+
EOT
|
31
|
+
fd_impl.puts <<-EOT
|
32
|
+
#include #{File.basename(options.decl).inspect}
|
33
|
+
#ifdef HAVE_RB_THREAD_BLOCKING_REGION
|
34
|
+
EOT
|
35
|
+
ARGV.each do |file_h|
|
36
|
+
c_src = IO.read(file_h)
|
37
|
+
c_src.scan(/CK_PKCS11_FUNCTION_INFO\((.+?)\).*?\((.*?)\);/m) do
|
38
|
+
func_name, func_param_list = $1, $2
|
39
|
+
func_params = []
|
40
|
+
func_param_list.scan(/^\s+([A-Z_0-9]+)\s+([\w_]+)/) do |elem|
|
41
|
+
func_params << Attribute.new($1, $2)
|
42
|
+
end
|
43
|
+
puts "func_name:#{func_name.inspect} func_params: #{func_params.inspect}" if options.verbose
|
44
|
+
|
45
|
+
fd_decl.puts <<-EOT
|
46
|
+
struct tbr_#{func_name}_params {
|
47
|
+
CK_#{func_name} func;
|
48
|
+
struct { #{ func_params.map{|f| f.type+" "+f.name+";"}.join } } params;
|
49
|
+
CK_RV retval;
|
50
|
+
};
|
51
|
+
VALUE tbf_#{func_name}( void *data );
|
52
|
+
|
53
|
+
EOT
|
54
|
+
fd_impl.puts <<-EOT
|
55
|
+
VALUE tbf_#{func_name}( void *data ){
|
56
|
+
struct tbr_#{func_name}_params *p = (struct tbr_#{func_name}_params*)data;
|
57
|
+
p->retval = p->func( #{func_params.map{|f| "p->params."+f.name}.join(",") } );
|
58
|
+
return Qnil;
|
59
|
+
}
|
60
|
+
|
61
|
+
EOT
|
62
|
+
end
|
63
|
+
end
|
64
|
+
fd_impl.puts <<-EOT
|
65
|
+
#endif
|
66
|
+
EOT
|
67
|
+
fd_decl.puts <<-EOT
|
68
|
+
#endif
|
69
|
+
#endif
|
70
|
+
EOT
|
71
|
+
end
|
72
|
+
end
|
@@ -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
|