OpenDNSSEC-libhsm
1.3.8
|
00001 /* pkcs11.h 00002 Copyright 2006, 2007 g10 Code GmbH 00003 Copyright 2006 Andreas Jellinghaus 00004 00005 This file is free software; as a special exception the author gives 00006 unlimited permission to copy and/or distribute it, with or without 00007 modifications, as long as this notice is preserved. 00008 00009 This file is distributed in the hope that it will be useful, but 00010 WITHOUT ANY WARRANTY, to the extent permitted by law; without even 00011 the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR 00012 PURPOSE. */ 00013 00014 /* Please submit changes back to the Scute project at 00015 http://www.scute.org/ (or send them to marcus@g10code.com), so that 00016 they can be picked up by other projects from there as well. */ 00017 00018 /* This file is a modified implementation of the PKCS #11 standard by 00019 RSA Security Inc. It is mostly a drop-in replacement, with the 00020 following change: 00021 00022 This header file does not require any macro definitions by the user 00023 (like CK_DEFINE_FUNCTION etc). In fact, it defines those macros 00024 for you (if useful, some are missing, let me know if you need 00025 more). 00026 00027 There is an additional API available that does comply better to the 00028 GNU coding standard. It can be switched on by defining 00029 CRYPTOKI_GNU before including this header file. For this, the 00030 following changes are made to the specification: 00031 00032 All structure types are changed to a "struct ck_foo" where CK_FOO 00033 is the type name in PKCS #11. 00034 00035 All non-structure types are changed to ck_foo_t where CK_FOO is the 00036 lowercase version of the type name in PKCS #11. The basic types 00037 (CK_ULONG et al.) are removed without substitute. 00038 00039 All members of structures are modified in the following way: Type 00040 indication prefixes are removed, and underscore characters are 00041 inserted before words. Then the result is lowercased. 00042 00043 Note that function names are still in the original case, as they 00044 need for ABI compatibility. 00045 00046 CK_FALSE, CK_TRUE and NULL_PTR are removed without substitute. Use 00047 <stdbool.h>. 00048 00049 If CRYPTOKI_COMPAT is defined before including this header file, 00050 then none of the API changes above take place, and the API is the 00051 one defined by the PKCS #11 standard. */ 00052 00053 #ifndef PKCS11_H 00054 #define PKCS11_H 1 00055 00056 #if defined(__cplusplus) 00057 extern "C" { 00058 #endif 00059 00060 00061 /* The version of cryptoki we implement. The revision is changed with 00062 each modification of this file. If you do not use the "official" 00063 version of this file, please consider deleting the revision macro 00064 (you may use a macro with a different name to keep track of your 00065 versions). */ 00066 #define CRYPTOKI_VERSION_MAJOR 2 00067 #define CRYPTOKI_VERSION_MINOR 20 00068 #define CRYPTOKI_VERSION_REVISION 6 00069 00070 00071 /* Compatibility interface is default, unless CRYPTOKI_GNU is 00072 given. */ 00073 #ifndef CRYPTOKI_GNU 00074 #ifndef CRYPTOKI_COMPAT 00075 #define CRYPTOKI_COMPAT 1 00076 #endif 00077 #endif 00078 00079 /* System dependencies. */ 00080 00081 #if defined(_WIN32) || defined(CRYPTOKI_FORCE_WIN32) 00082 00083 /* There is a matching pop below. */ 00084 #pragma pack(push, cryptoki, 1) 00085 00086 #ifdef CRYPTOKI_EXPORTS 00087 #define CK_SPEC __declspec(dllexport) 00088 #else 00089 #define CK_SPEC __declspec(dllimport) 00090 #endif 00091 00092 #else 00093 00094 #define CK_SPEC 00095 00096 #endif 00097 00098 00099 #ifdef CRYPTOKI_COMPAT 00100 /* If we are in compatibility mode, switch all exposed names to the 00101 PKCS #11 variant. There are corresponding #undefs below. */ 00102 00103 #define ck_flags_t CK_FLAGS 00104 #define ck_version _CK_VERSION 00105 00106 #define ck_info _CK_INFO 00107 #define cryptoki_version cryptokiVersion 00108 #define manufacturer_id manufacturerID 00109 #define library_description libraryDescription 00110 #define library_version libraryVersion 00111 00112 #define ck_notification_t CK_NOTIFICATION 00113 #define ck_slot_id_t CK_SLOT_ID 00114 00115 #define ck_slot_info _CK_SLOT_INFO 00116 #define slot_description slotDescription 00117 #define hardware_version hardwareVersion 00118 #define firmware_version firmwareVersion 00119 00120 #define ck_token_info _CK_TOKEN_INFO 00121 #define serial_number serialNumber 00122 #define max_session_count ulMaxSessionCount 00123 #define session_count ulSessionCount 00124 #define max_rw_session_count ulMaxRwSessionCount 00125 #define rw_session_count ulRwSessionCount 00126 #define max_pin_len ulMaxPinLen 00127 #define min_pin_len ulMinPinLen 00128 #define total_public_memory ulTotalPublicMemory 00129 #define free_public_memory ulFreePublicMemory 00130 #define total_private_memory ulTotalPrivateMemory 00131 #define free_private_memory ulFreePrivateMemory 00132 #define utc_time utcTime 00133 00134 #define ck_session_handle_t CK_SESSION_HANDLE 00135 #define ck_user_type_t CK_USER_TYPE 00136 #define ck_state_t CK_STATE 00137 00138 #define ck_session_info _CK_SESSION_INFO 00139 #define slot_id slotID 00140 #define device_error ulDeviceError 00141 00142 #define ck_object_handle_t CK_OBJECT_HANDLE 00143 #define ck_object_class_t CK_OBJECT_CLASS 00144 #define ck_hw_feature_type_t CK_HW_FEATURE_TYPE 00145 #define ck_key_type_t CK_KEY_TYPE 00146 #define ck_certificate_type_t CK_CERTIFICATE_TYPE 00147 #define ck_attribute_type_t CK_ATTRIBUTE_TYPE 00148 00149 #define ck_attribute _CK_ATTRIBUTE 00150 #define value pValue 00151 #define value_len ulValueLen 00152 00153 #define ck_date _CK_DATE 00154 00155 #define ck_mechanism_type_t CK_MECHANISM_TYPE 00156 00157 #define ck_mechanism _CK_MECHANISM 00158 #define parameter pParameter 00159 #define parameter_len ulParameterLen 00160 00161 #define ck_mechanism_info _CK_MECHANISM_INFO 00162 #define min_key_size ulMinKeySize 00163 #define max_key_size ulMaxKeySize 00164 00165 #define ck_rv_t CK_RV 00166 #define ck_notify_t CK_NOTIFY 00167 00168 #define ck_function_list _CK_FUNCTION_LIST 00169 00170 #define ck_createmutex_t CK_CREATEMUTEX 00171 #define ck_destroymutex_t CK_DESTROYMUTEX 00172 #define ck_lockmutex_t CK_LOCKMUTEX 00173 #define ck_unlockmutex_t CK_UNLOCKMUTEX 00174 00175 #define ck_c_initialize_args _CK_C_INITIALIZE_ARGS 00176 #define create_mutex CreateMutex 00177 #define destroy_mutex DestroyMutex 00178 #define lock_mutex LockMutex 00179 #define unlock_mutex UnlockMutex 00180 #define reserved pReserved 00181 00182 #endif /* CRYPTOKI_COMPAT */ 00183 00184 00185 00186 typedef unsigned long ck_flags_t; 00187 00188 struct ck_version 00189 { 00190 unsigned char major; 00191 unsigned char minor; 00192 }; 00193 00194 00195 struct ck_info 00196 { 00197 struct ck_version cryptoki_version; 00198 unsigned char manufacturer_id[32]; 00199 ck_flags_t flags; 00200 unsigned char library_description[32]; 00201 struct ck_version library_version; 00202 }; 00203 00204 00205 typedef unsigned long ck_notification_t; 00206 00207 #define CKN_SURRENDER (0) 00208 00209 00210 typedef unsigned long ck_slot_id_t; 00211 00212 00213 struct ck_slot_info 00214 { 00215 unsigned char slot_description[64]; 00216 unsigned char manufacturer_id[32]; 00217 ck_flags_t flags; 00218 struct ck_version hardware_version; 00219 struct ck_version firmware_version; 00220 }; 00221 00222 00223 #define CKF_TOKEN_PRESENT (1 << 0) 00224 #define CKF_REMOVABLE_DEVICE (1 << 1) 00225 #define CKF_HW_SLOT (1 << 2) 00226 #define CKF_ARRAY_ATTRIBUTE (1 << 30) 00227 00228 00229 struct ck_token_info 00230 { 00231 unsigned char label[32]; 00232 unsigned char manufacturer_id[32]; 00233 unsigned char model[16]; 00234 unsigned char serial_number[16]; 00235 ck_flags_t flags; 00236 unsigned long max_session_count; 00237 unsigned long session_count; 00238 unsigned long max_rw_session_count; 00239 unsigned long rw_session_count; 00240 unsigned long max_pin_len; 00241 unsigned long min_pin_len; 00242 unsigned long total_public_memory; 00243 unsigned long free_public_memory; 00244 unsigned long total_private_memory; 00245 unsigned long free_private_memory; 00246 struct ck_version hardware_version; 00247 struct ck_version firmware_version; 00248 unsigned char utc_time[16]; 00249 }; 00250 00251 00252 #define CKF_RNG (1 << 0) 00253 #define CKF_WRITE_PROTECTED (1 << 1) 00254 #define CKF_LOGIN_REQUIRED (1 << 2) 00255 #define CKF_USER_PIN_INITIALIZED (1 << 3) 00256 #define CKF_RESTORE_KEY_NOT_NEEDED (1 << 5) 00257 #define CKF_CLOCK_ON_TOKEN (1 << 6) 00258 #define CKF_PROTECTED_AUTHENTICATION_PATH (1 << 8) 00259 #define CKF_DUAL_CRYPTO_OPERATIONS (1 << 9) 00260 #define CKF_TOKEN_INITIALIZED (1 << 10) 00261 #define CKF_SECONDARY_AUTHENTICATION (1 << 11) 00262 #define CKF_USER_PIN_COUNT_LOW (1 << 16) 00263 #define CKF_USER_PIN_FINAL_TRY (1 << 17) 00264 #define CKF_USER_PIN_LOCKED (1 << 18) 00265 #define CKF_USER_PIN_TO_BE_CHANGED (1 << 19) 00266 #define CKF_SO_PIN_COUNT_LOW (1 << 20) 00267 #define CKF_SO_PIN_FINAL_TRY (1 << 21) 00268 #define CKF_SO_PIN_LOCKED (1 << 22) 00269 #define CKF_SO_PIN_TO_BE_CHANGED (1 << 23) 00270 00271 #define CK_UNAVAILABLE_INFORMATION ((unsigned long) -1) 00272 #define CK_EFFECTIVELY_INFINITE (0) 00273 00274 00275 typedef unsigned long ck_session_handle_t; 00276 00277 #define CK_INVALID_HANDLE (0) 00278 00279 00280 typedef unsigned long ck_user_type_t; 00281 00282 #define CKU_SO (0) 00283 #define CKU_USER (1) 00284 #define CKU_CONTEXT_SPECIFIC (2) 00285 00286 00287 typedef unsigned long ck_state_t; 00288 00289 #define CKS_RO_PUBLIC_SESSION (0) 00290 #define CKS_RO_USER_FUNCTIONS (1) 00291 #define CKS_RW_PUBLIC_SESSION (2) 00292 #define CKS_RW_USER_FUNCTIONS (3) 00293 #define CKS_RW_SO_FUNCTIONS (4) 00294 00295 00296 struct ck_session_info 00297 { 00298 ck_slot_id_t slot_id; 00299 ck_state_t state; 00300 ck_flags_t flags; 00301 unsigned long device_error; 00302 }; 00303 00304 #define CKF_RW_SESSION (1 << 1) 00305 #define CKF_SERIAL_SESSION (1 << 2) 00306 00307 00308 typedef unsigned long ck_object_handle_t; 00309 00310 00311 typedef unsigned long ck_object_class_t; 00312 00313 #define CKO_DATA (0) 00314 #define CKO_CERTIFICATE (1) 00315 #define CKO_PUBLIC_KEY (2) 00316 #define CKO_PRIVATE_KEY (3) 00317 #define CKO_SECRET_KEY (4) 00318 #define CKO_HW_FEATURE (5) 00319 #define CKO_DOMAIN_PARAMETERS (6) 00320 #define CKO_MECHANISM (7) 00321 #define CKO_VENDOR_DEFINED ((unsigned long) (1 << 31)) 00322 00323 00324 typedef unsigned long ck_hw_feature_type_t; 00325 00326 #define CKH_MONOTONIC_COUNTER (1) 00327 #define CKH_CLOCK (2) 00328 #define CKH_USER_INTERFACE (3) 00329 #define CKH_VENDOR_DEFINED ((unsigned long) (1 << 31)) 00330 00331 00332 typedef unsigned long ck_key_type_t; 00333 00334 #define CKK_RSA (0) 00335 #define CKK_DSA (1) 00336 #define CKK_DH (2) 00337 #define CKK_ECDSA (3) 00338 #define CKK_EC (3) 00339 #define CKK_X9_42_DH (4) 00340 #define CKK_KEA (5) 00341 #define CKK_GENERIC_SECRET (0x10) 00342 #define CKK_RC2 (0x11) 00343 #define CKK_RC4 (0x12) 00344 #define CKK_DES (0x13) 00345 #define CKK_DES2 (0x14) 00346 #define CKK_DES3 (0x15) 00347 #define CKK_CAST (0x16) 00348 #define CKK_CAST3 (0x17) 00349 #define CKK_CAST128 (0x18) 00350 #define CKK_RC5 (0x19) 00351 #define CKK_IDEA (0x1a) 00352 #define CKK_SKIPJACK (0x1b) 00353 #define CKK_BATON (0x1c) 00354 #define CKK_JUNIPER (0x1d) 00355 #define CKK_CDMF (0x1e) 00356 #define CKK_AES (0x1f) 00357 #define CKK_BLOWFISH (0x20) 00358 #define CKK_TWOFISH (0x21) 00359 #define CKK_VENDOR_DEFINED ((unsigned long) (1 << 31)) 00360 00361 00362 typedef unsigned long ck_certificate_type_t; 00363 00364 #define CKC_X_509 (0) 00365 #define CKC_X_509_ATTR_CERT (1) 00366 #define CKC_WTLS (2) 00367 #define CKC_VENDOR_DEFINED ((unsigned long) (1 << 31)) 00368 00369 00370 typedef unsigned long ck_attribute_type_t; 00371 00372 #define CKA_CLASS (0) 00373 #define CKA_TOKEN (1) 00374 #define CKA_PRIVATE (2) 00375 #define CKA_LABEL (3) 00376 #define CKA_APPLICATION (0x10) 00377 #define CKA_VALUE (0x11) 00378 #define CKA_OBJECT_ID (0x12) 00379 #define CKA_CERTIFICATE_TYPE (0x80) 00380 #define CKA_ISSUER (0x81) 00381 #define CKA_SERIAL_NUMBER (0x82) 00382 #define CKA_AC_ISSUER (0x83) 00383 #define CKA_OWNER (0x84) 00384 #define CKA_ATTR_TYPES (0x85) 00385 #define CKA_TRUSTED (0x86) 00386 #define CKA_CERTIFICATE_CATEGORY (0x87) 00387 #define CKA_JAVA_MIDP_SECURITY_DOMAIN (0x88) 00388 #define CKA_URL (0x89) 00389 #define CKA_HASH_OF_SUBJECT_PUBLIC_KEY (0x8a) 00390 #define CKA_HASH_OF_ISSUER_PUBLIC_KEY (0x8b) 00391 #define CKA_CHECK_VALUE (0x90) 00392 #define CKA_KEY_TYPE (0x100) 00393 #define CKA_SUBJECT (0x101) 00394 #define CKA_ID (0x102) 00395 #define CKA_SENSITIVE (0x103) 00396 #define CKA_ENCRYPT (0x104) 00397 #define CKA_DECRYPT (0x105) 00398 #define CKA_WRAP (0x106) 00399 #define CKA_UNWRAP (0x107) 00400 #define CKA_SIGN (0x108) 00401 #define CKA_SIGN_RECOVER (0x109) 00402 #define CKA_VERIFY (0x10a) 00403 #define CKA_VERIFY_RECOVER (0x10b) 00404 #define CKA_DERIVE (0x10c) 00405 #define CKA_START_DATE (0x110) 00406 #define CKA_END_DATE (0x111) 00407 #define CKA_MODULUS (0x120) 00408 #define CKA_MODULUS_BITS (0x121) 00409 #define CKA_PUBLIC_EXPONENT (0x122) 00410 #define CKA_PRIVATE_EXPONENT (0x123) 00411 #define CKA_PRIME_1 (0x124) 00412 #define CKA_PRIME_2 (0x125) 00413 #define CKA_EXPONENT_1 (0x126) 00414 #define CKA_EXPONENT_2 (0x127) 00415 #define CKA_COEFFICIENT (0x128) 00416 #define CKA_PRIME (0x130) 00417 #define CKA_SUBPRIME (0x131) 00418 #define CKA_BASE (0x132) 00419 #define CKA_PRIME_BITS (0x133) 00420 #define CKA_SUB_PRIME_BITS (0x134) 00421 #define CKA_VALUE_BITS (0x160) 00422 #define CKA_VALUE_LEN (0x161) 00423 #define CKA_EXTRACTABLE (0x162) 00424 #define CKA_LOCAL (0x163) 00425 #define CKA_NEVER_EXTRACTABLE (0x164) 00426 #define CKA_ALWAYS_SENSITIVE (0x165) 00427 #define CKA_KEY_GEN_MECHANISM (0x166) 00428 #define CKA_MODIFIABLE (0x170) 00429 #define CKA_ECDSA_PARAMS (0x180) 00430 #define CKA_EC_PARAMS (0x180) 00431 #define CKA_EC_POINT (0x181) 00432 #define CKA_SECONDARY_AUTH (0x200) 00433 #define CKA_AUTH_PIN_FLAGS (0x201) 00434 #define CKA_ALWAYS_AUTHENTICATE (0x202) 00435 #define CKA_WRAP_WITH_TRUSTED (0x210) 00436 #define CKA_HW_FEATURE_TYPE (0x300) 00437 #define CKA_RESET_ON_INIT (0x301) 00438 #define CKA_HAS_RESET (0x302) 00439 #define CKA_PIXEL_X (0x400) 00440 #define CKA_PIXEL_Y (0x401) 00441 #define CKA_RESOLUTION (0x402) 00442 #define CKA_CHAR_ROWS (0x403) 00443 #define CKA_CHAR_COLUMNS (0x404) 00444 #define CKA_COLOR (0x405) 00445 #define CKA_BITS_PER_PIXEL (0x406) 00446 #define CKA_CHAR_SETS (0x480) 00447 #define CKA_ENCODING_METHODS (0x481) 00448 #define CKA_MIME_TYPES (0x482) 00449 #define CKA_MECHANISM_TYPE (0x500) 00450 #define CKA_REQUIRED_CMS_ATTRIBUTES (0x501) 00451 #define CKA_DEFAULT_CMS_ATTRIBUTES (0x502) 00452 #define CKA_SUPPORTED_CMS_ATTRIBUTES (0x503) 00453 #define CKA_WRAP_TEMPLATE (CKF_ARRAY_ATTRIBUTE | 0x211) 00454 #define CKA_UNWRAP_TEMPLATE (CKF_ARRAY_ATTRIBUTE | 0x212) 00455 #define CKA_ALLOWED_MECHANISMS (CKF_ARRAY_ATTRIBUTE | 0x600) 00456 #define CKA_VENDOR_DEFINED ((unsigned long) (1 << 31)) 00457 00458 00459 struct ck_attribute 00460 { 00461 ck_attribute_type_t type; 00462 void *value; 00463 unsigned long value_len; 00464 }; 00465 00466 00467 struct ck_date 00468 { 00469 unsigned char year[4]; 00470 unsigned char month[2]; 00471 unsigned char day[2]; 00472 }; 00473 00474 00475 typedef unsigned long ck_mechanism_type_t; 00476 00477 #define CKM_RSA_PKCS_KEY_PAIR_GEN (0) 00478 #define CKM_RSA_PKCS (1) 00479 #define CKM_RSA_9796 (2) 00480 #define CKM_RSA_X_509 (3) 00481 #define CKM_MD2_RSA_PKCS (4) 00482 #define CKM_MD5_RSA_PKCS (5) 00483 #define CKM_SHA1_RSA_PKCS (6) 00484 #define CKM_RIPEMD128_RSA_PKCS (7) 00485 #define CKM_RIPEMD160_RSA_PKCS (8) 00486 #define CKM_RSA_PKCS_OAEP (9) 00487 #define CKM_RSA_X9_31_KEY_PAIR_GEN (0xa) 00488 #define CKM_RSA_X9_31 (0xb) 00489 #define CKM_SHA1_RSA_X9_31 (0xc) 00490 #define CKM_RSA_PKCS_PSS (0xd) 00491 #define CKM_SHA1_RSA_PKCS_PSS (0xe) 00492 #define CKM_DSA_KEY_PAIR_GEN (0x10) 00493 #define CKM_DSA (0x11) 00494 #define CKM_DSA_SHA1 (0x12) 00495 #define CKM_DH_PKCS_KEY_PAIR_GEN (0x20) 00496 #define CKM_DH_PKCS_DERIVE (0x21) 00497 #define CKM_X9_42_DH_KEY_PAIR_GEN (0x30) 00498 #define CKM_X9_42_DH_DERIVE (0x31) 00499 #define CKM_X9_42_DH_HYBRID_DERIVE (0x32) 00500 #define CKM_X9_42_MQV_DERIVE (0x33) 00501 #define CKM_SHA256_RSA_PKCS (0x40) 00502 #define CKM_SHA384_RSA_PKCS (0x41) 00503 #define CKM_SHA512_RSA_PKCS (0x42) 00504 #define CKM_SHA256_RSA_PKCS_PSS (0x43) 00505 #define CKM_SHA384_RSA_PKCS_PSS (0x44) 00506 #define CKM_SHA512_RSA_PKCS_PSS (0x45) 00507 #define CKM_RC2_KEY_GEN (0x100) 00508 #define CKM_RC2_ECB (0x101) 00509 #define CKM_RC2_CBC (0x102) 00510 #define CKM_RC2_MAC (0x103) 00511 #define CKM_RC2_MAC_GENERAL (0x104) 00512 #define CKM_RC2_CBC_PAD (0x105) 00513 #define CKM_RC4_KEY_GEN (0x110) 00514 #define CKM_RC4 (0x111) 00515 #define CKM_DES_KEY_GEN (0x120) 00516 #define CKM_DES_ECB (0x121) 00517 #define CKM_DES_CBC (0x122) 00518 #define CKM_DES_MAC (0x123) 00519 #define CKM_DES_MAC_GENERAL (0x124) 00520 #define CKM_DES_CBC_PAD (0x125) 00521 #define CKM_DES2_KEY_GEN (0x130) 00522 #define CKM_DES3_KEY_GEN (0x131) 00523 #define CKM_DES3_ECB (0x132) 00524 #define CKM_DES3_CBC (0x133) 00525 #define CKM_DES3_MAC (0x134) 00526 #define CKM_DES3_MAC_GENERAL (0x135) 00527 #define CKM_DES3_CBC_PAD (0x136) 00528 #define CKM_CDMF_KEY_GEN (0x140) 00529 #define CKM_CDMF_ECB (0x141) 00530 #define CKM_CDMF_CBC (0x142) 00531 #define CKM_CDMF_MAC (0x143) 00532 #define CKM_CDMF_MAC_GENERAL (0x144) 00533 #define CKM_CDMF_CBC_PAD (0x145) 00534 #define CKM_MD2 (0x200) 00535 #define CKM_MD2_HMAC (0x201) 00536 #define CKM_MD2_HMAC_GENERAL (0x202) 00537 #define CKM_MD5 (0x210) 00538 #define CKM_MD5_HMAC (0x211) 00539 #define CKM_MD5_HMAC_GENERAL (0x212) 00540 #define CKM_SHA_1 (0x220) 00541 #define CKM_SHA_1_HMAC (0x221) 00542 #define CKM_SHA_1_HMAC_GENERAL (0x222) 00543 #define CKM_RIPEMD128 (0x230) 00544 #define CKM_RIPEMD128_HMAC (0x231) 00545 #define CKM_RIPEMD128_HMAC_GENERAL (0x232) 00546 #define CKM_RIPEMD160 (0x240) 00547 #define CKM_RIPEMD160_HMAC (0x241) 00548 #define CKM_RIPEMD160_HMAC_GENERAL (0x242) 00549 #define CKM_SHA256 (0x250) 00550 #define CKM_SHA256_HMAC (0x251) 00551 #define CKM_SHA256_HMAC_GENERAL (0x252) 00552 #define CKM_SHA384 (0x260) 00553 #define CKM_SHA384_HMAC (0x261) 00554 #define CKM_SHA384_HMAC_GENERAL (0x262) 00555 #define CKM_SHA512 (0x270) 00556 #define CKM_SHA512_HMAC (0x271) 00557 #define CKM_SHA512_HMAC_GENERAL (0x272) 00558 #define CKM_CAST_KEY_GEN (0x300) 00559 #define CKM_CAST_ECB (0x301) 00560 #define CKM_CAST_CBC (0x302) 00561 #define CKM_CAST_MAC (0x303) 00562 #define CKM_CAST_MAC_GENERAL (0x304) 00563 #define CKM_CAST_CBC_PAD (0x305) 00564 #define CKM_CAST3_KEY_GEN (0x310) 00565 #define CKM_CAST3_ECB (0x311) 00566 #define CKM_CAST3_CBC (0x312) 00567 #define CKM_CAST3_MAC (0x313) 00568 #define CKM_CAST3_MAC_GENERAL (0x314) 00569 #define CKM_CAST3_CBC_PAD (0x315) 00570 #define CKM_CAST5_KEY_GEN (0x320) 00571 #define CKM_CAST128_KEY_GEN (0x320) 00572 #define CKM_CAST5_ECB (0x321) 00573 #define CKM_CAST128_ECB (0x321) 00574 #define CKM_CAST5_CBC (0x322) 00575 #define CKM_CAST128_CBC (0x322) 00576 #define CKM_CAST5_MAC (0x323) 00577 #define CKM_CAST128_MAC (0x323) 00578 #define CKM_CAST5_MAC_GENERAL (0x324) 00579 #define CKM_CAST128_MAC_GENERAL (0x324) 00580 #define CKM_CAST5_CBC_PAD (0x325) 00581 #define CKM_CAST128_CBC_PAD (0x325) 00582 #define CKM_RC5_KEY_GEN (0x330) 00583 #define CKM_RC5_ECB (0x331) 00584 #define CKM_RC5_CBC (0x332) 00585 #define CKM_RC5_MAC (0x333) 00586 #define CKM_RC5_MAC_GENERAL (0x334) 00587 #define CKM_RC5_CBC_PAD (0x335) 00588 #define CKM_IDEA_KEY_GEN (0x340) 00589 #define CKM_IDEA_ECB (0x341) 00590 #define CKM_IDEA_CBC (0x342) 00591 #define CKM_IDEA_MAC (0x343) 00592 #define CKM_IDEA_MAC_GENERAL (0x344) 00593 #define CKM_IDEA_CBC_PAD (0x345) 00594 #define CKM_GENERIC_SECRET_KEY_GEN (0x350) 00595 #define CKM_CONCATENATE_BASE_AND_KEY (0x360) 00596 #define CKM_CONCATENATE_BASE_AND_DATA (0x362) 00597 #define CKM_CONCATENATE_DATA_AND_BASE (0x363) 00598 #define CKM_XOR_BASE_AND_DATA (0x364) 00599 #define CKM_EXTRACT_KEY_FROM_KEY (0x365) 00600 #define CKM_SSL3_PRE_MASTER_KEY_GEN (0x370) 00601 #define CKM_SSL3_MASTER_KEY_DERIVE (0x371) 00602 #define CKM_SSL3_KEY_AND_MAC_DERIVE (0x372) 00603 #define CKM_SSL3_MASTER_KEY_DERIVE_DH (0x373) 00604 #define CKM_TLS_PRE_MASTER_KEY_GEN (0x374) 00605 #define CKM_TLS_MASTER_KEY_DERIVE (0x375) 00606 #define CKM_TLS_KEY_AND_MAC_DERIVE (0x376) 00607 #define CKM_TLS_MASTER_KEY_DERIVE_DH (0x377) 00608 #define CKM_SSL3_MD5_MAC (0x380) 00609 #define CKM_SSL3_SHA1_MAC (0x381) 00610 #define CKM_MD5_KEY_DERIVATION (0x390) 00611 #define CKM_MD2_KEY_DERIVATION (0x391) 00612 #define CKM_SHA1_KEY_DERIVATION (0x392) 00613 #define CKM_PBE_MD2_DES_CBC (0x3a0) 00614 #define CKM_PBE_MD5_DES_CBC (0x3a1) 00615 #define CKM_PBE_MD5_CAST_CBC (0x3a2) 00616 #define CKM_PBE_MD5_CAST3_CBC (0x3a3) 00617 #define CKM_PBE_MD5_CAST5_CBC (0x3a4) 00618 #define CKM_PBE_MD5_CAST128_CBC (0x3a4) 00619 #define CKM_PBE_SHA1_CAST5_CBC (0x3a5) 00620 #define CKM_PBE_SHA1_CAST128_CBC (0x3a5) 00621 #define CKM_PBE_SHA1_RC4_128 (0x3a6) 00622 #define CKM_PBE_SHA1_RC4_40 (0x3a7) 00623 #define CKM_PBE_SHA1_DES3_EDE_CBC (0x3a8) 00624 #define CKM_PBE_SHA1_DES2_EDE_CBC (0x3a9) 00625 #define CKM_PBE_SHA1_RC2_128_CBC (0x3aa) 00626 #define CKM_PBE_SHA1_RC2_40_CBC (0x3ab) 00627 #define CKM_PKCS5_PBKD2 (0x3b0) 00628 #define CKM_PBA_SHA1_WITH_SHA1_HMAC (0x3c0) 00629 #define CKM_KEY_WRAP_LYNKS (0x400) 00630 #define CKM_KEY_WRAP_SET_OAEP (0x401) 00631 #define CKM_SKIPJACK_KEY_GEN (0x1000) 00632 #define CKM_SKIPJACK_ECB64 (0x1001) 00633 #define CKM_SKIPJACK_CBC64 (0x1002) 00634 #define CKM_SKIPJACK_OFB64 (0x1003) 00635 #define CKM_SKIPJACK_CFB64 (0x1004) 00636 #define CKM_SKIPJACK_CFB32 (0x1005) 00637 #define CKM_SKIPJACK_CFB16 (0x1006) 00638 #define CKM_SKIPJACK_CFB8 (0x1007) 00639 #define CKM_SKIPJACK_WRAP (0x1008) 00640 #define CKM_SKIPJACK_PRIVATE_WRAP (0x1009) 00641 #define CKM_SKIPJACK_RELAYX (0x100a) 00642 #define CKM_KEA_KEY_PAIR_GEN (0x1010) 00643 #define CKM_KEA_KEY_DERIVE (0x1011) 00644 #define CKM_FORTEZZA_TIMESTAMP (0x1020) 00645 #define CKM_BATON_KEY_GEN (0x1030) 00646 #define CKM_BATON_ECB128 (0x1031) 00647 #define CKM_BATON_ECB96 (0x1032) 00648 #define CKM_BATON_CBC128 (0x1033) 00649 #define CKM_BATON_COUNTER (0x1034) 00650 #define CKM_BATON_SHUFFLE (0x1035) 00651 #define CKM_BATON_WRAP (0x1036) 00652 #define CKM_ECDSA_KEY_PAIR_GEN (0x1040) 00653 #define CKM_EC_KEY_PAIR_GEN (0x1040) 00654 #define CKM_ECDSA (0x1041) 00655 #define CKM_ECDSA_SHA1 (0x1042) 00656 #define CKM_ECDH1_DERIVE (0x1050) 00657 #define CKM_ECDH1_COFACTOR_DERIVE (0x1051) 00658 #define CKM_ECMQV_DERIVE (0x1052) 00659 #define CKM_JUNIPER_KEY_GEN (0x1060) 00660 #define CKM_JUNIPER_ECB128 (0x1061) 00661 #define CKM_JUNIPER_CBC128 (0x1062) 00662 #define CKM_JUNIPER_COUNTER (0x1063) 00663 #define CKM_JUNIPER_SHUFFLE (0x1064) 00664 #define CKM_JUNIPER_WRAP (0x1065) 00665 #define CKM_FASTHASH (0x1070) 00666 #define CKM_AES_KEY_GEN (0x1080) 00667 #define CKM_AES_ECB (0x1081) 00668 #define CKM_AES_CBC (0x1082) 00669 #define CKM_AES_MAC (0x1083) 00670 #define CKM_AES_MAC_GENERAL (0x1084) 00671 #define CKM_AES_CBC_PAD (0x1085) 00672 #define CKM_DSA_PARAMETER_GEN (0x2000) 00673 #define CKM_DH_PKCS_PARAMETER_GEN (0x2001) 00674 #define CKM_X9_42_DH_PARAMETER_GEN (0x2002) 00675 #define CKM_VENDOR_DEFINED ((unsigned long) (1 << 31)) 00676 00677 00678 struct ck_mechanism 00679 { 00680 ck_mechanism_type_t mechanism; 00681 void *parameter; 00682 unsigned long parameter_len; 00683 }; 00684 00685 00686 struct ck_mechanism_info 00687 { 00688 unsigned long min_key_size; 00689 unsigned long max_key_size; 00690 ck_flags_t flags; 00691 }; 00692 00693 #define CKF_HW (1 << 0) 00694 #define CKF_ENCRYPT (1 << 8) 00695 #define CKF_DECRYPT (1 << 9) 00696 #define CKF_DIGEST (1 << 10) 00697 #define CKF_SIGN (1 << 11) 00698 #define CKF_SIGN_RECOVER (1 << 12) 00699 #define CKF_VERIFY (1 << 13) 00700 #define CKF_VERIFY_RECOVER (1 << 14) 00701 #define CKF_GENERATE (1 << 15) 00702 #define CKF_GENERATE_KEY_PAIR (1 << 16) 00703 #define CKF_WRAP (1 << 17) 00704 #define CKF_UNWRAP (1 << 18) 00705 #define CKF_DERIVE (1 << 19) 00706 #define CKF_EXTENSION ((unsigned long) (1 << 31)) 00707 00708 00709 /* Flags for C_WaitForSlotEvent. */ 00710 #define CKF_DONT_BLOCK (1) 00711 00712 00713 typedef unsigned long ck_rv_t; 00714 00715 00716 typedef ck_rv_t (*ck_notify_t) (ck_session_handle_t session, 00717 ck_notification_t event, void *application); 00718 00719 /* Forward reference. */ 00720 struct ck_function_list; 00721 00722 #define _CK_DECLARE_FUNCTION(name, args) \ 00723 typedef ck_rv_t (*CK_ ## name) args; \ 00724 ck_rv_t CK_SPEC name args 00725 00726 _CK_DECLARE_FUNCTION (C_Initialize, (void *init_args)); 00727 _CK_DECLARE_FUNCTION (C_Finalize, (void *reserved)); 00728 _CK_DECLARE_FUNCTION (C_GetInfo, (struct ck_info *info)); 00729 _CK_DECLARE_FUNCTION (C_GetFunctionList, 00730 (struct ck_function_list **function_list)); 00731 00732 _CK_DECLARE_FUNCTION (C_GetSlotList, 00733 (unsigned char token_present, ck_slot_id_t *slot_list, 00734 unsigned long *count)); 00735 _CK_DECLARE_FUNCTION (C_GetSlotInfo, 00736 (ck_slot_id_t slot_id, struct ck_slot_info *info)); 00737 _CK_DECLARE_FUNCTION (C_GetTokenInfo, 00738 (ck_slot_id_t slot_id, struct ck_token_info *info)); 00739 _CK_DECLARE_FUNCTION (C_WaitForSlotEvent, 00740 (ck_flags_t flags, ck_slot_id_t *slot, void *reserved)); 00741 _CK_DECLARE_FUNCTION (C_GetMechanismList, 00742 (ck_slot_id_t slot_id, 00743 ck_mechanism_type_t *mechanism_list, 00744 unsigned long *count)); 00745 _CK_DECLARE_FUNCTION (C_GetMechanismInfo, 00746 (ck_slot_id_t slot_id, ck_mechanism_type_t type, 00747 struct ck_mechanism_info *info)); 00748 _CK_DECLARE_FUNCTION (C_InitToken, 00749 (ck_slot_id_t slot_id, unsigned char *pin, 00750 unsigned long pin_len, unsigned char *label)); 00751 _CK_DECLARE_FUNCTION (C_InitPIN, 00752 (ck_session_handle_t session, unsigned char *pin, 00753 unsigned long pin_len)); 00754 _CK_DECLARE_FUNCTION (C_SetPIN, 00755 (ck_session_handle_t session, unsigned char *old_pin, 00756 unsigned long old_len, unsigned char *new_pin, 00757 unsigned long new_len)); 00758 00759 _CK_DECLARE_FUNCTION (C_OpenSession, 00760 (ck_slot_id_t slot_id, ck_flags_t flags, 00761 void *application, ck_notify_t notify, 00762 ck_session_handle_t *session)); 00763 _CK_DECLARE_FUNCTION (C_CloseSession, (ck_session_handle_t session)); 00764 _CK_DECLARE_FUNCTION (C_CloseAllSessions, (ck_slot_id_t slot_id)); 00765 _CK_DECLARE_FUNCTION (C_GetSessionInfo, 00766 (ck_session_handle_t session, 00767 struct ck_session_info *info)); 00768 _CK_DECLARE_FUNCTION (C_GetOperationState, 00769 (ck_session_handle_t session, 00770 unsigned char *operation_state, 00771 unsigned long *operation_state_len)); 00772 _CK_DECLARE_FUNCTION (C_SetOperationState, 00773 (ck_session_handle_t session, 00774 unsigned char *operation_state, 00775 unsigned long operation_state_len, 00776 ck_object_handle_t encryption_key, 00777 ck_object_handle_t authentiation_key)); 00778 _CK_DECLARE_FUNCTION (C_Login, 00779 (ck_session_handle_t session, ck_user_type_t user_type, 00780 unsigned char *pin, unsigned long pin_len)); 00781 _CK_DECLARE_FUNCTION (C_Logout, (ck_session_handle_t session)); 00782 00783 _CK_DECLARE_FUNCTION (C_CreateObject, 00784 (ck_session_handle_t session, 00785 struct ck_attribute *templ, 00786 unsigned long count, ck_object_handle_t *object)); 00787 _CK_DECLARE_FUNCTION (C_CopyObject, 00788 (ck_session_handle_t session, ck_object_handle_t object, 00789 struct ck_attribute *templ, unsigned long count, 00790 ck_object_handle_t *new_object)); 00791 _CK_DECLARE_FUNCTION (C_DestroyObject, 00792 (ck_session_handle_t session, 00793 ck_object_handle_t object)); 00794 _CK_DECLARE_FUNCTION (C_GetObjectSize, 00795 (ck_session_handle_t session, 00796 ck_object_handle_t object, 00797 unsigned long *size)); 00798 _CK_DECLARE_FUNCTION (C_GetAttributeValue, 00799 (ck_session_handle_t session, 00800 ck_object_handle_t object, 00801 struct ck_attribute *templ, 00802 unsigned long count)); 00803 _CK_DECLARE_FUNCTION (C_SetAttributeValue, 00804 (ck_session_handle_t session, 00805 ck_object_handle_t object, 00806 struct ck_attribute *templ, 00807 unsigned long count)); 00808 _CK_DECLARE_FUNCTION (C_FindObjectsInit, 00809 (ck_session_handle_t session, 00810 struct ck_attribute *templ, 00811 unsigned long count)); 00812 _CK_DECLARE_FUNCTION (C_FindObjects, 00813 (ck_session_handle_t session, 00814 ck_object_handle_t *object, 00815 unsigned long max_object_count, 00816 unsigned long *object_count)); 00817 _CK_DECLARE_FUNCTION (C_FindObjectsFinal, 00818 (ck_session_handle_t session)); 00819 00820 _CK_DECLARE_FUNCTION (C_EncryptInit, 00821 (ck_session_handle_t session, 00822 struct ck_mechanism *mechanism, 00823 ck_object_handle_t key)); 00824 _CK_DECLARE_FUNCTION (C_Encrypt, 00825 (ck_session_handle_t session, 00826 unsigned char *data, unsigned long data_len, 00827 unsigned char *encrypted_data, 00828 unsigned long *encrypted_data_len)); 00829 _CK_DECLARE_FUNCTION (C_EncryptUpdate, 00830 (ck_session_handle_t session, 00831 unsigned char *part, unsigned long part_len, 00832 unsigned char *encrypted_part, 00833 unsigned long *encrypted_part_len)); 00834 _CK_DECLARE_FUNCTION (C_EncryptFinal, 00835 (ck_session_handle_t session, 00836 unsigned char *last_encrypted_part, 00837 unsigned long *last_encrypted_part_len)); 00838 00839 _CK_DECLARE_FUNCTION (C_DecryptInit, 00840 (ck_session_handle_t session, 00841 struct ck_mechanism *mechanism, 00842 ck_object_handle_t key)); 00843 _CK_DECLARE_FUNCTION (C_Decrypt, 00844 (ck_session_handle_t session, 00845 unsigned char *encrypted_data, 00846 unsigned long encrypted_data_len, 00847 unsigned char *data, unsigned long *data_len)); 00848 _CK_DECLARE_FUNCTION (C_DecryptUpdate, 00849 (ck_session_handle_t session, 00850 unsigned char *encrypted_part, 00851 unsigned long encrypted_part_len, 00852 unsigned char *part, unsigned long *part_len)); 00853 _CK_DECLARE_FUNCTION (C_DecryptFinal, 00854 (ck_session_handle_t session, 00855 unsigned char *last_part, 00856 unsigned long *last_part_len)); 00857 00858 _CK_DECLARE_FUNCTION (C_DigestInit, 00859 (ck_session_handle_t session, 00860 struct ck_mechanism *mechanism)); 00861 _CK_DECLARE_FUNCTION (C_Digest, 00862 (ck_session_handle_t session, 00863 unsigned char *data, unsigned long data_len, 00864 unsigned char *digest, 00865 unsigned long *digest_len)); 00866 _CK_DECLARE_FUNCTION (C_DigestUpdate, 00867 (ck_session_handle_t session, 00868 unsigned char *part, unsigned long part_len)); 00869 _CK_DECLARE_FUNCTION (C_DigestKey, 00870 (ck_session_handle_t session, ck_object_handle_t key)); 00871 _CK_DECLARE_FUNCTION (C_DigestFinal, 00872 (ck_session_handle_t session, 00873 unsigned char *digest, 00874 unsigned long *digest_len)); 00875 00876 _CK_DECLARE_FUNCTION (C_SignInit, 00877 (ck_session_handle_t session, 00878 struct ck_mechanism *mechanism, 00879 ck_object_handle_t key)); 00880 _CK_DECLARE_FUNCTION (C_Sign, 00881 (ck_session_handle_t session, 00882 unsigned char *data, unsigned long data_len, 00883 unsigned char *signature, 00884 unsigned long *signature_len)); 00885 _CK_DECLARE_FUNCTION (C_SignUpdate, 00886 (ck_session_handle_t session, 00887 unsigned char *part, unsigned long part_len)); 00888 _CK_DECLARE_FUNCTION (C_SignFinal, 00889 (ck_session_handle_t session, 00890 unsigned char *signature, 00891 unsigned long *signature_len)); 00892 _CK_DECLARE_FUNCTION (C_SignRecoverInit, 00893 (ck_session_handle_t session, 00894 struct ck_mechanism *mechanism, 00895 ck_object_handle_t key)); 00896 _CK_DECLARE_FUNCTION (C_SignRecover, 00897 (ck_session_handle_t session, 00898 unsigned char *data, unsigned long data_len, 00899 unsigned char *signature, 00900 unsigned long *signature_len)); 00901 00902 _CK_DECLARE_FUNCTION (C_VerifyInit, 00903 (ck_session_handle_t session, 00904 struct ck_mechanism *mechanism, 00905 ck_object_handle_t key)); 00906 _CK_DECLARE_FUNCTION (C_Verify, 00907 (ck_session_handle_t session, 00908 unsigned char *data, unsigned long data_len, 00909 unsigned char *signature, 00910 unsigned long signature_len)); 00911 _CK_DECLARE_FUNCTION (C_VerifyUpdate, 00912 (ck_session_handle_t session, 00913 unsigned char *part, unsigned long part_len)); 00914 _CK_DECLARE_FUNCTION (C_VerifyFinal, 00915 (ck_session_handle_t session, 00916 unsigned char *signature, 00917 unsigned long signature_len)); 00918 _CK_DECLARE_FUNCTION (C_VerifyRecoverInit, 00919 (ck_session_handle_t session, 00920 struct ck_mechanism *mechanism, 00921 ck_object_handle_t key)); 00922 _CK_DECLARE_FUNCTION (C_VerifyRecover, 00923 (ck_session_handle_t session, 00924 unsigned char *signature, 00925 unsigned long signature_len, 00926 unsigned char *data, 00927 unsigned long *data_len)); 00928 00929 _CK_DECLARE_FUNCTION (C_DigestEncryptUpdate, 00930 (ck_session_handle_t session, 00931 unsigned char *part, unsigned long part_len, 00932 unsigned char *encrypted_part, 00933 unsigned long *encrypted_part_len)); 00934 _CK_DECLARE_FUNCTION (C_DecryptDigestUpdate, 00935 (ck_session_handle_t session, 00936 unsigned char *encrypted_part, 00937 unsigned long encrypted_part_len, 00938 unsigned char *part, 00939 unsigned long *part_len)); 00940 _CK_DECLARE_FUNCTION (C_SignEncryptUpdate, 00941 (ck_session_handle_t session, 00942 unsigned char *part, unsigned long part_len, 00943 unsigned char *encrypted_part, 00944 unsigned long *encrypted_part_len)); 00945 _CK_DECLARE_FUNCTION (C_DecryptVerifyUpdate, 00946 (ck_session_handle_t session, 00947 unsigned char *encrypted_part, 00948 unsigned long encrypted_part_len, 00949 unsigned char *part, 00950 unsigned long *part_len)); 00951 00952 _CK_DECLARE_FUNCTION (C_GenerateKey, 00953 (ck_session_handle_t session, 00954 struct ck_mechanism *mechanism, 00955 struct ck_attribute *templ, 00956 unsigned long count, 00957 ck_object_handle_t *key)); 00958 _CK_DECLARE_FUNCTION (C_GenerateKeyPair, 00959 (ck_session_handle_t session, 00960 struct ck_mechanism *mechanism, 00961 struct ck_attribute *public_key_template, 00962 unsigned long public_key_attribute_count, 00963 struct ck_attribute *private_key_template, 00964 unsigned long private_key_attribute_count, 00965 ck_object_handle_t *public_key, 00966 ck_object_handle_t *private_key)); 00967 _CK_DECLARE_FUNCTION (C_WrapKey, 00968 (ck_session_handle_t session, 00969 struct ck_mechanism *mechanism, 00970 ck_object_handle_t wrapping_key, 00971 ck_object_handle_t key, 00972 unsigned char *wrapped_key, 00973 unsigned long *wrapped_key_len)); 00974 _CK_DECLARE_FUNCTION (C_UnwrapKey, 00975 (ck_session_handle_t session, 00976 struct ck_mechanism *mechanism, 00977 ck_object_handle_t unwrapping_key, 00978 unsigned char *wrapped_key, 00979 unsigned long wrapped_key_len, 00980 struct ck_attribute *templ, 00981 unsigned long attribute_count, 00982 ck_object_handle_t *key)); 00983 _CK_DECLARE_FUNCTION (C_DeriveKey, 00984 (ck_session_handle_t session, 00985 struct ck_mechanism *mechanism, 00986 ck_object_handle_t base_key, 00987 struct ck_attribute *templ, 00988 unsigned long attribute_count, 00989 ck_object_handle_t *key)); 00990 00991 _CK_DECLARE_FUNCTION (C_SeedRandom, 00992 (ck_session_handle_t session, unsigned char *seed, 00993 unsigned long seed_len)); 00994 _CK_DECLARE_FUNCTION (C_GenerateRandom, 00995 (ck_session_handle_t session, 00996 unsigned char *random_data, 00997 unsigned long random_len)); 00998 00999 _CK_DECLARE_FUNCTION (C_GetFunctionStatus, (ck_session_handle_t session)); 01000 _CK_DECLARE_FUNCTION (C_CancelFunction, (ck_session_handle_t session)); 01001 01002 01003 struct ck_function_list 01004 { 01005 struct ck_version version; 01006 CK_C_Initialize C_Initialize; 01007 CK_C_Finalize C_Finalize; 01008 CK_C_GetInfo C_GetInfo; 01009 CK_C_GetFunctionList C_GetFunctionList; 01010 CK_C_GetSlotList C_GetSlotList; 01011 CK_C_GetSlotInfo C_GetSlotInfo; 01012 CK_C_GetTokenInfo C_GetTokenInfo; 01013 CK_C_GetMechanismList C_GetMechanismList; 01014 CK_C_GetMechanismInfo C_GetMechanismInfo; 01015 CK_C_InitToken C_InitToken; 01016 CK_C_InitPIN C_InitPIN; 01017 CK_C_SetPIN C_SetPIN; 01018 CK_C_OpenSession C_OpenSession; 01019 CK_C_CloseSession C_CloseSession; 01020 CK_C_CloseAllSessions C_CloseAllSessions; 01021 CK_C_GetSessionInfo C_GetSessionInfo; 01022 CK_C_GetOperationState C_GetOperationState; 01023 CK_C_SetOperationState C_SetOperationState; 01024 CK_C_Login C_Login; 01025 CK_C_Logout C_Logout; 01026 CK_C_CreateObject C_CreateObject; 01027 CK_C_CopyObject C_CopyObject; 01028 CK_C_DestroyObject C_DestroyObject; 01029 CK_C_GetObjectSize C_GetObjectSize; 01030 CK_C_GetAttributeValue C_GetAttributeValue; 01031 CK_C_SetAttributeValue C_SetAttributeValue; 01032 CK_C_FindObjectsInit C_FindObjectsInit; 01033 CK_C_FindObjects C_FindObjects; 01034 CK_C_FindObjectsFinal C_FindObjectsFinal; 01035 CK_C_EncryptInit C_EncryptInit; 01036 CK_C_Encrypt C_Encrypt; 01037 CK_C_EncryptUpdate C_EncryptUpdate; 01038 CK_C_EncryptFinal C_EncryptFinal; 01039 CK_C_DecryptInit C_DecryptInit; 01040 CK_C_Decrypt C_Decrypt; 01041 CK_C_DecryptUpdate C_DecryptUpdate; 01042 CK_C_DecryptFinal C_DecryptFinal; 01043 CK_C_DigestInit C_DigestInit; 01044 CK_C_Digest C_Digest; 01045 CK_C_DigestUpdate C_DigestUpdate; 01046 CK_C_DigestKey C_DigestKey; 01047 CK_C_DigestFinal C_DigestFinal; 01048 CK_C_SignInit C_SignInit; 01049 CK_C_Sign C_Sign; 01050 CK_C_SignUpdate C_SignUpdate; 01051 CK_C_SignFinal C_SignFinal; 01052 CK_C_SignRecoverInit C_SignRecoverInit; 01053 CK_C_SignRecover C_SignRecover; 01054 CK_C_VerifyInit C_VerifyInit; 01055 CK_C_Verify C_Verify; 01056 CK_C_VerifyUpdate C_VerifyUpdate; 01057 CK_C_VerifyFinal C_VerifyFinal; 01058 CK_C_VerifyRecoverInit C_VerifyRecoverInit; 01059 CK_C_VerifyRecover C_VerifyRecover; 01060 CK_C_DigestEncryptUpdate C_DigestEncryptUpdate; 01061 CK_C_DecryptDigestUpdate C_DecryptDigestUpdate; 01062 CK_C_SignEncryptUpdate C_SignEncryptUpdate; 01063 CK_C_DecryptVerifyUpdate C_DecryptVerifyUpdate; 01064 CK_C_GenerateKey C_GenerateKey; 01065 CK_C_GenerateKeyPair C_GenerateKeyPair; 01066 CK_C_WrapKey C_WrapKey; 01067 CK_C_UnwrapKey C_UnwrapKey; 01068 CK_C_DeriveKey C_DeriveKey; 01069 CK_C_SeedRandom C_SeedRandom; 01070 CK_C_GenerateRandom C_GenerateRandom; 01071 CK_C_GetFunctionStatus C_GetFunctionStatus; 01072 CK_C_CancelFunction C_CancelFunction; 01073 CK_C_WaitForSlotEvent C_WaitForSlotEvent; 01074 }; 01075 01076 01077 typedef ck_rv_t (*ck_createmutex_t) (void **mutex); 01078 typedef ck_rv_t (*ck_destroymutex_t) (void *mutex); 01079 typedef ck_rv_t (*ck_lockmutex_t) (void *mutex); 01080 typedef ck_rv_t (*ck_unlockmutex_t) (void *mutex); 01081 01082 01083 struct ck_c_initialize_args 01084 { 01085 ck_createmutex_t create_mutex; 01086 ck_destroymutex_t destroy_mutex; 01087 ck_lockmutex_t lock_mutex; 01088 ck_unlockmutex_t unlock_mutex; 01089 ck_flags_t flags; 01090 void *reserved; 01091 }; 01092 01093 01094 #define CKF_LIBRARY_CANT_CREATE_OS_THREADS (1 << 0) 01095 #define CKF_OS_LOCKING_OK (1 << 1) 01096 01097 #define CKR_OK (0) 01098 #define CKR_CANCEL (1) 01099 #define CKR_HOST_MEMORY (2) 01100 #define CKR_SLOT_ID_INVALID (3) 01101 #define CKR_GENERAL_ERROR (5) 01102 #define CKR_FUNCTION_FAILED (6) 01103 #define CKR_ARGUMENTS_BAD (7) 01104 #define CKR_NO_EVENT (8) 01105 #define CKR_NEED_TO_CREATE_THREADS (9) 01106 #define CKR_CANT_LOCK (0xa) 01107 #define CKR_ATTRIBUTE_READ_ONLY (0x10) 01108 #define CKR_ATTRIBUTE_SENSITIVE (0x11) 01109 #define CKR_ATTRIBUTE_TYPE_INVALID (0x12) 01110 #define CKR_ATTRIBUTE_VALUE_INVALID (0x13) 01111 #define CKR_DATA_INVALID (0x20) 01112 #define CKR_DATA_LEN_RANGE (0x21) 01113 #define CKR_DEVICE_ERROR (0x30) 01114 #define CKR_DEVICE_MEMORY (0x31) 01115 #define CKR_DEVICE_REMOVED (0x32) 01116 #define CKR_ENCRYPTED_DATA_INVALID (0x40) 01117 #define CKR_ENCRYPTED_DATA_LEN_RANGE (0x41) 01118 #define CKR_FUNCTION_CANCELED (0x50) 01119 #define CKR_FUNCTION_NOT_PARALLEL (0x51) 01120 #define CKR_FUNCTION_NOT_SUPPORTED (0x54) 01121 #define CKR_KEY_HANDLE_INVALID (0x60) 01122 #define CKR_KEY_SIZE_RANGE (0x62) 01123 #define CKR_KEY_TYPE_INCONSISTENT (0x63) 01124 #define CKR_KEY_NOT_NEEDED (0x64) 01125 #define CKR_KEY_CHANGED (0x65) 01126 #define CKR_KEY_NEEDED (0x66) 01127 #define CKR_KEY_INDIGESTIBLE (0x67) 01128 #define CKR_KEY_FUNCTION_NOT_PERMITTED (0x68) 01129 #define CKR_KEY_NOT_WRAPPABLE (0x69) 01130 #define CKR_KEY_UNEXTRACTABLE (0x6a) 01131 #define CKR_MECHANISM_INVALID (0x70) 01132 #define CKR_MECHANISM_PARAM_INVALID (0x71) 01133 #define CKR_OBJECT_HANDLE_INVALID (0x82) 01134 #define CKR_OPERATION_ACTIVE (0x90) 01135 #define CKR_OPERATION_NOT_INITIALIZED (0x91) 01136 #define CKR_PIN_INCORRECT (0xa0) 01137 #define CKR_PIN_INVALID (0xa1) 01138 #define CKR_PIN_LEN_RANGE (0xa2) 01139 #define CKR_PIN_EXPIRED (0xa3) 01140 #define CKR_PIN_LOCKED (0xa4) 01141 #define CKR_SESSION_CLOSED (0xb0) 01142 #define CKR_SESSION_COUNT (0xb1) 01143 #define CKR_SESSION_HANDLE_INVALID (0xb3) 01144 #define CKR_SESSION_PARALLEL_NOT_SUPPORTED (0xb4) 01145 #define CKR_SESSION_READ_ONLY (0xb5) 01146 #define CKR_SESSION_EXISTS (0xb6) 01147 #define CKR_SESSION_READ_ONLY_EXISTS (0xb7) 01148 #define CKR_SESSION_READ_WRITE_SO_EXISTS (0xb8) 01149 #define CKR_SIGNATURE_INVALID (0xc0) 01150 #define CKR_SIGNATURE_LEN_RANGE (0xc1) 01151 #define CKR_TEMPLATE_INCOMPLETE (0xd0) 01152 #define CKR_TEMPLATE_INCONSISTENT (0xd1) 01153 #define CKR_TOKEN_NOT_PRESENT (0xe0) 01154 #define CKR_TOKEN_NOT_RECOGNIZED (0xe1) 01155 #define CKR_TOKEN_WRITE_PROTECTED (0xe2) 01156 #define CKR_UNWRAPPING_KEY_HANDLE_INVALID (0xf0) 01157 #define CKR_UNWRAPPING_KEY_SIZE_RANGE (0xf1) 01158 #define CKR_UNWRAPPING_KEY_TYPE_INCONSISTENT (0xf2) 01159 #define CKR_USER_ALREADY_LOGGED_IN (0x100) 01160 #define CKR_USER_NOT_LOGGED_IN (0x101) 01161 #define CKR_USER_PIN_NOT_INITIALIZED (0x102) 01162 #define CKR_USER_TYPE_INVALID (0x103) 01163 #define CKR_USER_ANOTHER_ALREADY_LOGGED_IN (0x104) 01164 #define CKR_USER_TOO_MANY_TYPES (0x105) 01165 #define CKR_WRAPPED_KEY_INVALID (0x110) 01166 #define CKR_WRAPPED_KEY_LEN_RANGE (0x112) 01167 #define CKR_WRAPPING_KEY_HANDLE_INVALID (0x113) 01168 #define CKR_WRAPPING_KEY_SIZE_RANGE (0x114) 01169 #define CKR_WRAPPING_KEY_TYPE_INCONSISTENT (0x115) 01170 #define CKR_RANDOM_SEED_NOT_SUPPORTED (0x120) 01171 #define CKR_RANDOM_NO_RNG (0x121) 01172 #define CKR_DOMAIN_PARAMS_INVALID (0x130) 01173 #define CKR_BUFFER_TOO_SMALL (0x150) 01174 #define CKR_SAVED_STATE_INVALID (0x160) 01175 #define CKR_INFORMATION_SENSITIVE (0x170) 01176 #define CKR_STATE_UNSAVEABLE (0x180) 01177 #define CKR_CRYPTOKI_NOT_INITIALIZED (0x190) 01178 #define CKR_CRYPTOKI_ALREADY_INITIALIZED (0x191) 01179 #define CKR_MUTEX_BAD (0x1a0) 01180 #define CKR_MUTEX_NOT_LOCKED (0x1a1) 01181 #define CKR_FUNCTION_REJECTED (0x200) 01182 #define CKR_VENDOR_DEFINED ((unsigned long) (1 << 31)) 01183 01184 01185 01186 /* Compatibility layer. */ 01187 01188 #ifdef CRYPTOKI_COMPAT 01189 01190 #undef CK_DEFINE_FUNCTION 01191 #define CK_DEFINE_FUNCTION(retval, name) retval CK_SPEC name 01192 01193 /* For NULL. */ 01194 #include <stddef.h> 01195 01196 typedef unsigned char CK_BYTE; 01197 typedef unsigned char CK_CHAR; 01198 typedef unsigned char CK_UTF8CHAR; 01199 typedef unsigned char CK_BBOOL; 01200 typedef unsigned long int CK_ULONG; 01201 typedef long int CK_LONG; 01202 typedef CK_BYTE *CK_BYTE_PTR; 01203 typedef CK_CHAR *CK_CHAR_PTR; 01204 typedef CK_UTF8CHAR *CK_UTF8CHAR_PTR; 01205 typedef CK_ULONG *CK_ULONG_PTR; 01206 typedef void *CK_VOID_PTR; 01207 typedef void **CK_VOID_PTR_PTR; 01208 #define CK_FALSE 0 01209 #define CK_TRUE 1 01210 #ifndef CK_DISABLE_TRUE_FALSE 01211 #ifndef FALSE 01212 #define FALSE 0 01213 #endif 01214 #ifndef TRUE 01215 #define TRUE 1 01216 #endif 01217 #endif 01218 01219 typedef struct ck_version CK_VERSION; 01220 typedef struct ck_version *CK_VERSION_PTR; 01221 01222 typedef struct ck_info CK_INFO; 01223 typedef struct ck_info *CK_INFO_PTR; 01224 01225 typedef ck_slot_id_t *CK_SLOT_ID_PTR; 01226 01227 typedef struct ck_slot_info CK_SLOT_INFO; 01228 typedef struct ck_slot_info *CK_SLOT_INFO_PTR; 01229 01230 typedef struct ck_token_info CK_TOKEN_INFO; 01231 typedef struct ck_token_info *CK_TOKEN_INFO_PTR; 01232 01233 typedef ck_session_handle_t *CK_SESSION_HANDLE_PTR; 01234 01235 typedef struct ck_session_info CK_SESSION_INFO; 01236 typedef struct ck_session_info *CK_SESSION_INFO_PTR; 01237 01238 typedef ck_object_handle_t *CK_OBJECT_HANDLE_PTR; 01239 01240 typedef ck_object_class_t *CK_OBJECT_CLASS_PTR; 01241 01242 typedef struct ck_attribute CK_ATTRIBUTE; 01243 typedef struct ck_attribute *CK_ATTRIBUTE_PTR; 01244 01245 typedef struct ck_date CK_DATE; 01246 typedef struct ck_date *CK_DATE_PTR; 01247 01248 typedef ck_mechanism_type_t *CK_MECHANISM_TYPE_PTR; 01249 01250 typedef struct ck_mechanism CK_MECHANISM; 01251 typedef struct ck_mechanism *CK_MECHANISM_PTR; 01252 01253 typedef struct ck_mechanism_info CK_MECHANISM_INFO; 01254 typedef struct ck_mechanism_info *CK_MECHANISM_INFO_PTR; 01255 01256 typedef struct ck_function_list CK_FUNCTION_LIST; 01257 typedef struct ck_function_list *CK_FUNCTION_LIST_PTR; 01258 typedef struct ck_function_list **CK_FUNCTION_LIST_PTR_PTR; 01259 01260 typedef struct ck_c_initialize_args CK_C_INITIALIZE_ARGS; 01261 typedef struct ck_c_initialize_args *CK_C_INITIALIZE_ARGS_PTR; 01262 01263 #define NULL_PTR NULL 01264 01265 /* Delete the helper macros defined at the top of the file. */ 01266 #undef ck_flags_t 01267 #undef ck_version 01268 01269 #undef ck_info 01270 #undef cryptoki_version 01271 #undef manufacturer_id 01272 #undef library_description 01273 #undef library_version 01274 01275 #undef ck_notification_t 01276 #undef ck_slot_id_t 01277 01278 #undef ck_slot_info 01279 #undef slot_description 01280 #undef hardware_version 01281 #undef firmware_version 01282 01283 #undef ck_token_info 01284 #undef serial_number 01285 #undef max_session_count 01286 #undef session_count 01287 #undef max_rw_session_count 01288 #undef rw_session_count 01289 #undef max_pin_len 01290 #undef min_pin_len 01291 #undef total_public_memory 01292 #undef free_public_memory 01293 #undef total_private_memory 01294 #undef free_private_memory 01295 #undef utc_time 01296 01297 #undef ck_session_handle_t 01298 #undef ck_user_type_t 01299 #undef ck_state_t 01300 01301 #undef ck_session_info 01302 #undef slot_id 01303 #undef device_error 01304 01305 #undef ck_object_handle_t 01306 #undef ck_object_class_t 01307 #undef ck_hw_feature_type_t 01308 #undef ck_key_type_t 01309 #undef ck_certificate_type_t 01310 #undef ck_attribute_type_t 01311 01312 #undef ck_attribute 01313 #undef value 01314 #undef value_len 01315 01316 #undef ck_date 01317 01318 #undef ck_mechanism_type_t 01319 01320 #undef ck_mechanism 01321 #undef parameter 01322 #undef parameter_len 01323 01324 #undef ck_mechanism_info 01325 #undef min_key_size 01326 #undef max_key_size 01327 01328 #undef ck_rv_t 01329 #undef ck_notify_t 01330 01331 #undef ck_function_list 01332 01333 #undef ck_createmutex_t 01334 #undef ck_destroymutex_t 01335 #undef ck_lockmutex_t 01336 #undef ck_unlockmutex_t 01337 01338 #undef ck_c_initialize_args 01339 #undef create_mutex 01340 #undef destroy_mutex 01341 #undef lock_mutex 01342 #undef unlock_mutex 01343 #undef reserved 01344 01345 #endif /* CRYPTOKI_COMPAT */ 01346 01347 01348 /* System dependencies. */ 01349 #if defined(_WIN32) || defined(CRYPTOKI_FORCE_WIN32) 01350 #pragma pack(pop, cryptoki) 01351 #endif 01352 01353 #if defined(__cplusplus) 01354 } 01355 #endif 01356 01357 #endif /* PKCS11_H */