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