xref: /titanic_44/usr/src/lib/pkcs11/include/pkcs11t.h (revision 0173c38a73f34277e0c97a19fedfd25d81ba8380)
1 /* pkcs11t.h include file for PKCS #11. */
2 /* $Revision: 1.6 $ */
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 /* See top of pkcs11.h for information about the macros that
20  * must be defined and the structure-packing conventions that
21  * must be set before including this file. */
22 
23 #ifndef _PKCS11T_H_
24 #define _PKCS11T_H_ 1
25 
26 #define CK_TRUE 1
27 #define CK_FALSE 0
28 
29 #ifndef CK_DISABLE_TRUE_FALSE
30 #ifndef FALSE
31 #define FALSE CK_FALSE
32 #endif
33 
34 #ifndef TRUE
35 #define TRUE CK_TRUE
36 #endif
37 #endif
38 
39 /* an unsigned 8-bit value */
40 typedef unsigned char     CK_BYTE;
41 
42 /* an unsigned 8-bit character */
43 typedef CK_BYTE           CK_CHAR;
44 
45 /* an 8-bit UTF-8 character */
46 typedef CK_BYTE           CK_UTF8CHAR;
47 
48 /* a BYTE-sized Boolean flag */
49 typedef CK_BYTE           CK_BBOOL;
50 
51 /* an unsigned value, at least 32 bits long */
52 typedef unsigned long int CK_ULONG;
53 
54 /* a signed value, the same size as a CK_ULONG */
55 /* CK_LONG is new for v2.0 */
56 typedef long int          CK_LONG;
57 
58 /* at least 32 bits; each bit is a Boolean flag */
59 typedef CK_ULONG          CK_FLAGS;
60 
61 
62 /* some special values for certain CK_ULONG variables */
63 #define CK_UNAVAILABLE_INFORMATION (~0UL)
64 #define CK_EFFECTIVELY_INFINITE    0
65 
66 
67 typedef CK_BYTE     CK_PTR   CK_BYTE_PTR;
68 typedef CK_CHAR     CK_PTR   CK_CHAR_PTR;
69 typedef CK_UTF8CHAR CK_PTR   CK_UTF8CHAR_PTR;
70 typedef CK_ULONG    CK_PTR   CK_ULONG_PTR;
71 typedef void        CK_PTR   CK_VOID_PTR;
72 
73 /* Pointer to a CK_VOID_PTR-- i.e., pointer to pointer to void */
74 typedef CK_VOID_PTR CK_PTR CK_VOID_PTR_PTR;
75 
76 
77 /* The following value is always invalid if used as a session */
78 /* handle or object handle */
79 #define CK_INVALID_HANDLE 0
80 
81 
82 typedef struct CK_VERSION {
83   CK_BYTE       major;  /* integer portion of version number */
84   CK_BYTE       minor;  /* 1/100ths portion of version number */
85 } CK_VERSION;
86 
87 typedef CK_VERSION CK_PTR CK_VERSION_PTR;
88 
89 
90 typedef struct CK_INFO {
91   /* manufacturerID and libraryDecription have been changed from
92    * CK_CHAR to CK_UTF8CHAR for v2.10 */
93   CK_VERSION    cryptokiVersion;     /* Cryptoki interface ver */
94   CK_UTF8CHAR   manufacturerID[32];  /* blank padded */
95   CK_FLAGS      flags;               /* must be zero */
96 
97   /* libraryDescription and libraryVersion are new for v2.0 */
98   CK_UTF8CHAR   libraryDescription[32];  /* blank padded */
99   CK_VERSION    libraryVersion;          /* version of library */
100 } CK_INFO;
101 
102 typedef CK_INFO CK_PTR    CK_INFO_PTR;
103 
104 
105 /* CK_NOTIFICATION enumerates the types of notifications that
106  * Cryptoki provides to an application */
107 /* CK_NOTIFICATION has been changed from an enum to a CK_ULONG
108  * for v2.0 */
109 typedef CK_ULONG CK_NOTIFICATION;
110 #define CKN_SURRENDER       0
111 
112 
113 typedef CK_ULONG          CK_SLOT_ID;
114 
115 typedef CK_SLOT_ID CK_PTR CK_SLOT_ID_PTR;
116 
117 
118 /* CK_SLOT_INFO provides information about a slot */
119 typedef struct CK_SLOT_INFO {
120   /* slotDescription and manufacturerID have been changed from
121    * CK_CHAR to CK_UTF8CHAR for v2.10 */
122   CK_UTF8CHAR   slotDescription[64];  /* blank padded */
123   CK_UTF8CHAR   manufacturerID[32];   /* blank padded */
124   CK_FLAGS      flags;
125 
126   /* hardwareVersion and firmwareVersion are new for v2.0 */
127   CK_VERSION    hardwareVersion;  /* version of hardware */
128   CK_VERSION    firmwareVersion;  /* version of firmware */
129 } CK_SLOT_INFO;
130 
131 /* flags: bit flags that provide capabilities of the slot
132  *      Bit Flag              Mask        Meaning
133  */
134 #define CKF_TOKEN_PRESENT     0x00000001  /* a token is there */
135 #define CKF_REMOVABLE_DEVICE  0x00000002  /* removable devices*/
136 #define CKF_HW_SLOT           0x00000004  /* hardware slot */
137 
138 typedef CK_SLOT_INFO CK_PTR CK_SLOT_INFO_PTR;
139 
140 
141 /* CK_TOKEN_INFO provides information about a token */
142 typedef struct CK_TOKEN_INFO {
143   /* label, manufacturerID, and model have been changed from
144    * CK_CHAR to CK_UTF8CHAR for v2.10 */
145   CK_UTF8CHAR   label[32];           /* blank padded */
146   CK_UTF8CHAR   manufacturerID[32];  /* blank padded */
147   CK_UTF8CHAR   model[16];           /* blank padded */
148   CK_CHAR       serialNumber[16];    /* blank padded */
149   CK_FLAGS      flags;               /* see below */
150 
151   /* ulMaxSessionCount, ulSessionCount, ulMaxRwSessionCount,
152    * ulRwSessionCount, ulMaxPinLen, and ulMinPinLen have all been
153    * changed from CK_USHORT to CK_ULONG for v2.0 */
154   CK_ULONG      ulMaxSessionCount;     /* max open sessions */
155   CK_ULONG      ulSessionCount;        /* sess. now open */
156   CK_ULONG      ulMaxRwSessionCount;   /* max R/W sessions */
157   CK_ULONG      ulRwSessionCount;      /* R/W sess. now open */
158   CK_ULONG      ulMaxPinLen;           /* in bytes */
159   CK_ULONG      ulMinPinLen;           /* in bytes */
160   CK_ULONG      ulTotalPublicMemory;   /* in bytes */
161   CK_ULONG      ulFreePublicMemory;    /* in bytes */
162   CK_ULONG      ulTotalPrivateMemory;  /* in bytes */
163   CK_ULONG      ulFreePrivateMemory;   /* in bytes */
164 
165   /* hardwareVersion, firmwareVersion, and time are new for
166    * v2.0 */
167   CK_VERSION    hardwareVersion;       /* version of hardware */
168   CK_VERSION    firmwareVersion;       /* version of firmware */
169   CK_CHAR       utcTime[16];           /* time */
170 } CK_TOKEN_INFO;
171 
172 /* The flags parameter is defined as follows:
173  *      Bit Flag                    Mask        Meaning
174  */
175 #define CKF_RNG                     0x00000001  /* has random #
176                                                  * generator */
177 #define CKF_WRITE_PROTECTED         0x00000002  /* token is
178                                                  * write-
179                                                  * protected */
180 #define CKF_LOGIN_REQUIRED          0x00000004  /* user must
181                                                  * login */
182 #define CKF_USER_PIN_INITIALIZED    0x00000008  /* normal user's
183                                                  * PIN is set */
184 
185 /* CKF_RESTORE_KEY_NOT_NEEDED is new for v2.0.  If it is set,
186  * that means that *every* time the state of cryptographic
187  * operations of a session is successfully saved, all keys
188  * needed to continue those operations are stored in the state */
189 #define CKF_RESTORE_KEY_NOT_NEEDED  0x00000020
190 
191 /* CKF_CLOCK_ON_TOKEN is new for v2.0.  If it is set, that means
192  * that the token has some sort of clock.  The time on that
193  * clock is returned in the token info structure */
194 #define CKF_CLOCK_ON_TOKEN          0x00000040
195 
196 /* CKF_PROTECTED_AUTHENTICATION_PATH is new for v2.0.  If it is
197  * set, that means that there is some way for the user to login
198  * without sending a PIN through the Cryptoki library itself */
199 #define CKF_PROTECTED_AUTHENTICATION_PATH 0x00000100
200 
201 /* CKF_DUAL_CRYPTO_OPERATIONS is new for v2.0.  If it is true,
202  * that means that a single session with the token can perform
203  * dual simultaneous cryptographic operations (digest and
204  * encrypt; decrypt and digest; sign and encrypt; and decrypt
205  * and sign) */
206 #define CKF_DUAL_CRYPTO_OPERATIONS  0x00000200
207 
208 /* CKF_TOKEN_INITIALIZED if new for v2.10. If it is true, the
209  * token has been initialized using C_InitializeToken or an
210  * equivalent mechanism outside the scope of PKCS #11.
211  * Calling C_InitializeToken when this flag is set will cause
212  * the token to be reinitialized. */
213 #define CKF_TOKEN_INITIALIZED       0x00000400
214 
215 /* CKF_SECONDARY_AUTHENTICATION if new for v2.10. If it is
216  * true, the token supports secondary authentication for
217  * private key objects. This flag is deprecated in v2.11 and
218    onwards. */
219 #define CKF_SECONDARY_AUTHENTICATION  0x00000800
220 
221 /* CKF_USER_PIN_COUNT_LOW if new for v2.10. If it is true, an
222  * incorrect user login PIN has been entered at least once
223  * since the last successful authentication. */
224 #define CKF_USER_PIN_COUNT_LOW       0x00010000
225 
226 /* CKF_USER_PIN_FINAL_TRY if new for v2.10. If it is true,
227  * supplying an incorrect user PIN will it to become locked. */
228 #define CKF_USER_PIN_FINAL_TRY       0x00020000
229 
230 /* CKF_USER_PIN_LOCKED if new for v2.10. If it is true, the
231  * user PIN has been locked. User login to the token is not
232  * possible. */
233 #define CKF_USER_PIN_LOCKED          0x00040000
234 
235 /* CKF_USER_PIN_TO_BE_CHANGED if new for v2.10. If it is true,
236  * the user PIN value is the default value set by token
237  * initialization or manufacturing, or the PIN has been
238  * expired by the card. */
239 #define CKF_USER_PIN_TO_BE_CHANGED   0x00080000
240 
241 /* CKF_SO_PIN_COUNT_LOW if new for v2.10. If it is true, an
242  * incorrect SO login PIN has been entered at least once since
243  * the last successful authentication. */
244 #define CKF_SO_PIN_COUNT_LOW         0x00100000
245 
246 /* CKF_SO_PIN_FINAL_TRY if new for v2.10. If it is true,
247  * supplying an incorrect SO PIN will it to become locked. */
248 #define CKF_SO_PIN_FINAL_TRY         0x00200000
249 
250 /* CKF_SO_PIN_LOCKED if new for v2.10. If it is true, the SO
251  * PIN has been locked. SO login to the token is not possible.
252  */
253 #define CKF_SO_PIN_LOCKED            0x00400000
254 
255 /* CKF_SO_PIN_TO_BE_CHANGED if new for v2.10. If it is true,
256  * the SO PIN value is the default value set by token
257  * initialization or manufacturing, or the PIN has been
258  * expired by the card. */
259 #define CKF_SO_PIN_TO_BE_CHANGED     0x00800000
260 
261 typedef CK_TOKEN_INFO CK_PTR CK_TOKEN_INFO_PTR;
262 
263 
264 /* CK_SESSION_HANDLE is a Cryptoki-assigned value that
265  * identifies a session */
266 typedef CK_ULONG          CK_SESSION_HANDLE;
267 
268 typedef CK_SESSION_HANDLE CK_PTR CK_SESSION_HANDLE_PTR;
269 
270 
271 /* CK_USER_TYPE enumerates the types of Cryptoki users */
272 /* CK_USER_TYPE has been changed from an enum to a CK_ULONG for
273  * v2.0 */
274 typedef CK_ULONG          CK_USER_TYPE;
275 /* Security Officer */
276 #define CKU_SO    0
277 /* Normal user */
278 #define CKU_USER  1
279 /* Context specific (added in v2.20) */
280 #define CKU_CONTEXT_SPECIFIC   2
281 
282 /* CK_STATE enumerates the session states */
283 /* CK_STATE has been changed from an enum to a CK_ULONG for
284  * v2.0 */
285 typedef CK_ULONG          CK_STATE;
286 #define CKS_RO_PUBLIC_SESSION  0
287 #define CKS_RO_USER_FUNCTIONS  1
288 #define CKS_RW_PUBLIC_SESSION  2
289 #define CKS_RW_USER_FUNCTIONS  3
290 #define CKS_RW_SO_FUNCTIONS    4
291 
292 
293 /* CK_SESSION_INFO provides information about a session */
294 typedef struct CK_SESSION_INFO {
295   CK_SLOT_ID    slotID;
296   CK_STATE      state;
297   CK_FLAGS      flags;          /* see below */
298 
299   /* ulDeviceError was changed from CK_USHORT to CK_ULONG for
300    * v2.0 */
301   CK_ULONG      ulDeviceError;  /* device-dependent error code */
302 } CK_SESSION_INFO;
303 
304 /* The flags are defined in the following table:
305  *      Bit Flag                Mask        Meaning
306  */
307 #define CKF_RW_SESSION          0x00000002  /* session is r/w */
308 #define CKF_SERIAL_SESSION      0x00000004  /* no parallel */
309 
310 typedef CK_SESSION_INFO CK_PTR CK_SESSION_INFO_PTR;
311 
312 
313 /* CK_OBJECT_HANDLE is a token-specific identifier for an
314  * object  */
315 typedef CK_ULONG          CK_OBJECT_HANDLE;
316 
317 typedef CK_OBJECT_HANDLE CK_PTR CK_OBJECT_HANDLE_PTR;
318 
319 
320 /* CK_OBJECT_CLASS is a value that identifies the classes (or
321  * types) of objects that Cryptoki recognizes.  It is defined
322  * as follows: */
323 /* CK_OBJECT_CLASS was changed from CK_USHORT to CK_ULONG for
324  * v2.0 */
325 typedef CK_ULONG          CK_OBJECT_CLASS;
326 
327 /* The following classes of objects are defined: */
328 /* CKO_HW_FEATURE is new for v2.10 */
329 /* CKO_DOMAIN_PARAMETERS is new for v2.11 */
330 /* CKO_MECHANISM is new for v2.20 */
331 #define CKO_DATA              0x00000000
332 #define CKO_CERTIFICATE       0x00000001
333 #define CKO_PUBLIC_KEY        0x00000002
334 #define CKO_PRIVATE_KEY       0x00000003
335 #define CKO_SECRET_KEY        0x00000004
336 #define CKO_HW_FEATURE        0x00000005
337 #define CKO_DOMAIN_PARAMETERS 0x00000006
338 #define CKO_MECHANISM         0x00000007
339 #define CKO_VENDOR_DEFINED    0x80000000
340 
341 typedef CK_OBJECT_CLASS CK_PTR CK_OBJECT_CLASS_PTR;
342 
343 /* CK_HW_FEATURE_TYPE is new for v2.10. CK_HW_FEATURE_TYPE is a
344  * value that identifies the hardware feature type of an object
345  * with CK_OBJECT_CLASS equal to CKO_HW_FEATURE. */
346 typedef CK_ULONG          CK_HW_FEATURE_TYPE;
347 
348 /* The following hardware feature types are defined */
349 /* CKH_USER_INTERFACE is new for v2.20 */
350 #define CKH_MONOTONIC_COUNTER  0x00000001
351 #define CKH_CLOCK           0x00000002
352 #define CKH_USER_INTERFACE  0x00000003
353 #define CKH_VENDOR_DEFINED  0x80000000
354 
355 /* CK_KEY_TYPE is a value that identifies a key type */
356 /* CK_KEY_TYPE was changed from CK_USHORT to CK_ULONG for v2.0 */
357 typedef CK_ULONG          CK_KEY_TYPE;
358 
359 /* the following key types are defined: */
360 #define CKK_RSA             0x00000000
361 #define CKK_DSA             0x00000001
362 #define CKK_DH              0x00000002
363 
364 /* CKK_ECDSA and CKK_KEA are new for v2.0 */
365 /* CKK_ECDSA is deprecated in v2.11, CKK_EC is preferred. */
366 #define CKK_ECDSA           0x00000003
367 #define CKK_EC              0x00000003
368 #define CKK_X9_42_DH        0x00000004
369 #define CKK_KEA             0x00000005
370 
371 #define CKK_GENERIC_SECRET  0x00000010
372 #define CKK_RC2             0x00000011
373 #define CKK_RC4             0x00000012
374 #define CKK_DES             0x00000013
375 #define CKK_DES2            0x00000014
376 #define CKK_DES3            0x00000015
377 
378 /* all these key types are new for v2.0 */
379 #define CKK_CAST            0x00000016
380 #define CKK_CAST3           0x00000017
381 /* CKK_CAST5 is deprecated in v2.11, CKK_CAST128 is preferred. */
382 #define CKK_CAST5           0x00000018
383 #define CKK_CAST128         0x00000018
384 #define CKK_RC5             0x00000019
385 #define CKK_IDEA            0x0000001A
386 #define CKK_SKIPJACK        0x0000001B
387 #define CKK_BATON           0x0000001C
388 #define CKK_JUNIPER         0x0000001D
389 #define CKK_CDMF            0x0000001E
390 #define CKK_AES             0x0000001F
391 
392 /* BlowFish and TwoFish are new for v2.20 */
393 #define CKK_BLOWFISH        0x00000020
394 #define CKK_TWOFISH         0x00000021
395 
396 #define CKK_VENDOR_DEFINED  0x80000000
397 
398 
399 /* CK_CERTIFICATE_TYPE is a value that identifies a certificate
400  * type */
401 /* CK_CERTIFICATE_TYPE was changed from CK_USHORT to CK_ULONG
402  * for v2.0 */
403 typedef CK_ULONG          CK_CERTIFICATE_TYPE;
404 
405 /* The following certificate types are defined: */
406 /* CKC_X_509_ATTR_CERT is new for v2.10 */
407 /* CKC_WTLS is new for v2.20 */
408 #define CKC_X_509           0x00000000
409 #define CKC_X_509_ATTR_CERT 0x00000001
410 #define CKC_WTLS            0x00000002
411 #define CKC_VENDOR_DEFINED  0x80000000
412 
413 
414 /* CK_ATTRIBUTE_TYPE is a value that identifies an attribute
415  * type */
416 /* CK_ATTRIBUTE_TYPE was changed from CK_USHORT to CK_ULONG for
417  * v2.0 */
418 typedef CK_ULONG          CK_ATTRIBUTE_TYPE;
419 
420 /* The CKF_ARRAY_ATTRIBUTE flag identifies an attribute which
421    consists of an array of values. */
422 #define CKF_ARRAY_ATTRIBUTE    0x40000000
423 
424 /* The following attribute types are defined: */
425 #define CKA_CLASS              0x00000000
426 #define CKA_TOKEN              0x00000001
427 #define CKA_PRIVATE            0x00000002
428 #define CKA_LABEL              0x00000003
429 #define CKA_APPLICATION        0x00000010
430 #define CKA_VALUE              0x00000011
431 
432 /* CKA_OBJECT_ID is new for v2.10 */
433 #define CKA_OBJECT_ID          0x00000012
434 
435 #define CKA_CERTIFICATE_TYPE   0x00000080
436 #define CKA_ISSUER             0x00000081
437 #define CKA_SERIAL_NUMBER      0x00000082
438 
439 /* CKA_AC_ISSUER, CKA_OWNER, and CKA_ATTR_TYPES are new
440  * for v2.10 */
441 #define CKA_AC_ISSUER          0x00000083
442 #define CKA_OWNER              0x00000084
443 #define CKA_ATTR_TYPES         0x00000085
444 
445 /* CKA_TRUSTED is new for v2.11 */
446 #define CKA_TRUSTED            0x00000086
447 
448 /* CKA_CERTIFICATE_CATEGORY ...
449  * CKA_CHECK_VALUE are new for v2.20 */
450 #define CKA_CERTIFICATE_CATEGORY        0x00000087
451 #define CKA_JAVA_MIDP_SECURITY_DOMAIN   0x00000088
452 #define CKA_URL                         0x00000089
453 #define CKA_HASH_OF_SUBJECT_PUBLIC_KEY  0x0000008A
454 #define CKA_HASH_OF_ISSUER_PUBLIC_KEY   0x0000008B
455 #define CKA_CHECK_VALUE                 0x00000090
456 
457 #define CKA_KEY_TYPE           0x00000100
458 #define CKA_SUBJECT            0x00000101
459 #define CKA_ID                 0x00000102
460 #define CKA_SENSITIVE          0x00000103
461 #define CKA_ENCRYPT            0x00000104
462 #define CKA_DECRYPT            0x00000105
463 #define CKA_WRAP               0x00000106
464 #define CKA_UNWRAP             0x00000107
465 #define CKA_SIGN               0x00000108
466 #define CKA_SIGN_RECOVER       0x00000109
467 #define CKA_VERIFY             0x0000010A
468 #define CKA_VERIFY_RECOVER     0x0000010B
469 #define CKA_DERIVE             0x0000010C
470 #define CKA_START_DATE         0x00000110
471 #define CKA_END_DATE           0x00000111
472 #define CKA_MODULUS            0x00000120
473 #define CKA_MODULUS_BITS       0x00000121
474 #define CKA_PUBLIC_EXPONENT    0x00000122
475 #define CKA_PRIVATE_EXPONENT   0x00000123
476 #define CKA_PRIME_1            0x00000124
477 #define CKA_PRIME_2            0x00000125
478 #define CKA_EXPONENT_1         0x00000126
479 #define CKA_EXPONENT_2         0x00000127
480 #define CKA_COEFFICIENT        0x00000128
481 #define CKA_PRIME              0x00000130
482 #define CKA_SUBPRIME           0x00000131
483 #define CKA_BASE               0x00000132
484 
485 /* CKA_PRIME_BITS and CKA_SUB_PRIME_BITS are new for v2.11 */
486 #define CKA_PRIME_BITS         0x00000133
487 #define CKA_SUBPRIME_BITS      0x00000134
488 #define CKA_SUB_PRIME_BITS     CKA_SUBPRIME_BITS
489 /* (To retain backwards-compatibility) */
490 
491 #define CKA_VALUE_BITS         0x00000160
492 #define CKA_VALUE_LEN          0x00000161
493 
494 /* CKA_EXTRACTABLE, CKA_LOCAL, CKA_NEVER_EXTRACTABLE,
495  * CKA_ALWAYS_SENSITIVE, CKA_MODIFIABLE, CKA_ECDSA_PARAMS,
496  * and CKA_EC_POINT are new for v2.0 */
497 #define CKA_EXTRACTABLE        0x00000162
498 #define CKA_LOCAL              0x00000163
499 #define CKA_NEVER_EXTRACTABLE  0x00000164
500 #define CKA_ALWAYS_SENSITIVE   0x00000165
501 
502 /* CKA_KEY_GEN_MECHANISM is new for v2.11 */
503 #define CKA_KEY_GEN_MECHANISM  0x00000166
504 
505 #define CKA_MODIFIABLE         0x00000170
506 
507 /* CKA_ECDSA_PARAMS is deprecated in v2.11,
508  * CKA_EC_PARAMS is preferred. */
509 #define CKA_ECDSA_PARAMS       0x00000180
510 #define CKA_EC_PARAMS          0x00000180
511 
512 #define CKA_EC_POINT           0x00000181
513 
514 /* CKA_SECONDARY_AUTH, CKA_AUTH_PIN_FLAGS,
515  * are new for v2.10. Deprecated in v2.11 and onwards. */
516 #define CKA_SECONDARY_AUTH     0x00000200
517 #define CKA_AUTH_PIN_FLAGS     0x00000201
518 
519 /* CKA_ALWAYS_AUTHENTICATE ...
520  * CKA_UNWRAP_TEMPLATE are new for v2.20 */
521 #define CKA_ALWAYS_AUTHENTICATE  0x00000202
522 
523 #define CKA_WRAP_WITH_TRUSTED    0x00000210
524 #define CKA_WRAP_TEMPLATE        (CKF_ARRAY_ATTRIBUTE|0x00000211)
525 #define CKA_UNWRAP_TEMPLATE      (CKF_ARRAY_ATTRIBUTE|0x00000212)
526 
527 /* CKA_HW_FEATURE_TYPE, CKA_RESET_ON_INIT, and CKA_HAS_RESET
528  * are new for v2.10 */
529 #define CKA_HW_FEATURE_TYPE    0x00000300
530 #define CKA_RESET_ON_INIT      0x00000301
531 #define CKA_HAS_RESET          0x00000302
532 
533 /* The following attributes are new for v2.20 */
534 #define CKA_PIXEL_X                     0x00000400
535 #define CKA_PIXEL_Y                     0x00000401
536 #define CKA_RESOLUTION                  0x00000402
537 #define CKA_CHAR_ROWS                   0x00000403
538 #define CKA_CHAR_COLUMNS                0x00000404
539 #define CKA_COLOR                       0x00000405
540 #define CKA_BITS_PER_PIXEL              0x00000406
541 #define CKA_CHAR_SETS                   0x00000480
542 #define CKA_ENCODING_METHODS            0x00000481
543 #define CKA_MIME_TYPES                  0x00000482
544 #define CKA_MECHANISM_TYPE              0x00000500
545 #define CKA_REQUIRED_CMS_ATTRIBUTES     0x00000501
546 #define CKA_DEFAULT_CMS_ATTRIBUTES      0x00000502
547 #define CKA_SUPPORTED_CMS_ATTRIBUTES    0x00000503
548 #define CKA_ALLOWED_MECHANISMS          (CKF_ARRAY_ATTRIBUTE|0x00000600)
549 
550 #define CKA_VENDOR_DEFINED     0x80000000
551 
552 
553 /* CK_ATTRIBUTE is a structure that includes the type, length
554  * and value of an attribute */
555 typedef struct CK_ATTRIBUTE {
556   CK_ATTRIBUTE_TYPE type;
557   CK_VOID_PTR       pValue;
558 
559   /* ulValueLen went from CK_USHORT to CK_ULONG for v2.0 */
560   CK_ULONG          ulValueLen;  /* in bytes */
561 } CK_ATTRIBUTE;
562 
563 typedef CK_ATTRIBUTE CK_PTR CK_ATTRIBUTE_PTR;
564 
565 
566 /* CK_DATE is a structure that defines a date */
567 typedef struct CK_DATE{
568   CK_CHAR       year[4];   /* the year ("1900" - "9999") */
569   CK_CHAR       month[2];  /* the month ("01" - "12") */
570   CK_CHAR       day[2];    /* the day   ("01" - "31") */
571 } CK_DATE;
572 
573 
574 /* CK_MECHANISM_TYPE is a value that identifies a mechanism
575  * type */
576 /* CK_MECHANISM_TYPE was changed from CK_USHORT to CK_ULONG for
577  * v2.0 */
578 typedef CK_ULONG          CK_MECHANISM_TYPE;
579 
580 /* the following mechanism types are defined: */
581 #define CKM_RSA_PKCS_KEY_PAIR_GEN      0x00000000
582 #define CKM_RSA_PKCS                   0x00000001
583 #define CKM_RSA_9796                   0x00000002
584 #define CKM_RSA_X_509                  0x00000003
585 
586 /* CKM_MD2_RSA_PKCS, CKM_MD5_RSA_PKCS, and CKM_SHA1_RSA_PKCS
587  * are new for v2.0.  They are mechanisms which hash and sign */
588 #define CKM_MD2_RSA_PKCS               0x00000004
589 #define CKM_MD5_RSA_PKCS               0x00000005
590 #define CKM_SHA1_RSA_PKCS              0x00000006
591 
592 /* CKM_RIPEMD128_RSA_PKCS, CKM_RIPEMD160_RSA_PKCS, and
593  * CKM_RSA_PKCS_OAEP are new for v2.10 */
594 #define CKM_RIPEMD128_RSA_PKCS         0x00000007
595 #define CKM_RIPEMD160_RSA_PKCS         0x00000008
596 #define CKM_RSA_PKCS_OAEP              0x00000009
597 
598 /* CKM_RSA_X9_31_KEY_PAIR_GEN, CKM_RSA_X9_31, CKM_SHA1_RSA_X9_31,
599  * CKM_RSA_PKCS_PSS, and CKM_SHA1_RSA_PKCS_PSS are new for v2.11 */
600 #define CKM_RSA_X9_31_KEY_PAIR_GEN     0x0000000A
601 #define CKM_RSA_X9_31                  0x0000000B
602 #define CKM_SHA1_RSA_X9_31             0x0000000C
603 #define CKM_RSA_PKCS_PSS               0x0000000D
604 #define CKM_SHA1_RSA_PKCS_PSS          0x0000000E
605 
606 #define CKM_DSA_KEY_PAIR_GEN           0x00000010
607 #define CKM_DSA                        0x00000011
608 #define CKM_DSA_SHA1                   0x00000012
609 #define CKM_DH_PKCS_KEY_PAIR_GEN       0x00000020
610 #define CKM_DH_PKCS_DERIVE             0x00000021
611 
612 /* CKM_X9_42_DH_KEY_PAIR_GEN, CKM_X9_42_DH_DERIVE,
613  * CKM_X9_42_DH_HYBRID_DERIVE, and CKM_X9_42_MQV_DERIVE are new for
614  * v2.11 */
615 #define CKM_X9_42_DH_KEY_PAIR_GEN      0x00000030
616 #define CKM_X9_42_DH_DERIVE            0x00000031
617 #define CKM_X9_42_DH_HYBRID_DERIVE     0x00000032
618 #define CKM_X9_42_MQV_DERIVE           0x00000033
619 
620 /* CKM_SHA256/384/512 are new for v2.20 */
621 #define CKM_SHA256_RSA_PKCS            0x00000040
622 #define CKM_SHA384_RSA_PKCS            0x00000041
623 #define CKM_SHA512_RSA_PKCS            0x00000042
624 #define CKM_SHA256_RSA_PKCS_PSS        0x00000043
625 #define CKM_SHA384_RSA_PKCS_PSS        0x00000044
626 #define CKM_SHA512_RSA_PKCS_PSS        0x00000045
627 
628 #define CKM_RC2_KEY_GEN                0x00000100
629 #define CKM_RC2_ECB                    0x00000101
630 #define CKM_RC2_CBC                    0x00000102
631 #define CKM_RC2_MAC                    0x00000103
632 
633 /* CKM_RC2_MAC_GENERAL and CKM_RC2_CBC_PAD are new for v2.0 */
634 #define CKM_RC2_MAC_GENERAL            0x00000104
635 #define CKM_RC2_CBC_PAD                0x00000105
636 
637 #define CKM_RC4_KEY_GEN                0x00000110
638 #define CKM_RC4                        0x00000111
639 #define CKM_DES_KEY_GEN                0x00000120
640 #define CKM_DES_ECB                    0x00000121
641 #define CKM_DES_CBC                    0x00000122
642 #define CKM_DES_MAC                    0x00000123
643 
644 /* CKM_DES_MAC_GENERAL and CKM_DES_CBC_PAD are new for v2.0 */
645 #define CKM_DES_MAC_GENERAL            0x00000124
646 #define CKM_DES_CBC_PAD                0x00000125
647 
648 #define CKM_DES2_KEY_GEN               0x00000130
649 #define CKM_DES3_KEY_GEN               0x00000131
650 #define CKM_DES3_ECB                   0x00000132
651 #define CKM_DES3_CBC                   0x00000133
652 #define CKM_DES3_MAC                   0x00000134
653 
654 /* CKM_DES3_MAC_GENERAL, CKM_DES3_CBC_PAD, CKM_CDMF_KEY_GEN,
655  * CKM_CDMF_ECB, CKM_CDMF_CBC, CKM_CDMF_MAC,
656  * CKM_CDMF_MAC_GENERAL, and CKM_CDMF_CBC_PAD are new for v2.0 */
657 #define CKM_DES3_MAC_GENERAL           0x00000135
658 #define CKM_DES3_CBC_PAD               0x00000136
659 #define CKM_CDMF_KEY_GEN               0x00000140
660 #define CKM_CDMF_ECB                   0x00000141
661 #define CKM_CDMF_CBC                   0x00000142
662 #define CKM_CDMF_MAC                   0x00000143
663 #define CKM_CDMF_MAC_GENERAL           0x00000144
664 #define CKM_CDMF_CBC_PAD               0x00000145
665 
666 /* the following four DES mechanisms are new for v2.20 */
667 #define CKM_DES_OFB64                  0x00000150
668 #define CKM_DES_OFB8                   0x00000151
669 #define CKM_DES_CFB64                  0x00000152
670 #define CKM_DES_CFB8                   0x00000153
671 
672 #define CKM_MD2                        0x00000200
673 
674 /* CKM_MD2_HMAC and CKM_MD2_HMAC_GENERAL are new for v2.0 */
675 #define CKM_MD2_HMAC                   0x00000201
676 #define CKM_MD2_HMAC_GENERAL           0x00000202
677 
678 #define CKM_MD5                        0x00000210
679 
680 /* CKM_MD5_HMAC and CKM_MD5_HMAC_GENERAL are new for v2.0 */
681 #define CKM_MD5_HMAC                   0x00000211
682 #define CKM_MD5_HMAC_GENERAL           0x00000212
683 
684 #define CKM_SHA_1                      0x00000220
685 
686 /* CKM_SHA_1_HMAC and CKM_SHA_1_HMAC_GENERAL are new for v2.0 */
687 #define CKM_SHA_1_HMAC                 0x00000221
688 #define CKM_SHA_1_HMAC_GENERAL         0x00000222
689 
690 /* CKM_RIPEMD128, CKM_RIPEMD128_HMAC,
691  * CKM_RIPEMD128_HMAC_GENERAL, CKM_RIPEMD160, CKM_RIPEMD160_HMAC,
692  * and CKM_RIPEMD160_HMAC_GENERAL are new for v2.10 */
693 #define CKM_RIPEMD128                  0x00000230
694 #define CKM_RIPEMD128_HMAC             0x00000231
695 #define CKM_RIPEMD128_HMAC_GENERAL     0x00000232
696 #define CKM_RIPEMD160                  0x00000240
697 #define CKM_RIPEMD160_HMAC             0x00000241
698 #define CKM_RIPEMD160_HMAC_GENERAL     0x00000242
699 
700 /* CKM_SHA256/384/512 are new for v2.20 */
701 #define CKM_SHA256                     0x00000250
702 #define CKM_SHA256_HMAC                0x00000251
703 #define CKM_SHA256_HMAC_GENERAL        0x00000252
704 #define CKM_SHA384                     0x00000260
705 #define CKM_SHA384_HMAC                0x00000261
706 #define CKM_SHA384_HMAC_GENERAL        0x00000262
707 #define CKM_SHA512                     0x00000270
708 #define CKM_SHA512_HMAC                0x00000271
709 #define CKM_SHA512_HMAC_GENERAL        0x00000272
710 
711 /* All of the following mechanisms are new for v2.0 */
712 /* Note that CAST128 and CAST5 are the same algorithm */
713 #define CKM_CAST_KEY_GEN               0x00000300
714 #define CKM_CAST_ECB                   0x00000301
715 #define CKM_CAST_CBC                   0x00000302
716 #define CKM_CAST_MAC                   0x00000303
717 #define CKM_CAST_MAC_GENERAL           0x00000304
718 #define CKM_CAST_CBC_PAD               0x00000305
719 #define CKM_CAST3_KEY_GEN              0x00000310
720 #define CKM_CAST3_ECB                  0x00000311
721 #define CKM_CAST3_CBC                  0x00000312
722 #define CKM_CAST3_MAC                  0x00000313
723 #define CKM_CAST3_MAC_GENERAL          0x00000314
724 #define CKM_CAST3_CBC_PAD              0x00000315
725 #define CKM_CAST5_KEY_GEN              0x00000320
726 #define CKM_CAST128_KEY_GEN            0x00000320
727 #define CKM_CAST5_ECB                  0x00000321
728 #define CKM_CAST128_ECB                0x00000321
729 #define CKM_CAST5_CBC                  0x00000322
730 #define CKM_CAST128_CBC                0x00000322
731 #define CKM_CAST5_MAC                  0x00000323
732 #define CKM_CAST128_MAC                0x00000323
733 #define CKM_CAST5_MAC_GENERAL          0x00000324
734 #define CKM_CAST128_MAC_GENERAL        0x00000324
735 #define CKM_CAST5_CBC_PAD              0x00000325
736 #define CKM_CAST128_CBC_PAD            0x00000325
737 #define CKM_RC5_KEY_GEN                0x00000330
738 #define CKM_RC5_ECB                    0x00000331
739 #define CKM_RC5_CBC                    0x00000332
740 #define CKM_RC5_MAC                    0x00000333
741 #define CKM_RC5_MAC_GENERAL            0x00000334
742 #define CKM_RC5_CBC_PAD                0x00000335
743 #define CKM_IDEA_KEY_GEN               0x00000340
744 #define CKM_IDEA_ECB                   0x00000341
745 #define CKM_IDEA_CBC                   0x00000342
746 #define CKM_IDEA_MAC                   0x00000343
747 #define CKM_IDEA_MAC_GENERAL           0x00000344
748 #define CKM_IDEA_CBC_PAD               0x00000345
749 #define CKM_GENERIC_SECRET_KEY_GEN     0x00000350
750 #define CKM_CONCATENATE_BASE_AND_KEY   0x00000360
751 #define CKM_CONCATENATE_BASE_AND_DATA  0x00000362
752 #define CKM_CONCATENATE_DATA_AND_BASE  0x00000363
753 #define CKM_XOR_BASE_AND_DATA          0x00000364
754 #define CKM_EXTRACT_KEY_FROM_KEY       0x00000365
755 #define CKM_SSL3_PRE_MASTER_KEY_GEN    0x00000370
756 #define CKM_SSL3_MASTER_KEY_DERIVE     0x00000371
757 #define CKM_SSL3_KEY_AND_MAC_DERIVE    0x00000372
758 
759 /* CKM_SSL3_MASTER_KEY_DERIVE_DH, CKM_TLS_PRE_MASTER_KEY_GEN,
760  * CKM_TLS_MASTER_KEY_DERIVE, CKM_TLS_KEY_AND_MAC_DERIVE, and
761  * CKM_TLS_MASTER_KEY_DERIVE_DH are new for v2.11 */
762 #define CKM_SSL3_MASTER_KEY_DERIVE_DH  0x00000373
763 #define CKM_TLS_PRE_MASTER_KEY_GEN     0x00000374
764 #define CKM_TLS_MASTER_KEY_DERIVE      0x00000375
765 #define CKM_TLS_KEY_AND_MAC_DERIVE     0x00000376
766 #define CKM_TLS_MASTER_KEY_DERIVE_DH   0x00000377
767 
768 /* CKM_TLS_PRF is new for v2.20 */
769 #define CKM_TLS_PRF                    0x00000378
770 
771 #define CKM_SSL3_MD5_MAC               0x00000380
772 #define CKM_SSL3_SHA1_MAC              0x00000381
773 #define CKM_MD5_KEY_DERIVATION         0x00000390
774 #define CKM_MD2_KEY_DERIVATION         0x00000391
775 #define CKM_SHA1_KEY_DERIVATION        0x00000392
776 
777 /* CKM_SHA256/384/512 are new for v2.20 */
778 #define CKM_SHA256_KEY_DERIVATION      0x00000393
779 #define CKM_SHA384_KEY_DERIVATION      0x00000394
780 #define CKM_SHA512_KEY_DERIVATION      0x00000395
781 
782 #define CKM_PBE_MD2_DES_CBC            0x000003A0
783 #define CKM_PBE_MD5_DES_CBC            0x000003A1
784 #define CKM_PBE_MD5_CAST_CBC           0x000003A2
785 #define CKM_PBE_MD5_CAST3_CBC          0x000003A3
786 #define CKM_PBE_MD5_CAST5_CBC          0x000003A4
787 #define CKM_PBE_MD5_CAST128_CBC        0x000003A4
788 #define CKM_PBE_SHA1_CAST5_CBC         0x000003A5
789 #define CKM_PBE_SHA1_CAST128_CBC       0x000003A5
790 #define CKM_PBE_SHA1_RC4_128           0x000003A6
791 #define CKM_PBE_SHA1_RC4_40            0x000003A7
792 #define CKM_PBE_SHA1_DES3_EDE_CBC      0x000003A8
793 #define CKM_PBE_SHA1_DES2_EDE_CBC      0x000003A9
794 #define CKM_PBE_SHA1_RC2_128_CBC       0x000003AA
795 #define CKM_PBE_SHA1_RC2_40_CBC        0x000003AB
796 
797 /* CKM_PKCS5_PBKD2 is new for v2.10 */
798 #define CKM_PKCS5_PBKD2                0x000003B0
799 
800 #define CKM_PBA_SHA1_WITH_SHA1_HMAC    0x000003C0
801 
802 /* WTLS mechanisms are new for v2.20 */
803 #define CKM_WTLS_PRE_MASTER_KEY_GEN         0x000003D0
804 #define CKM_WTLS_MASTER_KEY_DERIVE          0x000003D1
805 #define CKM_WTLS_MASTER_KEY_DERIVE_DH_ECC   0x000003D2
806 #define CKM_WTLS_PRF                        0x000003D3
807 #define CKM_WTLS_SERVER_KEY_AND_MAC_DERIVE  0x000003D4
808 #define CKM_WTLS_CLIENT_KEY_AND_MAC_DERIVE  0x000003D5
809 
810 #define CKM_KEY_WRAP_LYNKS             0x00000400
811 #define CKM_KEY_WRAP_SET_OAEP          0x00000401
812 
813 /* CKM_CMS_SIG is new for v2.20 */
814 #define CKM_CMS_SIG                    0x00000500
815 
816 /* Fortezza mechanisms */
817 #define CKM_SKIPJACK_KEY_GEN           0x00001000
818 #define CKM_SKIPJACK_ECB64             0x00001001
819 #define CKM_SKIPJACK_CBC64             0x00001002
820 #define CKM_SKIPJACK_OFB64             0x00001003
821 #define CKM_SKIPJACK_CFB64             0x00001004
822 #define CKM_SKIPJACK_CFB32             0x00001005
823 #define CKM_SKIPJACK_CFB16             0x00001006
824 #define CKM_SKIPJACK_CFB8              0x00001007
825 #define CKM_SKIPJACK_WRAP              0x00001008
826 #define CKM_SKIPJACK_PRIVATE_WRAP      0x00001009
827 #define CKM_SKIPJACK_RELAYX            0x0000100a
828 #define CKM_KEA_KEY_PAIR_GEN           0x00001010
829 #define CKM_KEA_KEY_DERIVE             0x00001011
830 #define CKM_FORTEZZA_TIMESTAMP         0x00001020
831 #define CKM_BATON_KEY_GEN              0x00001030
832 #define CKM_BATON_ECB128               0x00001031
833 #define CKM_BATON_ECB96                0x00001032
834 #define CKM_BATON_CBC128               0x00001033
835 #define CKM_BATON_COUNTER              0x00001034
836 #define CKM_BATON_SHUFFLE              0x00001035
837 #define CKM_BATON_WRAP                 0x00001036
838 
839 /* CKM_ECDSA_KEY_PAIR_GEN is deprecated in v2.11,
840  * CKM_EC_KEY_PAIR_GEN is preferred */
841 #define CKM_ECDSA_KEY_PAIR_GEN         0x00001040
842 #define CKM_EC_KEY_PAIR_GEN            0x00001040
843 
844 #define CKM_ECDSA                      0x00001041
845 #define CKM_ECDSA_SHA1                 0x00001042
846 
847 /* CKM_ECDH1_DERIVE, CKM_ECDH1_COFACTOR_DERIVE, and CKM_ECMQV_DERIVE
848  * are new for v2.11 */
849 #define CKM_ECDH1_DERIVE               0x00001050
850 #define CKM_ECDH1_COFACTOR_DERIVE      0x00001051
851 #define CKM_ECMQV_DERIVE               0x00001052
852 
853 #define CKM_JUNIPER_KEY_GEN            0x00001060
854 #define CKM_JUNIPER_ECB128             0x00001061
855 #define CKM_JUNIPER_CBC128             0x00001062
856 #define CKM_JUNIPER_COUNTER            0x00001063
857 #define CKM_JUNIPER_SHUFFLE            0x00001064
858 #define CKM_JUNIPER_WRAP               0x00001065
859 #define CKM_FASTHASH                   0x00001070
860 
861 /* CKM_AES_KEY_GEN, CKM_AES_ECB, CKM_AES_CBC, CKM_AES_MAC,
862  * CKM_AES_MAC_GENERAL, CKM_AES_CBC_PAD, CKM_DSA_PARAMETER_GEN,
863  * CKM_DH_PKCS_PARAMETER_GEN, and CKM_X9_42_DH_PARAMETER_GEN are
864  * new for v2.11 */
865 #define CKM_AES_KEY_GEN                0x00001080
866 #define CKM_AES_ECB                    0x00001081
867 #define CKM_AES_CBC                    0x00001082
868 #define CKM_AES_MAC                    0x00001083
869 #define CKM_AES_MAC_GENERAL            0x00001084
870 #define CKM_AES_CBC_PAD                0x00001085
871 
872 /* BlowFish and TwoFish are new for v2.20 */
873 #define CKM_BLOWFISH_KEY_GEN           0x00001090
874 #define CKM_BLOWFISH_CBC               0x00001091
875 #define CKM_TWOFISH_KEY_GEN            0x00001092
876 #define CKM_TWOFISH_CBC                0x00001093
877 
878 
879 /* CKM_xxx_ENCRYPT_DATA mechanisms are new for v2.20 */
880 #define CKM_DES_ECB_ENCRYPT_DATA       0x00001100
881 #define CKM_DES_CBC_ENCRYPT_DATA       0x00001101
882 #define CKM_DES3_ECB_ENCRYPT_DATA      0x00001102
883 #define CKM_DES3_CBC_ENCRYPT_DATA      0x00001103
884 #define CKM_AES_ECB_ENCRYPT_DATA       0x00001104
885 #define CKM_AES_CBC_ENCRYPT_DATA       0x00001105
886 
887 #define CKM_DSA_PARAMETER_GEN          0x00002000
888 #define CKM_DH_PKCS_PARAMETER_GEN      0x00002001
889 #define CKM_X9_42_DH_PARAMETER_GEN     0x00002002
890 
891 #define CKM_VENDOR_DEFINED             0x80000000
892 
893 typedef CK_MECHANISM_TYPE CK_PTR CK_MECHANISM_TYPE_PTR;
894 
895 
896 /* CK_MECHANISM is a structure that specifies a particular
897  * mechanism  */
898 typedef struct CK_MECHANISM {
899   CK_MECHANISM_TYPE mechanism;
900   CK_VOID_PTR       pParameter;
901 
902   /* ulParameterLen was changed from CK_USHORT to CK_ULONG for
903    * v2.0 */
904   CK_ULONG          ulParameterLen;  /* in bytes */
905 } CK_MECHANISM;
906 
907 typedef CK_MECHANISM CK_PTR CK_MECHANISM_PTR;
908 
909 
910 /* CK_MECHANISM_INFO provides information about a particular
911  * mechanism */
912 typedef struct CK_MECHANISM_INFO {
913     CK_ULONG    ulMinKeySize;
914     CK_ULONG    ulMaxKeySize;
915     CK_FLAGS    flags;
916 } CK_MECHANISM_INFO;
917 
918 /* The flags are defined as follows:
919  *      Bit Flag               Mask        Meaning */
920 #define CKF_HW                 0x00000001  /* performed by HW */
921 
922 /* The flags CKF_ENCRYPT, CKF_DECRYPT, CKF_DIGEST, CKF_SIGN,
923  * CKG_SIGN_RECOVER, CKF_VERIFY, CKF_VERIFY_RECOVER,
924  * CKF_GENERATE, CKF_GENERATE_KEY_PAIR, CKF_WRAP, CKF_UNWRAP,
925  * and CKF_DERIVE are new for v2.0.  They specify whether or not
926  * a mechanism can be used for a particular task */
927 #define CKF_ENCRYPT            0x00000100
928 #define CKF_DECRYPT            0x00000200
929 #define CKF_DIGEST             0x00000400
930 #define CKF_SIGN               0x00000800
931 #define CKF_SIGN_RECOVER       0x00001000
932 #define CKF_VERIFY             0x00002000
933 #define CKF_VERIFY_RECOVER     0x00004000
934 #define CKF_GENERATE           0x00008000
935 #define CKF_GENERATE_KEY_PAIR  0x00010000
936 #define CKF_WRAP               0x00020000
937 #define CKF_UNWRAP             0x00040000
938 #define CKF_DERIVE             0x00080000
939 
940 /* CKF_EC_F_P, CKF_EC_F_2M, CKF_EC_ECPARAMETERS, CKF_EC_NAMEDCURVE,
941  * CKF_EC_UNCOMPRESS, and CKF_EC_COMPRESS are new for v2.11. They
942  * describe a token's EC capabilities not available in mechanism
943  * information. */
944 #define CKF_EC_F_P             0x00100000
945 #define CKF_EC_F_2M            0x00200000
946 #define CKF_EC_ECPARAMETERS    0x00400000
947 #define CKF_EC_NAMEDCURVE      0x00800000
948 #define CKF_EC_UNCOMPRESS      0x01000000
949 #define CKF_EC_COMPRESS        0x02000000
950 
951 #define CKF_EXTENSION          0x80000000 /* FALSE for this version */
952 
953 typedef CK_MECHANISM_INFO CK_PTR CK_MECHANISM_INFO_PTR;
954 
955 
956 /* CK_RV is a value that identifies the return value of a
957  * Cryptoki function */
958 /* CK_RV was changed from CK_USHORT to CK_ULONG for v2.0 */
959 typedef CK_ULONG          CK_RV;
960 
961 #define CKR_OK                                0x00000000
962 #define CKR_CANCEL                            0x00000001
963 #define CKR_HOST_MEMORY                       0x00000002
964 #define CKR_SLOT_ID_INVALID                   0x00000003
965 
966 /* CKR_FLAGS_INVALID was removed for v2.0 */
967 
968 /* CKR_GENERAL_ERROR and CKR_FUNCTION_FAILED are new for v2.0 */
969 #define CKR_GENERAL_ERROR                     0x00000005
970 #define CKR_FUNCTION_FAILED                   0x00000006
971 
972 /* CKR_ARGUMENTS_BAD, CKR_NO_EVENT, CKR_NEED_TO_CREATE_THREADS,
973  * and CKR_CANT_LOCK are new for v2.01 */
974 #define CKR_ARGUMENTS_BAD                     0x00000007
975 #define CKR_NO_EVENT                          0x00000008
976 #define CKR_NEED_TO_CREATE_THREADS            0x00000009
977 #define CKR_CANT_LOCK                         0x0000000A
978 
979 #define CKR_ATTRIBUTE_READ_ONLY               0x00000010
980 #define CKR_ATTRIBUTE_SENSITIVE               0x00000011
981 #define CKR_ATTRIBUTE_TYPE_INVALID            0x00000012
982 #define CKR_ATTRIBUTE_VALUE_INVALID           0x00000013
983 #define CKR_DATA_INVALID                      0x00000020
984 #define CKR_DATA_LEN_RANGE                    0x00000021
985 #define CKR_DEVICE_ERROR                      0x00000030
986 #define CKR_DEVICE_MEMORY                     0x00000031
987 #define CKR_DEVICE_REMOVED                    0x00000032
988 #define CKR_ENCRYPTED_DATA_INVALID            0x00000040
989 #define CKR_ENCRYPTED_DATA_LEN_RANGE          0x00000041
990 #define CKR_FUNCTION_CANCELED                 0x00000050
991 #define CKR_FUNCTION_NOT_PARALLEL             0x00000051
992 
993 /* CKR_FUNCTION_NOT_SUPPORTED is new for v2.0 */
994 #define CKR_FUNCTION_NOT_SUPPORTED            0x00000054
995 
996 #define CKR_KEY_HANDLE_INVALID                0x00000060
997 
998 /* CKR_KEY_SENSITIVE was removed for v2.0 */
999 
1000 #define CKR_KEY_SIZE_RANGE                    0x00000062
1001 #define CKR_KEY_TYPE_INCONSISTENT             0x00000063
1002 
1003 /* CKR_KEY_NOT_NEEDED, CKR_KEY_CHANGED, CKR_KEY_NEEDED,
1004  * CKR_KEY_INDIGESTIBLE, CKR_KEY_FUNCTION_NOT_PERMITTED,
1005  * CKR_KEY_NOT_WRAPPABLE, and CKR_KEY_UNEXTRACTABLE are new for
1006  * v2.0 */
1007 #define CKR_KEY_NOT_NEEDED                    0x00000064
1008 #define CKR_KEY_CHANGED                       0x00000065
1009 #define CKR_KEY_NEEDED                        0x00000066
1010 #define CKR_KEY_INDIGESTIBLE                  0x00000067
1011 #define CKR_KEY_FUNCTION_NOT_PERMITTED        0x00000068
1012 #define CKR_KEY_NOT_WRAPPABLE                 0x00000069
1013 #define CKR_KEY_UNEXTRACTABLE                 0x0000006A
1014 
1015 #define CKR_MECHANISM_INVALID                 0x00000070
1016 #define CKR_MECHANISM_PARAM_INVALID           0x00000071
1017 
1018 /* CKR_OBJECT_CLASS_INCONSISTENT and CKR_OBJECT_CLASS_INVALID
1019  * were removed for v2.0 */
1020 #define CKR_OBJECT_HANDLE_INVALID             0x00000082
1021 #define CKR_OPERATION_ACTIVE                  0x00000090
1022 #define CKR_OPERATION_NOT_INITIALIZED         0x00000091
1023 #define CKR_PIN_INCORRECT                     0x000000A0
1024 #define CKR_PIN_INVALID                       0x000000A1
1025 #define CKR_PIN_LEN_RANGE                     0x000000A2
1026 
1027 /* CKR_PIN_EXPIRED and CKR_PIN_LOCKED are new for v2.0 */
1028 #define CKR_PIN_EXPIRED                       0x000000A3
1029 #define CKR_PIN_LOCKED                        0x000000A4
1030 
1031 #define CKR_SESSION_CLOSED                    0x000000B0
1032 #define CKR_SESSION_COUNT                     0x000000B1
1033 #define CKR_SESSION_HANDLE_INVALID            0x000000B3
1034 #define CKR_SESSION_PARALLEL_NOT_SUPPORTED    0x000000B4
1035 #define CKR_SESSION_READ_ONLY                 0x000000B5
1036 #define CKR_SESSION_EXISTS                    0x000000B6
1037 
1038 /* CKR_SESSION_READ_ONLY_EXISTS and
1039  * CKR_SESSION_READ_WRITE_SO_EXISTS are new for v2.0 */
1040 #define CKR_SESSION_READ_ONLY_EXISTS          0x000000B7
1041 #define CKR_SESSION_READ_WRITE_SO_EXISTS      0x000000B8
1042 
1043 #define CKR_SIGNATURE_INVALID                 0x000000C0
1044 #define CKR_SIGNATURE_LEN_RANGE               0x000000C1
1045 #define CKR_TEMPLATE_INCOMPLETE               0x000000D0
1046 #define CKR_TEMPLATE_INCONSISTENT             0x000000D1
1047 #define CKR_TOKEN_NOT_PRESENT                 0x000000E0
1048 #define CKR_TOKEN_NOT_RECOGNIZED              0x000000E1
1049 #define CKR_TOKEN_WRITE_PROTECTED             0x000000E2
1050 #define CKR_UNWRAPPING_KEY_HANDLE_INVALID     0x000000F0
1051 #define CKR_UNWRAPPING_KEY_SIZE_RANGE         0x000000F1
1052 #define CKR_UNWRAPPING_KEY_TYPE_INCONSISTENT  0x000000F2
1053 #define CKR_USER_ALREADY_LOGGED_IN            0x00000100
1054 #define CKR_USER_NOT_LOGGED_IN                0x00000101
1055 #define CKR_USER_PIN_NOT_INITIALIZED          0x00000102
1056 #define CKR_USER_TYPE_INVALID                 0x00000103
1057 
1058 /* CKR_USER_ANOTHER_ALREADY_LOGGED_IN and CKR_USER_TOO_MANY_TYPES
1059  * are new to v2.01 */
1060 #define CKR_USER_ANOTHER_ALREADY_LOGGED_IN    0x00000104
1061 #define CKR_USER_TOO_MANY_TYPES               0x00000105
1062 
1063 #define CKR_WRAPPED_KEY_INVALID               0x00000110
1064 #define CKR_WRAPPED_KEY_LEN_RANGE             0x00000112
1065 #define CKR_WRAPPING_KEY_HANDLE_INVALID       0x00000113
1066 #define CKR_WRAPPING_KEY_SIZE_RANGE           0x00000114
1067 #define CKR_WRAPPING_KEY_TYPE_INCONSISTENT    0x00000115
1068 #define CKR_RANDOM_SEED_NOT_SUPPORTED         0x00000120
1069 
1070 /* These are new to v2.0 */
1071 #define CKR_RANDOM_NO_RNG                     0x00000121
1072 
1073 /* These are new to v2.11 */
1074 #define CKR_DOMAIN_PARAMS_INVALID             0x00000130
1075 
1076 /* These are new to v2.0 */
1077 #define CKR_BUFFER_TOO_SMALL                  0x00000150
1078 #define CKR_SAVED_STATE_INVALID               0x00000160
1079 #define CKR_INFORMATION_SENSITIVE             0x00000170
1080 #define CKR_STATE_UNSAVEABLE                  0x00000180
1081 
1082 /* These are new to v2.01 */
1083 #define CKR_CRYPTOKI_NOT_INITIALIZED          0x00000190
1084 #define CKR_CRYPTOKI_ALREADY_INITIALIZED      0x00000191
1085 #define CKR_MUTEX_BAD                         0x000001A0
1086 #define CKR_MUTEX_NOT_LOCKED                  0x000001A1
1087 
1088 /* This is new to v2.20 */
1089 #define CKR_FUNCTION_REJECTED                 0x00000200
1090 
1091 #define CKR_VENDOR_DEFINED                    0x80000000
1092 
1093 
1094 /* CK_NOTIFY is an application callback that processes events */
1095 typedef CK_CALLBACK_FUNCTION(CK_RV, CK_NOTIFY)(
1096   CK_SESSION_HANDLE hSession,     /* the session's handle */
1097   CK_NOTIFICATION   event,
1098   CK_VOID_PTR       pApplication  /* passed to C_OpenSession */
1099 );
1100 
1101 
1102 /* CK_FUNCTION_LIST is a structure holding a Cryptoki spec
1103  * version and pointers of appropriate types to all the
1104  * Cryptoki functions */
1105 /* CK_FUNCTION_LIST is new for v2.0 */
1106 typedef struct CK_FUNCTION_LIST CK_FUNCTION_LIST;
1107 
1108 typedef CK_FUNCTION_LIST CK_PTR CK_FUNCTION_LIST_PTR;
1109 
1110 typedef CK_FUNCTION_LIST_PTR CK_PTR CK_FUNCTION_LIST_PTR_PTR;
1111 
1112 
1113 /* CK_CREATEMUTEX is an application callback for creating a
1114  * mutex object */
1115 typedef CK_CALLBACK_FUNCTION(CK_RV, CK_CREATEMUTEX)(
1116   CK_VOID_PTR_PTR ppMutex  /* location to receive ptr to mutex */
1117 );
1118 
1119 
1120 /* CK_DESTROYMUTEX is an application callback for destroying a
1121  * mutex object */
1122 typedef CK_CALLBACK_FUNCTION(CK_RV, CK_DESTROYMUTEX)(
1123   CK_VOID_PTR pMutex  /* pointer to mutex */
1124 );
1125 
1126 
1127 /* CK_LOCKMUTEX is an application callback for locking a mutex */
1128 typedef CK_CALLBACK_FUNCTION(CK_RV, CK_LOCKMUTEX)(
1129   CK_VOID_PTR pMutex  /* pointer to mutex */
1130 );
1131 
1132 
1133 /* CK_UNLOCKMUTEX is an application callback for unlocking a
1134  * mutex */
1135 typedef CK_CALLBACK_FUNCTION(CK_RV, CK_UNLOCKMUTEX)(
1136   CK_VOID_PTR pMutex  /* pointer to mutex */
1137 );
1138 
1139 
1140 /* CK_C_INITIALIZE_ARGS provides the optional arguments to
1141  * C_Initialize */
1142 typedef struct CK_C_INITIALIZE_ARGS {
1143   CK_CREATEMUTEX CreateMutex;
1144   CK_DESTROYMUTEX DestroyMutex;
1145   CK_LOCKMUTEX LockMutex;
1146   CK_UNLOCKMUTEX UnlockMutex;
1147   CK_FLAGS flags;
1148   CK_VOID_PTR pReserved;
1149 } CK_C_INITIALIZE_ARGS;
1150 
1151 /* flags: bit flags that provide capabilities of the slot
1152  *      Bit Flag                           Mask       Meaning
1153  */
1154 #define CKF_LIBRARY_CANT_CREATE_OS_THREADS 0x00000001
1155 #define CKF_OS_LOCKING_OK                  0x00000002
1156 
1157 typedef CK_C_INITIALIZE_ARGS CK_PTR CK_C_INITIALIZE_ARGS_PTR;
1158 
1159 
1160 /* additional flags for parameters to functions */
1161 
1162 /* CKF_DONT_BLOCK is for the function C_WaitForSlotEvent */
1163 #define CKF_DONT_BLOCK     1
1164 
1165 /* CK_RSA_PKCS_OAEP_MGF_TYPE is new for v2.10.
1166  * CK_RSA_PKCS_OAEP_MGF_TYPE  is used to indicate the Message
1167  * Generation Function (MGF) applied to a message block when
1168  * formatting a message block for the PKCS #1 OAEP encryption
1169  * scheme. */
1170 typedef CK_ULONG CK_RSA_PKCS_MGF_TYPE;
1171 
1172 typedef CK_RSA_PKCS_MGF_TYPE CK_PTR CK_RSA_PKCS_MGF_TYPE_PTR;
1173 
1174 /* The following MGFs are defined */
1175 /* CKG_MGF1_SHA256, CKG_MGF1_SHA384, and CKG_MGF1_SHA512
1176  * are new for v2.20 */
1177 #define CKG_MGF1_SHA1         0x00000001
1178 #define CKG_MGF1_SHA256       0x00000002
1179 #define CKG_MGF1_SHA384       0x00000003
1180 #define CKG_MGF1_SHA512       0x00000004
1181 
1182 /* CK_RSA_PKCS_OAEP_SOURCE_TYPE is new for v2.10.
1183  * CK_RSA_PKCS_OAEP_SOURCE_TYPE  is used to indicate the source
1184  * of the encoding parameter when formatting a message block
1185  * for the PKCS #1 OAEP encryption scheme. */
1186 typedef CK_ULONG CK_RSA_PKCS_OAEP_SOURCE_TYPE;
1187 
1188 typedef CK_RSA_PKCS_OAEP_SOURCE_TYPE CK_PTR CK_RSA_PKCS_OAEP_SOURCE_TYPE_PTR;
1189 
1190 /* The following encoding parameter sources are defined */
1191 #define CKZ_DATA_SPECIFIED    0x00000001
1192 
1193 /* CK_RSA_PKCS_OAEP_PARAMS is new for v2.10.
1194  * CK_RSA_PKCS_OAEP_PARAMS provides the parameters to the
1195  * CKM_RSA_PKCS_OAEP mechanism. */
1196 typedef struct CK_RSA_PKCS_OAEP_PARAMS {
1197         CK_MECHANISM_TYPE hashAlg;
1198         CK_RSA_PKCS_MGF_TYPE mgf;
1199         CK_RSA_PKCS_OAEP_SOURCE_TYPE source;
1200         CK_VOID_PTR pSourceData;
1201         CK_ULONG ulSourceDataLen;
1202 } CK_RSA_PKCS_OAEP_PARAMS;
1203 
1204 typedef CK_RSA_PKCS_OAEP_PARAMS CK_PTR CK_RSA_PKCS_OAEP_PARAMS_PTR;
1205 
1206 /* CK_RSA_PKCS_PSS_PARAMS is new for v2.11.
1207  * CK_RSA_PKCS_PSS_PARAMS provides the parameters to the
1208  * CKM_RSA_PKCS_PSS mechanism(s). */
1209 typedef struct CK_RSA_PKCS_PSS_PARAMS {
1210         CK_MECHANISM_TYPE    hashAlg;
1211         CK_RSA_PKCS_MGF_TYPE mgf;
1212         CK_ULONG             sLen;
1213 } CK_RSA_PKCS_PSS_PARAMS;
1214 
1215 typedef CK_RSA_PKCS_PSS_PARAMS CK_PTR CK_RSA_PKCS_PSS_PARAMS_PTR;
1216 
1217 /* CK_EC_KDF_TYPE is new for v2.11. */
1218 typedef CK_ULONG CK_EC_KDF_TYPE;
1219 
1220 /* The following EC Key Derivation Functions are defined */
1221 #define CKD_NULL                 0x00000001
1222 #define CKD_SHA1_KDF             0x00000002
1223 
1224 /* CK_ECDH1_DERIVE_PARAMS is new for v2.11.
1225  * CK_ECDH1_DERIVE_PARAMS provides the parameters to the
1226  * CKM_ECDH1_DERIVE and CKM_ECDH1_COFACTOR_DERIVE mechanisms,
1227  * where each party contributes one key pair.
1228  */
1229 typedef struct CK_ECDH1_DERIVE_PARAMS {
1230   CK_EC_KDF_TYPE kdf;
1231   CK_ULONG ulSharedDataLen;
1232   CK_BYTE_PTR pSharedData;
1233   CK_ULONG ulPublicDataLen;
1234   CK_BYTE_PTR pPublicData;
1235 } CK_ECDH1_DERIVE_PARAMS;
1236 
1237 typedef CK_ECDH1_DERIVE_PARAMS CK_PTR CK_ECDH1_DERIVE_PARAMS_PTR;
1238 
1239 
1240 /* CK_ECDH2_DERIVE_PARAMS is new for v2.11.
1241  * CK_ECDH2_DERIVE_PARAMS provides the parameters to the
1242  * CKM_ECMQV_DERIVE mechanism, where each party contributes two key pairs. */
1243 typedef struct CK_ECDH2_DERIVE_PARAMS {
1244   CK_EC_KDF_TYPE kdf;
1245   CK_ULONG ulSharedDataLen;
1246   CK_BYTE_PTR pSharedData;
1247   CK_ULONG ulPublicDataLen;
1248   CK_BYTE_PTR pPublicData;
1249   CK_ULONG ulPrivateDataLen;
1250   CK_OBJECT_HANDLE hPrivateData;
1251   CK_ULONG ulPublicDataLen2;
1252   CK_BYTE_PTR pPublicData2;
1253 } CK_ECDH2_DERIVE_PARAMS;
1254 
1255 typedef CK_ECDH2_DERIVE_PARAMS CK_PTR CK_ECDH2_DERIVE_PARAMS_PTR;
1256 
1257 typedef struct CK_ECMQV_DERIVE_PARAMS {
1258   CK_EC_KDF_TYPE kdf;
1259   CK_ULONG ulSharedDataLen;
1260   CK_BYTE_PTR pSharedData;
1261   CK_ULONG ulPublicDataLen;
1262   CK_BYTE_PTR pPublicData;
1263   CK_ULONG ulPrivateDataLen;
1264   CK_OBJECT_HANDLE hPrivateData;
1265   CK_ULONG ulPublicDataLen2;
1266   CK_BYTE_PTR pPublicData2;
1267   CK_OBJECT_HANDLE publicKey;
1268 } CK_ECMQV_DERIVE_PARAMS;
1269 
1270 typedef CK_ECMQV_DERIVE_PARAMS CK_PTR CK_ECMQV_DERIVE_PARAMS_PTR;
1271 
1272 /* Typedefs and defines for the CKM_X9_42_DH_KEY_PAIR_GEN and the
1273  * CKM_X9_42_DH_PARAMETER_GEN mechanisms (new for PKCS #11 v2.11) */
1274 typedef CK_ULONG CK_X9_42_DH_KDF_TYPE;
1275 typedef CK_X9_42_DH_KDF_TYPE CK_PTR CK_X9_42_DH_KDF_TYPE_PTR;
1276 
1277 /* The following X9.42 DH key derivation functions are defined
1278    (besides CKD_NULL already defined : */
1279 #define CKD_SHA1_KDF_ASN1        0x00000003
1280 #define CKD_SHA1_KDF_CONCATENATE 0x00000004
1281 
1282 /* CK_X9_42_DH1_DERIVE_PARAMS is new for v2.11.
1283  * CK_X9_42_DH1_DERIVE_PARAMS provides the parameters to the
1284  * CKM_X9_42_DH_DERIVE key derivation mechanism, where each party
1285  * contributes one key pair */
1286 typedef struct CK_X9_42_DH1_DERIVE_PARAMS {
1287   CK_X9_42_DH_KDF_TYPE kdf;
1288   CK_ULONG ulOtherInfoLen;
1289   CK_BYTE_PTR pOtherInfo;
1290   CK_ULONG ulPublicDataLen;
1291   CK_BYTE_PTR pPublicData;
1292 } CK_X9_42_DH1_DERIVE_PARAMS;
1293 
1294 typedef struct CK_X9_42_DH1_DERIVE_PARAMS CK_PTR CK_X9_42_DH1_DERIVE_PARAMS_PTR;
1295 
1296 /* CK_X9_42_DH2_DERIVE_PARAMS is new for v2.11.
1297  * CK_X9_42_DH2_DERIVE_PARAMS provides the parameters to the
1298  * CKM_X9_42_DH_HYBRID_DERIVE and CKM_X9_42_MQV_DERIVE key derivation
1299  * mechanisms, where each party contributes two key pairs */
1300 typedef struct CK_X9_42_DH2_DERIVE_PARAMS {
1301   CK_X9_42_DH_KDF_TYPE kdf;
1302   CK_ULONG ulOtherInfoLen;
1303   CK_BYTE_PTR pOtherInfo;
1304   CK_ULONG ulPublicDataLen;
1305   CK_BYTE_PTR pPublicData;
1306   CK_ULONG ulPrivateDataLen;
1307   CK_OBJECT_HANDLE hPrivateData;
1308   CK_ULONG ulPublicDataLen2;
1309   CK_BYTE_PTR pPublicData2;
1310 } CK_X9_42_DH2_DERIVE_PARAMS;
1311 
1312 typedef CK_X9_42_DH2_DERIVE_PARAMS CK_PTR CK_X9_42_DH2_DERIVE_PARAMS_PTR;
1313 
1314 typedef struct CK_X9_42_MQV_DERIVE_PARAMS {
1315   CK_X9_42_DH_KDF_TYPE kdf;
1316   CK_ULONG ulOtherInfoLen;
1317   CK_BYTE_PTR pOtherInfo;
1318   CK_ULONG ulPublicDataLen;
1319   CK_BYTE_PTR pPublicData;
1320   CK_ULONG ulPrivateDataLen;
1321   CK_OBJECT_HANDLE hPrivateData;
1322   CK_ULONG ulPublicDataLen2;
1323   CK_BYTE_PTR pPublicData2;
1324   CK_OBJECT_HANDLE publicKey;
1325 } CK_X9_42_MQV_DERIVE_PARAMS;
1326 
1327 typedef CK_X9_42_MQV_DERIVE_PARAMS CK_PTR CK_X9_42_MQV_DERIVE_PARAMS_PTR;
1328 
1329 /* CK_KEA_DERIVE_PARAMS provides the parameters to the
1330  * CKM_KEA_DERIVE mechanism */
1331 /* CK_KEA_DERIVE_PARAMS is new for v2.0 */
1332 typedef struct CK_KEA_DERIVE_PARAMS {
1333   CK_BBOOL      isSender;
1334   CK_ULONG      ulRandomLen;
1335   CK_BYTE_PTR   pRandomA;
1336   CK_BYTE_PTR   pRandomB;
1337   CK_ULONG      ulPublicDataLen;
1338   CK_BYTE_PTR   pPublicData;
1339 } CK_KEA_DERIVE_PARAMS;
1340 
1341 typedef CK_KEA_DERIVE_PARAMS CK_PTR CK_KEA_DERIVE_PARAMS_PTR;
1342 
1343 
1344 /* CK_RC2_PARAMS provides the parameters to the CKM_RC2_ECB and
1345  * CKM_RC2_MAC mechanisms.  An instance of CK_RC2_PARAMS just
1346  * holds the effective keysize */
1347 typedef CK_ULONG          CK_RC2_PARAMS;
1348 
1349 typedef CK_RC2_PARAMS CK_PTR CK_RC2_PARAMS_PTR;
1350 
1351 
1352 /* CK_RC2_CBC_PARAMS provides the parameters to the CKM_RC2_CBC
1353  * mechanism */
1354 typedef struct CK_RC2_CBC_PARAMS {
1355   /* ulEffectiveBits was changed from CK_USHORT to CK_ULONG for
1356    * v2.0 */
1357   CK_ULONG      ulEffectiveBits;  /* effective bits (1-1024) */
1358 
1359   CK_BYTE       iv[8];            /* IV for CBC mode */
1360 } CK_RC2_CBC_PARAMS;
1361 
1362 typedef CK_RC2_CBC_PARAMS CK_PTR CK_RC2_CBC_PARAMS_PTR;
1363 
1364 
1365 /* CK_RC2_MAC_GENERAL_PARAMS provides the parameters for the
1366  * CKM_RC2_MAC_GENERAL mechanism */
1367 /* CK_RC2_MAC_GENERAL_PARAMS is new for v2.0 */
1368 typedef struct CK_RC2_MAC_GENERAL_PARAMS {
1369   CK_ULONG      ulEffectiveBits;  /* effective bits (1-1024) */
1370   CK_ULONG      ulMacLength;      /* Length of MAC in bytes */
1371 } CK_RC2_MAC_GENERAL_PARAMS;
1372 
1373 typedef CK_RC2_MAC_GENERAL_PARAMS CK_PTR \
1374   CK_RC2_MAC_GENERAL_PARAMS_PTR;
1375 
1376 
1377 /* CK_RC5_PARAMS provides the parameters to the CKM_RC5_ECB and
1378  * CKM_RC5_MAC mechanisms */
1379 /* CK_RC5_PARAMS is new for v2.0 */
1380 typedef struct CK_RC5_PARAMS {
1381   CK_ULONG      ulWordsize;  /* wordsize in bits */
1382   CK_ULONG      ulRounds;    /* number of rounds */
1383 } CK_RC5_PARAMS;
1384 
1385 typedef CK_RC5_PARAMS CK_PTR CK_RC5_PARAMS_PTR;
1386 
1387 
1388 /* CK_RC5_CBC_PARAMS provides the parameters to the CKM_RC5_CBC
1389  * mechanism */
1390 /* CK_RC5_CBC_PARAMS is new for v2.0 */
1391 typedef struct CK_RC5_CBC_PARAMS {
1392   CK_ULONG      ulWordsize;  /* wordsize in bits */
1393   CK_ULONG      ulRounds;    /* number of rounds */
1394   CK_BYTE_PTR   pIv;         /* pointer to IV */
1395   CK_ULONG      ulIvLen;     /* length of IV in bytes */
1396 } CK_RC5_CBC_PARAMS;
1397 
1398 typedef CK_RC5_CBC_PARAMS CK_PTR CK_RC5_CBC_PARAMS_PTR;
1399 
1400 
1401 /* CK_RC5_MAC_GENERAL_PARAMS provides the parameters for the
1402  * CKM_RC5_MAC_GENERAL mechanism */
1403 /* CK_RC5_MAC_GENERAL_PARAMS is new for v2.0 */
1404 typedef struct CK_RC5_MAC_GENERAL_PARAMS {
1405   CK_ULONG      ulWordsize;   /* wordsize in bits */
1406   CK_ULONG      ulRounds;     /* number of rounds */
1407   CK_ULONG      ulMacLength;  /* Length of MAC in bytes */
1408 } CK_RC5_MAC_GENERAL_PARAMS;
1409 
1410 typedef CK_RC5_MAC_GENERAL_PARAMS CK_PTR \
1411   CK_RC5_MAC_GENERAL_PARAMS_PTR;
1412 
1413 
1414 /* CK_MAC_GENERAL_PARAMS provides the parameters to most block
1415  * ciphers' MAC_GENERAL mechanisms.  Its value is the length of
1416  * the MAC */
1417 /* CK_MAC_GENERAL_PARAMS is new for v2.0 */
1418 typedef CK_ULONG          CK_MAC_GENERAL_PARAMS;
1419 
1420 typedef CK_MAC_GENERAL_PARAMS CK_PTR CK_MAC_GENERAL_PARAMS_PTR;
1421 
1422 /* CK_DES/AES_ECB/CBC_ENCRYPT_DATA_PARAMS are new for v2.20 */
1423 typedef struct CK_DES_CBC_ENCRYPT_DATA_PARAMS {
1424   CK_BYTE      iv[8];
1425   CK_BYTE_PTR  pData;
1426   CK_ULONG     length;
1427 } CK_DES_CBC_ENCRYPT_DATA_PARAMS;
1428 
1429 typedef CK_DES_CBC_ENCRYPT_DATA_PARAMS CK_PTR CK_DES_CBC_ENCRYPT_DATA_PARAMS_PTR;
1430 
1431 typedef struct CK_AES_CBC_ENCRYPT_DATA_PARAMS {
1432   CK_BYTE      iv[16];
1433   CK_BYTE_PTR  pData;
1434   CK_ULONG     length;
1435 } CK_AES_CBC_ENCRYPT_DATA_PARAMS;
1436 
1437 typedef CK_AES_CBC_ENCRYPT_DATA_PARAMS CK_PTR CK_AES_CBC_ENCRYPT_DATA_PARAMS_PTR;
1438 
1439 /* CK_SKIPJACK_PRIVATE_WRAP_PARAMS provides the parameters to the
1440  * CKM_SKIPJACK_PRIVATE_WRAP mechanism */
1441 /* CK_SKIPJACK_PRIVATE_WRAP_PARAMS is new for v2.0 */
1442 typedef struct CK_SKIPJACK_PRIVATE_WRAP_PARAMS {
1443   CK_ULONG      ulPasswordLen;
1444   CK_BYTE_PTR   pPassword;
1445   CK_ULONG      ulPublicDataLen;
1446   CK_BYTE_PTR   pPublicData;
1447   CK_ULONG      ulPAndGLen;
1448   CK_ULONG      ulQLen;
1449   CK_ULONG      ulRandomLen;
1450   CK_BYTE_PTR   pRandomA;
1451   CK_BYTE_PTR   pPrimeP;
1452   CK_BYTE_PTR   pBaseG;
1453   CK_BYTE_PTR   pSubprimeQ;
1454 } CK_SKIPJACK_PRIVATE_WRAP_PARAMS;
1455 
1456 typedef CK_SKIPJACK_PRIVATE_WRAP_PARAMS CK_PTR \
1457   CK_SKIPJACK_PRIVATE_WRAP_PTR;
1458 
1459 
1460 /* CK_SKIPJACK_RELAYX_PARAMS provides the parameters to the
1461  * CKM_SKIPJACK_RELAYX mechanism */
1462 /* CK_SKIPJACK_RELAYX_PARAMS is new for v2.0 */
1463 typedef struct CK_SKIPJACK_RELAYX_PARAMS {
1464   CK_ULONG      ulOldWrappedXLen;
1465   CK_BYTE_PTR   pOldWrappedX;
1466   CK_ULONG      ulOldPasswordLen;
1467   CK_BYTE_PTR   pOldPassword;
1468   CK_ULONG      ulOldPublicDataLen;
1469   CK_BYTE_PTR   pOldPublicData;
1470   CK_ULONG      ulOldRandomLen;
1471   CK_BYTE_PTR   pOldRandomA;
1472   CK_ULONG      ulNewPasswordLen;
1473   CK_BYTE_PTR   pNewPassword;
1474   CK_ULONG      ulNewPublicDataLen;
1475   CK_BYTE_PTR   pNewPublicData;
1476   CK_ULONG      ulNewRandomLen;
1477   CK_BYTE_PTR   pNewRandomA;
1478 } CK_SKIPJACK_RELAYX_PARAMS;
1479 
1480 typedef CK_SKIPJACK_RELAYX_PARAMS CK_PTR \
1481   CK_SKIPJACK_RELAYX_PARAMS_PTR;
1482 
1483 
1484 typedef struct CK_PBE_PARAMS {
1485   CK_BYTE_PTR      pInitVector;
1486   CK_UTF8CHAR_PTR  pPassword;
1487   CK_ULONG         ulPasswordLen;
1488   CK_BYTE_PTR      pSalt;
1489   CK_ULONG         ulSaltLen;
1490   CK_ULONG         ulIteration;
1491 } CK_PBE_PARAMS;
1492 
1493 typedef CK_PBE_PARAMS CK_PTR CK_PBE_PARAMS_PTR;
1494 
1495 
1496 /* CK_KEY_WRAP_SET_OAEP_PARAMS provides the parameters to the
1497  * CKM_KEY_WRAP_SET_OAEP mechanism */
1498 /* CK_KEY_WRAP_SET_OAEP_PARAMS is new for v2.0 */
1499 typedef struct CK_KEY_WRAP_SET_OAEP_PARAMS {
1500   CK_BYTE       bBC;     /* block contents byte */
1501   CK_BYTE_PTR   pX;      /* extra data */
1502   CK_ULONG      ulXLen;  /* length of extra data in bytes */
1503 } CK_KEY_WRAP_SET_OAEP_PARAMS;
1504 
1505 typedef CK_KEY_WRAP_SET_OAEP_PARAMS CK_PTR \
1506   CK_KEY_WRAP_SET_OAEP_PARAMS_PTR;
1507 
1508 
1509 typedef struct CK_SSL3_RANDOM_DATA {
1510   CK_BYTE_PTR  pClientRandom;
1511   CK_ULONG     ulClientRandomLen;
1512   CK_BYTE_PTR  pServerRandom;
1513   CK_ULONG     ulServerRandomLen;
1514 } CK_SSL3_RANDOM_DATA;
1515 
1516 
1517 typedef struct CK_SSL3_MASTER_KEY_DERIVE_PARAMS {
1518   CK_SSL3_RANDOM_DATA RandomInfo;
1519   CK_VERSION_PTR pVersion;
1520 } CK_SSL3_MASTER_KEY_DERIVE_PARAMS;
1521 
1522 typedef struct CK_SSL3_MASTER_KEY_DERIVE_PARAMS CK_PTR \
1523   CK_SSL3_MASTER_KEY_DERIVE_PARAMS_PTR;
1524 
1525 
1526 typedef struct CK_SSL3_KEY_MAT_OUT {
1527   CK_OBJECT_HANDLE hClientMacSecret;
1528   CK_OBJECT_HANDLE hServerMacSecret;
1529   CK_OBJECT_HANDLE hClientKey;
1530   CK_OBJECT_HANDLE hServerKey;
1531   CK_BYTE_PTR      pIVClient;
1532   CK_BYTE_PTR      pIVServer;
1533 } CK_SSL3_KEY_MAT_OUT;
1534 
1535 typedef CK_SSL3_KEY_MAT_OUT CK_PTR CK_SSL3_KEY_MAT_OUT_PTR;
1536 
1537 
1538 typedef struct CK_SSL3_KEY_MAT_PARAMS {
1539   CK_ULONG                ulMacSizeInBits;
1540   CK_ULONG                ulKeySizeInBits;
1541   CK_ULONG                ulIVSizeInBits;
1542   CK_BBOOL                bIsExport;
1543   CK_SSL3_RANDOM_DATA     RandomInfo;
1544   CK_SSL3_KEY_MAT_OUT_PTR pReturnedKeyMaterial;
1545 } CK_SSL3_KEY_MAT_PARAMS;
1546 
1547 typedef CK_SSL3_KEY_MAT_PARAMS CK_PTR CK_SSL3_KEY_MAT_PARAMS_PTR;
1548 
1549 /* CK_TLS_PRF_PARAMS is new for version 2.20 */
1550 typedef struct CK_TLS_PRF_PARAMS {
1551   CK_BYTE_PTR  pSeed;
1552   CK_ULONG     ulSeedLen;
1553   CK_BYTE_PTR  pLabel;
1554   CK_ULONG     ulLabelLen;
1555   CK_BYTE_PTR  pOutput;
1556   CK_ULONG_PTR pulOutputLen;
1557 } CK_TLS_PRF_PARAMS;
1558 
1559 typedef CK_TLS_PRF_PARAMS CK_PTR CK_TLS_PRF_PARAMS_PTR;
1560 
1561 /* WTLS is new for version 2.20 */
1562 typedef struct CK_WTLS_RANDOM_DATA {
1563   CK_BYTE_PTR pClientRandom;
1564   CK_ULONG    ulClientRandomLen;
1565   CK_BYTE_PTR pServerRandom;
1566   CK_ULONG    ulServerRandomLen;
1567 } CK_WTLS_RANDOM_DATA;
1568 
1569 typedef CK_WTLS_RANDOM_DATA CK_PTR CK_WTLS_RANDOM_DATA_PTR;
1570 
1571 typedef struct CK_WTLS_MASTER_KEY_DERIVE_PARAMS {
1572   CK_MECHANISM_TYPE   DigestMechanism;
1573   CK_WTLS_RANDOM_DATA RandomInfo;
1574   CK_BYTE_PTR         pVersion;
1575 } CK_WTLS_MASTER_KEY_DERIVE_PARAMS;
1576 
1577 typedef CK_WTLS_MASTER_KEY_DERIVE_PARAMS CK_PTR \
1578   CK_WTLS_MASTER_KEY_DERIVE_PARAMS_PTR;
1579 
1580 typedef struct CK_WTLS_PRF_PARAMS {
1581   CK_MECHANISM_TYPE DigestMechanism;
1582   CK_BYTE_PTR       pSeed;
1583   CK_ULONG          ulSeedLen;
1584   CK_BYTE_PTR       pLabel;
1585   CK_ULONG          ulLabelLen;
1586   CK_BYTE_PTR       pOutput;
1587   CK_ULONG_PTR      pulOutputLen;
1588 } CK_WTLS_PRF_PARAMS;
1589 
1590 typedef CK_WTLS_PRF_PARAMS CK_PTR CK_WTLS_PRF_PARAMS_PTR;
1591 
1592 typedef struct CK_WTLS_KEY_MAT_OUT {
1593   CK_OBJECT_HANDLE hMacSecret;
1594   CK_OBJECT_HANDLE hKey;
1595   CK_BYTE_PTR      pIV;
1596 } CK_WTLS_KEY_MAT_OUT;
1597 
1598 typedef CK_WTLS_KEY_MAT_OUT CK_PTR CK_WTLS_KEY_MAT_OUT_PTR;
1599 
1600 typedef struct CK_WTLS_KEY_MAT_PARAMS {
1601   CK_MECHANISM_TYPE       DigestMechanism;
1602   CK_ULONG                ulMacSizeInBits;
1603   CK_ULONG                ulKeySizeInBits;
1604   CK_ULONG                ulIVSizeInBits;
1605   CK_ULONG                ulSequenceNumber;
1606   CK_BBOOL                bIsExport;
1607   CK_WTLS_RANDOM_DATA     RandomInfo;
1608   CK_WTLS_KEY_MAT_OUT_PTR pReturnedKeyMaterial;
1609 } CK_WTLS_KEY_MAT_PARAMS;
1610 
1611 typedef CK_WTLS_KEY_MAT_PARAMS CK_PTR CK_WTLS_KEY_MAT_PARAMS_PTR;
1612 
1613 /* CMS is new for version 2.20 */
1614 typedef struct CK_CMS_SIG_PARAMS {
1615   CK_OBJECT_HANDLE      certificateHandle;
1616   CK_MECHANISM_PTR      pSigningMechanism;
1617   CK_MECHANISM_PTR      pDigestMechanism;
1618   CK_UTF8CHAR_PTR       pContentType;
1619   CK_BYTE_PTR           pRequestedAttributes;
1620   CK_ULONG              ulRequestedAttributesLen;
1621   CK_BYTE_PTR           pRequiredAttributes;
1622   CK_ULONG              ulRequiredAttributesLen;
1623 } CK_CMS_SIG_PARAMS;
1624 
1625 typedef CK_CMS_SIG_PARAMS CK_PTR CK_CMS_SIG_PARAMS_PTR;
1626 
1627 typedef struct CK_KEY_DERIVATION_STRING_DATA {
1628   CK_BYTE_PTR pData;
1629   CK_ULONG    ulLen;
1630 } CK_KEY_DERIVATION_STRING_DATA;
1631 
1632 typedef CK_KEY_DERIVATION_STRING_DATA CK_PTR \
1633   CK_KEY_DERIVATION_STRING_DATA_PTR;
1634 
1635 
1636 /* The CK_EXTRACT_PARAMS is used for the
1637  * CKM_EXTRACT_KEY_FROM_KEY mechanism.  It specifies which bit
1638  * of the base key should be used as the first bit of the
1639  * derived key */
1640 /* CK_EXTRACT_PARAMS is new for v2.0 */
1641 typedef CK_ULONG CK_EXTRACT_PARAMS;
1642 
1643 typedef CK_EXTRACT_PARAMS CK_PTR CK_EXTRACT_PARAMS_PTR;
1644 
1645 /* CK_PKCS5_PBKD2_PSEUDO_RANDOM_FUNCTION_TYPE is new for v2.10.
1646  * CK_PKCS5_PBKD2_PSEUDO_RANDOM_FUNCTION_TYPE is used to
1647  * indicate the Pseudo-Random Function (PRF) used to generate
1648  * key bits using PKCS #5 PBKDF2. */
1649 typedef CK_ULONG CK_PKCS5_PBKD2_PSEUDO_RANDOM_FUNCTION_TYPE;
1650 
1651 typedef CK_PKCS5_PBKD2_PSEUDO_RANDOM_FUNCTION_TYPE CK_PTR CK_PKCS5_PBKD2_PSEUDO_RANDOM_FUNCTION_TYPE_PTR;
1652 
1653 /* The following PRFs are defined in PKCS #5 v2.0. */
1654 #define CKP_PKCS5_PBKD2_HMAC_SHA1 0x00000001
1655 
1656 
1657 /* CK_PKCS5_PBKDF2_SALT_SOURCE_TYPE is new for v2.10.
1658  * CK_PKCS5_PBKDF2_SALT_SOURCE_TYPE is used to indicate the
1659  * source of the salt value when deriving a key using PKCS #5
1660  * PBKDF2. */
1661 typedef CK_ULONG CK_PKCS5_PBKDF2_SALT_SOURCE_TYPE;
1662 
1663 typedef CK_PKCS5_PBKDF2_SALT_SOURCE_TYPE CK_PTR CK_PKCS5_PBKDF2_SALT_SOURCE_TYPE_PTR;
1664 
1665 /* The following salt value sources are defined in PKCS #5 v2.0. */
1666 #define CKZ_SALT_SPECIFIED        0x00000001
1667 
1668 /* CK_PKCS5_PBKD2_PARAMS is new for v2.10.
1669  * CK_PKCS5_PBKD2_PARAMS is a structure that provides the
1670  * parameters to the CKM_PKCS5_PBKD2 mechanism. */
1671 typedef struct CK_PKCS5_PBKD2_PARAMS {
1672         CK_PKCS5_PBKDF2_SALT_SOURCE_TYPE           saltSource;
1673         CK_VOID_PTR                                pSaltSourceData;
1674         CK_ULONG                                   ulSaltSourceDataLen;
1675         CK_ULONG                                   iterations;
1676         CK_PKCS5_PBKD2_PSEUDO_RANDOM_FUNCTION_TYPE prf;
1677         CK_VOID_PTR                                pPrfData;
1678         CK_ULONG                                   ulPrfDataLen;
1679         CK_UTF8CHAR_PTR                            pPassword;
1680         CK_ULONG_PTR                               ulPasswordLen;
1681 } CK_PKCS5_PBKD2_PARAMS;
1682 
1683 typedef CK_PKCS5_PBKD2_PARAMS CK_PTR CK_PKCS5_PBKD2_PARAMS_PTR;
1684 
1685 #endif
1686