pkcs11.h revision 1.1.1.1.12.1 1 /* $NetBSD: pkcs11.h,v 1.1.1.1.12.1 2017/08/30 06:54:28 snj Exp $ */
2
3 /* pkcs11.h
4 Copyright 2006, 2007 g10 Code GmbH
5 Copyright 2006 Andreas Jellinghaus
6
7 This file is free software; as a special exception the author gives
8 unlimited permission to copy and/or distribute it, with or without
9 modifications, as long as this notice is preserved.
10
11 This file is distributed in the hope that it will be useful, but
12 WITHOUT ANY WARRANTY, to the extent permitted by law; without even
13 the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
14 PURPOSE. */
15
16 /* Please submit changes back to the Scute project at
17 http://www.scute.org/ (or send them to marcus (at) g10code.com), so that
18 they can be picked up by other projects from there as well. */
19
20 /* This file is a modified implementation of the PKCS #11 standard by
21 RSA Security Inc. It is mostly a drop-in replacement, with the
22 following change:
23
24 This header file does not require any macro definitions by the user
25 (like CK_DEFINE_FUNCTION etc). In fact, it defines those macros
26 for you (if useful, some are missing, let me know if you need
27 more).
28
29 There is an additional API available that does comply better to the
30 GNU coding standard. It can be switched on by defining
31 CRYPTOKI_GNU before including this header file. For this, the
32 following changes are made to the specification:
33
34 All structure types are changed to a "struct ck_foo" where CK_FOO
35 is the type name in PKCS #11.
36
37 All non-structure types are changed to ck_foo_t where CK_FOO is the
38 lowercase version of the type name in PKCS #11. The basic types
39 (CK_ULONG et al.) are removed without substitute.
40
41 All members of structures are modified in the following way: Type
42 indication prefixes are removed, and underscore characters are
43 inserted before words. Then the result is lowercased.
44
45 Note that function names are still in the original case, as they
46 need for ABI compatibility.
47
48 CK_FALSE, CK_TRUE and NULL_PTR are removed without substitute. Use
49 <stdbool.h>.
50
51 If CRYPTOKI_COMPAT is defined before including this header file,
52 then none of the API changes above take place, and the API is the
53 one defined by the PKCS #11 standard. */
54
55 #ifndef PKCS11_H
56 #define PKCS11_H 1
57
58 #if defined(__cplusplus)
59 extern "C" {
60 #endif
61
62
63 /* The version of cryptoki we implement. The revision is changed with
64 each modification of this file. If you do not use the "official"
65 version of this file, please consider deleting the revision macro
66 (you may use a macro with a different name to keep track of your
67 versions). */
68 #define CRYPTOKI_VERSION_MAJOR 2
69 #define CRYPTOKI_VERSION_MINOR 30
70 #define CRYPTOKI_VERSION_REVISION 0
71 #define CRYPTOKI_VERSION_AMENDMENT 0
72
73
74 /* Compatibility interface is default, unless CRYPTOKI_GNU is
75 given. */
76 #ifndef CRYPTOKI_GNU
77 #ifndef CRYPTOKI_COMPAT
78 #define CRYPTOKI_COMPAT 1
79 #endif
80 #endif
81
82 /* System dependencies. */
83
84 #if defined(_WIN32) || defined(CRYPTOKI_FORCE_WIN32)
85
86 /* There is a matching pop below. */
87 #pragma pack(push, cryptoki, 1)
88
89 #ifdef CRYPTOKI_EXPORTS
90 #define CK_SPEC __declspec(dllexport)
91 #else
92 #define CK_SPEC __declspec(dllimport)
93 #endif
94
95 #else
96
97 #if defined(CRYPTOKI_VISIBILITY) && defined(CRYPTOKI_EXPORTS)
98 #define CK_SPEC __attribute__((visibility("default")))
99 #else
100 #define CK_SPEC
101 #endif
102
103 #endif
104
105
106 #ifdef CRYPTOKI_COMPAT
108 /* If we are in compatibility mode, switch all exposed names to the
109 PKCS #11 variant. There are corresponding #undefs below. */
110
111 #define ck_flags_t CK_FLAGS
112 #define ck_version _CK_VERSION
113
114 #define ck_info _CK_INFO
115 #define cryptoki_version cryptokiVersion
116 #define manufacturer_id manufacturerID
117 #define library_description libraryDescription
118 #define library_version libraryVersion
119
120 #define ck_notification_t CK_NOTIFICATION
121 #define ck_slot_id_t CK_SLOT_ID
122
123 #define ck_slot_info _CK_SLOT_INFO
124 #define slot_description slotDescription
125 #define hardware_version hardwareVersion
126 #define firmware_version firmwareVersion
127
128 #define ck_token_info _CK_TOKEN_INFO
129 #define serial_number serialNumber
130 #define max_session_count ulMaxSessionCount
131 #define session_count ulSessionCount
132 #define max_rw_session_count ulMaxRwSessionCount
133 #define rw_session_count ulRwSessionCount
134 #define max_pin_len ulMaxPinLen
135 #define min_pin_len ulMinPinLen
136 #define total_public_memory ulTotalPublicMemory
137 #define free_public_memory ulFreePublicMemory
138 #define total_private_memory ulTotalPrivateMemory
139 #define free_private_memory ulFreePrivateMemory
140 #define utc_time utcTime
141
142 #define ck_session_handle_t CK_SESSION_HANDLE
143 #define ck_user_type_t CK_USER_TYPE
144 #define ck_state_t CK_STATE
145
146 #define ck_session_info _CK_SESSION_INFO
147 #define slot_id slotID
148 #define device_error ulDeviceError
149
150 #define ck_object_handle_t CK_OBJECT_HANDLE
151 #define ck_object_class_t CK_OBJECT_CLASS
152 #define ck_hw_feature_type_t CK_HW_FEATURE_TYPE
153 #define ck_key_type_t CK_KEY_TYPE
154 #define ck_certificate_type_t CK_CERTIFICATE_TYPE
155 #define ck_attribute_type_t CK_ATTRIBUTE_TYPE
156
157 #define ck_attribute _CK_ATTRIBUTE
158 #define value pValue
159 #define value_len ulValueLen
160
161 #define ck_date _CK_DATE
162
163 #define ck_mechanism_type_t CK_MECHANISM_TYPE
164
165 #define ck_mechanism _CK_MECHANISM
166 #define parameter pParameter
167 #define parameter_len ulParameterLen
168
169 #define ck_mechanism_info _CK_MECHANISM_INFO
170 #define min_key_size ulMinKeySize
171 #define max_key_size ulMaxKeySize
172
173 #define hash_alg hashAlg
174 #define source_data pSourceData
175 #define source_data_len ulSourceDataLen
176
177 #define slen sLen
178
179 #define ck_ec_kdf_type_t CK_EC_KDF_TYPE
180
181 #define shared_data_len ulSharedDataLen
182 #define shared_data pSharedData
183 #define public_data_len ulPublicDataLen
184 #define public_data pPublicData
185
186 #define private_data_len ulPrivateDataLen
187 #define private_data hPrivateData
188 #define public_data_len2 ulPublicDataLen2
189 #define public_data2 pPublicData2
190
191 #define public_key publicKey
192
193 #define ck_x9_42_dh_kdf_type_t CK_X9_42_DH_KDF_TYPE
194
195 #define other_info_len ulOtherInfoLen
196 #define other_info pOtherInfo
197
198 #define data pData
199 #define len ulLen
200
201 #define ck_rv_t CK_RV
202 #define ck_notify_t CK_NOTIFY
203
204 #define ck_function_list _CK_FUNCTION_LIST
205
206 #define ck_createmutex_t CK_CREATEMUTEX
207 #define ck_destroymutex_t CK_DESTROYMUTEX
208 #define ck_lockmutex_t CK_LOCKMUTEX
209 #define ck_unlockmutex_t CK_UNLOCKMUTEX
210
211 #define ck_c_initialize_args _CK_C_INITIALIZE_ARGS
212 #define create_mutex CreateMutex
213 #define destroy_mutex DestroyMutex
214 #define lock_mutex LockMutex
215 #define unlock_mutex UnlockMutex
216 #define reserved pReserved
217
218 #endif /* CRYPTOKI_COMPAT */
219
220
221
223 typedef unsigned long ck_flags_t;
224
225 struct ck_version
226 {
227 unsigned char major;
228 unsigned char minor;
229 };
230
231
232 struct ck_info
233 {
234 struct ck_version cryptoki_version;
235 unsigned char manufacturer_id[32];
236 ck_flags_t flags;
237 unsigned char library_description[32];
238 struct ck_version library_version;
239 };
240
241
242 typedef unsigned long ck_notification_t;
243
244 #define CKN_SURRENDER (0)
245 #define CKN_OTP_CHANGED (1)
246
247 typedef unsigned long ck_slot_id_t;
248
249
250 struct ck_slot_info
251 {
252 unsigned char slot_description[64];
253 unsigned char manufacturer_id[32];
254 ck_flags_t flags;
255 struct ck_version hardware_version;
256 struct ck_version firmware_version;
257 };
258
259
260 #define CKF_TOKEN_PRESENT (1 << 0)
261 #define CKF_REMOVABLE_DEVICE (1 << 1)
262 #define CKF_HW_SLOT (1 << 2)
263 #define CKF_ARRAY_ATTRIBUTE (1 << 30)
264
265
266 struct ck_token_info
267 {
268 unsigned char label[32];
269 unsigned char manufacturer_id[32];
270 unsigned char model[16];
271 unsigned char serial_number[16];
272 ck_flags_t flags;
273 unsigned long max_session_count;
274 unsigned long session_count;
275 unsigned long max_rw_session_count;
276 unsigned long rw_session_count;
277 unsigned long max_pin_len;
278 unsigned long min_pin_len;
279 unsigned long total_public_memory;
280 unsigned long free_public_memory;
281 unsigned long total_private_memory;
282 unsigned long free_private_memory;
283 struct ck_version hardware_version;
284 struct ck_version firmware_version;
285 unsigned char utc_time[16];
286 };
287
288
289 #define CKF_RNG (1 << 0)
290 #define CKF_WRITE_PROTECTED (1 << 1)
291 #define CKF_LOGIN_REQUIRED (1 << 2)
292 #define CKF_USER_PIN_INITIALIZED (1 << 3)
293 #define CKF_RESTORE_KEY_NOT_NEEDED (1 << 5)
294 #define CKF_CLOCK_ON_TOKEN (1 << 6)
295 #define CKF_PROTECTED_AUTHENTICATION_PATH (1 << 8)
296 #define CKF_DUAL_CRYPTO_OPERATIONS (1 << 9)
297 #define CKF_TOKEN_INITIALIZED (1 << 10)
298 #define CKF_SECONDARY_AUTHENTICATION (1 << 11)
299 #define CKF_USER_PIN_COUNT_LOW (1 << 16)
300 #define CKF_USER_PIN_FINAL_TRY (1 << 17)
301 #define CKF_USER_PIN_LOCKED (1 << 18)
302 #define CKF_USER_PIN_TO_BE_CHANGED (1 << 19)
303 #define CKF_SO_PIN_COUNT_LOW (1 << 20)
304 #define CKF_SO_PIN_FINAL_TRY (1 << 21)
305 #define CKF_SO_PIN_LOCKED (1 << 22)
306 #define CKF_SO_PIN_TO_BE_CHANGED (1 << 23)
307 #define CKF_ERROR_STATE (1 << 24)
308
309 #define CK_UNAVAILABLE_INFORMATION ((unsigned long) -1)
310 #define CK_EFFECTIVELY_INFINITE (0)
311
312
313 typedef unsigned long ck_session_handle_t;
314
315 #define CK_INVALID_HANDLE (0)
316
317
318 typedef unsigned long ck_user_type_t;
319
320 #define CKU_SO (0)
321 #define CKU_USER (1)
322 #define CKU_CONTEXT_SPECIFIC (2)
323
324
325 typedef unsigned long ck_state_t;
326
327 #define CKS_RO_PUBLIC_SESSION (0)
328 #define CKS_RO_USER_FUNCTIONS (1)
329 #define CKS_RW_PUBLIC_SESSION (2)
330 #define CKS_RW_USER_FUNCTIONS (3)
331 #define CKS_RW_SO_FUNCTIONS (4)
332
333
334 struct ck_session_info
335 {
336 ck_slot_id_t slot_id;
337 ck_state_t state;
338 ck_flags_t flags;
339 unsigned long device_error;
340 };
341
342 #define CKF_RW_SESSION (1 << 1)
343 #define CKF_SERIAL_SESSION (1 << 2)
344
345
346 typedef unsigned long ck_object_handle_t;
347
348
349 typedef unsigned long ck_object_class_t;
350
351 #define CKO_DATA (0)
352 #define CKO_CERTIFICATE (1)
353 #define CKO_PUBLIC_KEY (2)
354 #define CKO_PRIVATE_KEY (3)
355 #define CKO_SECRET_KEY (4)
356 #define CKO_HW_FEATURE (5)
357 #define CKO_DOMAIN_PARAMETERS (6)
358 #define CKO_MECHANISM (7)
359 #define CKO_OTP_KEY (8)
360 #define CKO_VENDOR_DEFINED ((unsigned long) (1ul << 31))
361
362
363 typedef unsigned long ck_hw_feature_type_t;
364
365 #define CKH_MONOTONIC_COUNTER (1)
366 #define CKH_CLOCK (2)
367 #define CKH_USER_INTERFACE (3)
368 #define CKH_VENDOR_DEFINED ((unsigned long) (1ul << 31))
369
370
371 typedef unsigned long ck_key_type_t;
372
373 #define CKK_RSA (0)
374 #define CKK_DSA (1)
375 #define CKK_DH (2)
376 #define CKK_ECDSA (3)
377 #define CKK_EC (3)
378 #define CKK_X9_42_DH (4)
379 #define CKK_KEA (5)
380 #define CKK_GENERIC_SECRET (0x10)
381 #define CKK_RC2 (0x11)
382 #define CKK_RC4 (0x12)
383 #define CKK_DES (0x13)
384 #define CKK_DES2 (0x14)
385 #define CKK_DES3 (0x15)
386 #define CKK_CAST (0x16)
387 #define CKK_CAST3 (0x17)
388 #define CKK_CAST5 (0x18)
389 #define CKK_CAST128 (0x18)
390 #define CKK_RC5 (0x19)
391 #define CKK_IDEA (0x1a)
392 #define CKK_SKIPJACK (0x1b)
393 #define CKK_BATON (0x1c)
394 #define CKK_JUNIPER (0x1d)
395 #define CKK_CDMF (0x1e)
396 #define CKK_AES (0x1f)
397 #define CKK_BLOWFISH (0x20)
398 #define CKK_TWOFISH (0x21)
399 #define CKK_SECURID (0x22)
400 #define CKK_HOTP (0x23)
401 #define CKK_ACTI (0x24)
402 #define CKK_CAMELLIA (0x25)
403 #define CKK_ARIA (0x26)
404 #define CKK_MD5_HMAC (0x27)
405 #define CKK_SHA_1_HMAC (0x28)
406 #define CKK_RIPEMD128_HMAC (0x29)
407 #define CKK_RIPEMD160_HMAC (0x2A)
408 #define CKK_SHA256_HMAC (0x2B)
409 #define CKK_SHA384_HMAC (0x2C)
410 #define CKK_SHA512_HMAC (0x2D)
411 #define CKK_SHA224_HMAC (0x2E)
412 #define CKK_SEED (0x2F)
413 #define CKK_GOSTR3410 (0x30)
414 #define CKK_GOSTR3411 (0x31)
415 #define CKK_GOST28147 (0x32)
416 #define CKK_VENDOR_DEFINED ((unsigned long) (1ul << 31))
417
418
419 typedef unsigned long ck_certificate_type_t;
420
421 #define CKC_X_509 (0)
422 #define CKC_X_509_ATTR_CERT (1)
423 #define CKC_WTLS (2)
424 #define CKC_VENDOR_DEFINED ((unsigned long) (1ul << 31))
425 #define CKC_OPENPGP (CKC_VENDOR_DEFINED|0x00504750)
426
427 #define CK_OTP_FORMAT_DECIMAL (0)
428 #define CK_OTP_FORMAT_HEXADECIMAL (1)
429 #define CK_OTP_FORMAT_ALPHANUMERIC (2)
430 #define CK_OTP_FORMAT_BINARY (3)
431
432 #define CK_OTP_PARAM_IGNORED (0)
433 #define CK_OTP_PARAM_OPTIONAL (1)
434 #define CK_OTP_PARAM_MANDATORY (2)
435
436 typedef unsigned long ck_attribute_type_t;
437
438 #define CKA_CLASS (0)
439 #define CKA_TOKEN (1)
440 #define CKA_PRIVATE (2)
441 #define CKA_LABEL (3)
442 #define CKA_APPLICATION (0x10)
443 #define CKA_VALUE (0x11)
444 #define CKA_OBJECT_ID (0x12)
445 #define CKA_CERTIFICATE_TYPE (0x80)
446 #define CKA_ISSUER (0x81)
447 #define CKA_SERIAL_NUMBER (0x82)
448 #define CKA_AC_ISSUER (0x83)
449 #define CKA_OWNER (0x84)
450 #define CKA_ATTR_TYPES (0x85)
451 #define CKA_TRUSTED (0x86)
452 #define CKA_CERTIFICATE_CATEGORY (0x87)
453 #define CKA_JAVA_MIDP_SECURITY_DOMAIN (0x88)
454 #define CKA_URL (0x89)
455 #define CKA_HASH_OF_SUBJECT_PUBLIC_KEY (0x8a)
456 #define CKA_HASH_OF_ISSUER_PUBLIC_KEY (0x8b)
457 #define CKA_NAME_HASH_ALGORITHM (0x8c)
458 #define CKA_CHECK_VALUE (0x90)
459 #define CKA_KEY_TYPE (0x100)
460 #define CKA_SUBJECT (0x101)
461 #define CKA_ID (0x102)
462 #define CKA_SENSITIVE (0x103)
463 #define CKA_ENCRYPT (0x104)
464 #define CKA_DECRYPT (0x105)
465 #define CKA_WRAP (0x106)
466 #define CKA_UNWRAP (0x107)
467 #define CKA_SIGN (0x108)
468 #define CKA_SIGN_RECOVER (0x109)
469 #define CKA_VERIFY (0x10a)
470 #define CKA_VERIFY_RECOVER (0x10b)
471 #define CKA_DERIVE (0x10c)
472 #define CKA_START_DATE (0x110)
473 #define CKA_END_DATE (0x111)
474 #define CKA_MODULUS (0x120)
475 #define CKA_MODULUS_BITS (0x121)
476 #define CKA_PUBLIC_EXPONENT (0x122)
477 #define CKA_PRIVATE_EXPONENT (0x123)
478 #define CKA_PRIME_1 (0x124)
479 #define CKA_PRIME_2 (0x125)
480 #define CKA_EXPONENT_1 (0x126)
481 #define CKA_EXPONENT_2 (0x127)
482 #define CKA_COEFFICIENT (0x128)
483 #define CKA_PRIME (0x130)
484 #define CKA_SUBPRIME (0x131)
485 #define CKA_BASE (0x132)
486 #define CKA_PRIME_BITS (0x133)
487 #define CKA_SUB_PRIME_BITS (0x134)
488 #define CKA_SUBPRIME_BITS (0x134)
489 #define CKA_VALUE_BITS (0x160)
490 #define CKA_VALUE_LEN (0x161)
491 #define CKA_EXTRACTABLE (0x162)
492 #define CKA_LOCAL (0x163)
493 #define CKA_NEVER_EXTRACTABLE (0x164)
494 #define CKA_ALWAYS_SENSITIVE (0x165)
495 #define CKA_KEY_GEN_MECHANISM (0x166)
496 #define CKA_MODIFIABLE (0x170)
497 #define CKA_COPYABLE (0x171)
498 #define CKA_ECDSA_PARAMS (0x180)
499 #define CKA_EC_PARAMS (0x180)
500 #define CKA_EC_POINT (0x181)
501 #define CKA_SECONDARY_AUTH (0x200)
502 #define CKA_AUTH_PIN_FLAGS (0x201)
503 #define CKA_ALWAYS_AUTHENTICATE (0x202)
504 #define CKA_WRAP_WITH_TRUSTED (0x210)
505 #define CKA_OTP_FORMAT (0x220)
506 #define CKA_OTP_LENGTH (0x221)
507 #define CKA_OTP_TIME_INTERVAL (0x222)
508 #define CKA_OTP_USER_FRIENDLY_MODE (0x223)
509 #define CKA_OTP_CHALLENGE_REQUIREMENT (0x224)
510 #define CKA_OTP_TIME_REQUIREMENT (0x225)
511 #define CKA_OTP_COUNTER_REQUIREMENT (0x226)
512 #define CKA_OTP_PIN_REQUIREMENT (0x227)
513 #define CKA_OTP_COUNTER (0x22E)
514 #define CKA_OTP_TIME (0x22F)
515 #define CKA_OTP_USER_IDENTIFIER (0x22A)
516 #define CKA_OTP_SERVICE_IDENTIFIER (0x22B)
517 #define CKA_OTP_SERVICE_LOGO (0x22C)
518 #define CKA_OTP_SERVICE_LOGO_TYPE (0x22D)
519 #define CKA_GOSTR3410_PARAMS (0x250)
520 #define CKA_GOSTR3411_PARAMS (0x251)
521 #define CKA_GOST28147_PARAMS (0x252)
522 #define CKA_HW_FEATURE_TYPE (0x300)
523 #define CKA_RESET_ON_INIT (0x301)
524 #define CKA_HAS_RESET (0x302)
525 #define CKA_PIXEL_X (0x400)
526 #define CKA_PIXEL_Y (0x401)
527 #define CKA_RESOLUTION (0x402)
528 #define CKA_CHAR_ROWS (0x403)
529 #define CKA_CHAR_COLUMNS (0x404)
530 #define CKA_COLOR (0x405)
531 #define CKA_BITS_PER_PIXEL (0x406)
532 #define CKA_CHAR_SETS (0x480)
533 #define CKA_ENCODING_METHODS (0x481)
534 #define CKA_MIME_TYPES (0x482)
535 #define CKA_MECHANISM_TYPE (0x500)
536 #define CKA_REQUIRED_CMS_ATTRIBUTES (0x501)
537 #define CKA_DEFAULT_CMS_ATTRIBUTES (0x502)
538 #define CKA_SUPPORTED_CMS_ATTRIBUTES (0x503)
539 #define CKA_WRAP_TEMPLATE (CKF_ARRAY_ATTRIBUTE | 0x211)
540 #define CKA_UNWRAP_TEMPLATE (CKF_ARRAY_ATTRIBUTE | 0x212)
541 #define CKA_DERIVE_TEMPLATE (CKF_ARRAY_ATTRIBUTE | 0x213)
542 #define CKA_ALLOWED_MECHANISMS (CKF_ARRAY_ATTRIBUTE | 0x600)
543 #define CKA_VENDOR_DEFINED ((unsigned long) (1ul << 31))
544
545
546 struct ck_attribute
547 {
548 ck_attribute_type_t type;
549 void *value;
550 unsigned long value_len;
551 };
552
553
554 struct ck_date
555 {
556 unsigned char year[4];
557 unsigned char month[2];
558 unsigned char day[2];
559 };
560
561
562 typedef unsigned long ck_mechanism_type_t;
563
564 #define CKM_RSA_PKCS_KEY_PAIR_GEN (0)
565 #define CKM_RSA_PKCS (1)
566 #define CKM_RSA_9796 (2)
567 #define CKM_RSA_X_509 (3)
568 #define CKM_MD2_RSA_PKCS (4)
569 #define CKM_MD5_RSA_PKCS (5)
570 #define CKM_SHA1_RSA_PKCS (6)
571 #define CKM_RIPEMD128_RSA_PKCS (7)
572 #define CKM_RIPEMD160_RSA_PKCS (8)
573 #define CKM_RSA_PKCS_OAEP (9)
574 #define CKM_RSA_X9_31_KEY_PAIR_GEN (0xa)
575 #define CKM_RSA_X9_31 (0xb)
576 #define CKM_SHA1_RSA_X9_31 (0xc)
577 #define CKM_RSA_PKCS_PSS (0xd)
578 #define CKM_SHA1_RSA_PKCS_PSS (0xe)
579 #define CKM_DSA_KEY_PAIR_GEN (0x10)
580 #define CKM_DSA (0x11)
581 #define CKM_DSA_SHA1 (0x12)
582 #define CKM_DSA_SHA224 (0x13)
583 #define CKM_DSA_SHA256 (0x14)
584 #define CKM_DSA_SHA384 (0x15)
585 #define CKM_DSA_SHA512 (0x16)
586 #define CKM_DH_PKCS_KEY_PAIR_GEN (0x20)
587 #define CKM_DH_PKCS_DERIVE (0x21)
588 #define CKM_X9_42_DH_KEY_PAIR_GEN (0x30)
589 #define CKM_X9_42_DH_DERIVE (0x31)
590 #define CKM_X9_42_DH_HYBRID_DERIVE (0x32)
591 #define CKM_X9_42_MQV_DERIVE (0x33)
592 #define CKM_SHA256_RSA_PKCS (0x40)
593 #define CKM_SHA384_RSA_PKCS (0x41)
594 #define CKM_SHA512_RSA_PKCS (0x42)
595 #define CKM_SHA256_RSA_PKCS_PSS (0x43)
596 #define CKM_SHA384_RSA_PKCS_PSS (0x44)
597 #define CKM_SHA512_RSA_PKCS_PSS (0x45)
598 #define CKM_SHA224_RSA_PKCS (0x46)
599 #define CKM_SHA224_RSA_PKCS_PSS (0x47)
600 #define CKM_RC2_KEY_GEN (0x100)
601 #define CKM_RC2_ECB (0x101)
602 #define CKM_RC2_CBC (0x102)
603 #define CKM_RC2_MAC (0x103)
604 #define CKM_RC2_MAC_GENERAL (0x104)
605 #define CKM_RC2_CBC_PAD (0x105)
606 #define CKM_RC4_KEY_GEN (0x110)
607 #define CKM_RC4 (0x111)
608 #define CKM_DES_KEY_GEN (0x120)
609 #define CKM_DES_ECB (0x121)
610 #define CKM_DES_CBC (0x122)
611 #define CKM_DES_MAC (0x123)
612 #define CKM_DES_MAC_GENERAL (0x124)
613 #define CKM_DES_CBC_PAD (0x125)
614 #define CKM_DES2_KEY_GEN (0x130)
615 #define CKM_DES3_KEY_GEN (0x131)
616 #define CKM_DES3_ECB (0x132)
617 #define CKM_DES3_CBC (0x133)
618 #define CKM_DES3_MAC (0x134)
619 #define CKM_DES3_MAC_GENERAL (0x135)
620 #define CKM_DES3_CBC_PAD (0x136)
621 #define CKM_DES3_CMAC_GENERAL (0x137)
622 #define CKM_DES3_CMAC (0x138)
623 #define CKM_CDMF_KEY_GEN (0x140)
624 #define CKM_CDMF_ECB (0x141)
625 #define CKM_CDMF_CBC (0x142)
626 #define CKM_CDMF_MAC (0x143)
627 #define CKM_CDMF_MAC_GENERAL (0x144)
628 #define CKM_CDMF_CBC_PAD (0x145)
629 #define CKM_DES_OFB64 (0x150)
630 #define CKM_DES_OFB8 (0x151)
631 #define CKM_DES_CFB64 (0x152)
632 #define CKM_DES_CFB8 (0x153)
633 #define CKM_MD2 (0x200)
634 #define CKM_MD2_HMAC (0x201)
635 #define CKM_MD2_HMAC_GENERAL (0x202)
636 #define CKM_MD5 (0x210)
637 #define CKM_MD5_HMAC (0x211)
638 #define CKM_MD5_HMAC_GENERAL (0x212)
639 #define CKM_SHA_1 (0x220)
640 #define CKM_SHA_1_HMAC (0x221)
641 #define CKM_SHA_1_HMAC_GENERAL (0x222)
642 #define CKM_RIPEMD128 (0x230)
643 #define CKM_RIPEMD128_HMAC (0x231)
644 #define CKM_RIPEMD128_HMAC_GENERAL (0x232)
645 #define CKM_RIPEMD160 (0x240)
646 #define CKM_RIPEMD160_HMAC (0x241)
647 #define CKM_RIPEMD160_HMAC_GENERAL (0x242)
648 #define CKM_SHA256 (0x250)
649 #define CKM_SHA256_HMAC (0x251)
650 #define CKM_SHA256_HMAC_GENERAL (0x252)
651 #define CKM_SHA224 (0x255)
652 #define CKM_SHA224_HMAC (0x256)
653 #define CKM_SHA224_HMAC_GENERAL (0x257)
654 #define CKM_SHA384 (0x260)
655 #define CKM_SHA384_HMAC (0x261)
656 #define CKM_SHA384_HMAC_GENERAL (0x262)
657 #define CKM_SHA512 (0x270)
658 #define CKM_SHA512_HMAC (0x271)
659 #define CKM_SHA512_HMAC_GENERAL (0x272)
660 #define CKM_SECURID_KEY_GEN (0x280)
661 #define CKM_SECURID (0x282)
662 #define CKM_HOTP_KEY_GEN (0x290)
663 #define CKM_HOTP (0x291)
664 #define CKM_ACTI (0x2A0)
665 #define CKM_ACTI_KEY_GEN (0x2A1)
666 #define CKM_CAST_KEY_GEN (0x300)
667 #define CKM_CAST_ECB (0x301)
668 #define CKM_CAST_CBC (0x302)
669 #define CKM_CAST_MAC (0x303)
670 #define CKM_CAST_MAC_GENERAL (0x304)
671 #define CKM_CAST_CBC_PAD (0x305)
672 #define CKM_CAST3_KEY_GEN (0x310)
673 #define CKM_CAST3_ECB (0x311)
674 #define CKM_CAST3_CBC (0x312)
675 #define CKM_CAST3_MAC (0x313)
676 #define CKM_CAST3_MAC_GENERAL (0x314)
677 #define CKM_CAST3_CBC_PAD (0x315)
678 #define CKM_CAST5_KEY_GEN (0x320)
679 #define CKM_CAST128_KEY_GEN (0x320)
680 #define CKM_CAST5_ECB (0x321)
681 #define CKM_CAST128_ECB (0x321)
682 #define CKM_CAST5_CBC (0x322)
683 #define CKM_CAST128_CBC (0x322)
684 #define CKM_CAST5_MAC (0x323)
685 #define CKM_CAST128_MAC (0x323)
686 #define CKM_CAST5_MAC_GENERAL (0x324)
687 #define CKM_CAST128_MAC_GENERAL (0x324)
688 #define CKM_CAST5_CBC_PAD (0x325)
689 #define CKM_CAST128_CBC_PAD (0x325)
690 #define CKM_RC5_KEY_GEN (0x330)
691 #define CKM_RC5_ECB (0x331)
692 #define CKM_RC5_CBC (0x332)
693 #define CKM_RC5_MAC (0x333)
694 #define CKM_RC5_MAC_GENERAL (0x334)
695 #define CKM_RC5_CBC_PAD (0x335)
696 #define CKM_IDEA_KEY_GEN (0x340)
697 #define CKM_IDEA_ECB (0x341)
698 #define CKM_IDEA_CBC (0x342)
699 #define CKM_IDEA_MAC (0x343)
700 #define CKM_IDEA_MAC_GENERAL (0x344)
701 #define CKM_IDEA_CBC_PAD (0x345)
702 #define CKM_GENERIC_SECRET_KEY_GEN (0x350)
703 #define CKM_CONCATENATE_BASE_AND_KEY (0x360)
704 #define CKM_CONCATENATE_BASE_AND_DATA (0x362)
705 #define CKM_CONCATENATE_DATA_AND_BASE (0x363)
706 #define CKM_XOR_BASE_AND_DATA (0x364)
707 #define CKM_EXTRACT_KEY_FROM_KEY (0x365)
708 #define CKM_SSL3_PRE_MASTER_KEY_GEN (0x370)
709 #define CKM_SSL3_MASTER_KEY_DERIVE (0x371)
710 #define CKM_SSL3_KEY_AND_MAC_DERIVE (0x372)
711 #define CKM_SSL3_MASTER_KEY_DERIVE_DH (0x373)
712 #define CKM_TLS_PRE_MASTER_KEY_GEN (0x374)
713 #define CKM_TLS_MASTER_KEY_DERIVE (0x375)
714 #define CKM_TLS_KEY_AND_MAC_DERIVE (0x376)
715 #define CKM_TLS_MASTER_KEY_DERIVE_DH (0x377)
716 #define CKM_TLS_PRF (0x378)
717 #define CKM_SSL3_MD5_MAC (0x380)
718 #define CKM_SSL3_SHA1_MAC (0x381)
719 #define CKM_MD5_KEY_DERIVATION (0x390)
720 #define CKM_MD2_KEY_DERIVATION (0x391)
721 #define CKM_SHA1_KEY_DERIVATION (0x392)
722 #define CKM_SHA256_KEY_DERIVATION (0x393)
723 #define CKM_SHA384_KEY_DERIVATION (0x394)
724 #define CKM_SHA512_KEY_DERIVATION (0x395)
725 #define CKM_SHA224_KEY_DERIVATION (0x396)
726 #define CKM_PBE_MD2_DES_CBC (0x3a0)
727 #define CKM_PBE_MD5_DES_CBC (0x3a1)
728 #define CKM_PBE_MD5_CAST_CBC (0x3a2)
729 #define CKM_PBE_MD5_CAST3_CBC (0x3a3)
730 #define CKM_PBE_MD5_CAST5_CBC (0x3a4)
731 #define CKM_PBE_MD5_CAST128_CBC (0x3a4)
732 #define CKM_PBE_SHA1_CAST5_CBC (0x3a5)
733 #define CKM_PBE_SHA1_CAST128_CBC (0x3a5)
734 #define CKM_PBE_SHA1_RC4_128 (0x3a6)
735 #define CKM_PBE_SHA1_RC4_40 (0x3a7)
736 #define CKM_PBE_SHA1_DES3_EDE_CBC (0x3a8)
737 #define CKM_PBE_SHA1_DES2_EDE_CBC (0x3a9)
738 #define CKM_PBE_SHA1_RC2_128_CBC (0x3aa)
739 #define CKM_PBE_SHA1_RC2_40_CBC (0x3ab)
740 #define CKM_PKCS5_PBKD2 (0x3b0)
741 #define CKM_PBA_SHA1_WITH_SHA1_HMAC (0x3c0)
742 #define CKM_WTLS_PRE_MASTER_KEY_GEN (0x3d0)
743 #define CKM_WTLS_MASTER_KEY_DERIVE (0x3d1)
744 #define CKM_WTLS_MASTER_KEY_DERIVE_DH_ECC (0x3d2)
745 #define CKM_WTLS_PRF (0x3d3)
746 #define CKM_WTLS_SERVER_KEY_AND_MAC_DERIVE (0x3d4)
747 #define CKM_WTLS_CLIENT_KEY_AND_MAC_DERIVE (0x3d5)
748 #define CKM_KEY_WRAP_LYNKS (0x400)
749 #define CKM_KEY_WRAP_SET_OAEP (0x401)
750 #define CKM_CMS_SIG (0x500)
751 #define CKM_KIP_DERIVE (0x510)
752 #define CKM_KIP_WRAP (0x511)
753 #define CKM_KIP_MAC (0x512)
754 #define CKM_CAMELLIA_KEY_GEN (0x550)
755 #define CKM_CAMELLIA_ECB (0x551)
756 #define CKM_CAMELLIA_CBC (0x552)
757 #define CKM_CAMELLIA_MAC (0x553)
758 #define CKM_CAMELLIA_MAC_GENERAL (0x554)
759 #define CKM_CAMELLIA_CBC_PAD (0x555)
760 #define CKM_CAMELLIA_ECB_ENCRYPT_DATA (0x556)
761 #define CKM_CAMELLIA_CBC_ENCRYPT_DATA (0x557)
762 #define CKM_CAMELLIA_CTR (0x558)
763 #define CKM_ARIA_KEY_GEN (0x560)
764 #define CKM_ARIA_ECB (0x561)
765 #define CKM_ARIA_CBC (0x562)
766 #define CKM_ARIA_MAC (0x563)
767 #define CKM_ARIA_MAC_GENERAL (0x564)
768 #define CKM_ARIA_CBC_PAD (0x565)
769 #define CKM_ARIA_ECB_ENCRYPT_DATA (0x566)
770 #define CKM_ARIA_CBC_ENCRYPT_DATA (0x567)
771 #define CKM_SEED_KEY_GEN (0x650)
772 #define CKM_SEED_ECB (0x651)
773 #define CKM_SEED_CBC (0x652)
774 #define CKM_SEED_MAC (0x653)
775 #define CKM_SEED_MAC_GENERAL (0x654)
776 #define CKM_SEED_CBC_PAD (0x655)
777 #define CKM_SEED_ECB_ENCRYPT_DATA (0x656)
778 #define CKM_SEED_CBC_ENCRYPT_DATA (0x657)
779 #define CKM_SKIPJACK_KEY_GEN (0x1000)
780 #define CKM_SKIPJACK_ECB64 (0x1001)
781 #define CKM_SKIPJACK_CBC64 (0x1002)
782 #define CKM_SKIPJACK_OFB64 (0x1003)
783 #define CKM_SKIPJACK_CFB64 (0x1004)
784 #define CKM_SKIPJACK_CFB32 (0x1005)
785 #define CKM_SKIPJACK_CFB16 (0x1006)
786 #define CKM_SKIPJACK_CFB8 (0x1007)
787 #define CKM_SKIPJACK_WRAP (0x1008)
788 #define CKM_SKIPJACK_PRIVATE_WRAP (0x1009)
789 #define CKM_SKIPJACK_RELAYX (0x100a)
790 #define CKM_KEA_KEY_PAIR_GEN (0x1010)
791 #define CKM_KEA_KEY_DERIVE (0x1011)
792 #define CKM_FORTEZZA_TIMESTAMP (0x1020)
793 #define CKM_BATON_KEY_GEN (0x1030)
794 #define CKM_BATON_ECB128 (0x1031)
795 #define CKM_BATON_ECB96 (0x1032)
796 #define CKM_BATON_CBC128 (0x1033)
797 #define CKM_BATON_COUNTER (0x1034)
798 #define CKM_BATON_SHUFFLE (0x1035)
799 #define CKM_BATON_WRAP (0x1036)
800 #define CKM_ECDSA_KEY_PAIR_GEN (0x1040)
801 #define CKM_EC_KEY_PAIR_GEN (0x1040)
802 #define CKM_ECDSA (0x1041)
803 #define CKM_ECDSA_SHA1 (0x1042)
804 #define CKM_ECDSA_SHA224 (0x1043)
805 #define CKM_ECDSA_SHA256 (0x1044)
806 #define CKM_ECDSA_SHA384 (0x1045)
807 #define CKM_ECDSA_SHA512 (0x1046)
808 #define CKM_ECDH1_DERIVE (0x1050)
809 #define CKM_ECDH1_COFACTOR_DERIVE (0x1051)
810 #define CKM_ECMQV_DERIVE (0x1052)
811 #define CKM_JUNIPER_KEY_GEN (0x1060)
812 #define CKM_JUNIPER_ECB128 (0x1061)
813 #define CKM_JUNIPER_CBC128 (0x1062)
814 #define CKM_JUNIPER_COUNTER (0x1063)
815 #define CKM_JUNIPER_SHUFFLE (0x1064)
816 #define CKM_JUNIPER_WRAP (0x1065)
817 #define CKM_FASTHASH (0x1070)
818 #define CKM_AES_KEY_GEN (0x1080)
819 #define CKM_AES_ECB (0x1081)
820 #define CKM_AES_CBC (0x1082)
821 #define CKM_AES_MAC (0x1083)
822 #define CKM_AES_MAC_GENERAL (0x1084)
823 #define CKM_AES_CBC_PAD (0x1085)
824 #define CKM_AES_CTR (0x1086)
825 #define CKM_AES_GCM (0x1087)
826 #define CKM_AES_CCM (0x1088)
827 #define CKM_AES_CTS (0x1089)
828 #define CKM_AES_CMAC (0x108a)
829 #define CKM_AES_CMAC_GENERAL (0x108b)
830 #define CKM_BLOWFISH_KEY_GEN (0x1090)
831 #define CKM_BLOWFISH_CBC (0x1091)
832 #define CKM_TWOFISH_KEY_GEN (0x1092)
833 #define CKM_TWOFISH_CBC (0x1093)
834 #define CKM_BLOWFISH_CBC_PAD (0x1094)
835 #define CKM_TWOFISH_CBC_PAD (0x1095)
836 #define CKM_DES_ECB_ENCRYPT_DATA (0x1100)
837 #define CKM_DES_CBC_ENCRYPT_DATA (0x1101)
838 #define CKM_DES3_ECB_ENCRYPT_DATA (0x1102)
839 #define CKM_DES3_CBC_ENCRYPT_DATA (0x1103)
840 #define CKM_AES_ECB_ENCRYPT_DATA (0x1104)
841 #define CKM_AES_CBC_ENCRYPT_DATA (0x1105)
842 #define CKM_GOSTR3410_KEY_PAIR_GEN (0x1200)
843 #define CKM_GOSTR3410 (0x1201)
844 #define CKM_GOSTR3410_WITH_GOSTR3411 (0x1202)
845 #define CKM_GOSTR3410_KEY_WRAP (0x1203)
846 #define CKM_GOSTR3410_DERIVE (0x1204)
847 #define CKM_GOSTR3411 (0x1210)
848 #define CKM_GOSTR3411_HMAC (0x1211)
849 #define CKM_GOST28147_KEY_GEN (0x1220)
850 #define CKM_GOST28147_ECB (0x1221)
851 #define CKM_GOST28147 (0x1222)
852 #define CKM_GOST28147_MAC (0x1223)
853 #define CKM_GOST28147_KEY_WRAP (0x1224)
854 #define CKM_DSA_PARAMETER_GEN (0x2000)
855 #define CKM_DH_PKCS_PARAMETER_GEN (0x2001)
856 #define CKM_X9_42_DH_PARAMETER_GEN (0x2002)
857 #define CKM_AES_OFB (0x2104)
858 #define CKM_AES_CFB64 (0x2105)
859 #define CKM_AES_CFB8 (0x2106)
860 #define CKM_AES_CFB128 (0x2107)
861 #define CKM_AES_KEY_WRAP (0x2109)
862 #define CKM_AES_KEY_WRAP_PAD (0x210a)
863 #define CKM_RSA_PKCS_TPM_1_1 (0x4001)
864 #define CKM_RSA_PKCS_OAEPTPM_1_1 (0x4002)
865 #define CKM_VENDOR_DEFINED ((unsigned long) (1ul << 31))
866
867
868 struct ck_mechanism
869 {
870 ck_mechanism_type_t mechanism;
871 void *parameter;
872 unsigned long parameter_len;
873 };
874
875
876 struct ck_mechanism_info
877 {
878 unsigned long min_key_size;
879 unsigned long max_key_size;
880 ck_flags_t flags;
881 };
882
883 #define CKF_HW (1 << 0)
884 #define CKF_ENCRYPT (1 << 8)
885 #define CKF_DECRYPT (1 << 9)
886 #define CKF_DIGEST (1 << 10)
887 #define CKF_SIGN (1 << 11)
888 #define CKF_SIGN_RECOVER (1 << 12)
889 #define CKF_VERIFY (1 << 13)
890 #define CKF_VERIFY_RECOVER (1 << 14)
891 #define CKF_GENERATE (1 << 15)
892 #define CKF_GENERATE_KEY_PAIR (1 << 16)
893 #define CKF_WRAP (1 << 17)
894 #define CKF_UNWRAP (1 << 18)
895 #define CKF_DERIVE (1 << 19)
896 #define CKF_EC_F_P (1 << 20)
897 #define CKF_EC_F_2M (1 << 21)
898 #define CKF_EC_ECPARAMETERS (1 << 22)
899 #define CKF_EC_NAMEDCURVE (1 << 23)
900 #define CKF_EC_UNCOMPRESS (1 << 24)
901 #define CKF_EC_COMPRESS (1 << 25)
902 #define CKF_EXTENSION ((unsigned long) (1ul << 31))
903
904
905 /* The following MGFs are defined */
906 #define CKG_MGF1_SHA1 (0x00000001)
907 #define CKG_MGF1_SHA256 (0x00000002)
908 #define CKG_MGF1_SHA384 (0x00000003)
909 #define CKG_MGF1_SHA512 (0x00000004)
910 #define CKG_MGF1_SHA224 (0x00000005)
911
912 #define CKZ_DATA_SPECIFIED (0x00000001)
913
914 struct ck_rsa_pkcs_oaep_params {
915 ck_mechanism_type_t hash_alg;
916 unsigned long mgf;
917 unsigned long source;
918 void *source_data;
919 unsigned long source_data_len;
920 };
921
922 struct ck_rsa_pkcs_pss_params {
923 ck_mechanism_type_t hash_alg;
924 unsigned long mgf;
925 unsigned long slen;
926 };
927
928 typedef unsigned long ck_ec_kdf_type_t;
929
930 /* The following EC Key Derivation Functions are defined */
931 #define CKD_NULL (0x00000001)
932 #define CKD_SHA1_KDF (0x00000002)
933
934 struct ck_ecdh1_derive_params {
935 ck_ec_kdf_type_t kdf;
936 unsigned long shared_data_len;
937 unsigned char *shared_data;
938 unsigned long public_data_len;
939 unsigned char *public_data;
940 };
941
942 struct ck_ecdh2_derive_params {
943 ck_ec_kdf_type_t kdf;
944 unsigned long shared_data_len;
945 unsigned char *shared_data;
946 unsigned long public_data_len;
947 unsigned char *public_data;
948 unsigned long private_data_len;
949 ck_object_handle_t private_data;
950 unsigned long public_data_len2;
951 unsigned char *public_data2;
952 };
953
954 struct ck_ecmqv_derive_params {
955 ck_ec_kdf_type_t kdf;
956 unsigned long shared_data_len;
957 unsigned char *shared_data;
958 unsigned long public_data_len;
959 unsigned char *public_data;
960 unsigned long private_data_len;
961 ck_object_handle_t private_data;
962 unsigned long public_data_len2;
963 unsigned char *public_data2;
964 ck_object_handle_t public_key;
965 };
966
967 typedef unsigned long ck_x9_42_dh_kdf_type_t;
968
969 /* The following X9.42 DH key derivation functions are defined */
970 #define CKD_SHA1_KDF_ASN1 (0x00000003)
971 #define CKD_SHA1_KDF_CONCATENATE (0x00000004)
972 #define CKD_SHA224_KDF (0x00000005)
973 #define CKD_SHA256_KDF (0x00000006)
974 #define CKD_SHA384_KDF (0x00000007)
975 #define CKD_SHA512_KDF (0x00000008)
976 #define CKD_CPDIVERSIFY_KDF (0x00000009)
977
978 struct ck_x9_42_dh1_derive_params {
979 ck_x9_42_dh_kdf_type_t kdf;
980 unsigned long other_info_len;
981 unsigned char *other_info;
982 unsigned long public_data_len;
983 unsigned char *public_data;
984 };
985
986 struct ck_x9_42_dh2_derive_params {
987 ck_x9_42_dh_kdf_type_t kdf;
988 unsigned long other_info_len;
989 unsigned char *other_info;
990 unsigned long public_data_len;
991 unsigned char *public_data;
992 unsigned long private_data_len;
993 ck_object_handle_t private_data;
994 unsigned long public_data_len2;
995 unsigned char *public_data2;
996 };
997
998 struct ck_x9_42_mqv_derive_params {
999 ck_x9_42_dh_kdf_type_t kdf;
1000 unsigned long other_info_len;
1001 unsigned char *other_info;
1002 unsigned long public_data_len;
1003 unsigned char *public_data;
1004 unsigned long private_data_len;
1005 ck_object_handle_t private_data;
1006 unsigned long public_data_len2;
1007 unsigned char *public_data2;
1008 ck_object_handle_t public_key;
1009 };
1010
1011 struct ck_des_cbc_encrypt_data_params {
1012 unsigned char iv[8];
1013 unsigned char *data;
1014 unsigned long length;
1015 };
1016
1017 struct ck_aes_cbc_encrypt_data_params {
1018 unsigned char iv[16];
1019 unsigned char *data;
1020 unsigned long length;
1021 };
1022
1023 struct ck_key_derivation_string_data {
1024 unsigned char *data;
1025 unsigned long len;
1026 };
1027
1028 /* Flags for C_WaitForSlotEvent. */
1029 #define CKF_DONT_BLOCK (1)
1030
1031
1032 typedef unsigned long ck_rv_t;
1033
1034
1035 typedef ck_rv_t (*ck_notify_t) (ck_session_handle_t session,
1036 ck_notification_t event, void *application);
1037
1038 /* Forward reference. */
1039 struct ck_function_list;
1040
1041 #define _CK_DECLARE_FUNCTION(name, args) \
1042 typedef ck_rv_t (*CK_ ## name) args; \
1043 ck_rv_t CK_SPEC name args
1044
1045 _CK_DECLARE_FUNCTION (C_Initialize, (void *init_args));
1046 _CK_DECLARE_FUNCTION (C_Finalize, (void *reserved));
1047 _CK_DECLARE_FUNCTION (C_GetInfo, (struct ck_info *info));
1048 _CK_DECLARE_FUNCTION (C_GetFunctionList,
1049 (struct ck_function_list **function_list));
1050
1051 _CK_DECLARE_FUNCTION (C_GetSlotList,
1052 (unsigned char token_present, ck_slot_id_t *slot_list,
1053 unsigned long *count));
1054 _CK_DECLARE_FUNCTION (C_GetSlotInfo,
1055 (ck_slot_id_t slot_id, struct ck_slot_info *info));
1056 _CK_DECLARE_FUNCTION (C_GetTokenInfo,
1057 (ck_slot_id_t slot_id, struct ck_token_info *info));
1058 _CK_DECLARE_FUNCTION (C_WaitForSlotEvent,
1059 (ck_flags_t flags, ck_slot_id_t *slot, void *reserved));
1060 _CK_DECLARE_FUNCTION (C_GetMechanismList,
1061 (ck_slot_id_t slot_id,
1062 ck_mechanism_type_t *mechanism_list,
1063 unsigned long *count));
1064 _CK_DECLARE_FUNCTION (C_GetMechanismInfo,
1065 (ck_slot_id_t slot_id, ck_mechanism_type_t type,
1066 struct ck_mechanism_info *info));
1067 _CK_DECLARE_FUNCTION (C_InitToken,
1068 (ck_slot_id_t slot_id, unsigned char *pin,
1069 unsigned long pin_len, unsigned char *label));
1070 _CK_DECLARE_FUNCTION (C_InitPIN,
1071 (ck_session_handle_t session, unsigned char *pin,
1072 unsigned long pin_len));
1073 _CK_DECLARE_FUNCTION (C_SetPIN,
1074 (ck_session_handle_t session, unsigned char *old_pin,
1075 unsigned long old_len, unsigned char *new_pin,
1076 unsigned long new_len));
1077
1078 _CK_DECLARE_FUNCTION (C_OpenSession,
1079 (ck_slot_id_t slot_id, ck_flags_t flags,
1080 void *application, ck_notify_t notify,
1081 ck_session_handle_t *session));
1082 _CK_DECLARE_FUNCTION (C_CloseSession, (ck_session_handle_t session));
1083 _CK_DECLARE_FUNCTION (C_CloseAllSessions, (ck_slot_id_t slot_id));
1084 _CK_DECLARE_FUNCTION (C_GetSessionInfo,
1085 (ck_session_handle_t session,
1086 struct ck_session_info *info));
1087 _CK_DECLARE_FUNCTION (C_GetOperationState,
1088 (ck_session_handle_t session,
1089 unsigned char *operation_state,
1090 unsigned long *operation_state_len));
1091 _CK_DECLARE_FUNCTION (C_SetOperationState,
1092 (ck_session_handle_t session,
1093 unsigned char *operation_state,
1094 unsigned long operation_state_len,
1095 ck_object_handle_t encryption_key,
1096 ck_object_handle_t authentiation_key));
1097 _CK_DECLARE_FUNCTION (C_Login,
1098 (ck_session_handle_t session, ck_user_type_t user_type,
1099 unsigned char *pin, unsigned long pin_len));
1100 _CK_DECLARE_FUNCTION (C_Logout, (ck_session_handle_t session));
1101
1102 _CK_DECLARE_FUNCTION (C_CreateObject,
1103 (ck_session_handle_t session,
1104 struct ck_attribute *templ,
1105 unsigned long count, ck_object_handle_t *object));
1106 _CK_DECLARE_FUNCTION (C_CopyObject,
1107 (ck_session_handle_t session, ck_object_handle_t object,
1108 struct ck_attribute *templ, unsigned long count,
1109 ck_object_handle_t *new_object));
1110 _CK_DECLARE_FUNCTION (C_DestroyObject,
1111 (ck_session_handle_t session,
1112 ck_object_handle_t object));
1113 _CK_DECLARE_FUNCTION (C_GetObjectSize,
1114 (ck_session_handle_t session,
1115 ck_object_handle_t object,
1116 unsigned long *size));
1117 _CK_DECLARE_FUNCTION (C_GetAttributeValue,
1118 (ck_session_handle_t session,
1119 ck_object_handle_t object,
1120 struct ck_attribute *templ,
1121 unsigned long count));
1122 _CK_DECLARE_FUNCTION (C_SetAttributeValue,
1123 (ck_session_handle_t session,
1124 ck_object_handle_t object,
1125 struct ck_attribute *templ,
1126 unsigned long count));
1127 _CK_DECLARE_FUNCTION (C_FindObjectsInit,
1128 (ck_session_handle_t session,
1129 struct ck_attribute *templ,
1130 unsigned long count));
1131 _CK_DECLARE_FUNCTION (C_FindObjects,
1132 (ck_session_handle_t session,
1133 ck_object_handle_t *object,
1134 unsigned long max_object_count,
1135 unsigned long *object_count));
1136 _CK_DECLARE_FUNCTION (C_FindObjectsFinal,
1137 (ck_session_handle_t session));
1138
1139 _CK_DECLARE_FUNCTION (C_EncryptInit,
1140 (ck_session_handle_t session,
1141 struct ck_mechanism *mechanism,
1142 ck_object_handle_t key));
1143 _CK_DECLARE_FUNCTION (C_Encrypt,
1144 (ck_session_handle_t session,
1145 unsigned char *data, unsigned long data_len,
1146 unsigned char *encrypted_data,
1147 unsigned long *encrypted_data_len));
1148 _CK_DECLARE_FUNCTION (C_EncryptUpdate,
1149 (ck_session_handle_t session,
1150 unsigned char *part, unsigned long part_len,
1151 unsigned char *encrypted_part,
1152 unsigned long *encrypted_part_len));
1153 _CK_DECLARE_FUNCTION (C_EncryptFinal,
1154 (ck_session_handle_t session,
1155 unsigned char *last_encrypted_part,
1156 unsigned long *last_encrypted_part_len));
1157
1158 _CK_DECLARE_FUNCTION (C_DecryptInit,
1159 (ck_session_handle_t session,
1160 struct ck_mechanism *mechanism,
1161 ck_object_handle_t key));
1162 _CK_DECLARE_FUNCTION (C_Decrypt,
1163 (ck_session_handle_t session,
1164 unsigned char *encrypted_data,
1165 unsigned long encrypted_data_len,
1166 unsigned char *data, unsigned long *data_len));
1167 _CK_DECLARE_FUNCTION (C_DecryptUpdate,
1168 (ck_session_handle_t session,
1169 unsigned char *encrypted_part,
1170 unsigned long encrypted_part_len,
1171 unsigned char *part, unsigned long *part_len));
1172 _CK_DECLARE_FUNCTION (C_DecryptFinal,
1173 (ck_session_handle_t session,
1174 unsigned char *last_part,
1175 unsigned long *last_part_len));
1176
1177 _CK_DECLARE_FUNCTION (C_DigestInit,
1178 (ck_session_handle_t session,
1179 struct ck_mechanism *mechanism));
1180 _CK_DECLARE_FUNCTION (C_Digest,
1181 (ck_session_handle_t session,
1182 unsigned char *data, unsigned long data_len,
1183 unsigned char *digest,
1184 unsigned long *digest_len));
1185 _CK_DECLARE_FUNCTION (C_DigestUpdate,
1186 (ck_session_handle_t session,
1187 unsigned char *part, unsigned long part_len));
1188 _CK_DECLARE_FUNCTION (C_DigestKey,
1189 (ck_session_handle_t session, ck_object_handle_t key));
1190 _CK_DECLARE_FUNCTION (C_DigestFinal,
1191 (ck_session_handle_t session,
1192 unsigned char *digest,
1193 unsigned long *digest_len));
1194
1195 _CK_DECLARE_FUNCTION (C_SignInit,
1196 (ck_session_handle_t session,
1197 struct ck_mechanism *mechanism,
1198 ck_object_handle_t key));
1199 _CK_DECLARE_FUNCTION (C_Sign,
1200 (ck_session_handle_t session,
1201 unsigned char *data, unsigned long data_len,
1202 unsigned char *signature,
1203 unsigned long *signature_len));
1204 _CK_DECLARE_FUNCTION (C_SignUpdate,
1205 (ck_session_handle_t session,
1206 unsigned char *part, unsigned long part_len));
1207 _CK_DECLARE_FUNCTION (C_SignFinal,
1208 (ck_session_handle_t session,
1209 unsigned char *signature,
1210 unsigned long *signature_len));
1211 _CK_DECLARE_FUNCTION (C_SignRecoverInit,
1212 (ck_session_handle_t session,
1213 struct ck_mechanism *mechanism,
1214 ck_object_handle_t key));
1215 _CK_DECLARE_FUNCTION (C_SignRecover,
1216 (ck_session_handle_t session,
1217 unsigned char *data, unsigned long data_len,
1218 unsigned char *signature,
1219 unsigned long *signature_len));
1220
1221 _CK_DECLARE_FUNCTION (C_VerifyInit,
1222 (ck_session_handle_t session,
1223 struct ck_mechanism *mechanism,
1224 ck_object_handle_t key));
1225 _CK_DECLARE_FUNCTION (C_Verify,
1226 (ck_session_handle_t session,
1227 unsigned char *data, unsigned long data_len,
1228 unsigned char *signature,
1229 unsigned long signature_len));
1230 _CK_DECLARE_FUNCTION (C_VerifyUpdate,
1231 (ck_session_handle_t session,
1232 unsigned char *part, unsigned long part_len));
1233 _CK_DECLARE_FUNCTION (C_VerifyFinal,
1234 (ck_session_handle_t session,
1235 unsigned char *signature,
1236 unsigned long signature_len));
1237 _CK_DECLARE_FUNCTION (C_VerifyRecoverInit,
1238 (ck_session_handle_t session,
1239 struct ck_mechanism *mechanism,
1240 ck_object_handle_t key));
1241 _CK_DECLARE_FUNCTION (C_VerifyRecover,
1242 (ck_session_handle_t session,
1243 unsigned char *signature,
1244 unsigned long signature_len,
1245 unsigned char *data,
1246 unsigned long *data_len));
1247
1248 _CK_DECLARE_FUNCTION (C_DigestEncryptUpdate,
1249 (ck_session_handle_t session,
1250 unsigned char *part, unsigned long part_len,
1251 unsigned char *encrypted_part,
1252 unsigned long *encrypted_part_len));
1253 _CK_DECLARE_FUNCTION (C_DecryptDigestUpdate,
1254 (ck_session_handle_t session,
1255 unsigned char *encrypted_part,
1256 unsigned long encrypted_part_len,
1257 unsigned char *part,
1258 unsigned long *part_len));
1259 _CK_DECLARE_FUNCTION (C_SignEncryptUpdate,
1260 (ck_session_handle_t session,
1261 unsigned char *part, unsigned long part_len,
1262 unsigned char *encrypted_part,
1263 unsigned long *encrypted_part_len));
1264 _CK_DECLARE_FUNCTION (C_DecryptVerifyUpdate,
1265 (ck_session_handle_t session,
1266 unsigned char *encrypted_part,
1267 unsigned long encrypted_part_len,
1268 unsigned char *part,
1269 unsigned long *part_len));
1270
1271 _CK_DECLARE_FUNCTION (C_GenerateKey,
1272 (ck_session_handle_t session,
1273 struct ck_mechanism *mechanism,
1274 struct ck_attribute *templ,
1275 unsigned long count,
1276 ck_object_handle_t *key));
1277 _CK_DECLARE_FUNCTION (C_GenerateKeyPair,
1278 (ck_session_handle_t session,
1279 struct ck_mechanism *mechanism,
1280 struct ck_attribute *public_key_template,
1281 unsigned long public_key_attribute_count,
1282 struct ck_attribute *private_key_template,
1283 unsigned long private_key_attribute_count,
1284 ck_object_handle_t *public_key,
1285 ck_object_handle_t *private_key));
1286 _CK_DECLARE_FUNCTION (C_WrapKey,
1287 (ck_session_handle_t session,
1288 struct ck_mechanism *mechanism,
1289 ck_object_handle_t wrapping_key,
1290 ck_object_handle_t key,
1291 unsigned char *wrapped_key,
1292 unsigned long *wrapped_key_len));
1293 _CK_DECLARE_FUNCTION (C_UnwrapKey,
1294 (ck_session_handle_t session,
1295 struct ck_mechanism *mechanism,
1296 ck_object_handle_t unwrapping_key,
1297 unsigned char *wrapped_key,
1298 unsigned long wrapped_key_len,
1299 struct ck_attribute *templ,
1300 unsigned long attribute_count,
1301 ck_object_handle_t *key));
1302 _CK_DECLARE_FUNCTION (C_DeriveKey,
1303 (ck_session_handle_t session,
1304 struct ck_mechanism *mechanism,
1305 ck_object_handle_t base_key,
1306 struct ck_attribute *templ,
1307 unsigned long attribute_count,
1308 ck_object_handle_t *key));
1309
1310 _CK_DECLARE_FUNCTION (C_SeedRandom,
1311 (ck_session_handle_t session, unsigned char *seed,
1312 unsigned long seed_len));
1313 _CK_DECLARE_FUNCTION (C_GenerateRandom,
1314 (ck_session_handle_t session,
1315 unsigned char *random_data,
1316 unsigned long random_len));
1317
1318 _CK_DECLARE_FUNCTION (C_GetFunctionStatus, (ck_session_handle_t session));
1319 _CK_DECLARE_FUNCTION (C_CancelFunction, (ck_session_handle_t session));
1320
1321
1322 struct ck_function_list
1323 {
1324 struct ck_version version;
1325 CK_C_Initialize C_Initialize;
1326 CK_C_Finalize C_Finalize;
1327 CK_C_GetInfo C_GetInfo;
1328 CK_C_GetFunctionList C_GetFunctionList;
1329 CK_C_GetSlotList C_GetSlotList;
1330 CK_C_GetSlotInfo C_GetSlotInfo;
1331 CK_C_GetTokenInfo C_GetTokenInfo;
1332 CK_C_GetMechanismList C_GetMechanismList;
1333 CK_C_GetMechanismInfo C_GetMechanismInfo;
1334 CK_C_InitToken C_InitToken;
1335 CK_C_InitPIN C_InitPIN;
1336 CK_C_SetPIN C_SetPIN;
1337 CK_C_OpenSession C_OpenSession;
1338 CK_C_CloseSession C_CloseSession;
1339 CK_C_CloseAllSessions C_CloseAllSessions;
1340 CK_C_GetSessionInfo C_GetSessionInfo;
1341 CK_C_GetOperationState C_GetOperationState;
1342 CK_C_SetOperationState C_SetOperationState;
1343 CK_C_Login C_Login;
1344 CK_C_Logout C_Logout;
1345 CK_C_CreateObject C_CreateObject;
1346 CK_C_CopyObject C_CopyObject;
1347 CK_C_DestroyObject C_DestroyObject;
1348 CK_C_GetObjectSize C_GetObjectSize;
1349 CK_C_GetAttributeValue C_GetAttributeValue;
1350 CK_C_SetAttributeValue C_SetAttributeValue;
1351 CK_C_FindObjectsInit C_FindObjectsInit;
1352 CK_C_FindObjects C_FindObjects;
1353 CK_C_FindObjectsFinal C_FindObjectsFinal;
1354 CK_C_EncryptInit C_EncryptInit;
1355 CK_C_Encrypt C_Encrypt;
1356 CK_C_EncryptUpdate C_EncryptUpdate;
1357 CK_C_EncryptFinal C_EncryptFinal;
1358 CK_C_DecryptInit C_DecryptInit;
1359 CK_C_Decrypt C_Decrypt;
1360 CK_C_DecryptUpdate C_DecryptUpdate;
1361 CK_C_DecryptFinal C_DecryptFinal;
1362 CK_C_DigestInit C_DigestInit;
1363 CK_C_Digest C_Digest;
1364 CK_C_DigestUpdate C_DigestUpdate;
1365 CK_C_DigestKey C_DigestKey;
1366 CK_C_DigestFinal C_DigestFinal;
1367 CK_C_SignInit C_SignInit;
1368 CK_C_Sign C_Sign;
1369 CK_C_SignUpdate C_SignUpdate;
1370 CK_C_SignFinal C_SignFinal;
1371 CK_C_SignRecoverInit C_SignRecoverInit;
1372 CK_C_SignRecover C_SignRecover;
1373 CK_C_VerifyInit C_VerifyInit;
1374 CK_C_Verify C_Verify;
1375 CK_C_VerifyUpdate C_VerifyUpdate;
1376 CK_C_VerifyFinal C_VerifyFinal;
1377 CK_C_VerifyRecoverInit C_VerifyRecoverInit;
1378 CK_C_VerifyRecover C_VerifyRecover;
1379 CK_C_DigestEncryptUpdate C_DigestEncryptUpdate;
1380 CK_C_DecryptDigestUpdate C_DecryptDigestUpdate;
1381 CK_C_SignEncryptUpdate C_SignEncryptUpdate;
1382 CK_C_DecryptVerifyUpdate C_DecryptVerifyUpdate;
1383 CK_C_GenerateKey C_GenerateKey;
1384 CK_C_GenerateKeyPair C_GenerateKeyPair;
1385 CK_C_WrapKey C_WrapKey;
1386 CK_C_UnwrapKey C_UnwrapKey;
1387 CK_C_DeriveKey C_DeriveKey;
1388 CK_C_SeedRandom C_SeedRandom;
1389 CK_C_GenerateRandom C_GenerateRandom;
1390 CK_C_GetFunctionStatus C_GetFunctionStatus;
1391 CK_C_CancelFunction C_CancelFunction;
1392 CK_C_WaitForSlotEvent C_WaitForSlotEvent;
1393 };
1394
1395
1396 typedef ck_rv_t (*ck_createmutex_t) (void **mutex);
1397 typedef ck_rv_t (*ck_destroymutex_t) (void *mutex);
1398 typedef ck_rv_t (*ck_lockmutex_t) (void *mutex);
1399 typedef ck_rv_t (*ck_unlockmutex_t) (void *mutex);
1400
1401
1402 struct ck_c_initialize_args
1403 {
1404 ck_createmutex_t create_mutex;
1405 ck_destroymutex_t destroy_mutex;
1406 ck_lockmutex_t lock_mutex;
1407 ck_unlockmutex_t unlock_mutex;
1408 ck_flags_t flags;
1409 void *reserved;
1410 };
1411
1412
1413 #define CKF_LIBRARY_CANT_CREATE_OS_THREADS (1 << 0)
1414 #define CKF_OS_LOCKING_OK (1 << 1)
1415
1416 #define CKR_OK (0)
1417 #define CKR_CANCEL (1)
1418 #define CKR_HOST_MEMORY (2)
1419 #define CKR_SLOT_ID_INVALID (3)
1420 #define CKR_GENERAL_ERROR (5)
1421 #define CKR_FUNCTION_FAILED (6)
1422 #define CKR_ARGUMENTS_BAD (7)
1423 #define CKR_NO_EVENT (8)
1424 #define CKR_NEED_TO_CREATE_THREADS (9)
1425 #define CKR_CANT_LOCK (0xa)
1426 #define CKR_ATTRIBUTE_READ_ONLY (0x10)
1427 #define CKR_ATTRIBUTE_SENSITIVE (0x11)
1428 #define CKR_ATTRIBUTE_TYPE_INVALID (0x12)
1429 #define CKR_ATTRIBUTE_VALUE_INVALID (0x13)
1430 #define CKR_COPY_PROHIBITED (0x1A)
1431 #define CKR_DATA_INVALID (0x20)
1432 #define CKR_DATA_LEN_RANGE (0x21)
1433 #define CKR_DEVICE_ERROR (0x30)
1434 #define CKR_DEVICE_MEMORY (0x31)
1435 #define CKR_DEVICE_REMOVED (0x32)
1436 #define CKR_ENCRYPTED_DATA_INVALID (0x40)
1437 #define CKR_ENCRYPTED_DATA_LEN_RANGE (0x41)
1438 #define CKR_FUNCTION_CANCELED (0x50)
1439 #define CKR_FUNCTION_NOT_PARALLEL (0x51)
1440 #define CKR_FUNCTION_NOT_SUPPORTED (0x54)
1441 #define CKR_KEY_HANDLE_INVALID (0x60)
1442 #define CKR_KEY_SIZE_RANGE (0x62)
1443 #define CKR_KEY_TYPE_INCONSISTENT (0x63)
1444 #define CKR_KEY_NOT_NEEDED (0x64)
1445 #define CKR_KEY_CHANGED (0x65)
1446 #define CKR_KEY_NEEDED (0x66)
1447 #define CKR_KEY_INDIGESTIBLE (0x67)
1448 #define CKR_KEY_FUNCTION_NOT_PERMITTED (0x68)
1449 #define CKR_KEY_NOT_WRAPPABLE (0x69)
1450 #define CKR_KEY_UNEXTRACTABLE (0x6a)
1451 #define CKR_MECHANISM_INVALID (0x70)
1452 #define CKR_MECHANISM_PARAM_INVALID (0x71)
1453 #define CKR_OBJECT_HANDLE_INVALID (0x82)
1454 #define CKR_OPERATION_ACTIVE (0x90)
1455 #define CKR_OPERATION_NOT_INITIALIZED (0x91)
1456 #define CKR_PIN_INCORRECT (0xa0)
1457 #define CKR_PIN_INVALID (0xa1)
1458 #define CKR_PIN_LEN_RANGE (0xa2)
1459 #define CKR_PIN_EXPIRED (0xa3)
1460 #define CKR_PIN_LOCKED (0xa4)
1461 #define CKR_SESSION_CLOSED (0xb0)
1462 #define CKR_SESSION_COUNT (0xb1)
1463 #define CKR_SESSION_HANDLE_INVALID (0xb3)
1464 #define CKR_SESSION_PARALLEL_NOT_SUPPORTED (0xb4)
1465 #define CKR_SESSION_READ_ONLY (0xb5)
1466 #define CKR_SESSION_EXISTS (0xb6)
1467 #define CKR_SESSION_READ_ONLY_EXISTS (0xb7)
1468 #define CKR_SESSION_READ_WRITE_SO_EXISTS (0xb8)
1469 #define CKR_SIGNATURE_INVALID (0xc0)
1470 #define CKR_SIGNATURE_LEN_RANGE (0xc1)
1471 #define CKR_TEMPLATE_INCOMPLETE (0xd0)
1472 #define CKR_TEMPLATE_INCONSISTENT (0xd1)
1473 #define CKR_TOKEN_NOT_PRESENT (0xe0)
1474 #define CKR_TOKEN_NOT_RECOGNIZED (0xe1)
1475 #define CKR_TOKEN_WRITE_PROTECTED (0xe2)
1476 #define CKR_UNWRAPPING_KEY_HANDLE_INVALID (0xf0)
1477 #define CKR_UNWRAPPING_KEY_SIZE_RANGE (0xf1)
1478 #define CKR_UNWRAPPING_KEY_TYPE_INCONSISTENT (0xf2)
1479 #define CKR_USER_ALREADY_LOGGED_IN (0x100)
1480 #define CKR_USER_NOT_LOGGED_IN (0x101)
1481 #define CKR_USER_PIN_NOT_INITIALIZED (0x102)
1482 #define CKR_USER_TYPE_INVALID (0x103)
1483 #define CKR_USER_ANOTHER_ALREADY_LOGGED_IN (0x104)
1484 #define CKR_USER_TOO_MANY_TYPES (0x105)
1485 #define CKR_WRAPPED_KEY_INVALID (0x110)
1486 #define CKR_WRAPPED_KEY_LEN_RANGE (0x112)
1487 #define CKR_WRAPPING_KEY_HANDLE_INVALID (0x113)
1488 #define CKR_WRAPPING_KEY_SIZE_RANGE (0x114)
1489 #define CKR_WRAPPING_KEY_TYPE_INCONSISTENT (0x115)
1490 #define CKR_RANDOM_SEED_NOT_SUPPORTED (0x120)
1491 #define CKR_RANDOM_NO_RNG (0x121)
1492 #define CKR_DOMAIN_PARAMS_INVALID (0x130)
1493 #define CKR_BUFFER_TOO_SMALL (0x150)
1494 #define CKR_SAVED_STATE_INVALID (0x160)
1495 #define CKR_INFORMATION_SENSITIVE (0x170)
1496 #define CKR_STATE_UNSAVEABLE (0x180)
1497 #define CKR_CRYPTOKI_NOT_INITIALIZED (0x190)
1498 #define CKR_CRYPTOKI_ALREADY_INITIALIZED (0x191)
1499 #define CKR_MUTEX_BAD (0x1a0)
1500 #define CKR_MUTEX_NOT_LOCKED (0x1a1)
1501 #define CKR_NEW_PIN_MODE (0x1b0)
1502 #define CKR_NEXT_OTP (0x1b1)
1503 #define CKR_EXCEEDED_MAX_ITERATIONS (0x1b5)
1504 #define CKR_FIPS_SELF_TEST_FAILED (0x1b6)
1505 #define CKR_LIBRARY_LOAD_FAILED (0x1b7)
1506 #define CKR_PIN_TOO_WEAK (0x1b8)
1507 #define CKR_PUBLIC_KEY_INVALID (0x1b9)
1508 #define CKR_FUNCTION_REJECTED (0x200)
1509 #define CKR_VENDOR_DEFINED ((unsigned long) (1ul << 31))
1510
1511
1512
1513 /* Compatibility layer. */
1515
1516 #ifdef CRYPTOKI_COMPAT
1517
1518 #undef CK_DEFINE_FUNCTION
1519 #define CK_DEFINE_FUNCTION(retval, name) retval CK_SPEC name
1520
1521 /* For NULL. */
1522 #include <stddef.h>
1523
1524 typedef unsigned char CK_BYTE;
1525 typedef unsigned char CK_CHAR;
1526 typedef unsigned char CK_UTF8CHAR;
1527 typedef unsigned char CK_BBOOL;
1528 typedef unsigned long int CK_ULONG;
1529 typedef long int CK_LONG;
1530 typedef CK_BYTE *CK_BYTE_PTR;
1531 typedef CK_CHAR *CK_CHAR_PTR;
1532 typedef CK_UTF8CHAR *CK_UTF8CHAR_PTR;
1533 typedef CK_ULONG *CK_ULONG_PTR;
1534 typedef void *CK_VOID_PTR;
1535 typedef void **CK_VOID_PTR_PTR;
1536 #define CK_FALSE 0
1537 #define CK_TRUE 1
1538 #ifndef CK_DISABLE_TRUE_FALSE
1539 #ifndef FALSE
1540 #define FALSE 0
1541 #endif
1542 #ifndef TRUE
1543 #define TRUE 1
1544 #endif
1545 #endif
1546
1547 typedef struct ck_version CK_VERSION;
1548 typedef struct ck_version *CK_VERSION_PTR;
1549
1550 typedef struct ck_info CK_INFO;
1551 typedef struct ck_info *CK_INFO_PTR;
1552
1553 typedef ck_slot_id_t *CK_SLOT_ID_PTR;
1554
1555 typedef struct ck_slot_info CK_SLOT_INFO;
1556 typedef struct ck_slot_info *CK_SLOT_INFO_PTR;
1557
1558 typedef struct ck_token_info CK_TOKEN_INFO;
1559 typedef struct ck_token_info *CK_TOKEN_INFO_PTR;
1560
1561 typedef ck_session_handle_t *CK_SESSION_HANDLE_PTR;
1562
1563 typedef struct ck_session_info CK_SESSION_INFO;
1564 typedef struct ck_session_info *CK_SESSION_INFO_PTR;
1565
1566 typedef ck_object_handle_t *CK_OBJECT_HANDLE_PTR;
1567
1568 typedef ck_object_class_t *CK_OBJECT_CLASS_PTR;
1569
1570 typedef struct ck_attribute CK_ATTRIBUTE;
1571 typedef struct ck_attribute *CK_ATTRIBUTE_PTR;
1572
1573 typedef struct ck_date CK_DATE;
1574 typedef struct ck_date *CK_DATE_PTR;
1575
1576 typedef ck_mechanism_type_t *CK_MECHANISM_TYPE_PTR;
1577
1578 typedef struct ck_mechanism CK_MECHANISM;
1579 typedef struct ck_mechanism *CK_MECHANISM_PTR;
1580
1581 typedef struct ck_mechanism_info CK_MECHANISM_INFO;
1582 typedef struct ck_mechanism_info *CK_MECHANISM_INFO_PTR;
1583
1584 typedef struct ck_rsa_pkcs_oaep_params CK_RSA_PKCS_OAEP_PARAMS;
1585 typedef struct ck_rsa_pkcs_oaep_params *CK_RSA_PKCS_OAEP_PARAMS_PTR;
1586
1587 typedef struct ck_rsa_pkcs_pss_params CK_RSA_PKCS_PSS_PARAMS;
1588 typedef struct ck_rsa_pkcs_pss_params *CK_RSA_PKCS_PSS_PARAMS_PTR;
1589
1590 typedef struct ck_ecdh1_derive_params CK_ECDH1_DERIVE_PARAMS;
1591 typedef struct ck_ecdh1_derive_params *CK_ECDH1_DERIVE_PARAMS_PTR;
1592
1593 typedef struct ck_des_cbc_encrypt_data_params CK_DES_CBC_ENCRYPT_DATA_PARAMS;
1594 typedef struct ck_des_cbc_encrypt_data_params *CK_DES_CBC_ENCRYPT_DATA_PARAMS_PTR;
1595
1596 typedef struct ck_aes_cbc_encrypt_data_params CK_AES_CBC_ENCRYPT_DATA_PARAMS;
1597 typedef struct ck_aes_cbc_encrypt_data_params *CK_AES_CBC_ENCRYPT_DATA_PARAMS_PTR;
1598
1599 typedef struct ck_key_derivation_string_data CK_KEY_DERIVATION_STRING_DATA;
1600 typedef struct ck_key_derivation_string_data *CK_KEY_DERIVATION_STRING_DATA_PTR;
1601
1602 typedef struct ck_function_list CK_FUNCTION_LIST;
1603 typedef struct ck_function_list *CK_FUNCTION_LIST_PTR;
1604 typedef struct ck_function_list **CK_FUNCTION_LIST_PTR_PTR;
1605
1606 typedef struct ck_c_initialize_args CK_C_INITIALIZE_ARGS;
1607 typedef struct ck_c_initialize_args *CK_C_INITIALIZE_ARGS_PTR;
1608
1609 #define NULL_PTR NULL
1610
1611 /* Delete the helper macros defined at the top of the file. */
1612 #undef ck_flags_t
1613 #undef ck_version
1614
1615 #undef ck_info
1616 #undef cryptoki_version
1617 #undef manufacturer_id
1618 #undef library_description
1619 #undef library_version
1620
1621 #undef ck_notification_t
1622 #undef ck_slot_id_t
1623
1624 #undef ck_slot_info
1625 #undef slot_description
1626 #undef hardware_version
1627 #undef firmware_version
1628
1629 #undef ck_token_info
1630 #undef serial_number
1631 #undef max_session_count
1632 #undef session_count
1633 #undef max_rw_session_count
1634 #undef rw_session_count
1635 #undef max_pin_len
1636 #undef min_pin_len
1637 #undef total_public_memory
1638 #undef free_public_memory
1639 #undef total_private_memory
1640 #undef free_private_memory
1641 #undef utc_time
1642
1643 #undef ck_session_handle_t
1644 #undef ck_user_type_t
1645 #undef ck_state_t
1646
1647 #undef ck_session_info
1648 #undef slot_id
1649 #undef device_error
1650
1651 #undef ck_object_handle_t
1652 #undef ck_object_class_t
1653 #undef ck_hw_feature_type_t
1654 #undef ck_key_type_t
1655 #undef ck_certificate_type_t
1656 #undef ck_attribute_type_t
1657
1658 #undef ck_attribute
1659 #undef value
1660 #undef value_len
1661
1662 #undef ck_date
1663
1664 #undef ck_mechanism_type_t
1665
1666 #undef ck_mechanism
1667 #undef parameter
1668 #undef parameter_len
1669
1670 #undef ck_mechanism_info
1671 #undef min_key_size
1672 #undef max_key_size
1673
1674 #undef ck_rsa_pkcs_oaep_params
1675 #undef hash_alg
1676 #undef source_data
1677 #undef source_data_len
1678 #undef slen
1679
1680 #undef ck_ec_kdf_type_t
1681 #undef shared_data_len
1682 #undef shared_data
1683 #undef public_data_len
1684 #undef public_data
1685 #undef private_data_len
1686 #undef private_data
1687 #undef public_data_len2
1688 #undef public_data2
1689 #undef public_key
1690
1691 #undef ck_x9_42_dh_kdf_type_t
1692 #undef other_info_len
1693 #undef other_info
1694
1695 #undef data
1696 #undef len
1697
1698 #undef ck_rv_t
1699 #undef ck_notify_t
1700
1701 #undef ck_function_list
1702
1703 #undef ck_createmutex_t
1704 #undef ck_destroymutex_t
1705 #undef ck_lockmutex_t
1706 #undef ck_unlockmutex_t
1707
1708 #undef ck_c_initialize_args
1709 #undef create_mutex
1710 #undef destroy_mutex
1711 #undef lock_mutex
1712 #undef unlock_mutex
1713 #undef reserved
1714
1715 #endif /* CRYPTOKI_COMPAT */
1716
1717
1718 /* System dependencies. */
1720 #if defined(_WIN32) || defined(CRYPTOKI_FORCE_WIN32)
1721 #pragma pack(pop, cryptoki)
1722 #endif
1723
1724 #if defined(__cplusplus)
1725 }
1726 #endif
1727
1728 #endif /* PKCS11_H */
1729