pkcs11 0.2.0-x86-mingw32 → 0.2.1-x86-mingw32
Sign up to get free protection for your applications and to get access to all the features.
- 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/ext/pk11_const.c
CHANGED
@@ -1,229 +1,205 @@
|
|
1
|
-
#include "pk11.h"
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
PKCS11_DEFINE_CONST(
|
53
|
-
PKCS11_DEFINE_CONST(
|
54
|
-
PKCS11_DEFINE_CONST(
|
55
|
-
|
56
|
-
|
57
|
-
PKCS11_DEFINE_CONST(
|
58
|
-
PKCS11_DEFINE_CONST(
|
59
|
-
PKCS11_DEFINE_CONST(
|
60
|
-
|
61
|
-
|
62
|
-
PKCS11_DEFINE_CONST(
|
63
|
-
|
64
|
-
|
65
|
-
PKCS11_DEFINE_CONST(
|
66
|
-
PKCS11_DEFINE_CONST(
|
67
|
-
PKCS11_DEFINE_CONST(
|
68
|
-
PKCS11_DEFINE_CONST(
|
69
|
-
PKCS11_DEFINE_CONST(
|
70
|
-
PKCS11_DEFINE_CONST(
|
71
|
-
PKCS11_DEFINE_CONST(
|
72
|
-
PKCS11_DEFINE_CONST(
|
73
|
-
PKCS11_DEFINE_CONST(
|
74
|
-
PKCS11_DEFINE_CONST(
|
75
|
-
PKCS11_DEFINE_CONST(
|
76
|
-
PKCS11_DEFINE_CONST(
|
77
|
-
PKCS11_DEFINE_CONST(
|
78
|
-
PKCS11_DEFINE_CONST(
|
79
|
-
PKCS11_DEFINE_CONST(
|
80
|
-
PKCS11_DEFINE_CONST(
|
81
|
-
PKCS11_DEFINE_CONST(
|
82
|
-
PKCS11_DEFINE_CONST(
|
83
|
-
PKCS11_DEFINE_CONST(
|
84
|
-
PKCS11_DEFINE_CONST(
|
85
|
-
PKCS11_DEFINE_CONST(
|
86
|
-
PKCS11_DEFINE_CONST(
|
87
|
-
PKCS11_DEFINE_CONST(
|
88
|
-
PKCS11_DEFINE_CONST(
|
89
|
-
PKCS11_DEFINE_CONST(
|
90
|
-
PKCS11_DEFINE_CONST(
|
91
|
-
PKCS11_DEFINE_CONST(
|
92
|
-
PKCS11_DEFINE_CONST(
|
93
|
-
PKCS11_DEFINE_CONST(
|
94
|
-
|
95
|
-
|
96
|
-
PKCS11_DEFINE_CONST(
|
97
|
-
PKCS11_DEFINE_CONST(
|
98
|
-
PKCS11_DEFINE_CONST(
|
99
|
-
|
100
|
-
|
101
|
-
PKCS11_DEFINE_CONST(
|
102
|
-
PKCS11_DEFINE_CONST(
|
103
|
-
PKCS11_DEFINE_CONST(
|
104
|
-
PKCS11_DEFINE_CONST(
|
105
|
-
|
106
|
-
|
107
|
-
PKCS11_DEFINE_CONST(
|
108
|
-
PKCS11_DEFINE_CONST(
|
109
|
-
PKCS11_DEFINE_CONST(
|
110
|
-
PKCS11_DEFINE_CONST(
|
111
|
-
PKCS11_DEFINE_CONST(
|
112
|
-
PKCS11_DEFINE_CONST(
|
113
|
-
PKCS11_DEFINE_CONST(
|
114
|
-
PKCS11_DEFINE_CONST(
|
115
|
-
PKCS11_DEFINE_CONST(
|
116
|
-
PKCS11_DEFINE_CONST(
|
117
|
-
PKCS11_DEFINE_CONST(
|
118
|
-
|
119
|
-
|
120
|
-
PKCS11_DEFINE_CONST(
|
121
|
-
PKCS11_DEFINE_CONST(
|
122
|
-
PKCS11_DEFINE_CONST(
|
123
|
-
|
124
|
-
|
125
|
-
PKCS11_DEFINE_CONST(
|
126
|
-
PKCS11_DEFINE_CONST(
|
127
|
-
PKCS11_DEFINE_CONST(
|
128
|
-
PKCS11_DEFINE_CONST(
|
129
|
-
|
130
|
-
|
131
|
-
PKCS11_DEFINE_CONST(
|
132
|
-
PKCS11_DEFINE_CONST(
|
133
|
-
PKCS11_DEFINE_CONST(
|
134
|
-
PKCS11_DEFINE_CONST(
|
135
|
-
PKCS11_DEFINE_CONST(
|
136
|
-
PKCS11_DEFINE_CONST(
|
137
|
-
PKCS11_DEFINE_CONST(
|
138
|
-
PKCS11_DEFINE_CONST(
|
139
|
-
|
140
|
-
|
141
|
-
PKCS11_DEFINE_CONST(
|
142
|
-
PKCS11_DEFINE_CONST(
|
143
|
-
PKCS11_DEFINE_CONST(
|
144
|
-
PKCS11_DEFINE_CONST(
|
145
|
-
|
146
|
-
|
147
|
-
PKCS11_DEFINE_CONST(
|
148
|
-
PKCS11_DEFINE_CONST(
|
149
|
-
PKCS11_DEFINE_CONST(
|
150
|
-
PKCS11_DEFINE_CONST(
|
151
|
-
PKCS11_DEFINE_CONST(
|
152
|
-
|
153
|
-
|
154
|
-
PKCS11_DEFINE_CONST(
|
155
|
-
PKCS11_DEFINE_CONST(
|
156
|
-
PKCS11_DEFINE_CONST(
|
157
|
-
PKCS11_DEFINE_CONST(
|
158
|
-
PKCS11_DEFINE_CONST(
|
159
|
-
|
160
|
-
|
161
|
-
PKCS11_DEFINE_CONST(
|
162
|
-
PKCS11_DEFINE_CONST(
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
PKCS11_DEFINE_CONST(
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
PKCS11_DEFINE_CONST(
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
PKCS11_DEFINE_CONST(
|
192
|
-
|
193
|
-
|
194
|
-
PKCS11_DEFINE_CONST(
|
195
|
-
PKCS11_DEFINE_CONST(
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
|
202
|
-
|
203
|
-
|
204
|
-
|
205
|
-
|
206
|
-
#include "pk11_const_def.inc"
|
207
|
-
|
208
|
-
rb_obj_freeze(vOBJECT_CLASSES);
|
209
|
-
rb_obj_freeze(vATTRIBUTES);
|
210
|
-
rb_obj_freeze(vMECHANISMS);
|
211
|
-
rb_obj_freeze(vRETURN_VALUES);
|
212
|
-
|
213
|
-
/* OTP parameters */
|
214
|
-
PKCS11_DEFINE_CONST(CK_OTP_CHALLENGE);
|
215
|
-
PKCS11_DEFINE_CONST(CK_OTP_COUNTER);
|
216
|
-
PKCS11_DEFINE_CONST(CK_OTP_FLAGS);
|
217
|
-
PKCS11_DEFINE_CONST(CK_OTP_FORMAT_ALPHANUMERIC);
|
218
|
-
PKCS11_DEFINE_CONST(CK_OTP_FORMAT_BINARY);
|
219
|
-
PKCS11_DEFINE_CONST(CK_OTP_FORMAT_DECIMAL);
|
220
|
-
PKCS11_DEFINE_CONST(CK_OTP_FORMAT_HEXADECIMAL);
|
221
|
-
PKCS11_DEFINE_CONST(CK_OTP_OUTPUT_FORMAT);
|
222
|
-
PKCS11_DEFINE_CONST(CK_OTP_OUTPUT_LENGTH);
|
223
|
-
PKCS11_DEFINE_CONST(CK_OTP_PARAM_IGNORED);
|
224
|
-
PKCS11_DEFINE_CONST(CK_OTP_PARAM_MANDATORY);
|
225
|
-
PKCS11_DEFINE_CONST(CK_OTP_PARAM_OPTIONAL);
|
226
|
-
PKCS11_DEFINE_CONST(CK_OTP_PIN);
|
227
|
-
PKCS11_DEFINE_CONST(CK_OTP_TIME);
|
228
|
-
PKCS11_DEFINE_CONST(CK_OTP_VALUE);
|
229
|
-
}
|
1
|
+
#include "pk11.h"
|
2
|
+
#include "pk11_const_macros.h"
|
3
|
+
|
4
|
+
#define MODULE_FOR_CONSTS cPKCS11
|
5
|
+
#define BASECLASS_FOR_ERRORS ePKCS11Error
|
6
|
+
|
7
|
+
static VALUE vOBJECT_CLASSES;
|
8
|
+
static VALUE vATTRIBUTES;
|
9
|
+
static VALUE vMECHANISMS;
|
10
|
+
static VALUE vRETURN_VALUES;
|
11
|
+
|
12
|
+
VALUE
|
13
|
+
pkcs11_return_value_to_class(CK_RV rv, VALUE ePKCS11Error)
|
14
|
+
{
|
15
|
+
VALUE class;
|
16
|
+
|
17
|
+
class = rb_hash_aref(vRETURN_VALUES, INT2NUM(rv));
|
18
|
+
if (NIL_P(class)){
|
19
|
+
class = ePKCS11Error;
|
20
|
+
}
|
21
|
+
|
22
|
+
return class;
|
23
|
+
}
|
24
|
+
|
25
|
+
void
|
26
|
+
Init_pkcs11_const(VALUE cPKCS11, VALUE ePKCS11Error)
|
27
|
+
{
|
28
|
+
PKCS11_DEFINE_CONST(CRYPTOKI_VERSION_MAJOR);
|
29
|
+
PKCS11_DEFINE_CONST(CRYPTOKI_VERSION_MINOR);
|
30
|
+
PKCS11_DEFINE_CONST(CRYPTOKI_VERSION_AMENDMENT);
|
31
|
+
|
32
|
+
/* General constant */
|
33
|
+
PKCS11_DEFINE_CONST(CK_UNAVAILABLE_INFORMATION);
|
34
|
+
PKCS11_DEFINE_CONST(CK_EFFECTIVELY_INFINITE);
|
35
|
+
PKCS11_DEFINE_CONST(CK_INVALID_HANDLE);
|
36
|
+
|
37
|
+
/* Notification */
|
38
|
+
PKCS11_DEFINE_CONST(CKN_SURRENDER);
|
39
|
+
|
40
|
+
/* Bit flag */
|
41
|
+
PKCS11_DEFINE_CONST(CKF_TOKEN_PRESENT);
|
42
|
+
PKCS11_DEFINE_CONST(CKF_REMOVABLE_DEVICE);
|
43
|
+
PKCS11_DEFINE_CONST(CKF_HW_SLOT);
|
44
|
+
PKCS11_DEFINE_CONST(CKF_RNG);
|
45
|
+
PKCS11_DEFINE_CONST(CKF_WRITE_PROTECTED);
|
46
|
+
PKCS11_DEFINE_CONST(CKF_LOGIN_REQUIRED);
|
47
|
+
PKCS11_DEFINE_CONST(CKF_USER_PIN_INITIALIZED);
|
48
|
+
PKCS11_DEFINE_CONST(CKF_RESTORE_KEY_NOT_NEEDED);
|
49
|
+
PKCS11_DEFINE_CONST(CKF_CLOCK_ON_TOKEN);
|
50
|
+
PKCS11_DEFINE_CONST(CKF_PROTECTED_AUTHENTICATION_PATH);
|
51
|
+
PKCS11_DEFINE_CONST(CKF_DUAL_CRYPTO_OPERATIONS);
|
52
|
+
PKCS11_DEFINE_CONST(CKF_TOKEN_INITIALIZED);
|
53
|
+
PKCS11_DEFINE_CONST(CKF_SECONDARY_AUTHENTICATION);
|
54
|
+
PKCS11_DEFINE_CONST(CKF_USER_PIN_COUNT_LOW);
|
55
|
+
PKCS11_DEFINE_CONST(CKF_USER_PIN_FINAL_TRY);
|
56
|
+
PKCS11_DEFINE_CONST(CKF_USER_PIN_LOCKED);
|
57
|
+
PKCS11_DEFINE_CONST(CKF_USER_PIN_TO_BE_CHANGED);
|
58
|
+
PKCS11_DEFINE_CONST(CKF_SO_PIN_COUNT_LOW);
|
59
|
+
PKCS11_DEFINE_CONST(CKF_SO_PIN_FINAL_TRY);
|
60
|
+
PKCS11_DEFINE_CONST(CKF_SO_PIN_LOCKED);
|
61
|
+
PKCS11_DEFINE_CONST(CKF_SO_PIN_TO_BE_CHANGED);
|
62
|
+
PKCS11_DEFINE_CONST(CKF_RW_SESSION);
|
63
|
+
PKCS11_DEFINE_CONST(CKF_SERIAL_SESSION);
|
64
|
+
PKCS11_DEFINE_CONST(CKF_LIBRARY_CANT_CREATE_OS_THREADS);
|
65
|
+
PKCS11_DEFINE_CONST(CKF_OS_LOCKING_OK);
|
66
|
+
PKCS11_DEFINE_CONST(CKF_DONT_BLOCK);
|
67
|
+
PKCS11_DEFINE_CONST(CKF_HW);
|
68
|
+
PKCS11_DEFINE_CONST(CKF_ENCRYPT);
|
69
|
+
PKCS11_DEFINE_CONST(CKF_DECRYPT);
|
70
|
+
PKCS11_DEFINE_CONST(CKF_DIGEST);
|
71
|
+
PKCS11_DEFINE_CONST(CKF_SIGN);
|
72
|
+
PKCS11_DEFINE_CONST(CKF_SIGN_RECOVER);
|
73
|
+
PKCS11_DEFINE_CONST(CKF_VERIFY);
|
74
|
+
PKCS11_DEFINE_CONST(CKF_VERIFY_RECOVER);
|
75
|
+
PKCS11_DEFINE_CONST(CKF_GENERATE);
|
76
|
+
PKCS11_DEFINE_CONST(CKF_GENERATE_KEY_PAIR);
|
77
|
+
PKCS11_DEFINE_CONST(CKF_WRAP);
|
78
|
+
PKCS11_DEFINE_CONST(CKF_UNWRAP);
|
79
|
+
PKCS11_DEFINE_CONST(CKF_DERIVE);
|
80
|
+
PKCS11_DEFINE_CONST(CKF_EC_F_P);
|
81
|
+
PKCS11_DEFINE_CONST(CKF_EC_F_2M);
|
82
|
+
PKCS11_DEFINE_CONST(CKF_EC_ECPARAMETERS);
|
83
|
+
PKCS11_DEFINE_CONST(CKF_EC_NAMEDCURVE);
|
84
|
+
PKCS11_DEFINE_CONST(CKF_EC_UNCOMPRESS);
|
85
|
+
PKCS11_DEFINE_CONST(CKF_EC_COMPRESS);
|
86
|
+
PKCS11_DEFINE_CONST(CKF_EXTENSION);
|
87
|
+
PKCS11_DEFINE_CONST(CKF_ARRAY_ATTRIBUTE);
|
88
|
+
PKCS11_DEFINE_CONST(CKF_EXCLUDE_CHALLENGE);
|
89
|
+
PKCS11_DEFINE_CONST(CKF_EXCLUDE_COUNTER);
|
90
|
+
PKCS11_DEFINE_CONST(CKF_EXCLUDE_PIN);
|
91
|
+
PKCS11_DEFINE_CONST(CKF_EXCLUDE_TIME);
|
92
|
+
PKCS11_DEFINE_CONST(CKF_NEXT_OTP);
|
93
|
+
PKCS11_DEFINE_CONST(CKF_USER_FRIENDLY_OTP);
|
94
|
+
|
95
|
+
/* User type */
|
96
|
+
PKCS11_DEFINE_CONST(CKU_SO);
|
97
|
+
PKCS11_DEFINE_CONST(CKU_USER);
|
98
|
+
PKCS11_DEFINE_CONST(CKU_CONTEXT_SPECIFIC);
|
99
|
+
|
100
|
+
/* Hardware feature type */
|
101
|
+
PKCS11_DEFINE_CONST(CKH_MONOTONIC_COUNTER);
|
102
|
+
PKCS11_DEFINE_CONST(CKH_CLOCK);
|
103
|
+
PKCS11_DEFINE_CONST(CKH_USER_INTERFACE);
|
104
|
+
PKCS11_DEFINE_CONST(CKH_VENDOR_DEFINED);
|
105
|
+
|
106
|
+
/* Key type */
|
107
|
+
PKCS11_DEFINE_CONST(CKK_RSA);
|
108
|
+
PKCS11_DEFINE_CONST(CKK_DSA);
|
109
|
+
PKCS11_DEFINE_CONST(CKK_DH);
|
110
|
+
PKCS11_DEFINE_CONST(CKK_ECDSA);
|
111
|
+
PKCS11_DEFINE_CONST(CKK_EC);
|
112
|
+
PKCS11_DEFINE_CONST(CKK_X9_42_DH);
|
113
|
+
PKCS11_DEFINE_CONST(CKK_KEA);
|
114
|
+
PKCS11_DEFINE_CONST(CKK_GENERIC_SECRET);
|
115
|
+
PKCS11_DEFINE_CONST(CKK_RC2);
|
116
|
+
PKCS11_DEFINE_CONST(CKK_RC4);
|
117
|
+
PKCS11_DEFINE_CONST(CKK_DES);
|
118
|
+
PKCS11_DEFINE_CONST(CKK_DES2);
|
119
|
+
PKCS11_DEFINE_CONST(CKK_DES3);
|
120
|
+
PKCS11_DEFINE_CONST(CKK_CAST);
|
121
|
+
PKCS11_DEFINE_CONST(CKK_CAST3);
|
122
|
+
PKCS11_DEFINE_CONST(CKK_CAST5);
|
123
|
+
PKCS11_DEFINE_CONST(CKK_CAST128);
|
124
|
+
PKCS11_DEFINE_CONST(CKK_RC5);
|
125
|
+
PKCS11_DEFINE_CONST(CKK_IDEA);
|
126
|
+
PKCS11_DEFINE_CONST(CKK_SKIPJACK);
|
127
|
+
PKCS11_DEFINE_CONST(CKK_BATON);
|
128
|
+
PKCS11_DEFINE_CONST(CKK_JUNIPER);
|
129
|
+
PKCS11_DEFINE_CONST(CKK_CDMF);
|
130
|
+
PKCS11_DEFINE_CONST(CKK_AES);
|
131
|
+
PKCS11_DEFINE_CONST(CKK_ACTI);
|
132
|
+
PKCS11_DEFINE_CONST(CKK_ARIA);
|
133
|
+
PKCS11_DEFINE_CONST(CKK_BLOWFISH);
|
134
|
+
PKCS11_DEFINE_CONST(CKK_CAMELLIA);
|
135
|
+
PKCS11_DEFINE_CONST(CKK_HOTP);
|
136
|
+
PKCS11_DEFINE_CONST(CKK_SECURID);
|
137
|
+
PKCS11_DEFINE_CONST(CKK_TWOFISH);
|
138
|
+
PKCS11_DEFINE_CONST(CKK_VENDOR_DEFINED);
|
139
|
+
|
140
|
+
/* Certificate type */
|
141
|
+
PKCS11_DEFINE_CONST(CKC_X_509);
|
142
|
+
PKCS11_DEFINE_CONST(CKC_X_509_ATTR_CERT);
|
143
|
+
PKCS11_DEFINE_CONST(CKC_WTLS);
|
144
|
+
PKCS11_DEFINE_CONST(CKC_VENDOR_DEFINED);
|
145
|
+
|
146
|
+
/* Session state */
|
147
|
+
PKCS11_DEFINE_CONST(CKS_RO_PUBLIC_SESSION);
|
148
|
+
PKCS11_DEFINE_CONST(CKS_RO_USER_FUNCTIONS);
|
149
|
+
PKCS11_DEFINE_CONST(CKS_RW_PUBLIC_SESSION);
|
150
|
+
PKCS11_DEFINE_CONST(CKS_RW_USER_FUNCTIONS);
|
151
|
+
PKCS11_DEFINE_CONST(CKS_RW_SO_FUNCTIONS);
|
152
|
+
|
153
|
+
/* Mask generation function */
|
154
|
+
PKCS11_DEFINE_CONST(CKG_MGF1_SHA1);
|
155
|
+
PKCS11_DEFINE_CONST(CKG_MGF1_SHA224);
|
156
|
+
PKCS11_DEFINE_CONST(CKG_MGF1_SHA256);
|
157
|
+
PKCS11_DEFINE_CONST(CKG_MGF1_SHA384);
|
158
|
+
PKCS11_DEFINE_CONST(CKG_MGF1_SHA512);
|
159
|
+
|
160
|
+
/* Key delivation function */
|
161
|
+
PKCS11_DEFINE_CONST(CKD_NULL);
|
162
|
+
PKCS11_DEFINE_CONST(CKD_SHA1_KDF);
|
163
|
+
PKCS11_DEFINE_CONST(CKD_SHA1_KDF_ASN1);
|
164
|
+
PKCS11_DEFINE_CONST(CKD_SHA1_KDF_CONCATENATE);
|
165
|
+
|
166
|
+
/* Pseudo-random function */
|
167
|
+
PKCS11_DEFINE_CONST(CKP_PKCS5_PBKD2_HMAC_SHA1);
|
168
|
+
|
169
|
+
/* Salt/Encoding parameter store */
|
170
|
+
PKCS11_DEFINE_CONST(CKZ_DATA_SPECIFIED);
|
171
|
+
PKCS11_DEFINE_CONST(CKZ_SALT_SPECIFIED);
|
172
|
+
|
173
|
+
vOBJECT_CLASSES = rb_hash_new();
|
174
|
+
vATTRIBUTES = rb_hash_new();
|
175
|
+
vMECHANISMS = rb_hash_new();
|
176
|
+
vRETURN_VALUES = rb_hash_new();
|
177
|
+
rb_define_const(cPKCS11, "OBJECT_CLASSES", vOBJECT_CLASSES);
|
178
|
+
rb_define_const(cPKCS11, "ATTRIBUTES", vATTRIBUTES);
|
179
|
+
rb_define_const(cPKCS11, "MECHANISMS", vMECHANISMS);
|
180
|
+
rb_define_const(cPKCS11, "RETURN_VALUES", vRETURN_VALUES);
|
181
|
+
|
182
|
+
#include "pk11_const_def.inc"
|
183
|
+
|
184
|
+
rb_obj_freeze(vOBJECT_CLASSES);
|
185
|
+
rb_obj_freeze(vATTRIBUTES);
|
186
|
+
rb_obj_freeze(vMECHANISMS);
|
187
|
+
rb_obj_freeze(vRETURN_VALUES);
|
188
|
+
|
189
|
+
/* OTP parameters */
|
190
|
+
PKCS11_DEFINE_CONST(CK_OTP_CHALLENGE);
|
191
|
+
PKCS11_DEFINE_CONST(CK_OTP_COUNTER);
|
192
|
+
PKCS11_DEFINE_CONST(CK_OTP_FLAGS);
|
193
|
+
PKCS11_DEFINE_CONST(CK_OTP_FORMAT_ALPHANUMERIC);
|
194
|
+
PKCS11_DEFINE_CONST(CK_OTP_FORMAT_BINARY);
|
195
|
+
PKCS11_DEFINE_CONST(CK_OTP_FORMAT_DECIMAL);
|
196
|
+
PKCS11_DEFINE_CONST(CK_OTP_FORMAT_HEXADECIMAL);
|
197
|
+
PKCS11_DEFINE_CONST(CK_OTP_OUTPUT_FORMAT);
|
198
|
+
PKCS11_DEFINE_CONST(CK_OTP_OUTPUT_LENGTH);
|
199
|
+
PKCS11_DEFINE_CONST(CK_OTP_PARAM_IGNORED);
|
200
|
+
PKCS11_DEFINE_CONST(CK_OTP_PARAM_MANDATORY);
|
201
|
+
PKCS11_DEFINE_CONST(CK_OTP_PARAM_OPTIONAL);
|
202
|
+
PKCS11_DEFINE_CONST(CK_OTP_PIN);
|
203
|
+
PKCS11_DEFINE_CONST(CK_OTP_TIME);
|
204
|
+
PKCS11_DEFINE_CONST(CK_OTP_VALUE);
|
205
|
+
}
|
@@ -0,0 +1,37 @@
|
|
1
|
+
#ifndef PK11_CONST_MACROS_INCLUDED
|
2
|
+
#define PK11_CONST_MACROS_INCLUDED
|
3
|
+
|
4
|
+
/**************************************************/
|
5
|
+
/* constant definition */
|
6
|
+
/**************************************************/
|
7
|
+
|
8
|
+
#define PKCS11_DEFINE_CONST(constant) \
|
9
|
+
rb_define_const(MODULE_FOR_CONSTS, #constant, INT2NUM(constant))
|
10
|
+
|
11
|
+
#define PKCS11_DEFINE_CONST_GROUP(group, name, value) \
|
12
|
+
do { \
|
13
|
+
VALUE rvalue = ULONG2NUM(value); \
|
14
|
+
rb_define_const(MODULE_FOR_CONSTS, name, rvalue); \
|
15
|
+
VALUE str = rb_obj_freeze(rb_str_new2(name)); \
|
16
|
+
VALUE old = rb_hash_aref(group, rvalue); \
|
17
|
+
if (!NIL_P(old)) rb_warning("%s is equal to %s", RSTRING_PTR(old), name); \
|
18
|
+
rb_hash_aset(group, rvalue, str); \
|
19
|
+
} while(0)
|
20
|
+
|
21
|
+
#define PKCS11_DEFINE_OBJECT_CLASS(constant) \
|
22
|
+
PKCS11_DEFINE_CONST_GROUP(vOBJECT_CLASSES, #constant, constant)
|
23
|
+
#define PKCS11_DEFINE_ATTRIBUTE(constant) \
|
24
|
+
PKCS11_DEFINE_CONST_GROUP(vATTRIBUTES, #constant, constant)
|
25
|
+
#define PKCS11_DEFINE_MECHANISM(constant) \
|
26
|
+
PKCS11_DEFINE_CONST_GROUP(vMECHANISMS, #constant, constant)
|
27
|
+
#define PKCS11_DEFINE_RETURN_VALUE(constant) \
|
28
|
+
do { \
|
29
|
+
VALUE eError = rb_define_class_under(MODULE_FOR_CONSTS, #constant, BASECLASS_FOR_ERRORS); \
|
30
|
+
VALUE rvalue = ULONG2NUM(constant); \
|
31
|
+
VALUE old = rb_hash_aref(vRETURN_VALUES, rvalue); \
|
32
|
+
if (!NIL_P(old)) rb_warning("%s is equal to %s", RSTRING_PTR(old), #constant); \
|
33
|
+
rb_hash_aset(vRETURN_VALUES, rvalue, eError); \
|
34
|
+
} while(0)
|
35
|
+
|
36
|
+
|
37
|
+
#endif
|