pkcs11.h revision 204861
1178476Sjb/* $OpenBSD: pkcs11.h,v 1.2 2010/02/24 06:12:53 djm Exp $ */ 2178476Sjb/* pkcs11.h 3178476Sjb Copyright 2006, 2007 g10 Code GmbH 4178476Sjb Copyright 2006 Andreas Jellinghaus 5178476Sjb 6178476Sjb This file is free software; as a special exception the author gives 7178476Sjb unlimited permission to copy and/or distribute it, with or without 8178476Sjb modifications, as long as this notice is preserved. 9178476Sjb 10178476Sjb This file is distributed in the hope that it will be useful, but 11178476Sjb WITHOUT ANY WARRANTY, to the extent permitted by law; without even 12178476Sjb the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR 13178476Sjb PURPOSE. */ 14178476Sjb 15178476Sjb/* Please submit changes back to the Scute project at 16178476Sjb http://www.scute.org/ (or send them to marcus@g10code.com), so that 17178476Sjb they can be picked up by other projects from there as well. */ 18178476Sjb 19178476Sjb/* This file is a modified implementation of the PKCS #11 standard by 20178476Sjb RSA Security Inc. It is mostly a drop-in replacement, with the 21178476Sjb following change: 22178476Sjb 23178476Sjb This header file does not require any macro definitions by the user 24178476Sjb (like CK_DEFINE_FUNCTION etc). In fact, it defines those macros 25178476Sjb for you (if useful, some are missing, let me know if you need 26178476Sjb more). 27178476Sjb 28178476Sjb There is an additional API available that does comply better to the 29178476Sjb GNU coding standard. It can be switched on by defining 30178476Sjb CRYPTOKI_GNU before including this header file. For this, the 31178476Sjb following changes are made to the specification: 32178476Sjb 33178476Sjb All structure types are changed to a "struct ck_foo" where CK_FOO 34178476Sjb is the type name in PKCS #11. 35178476Sjb 36178476Sjb All non-structure types are changed to ck_foo_t where CK_FOO is the 37178537Sjb lowercase version of the type name in PKCS #11. The basic types 38178476Sjb (CK_ULONG et al.) are removed without substitute. 39178476Sjb 40178476Sjb All members of structures are modified in the following way: Type 41178476Sjb indication prefixes are removed, and underscore characters are 42178476Sjb inserted before words. Then the result is lowercased. 43178476Sjb 44178537Sjb Note that function names are still in the original case, as they 45178476Sjb need for ABI compatibility. 46178537Sjb 47178476Sjb CK_FALSE, CK_TRUE and NULL_PTR are removed without substitute. Use 48178537Sjb <stdbool.h>. 49178476Sjb 50178537Sjb If CRYPTOKI_COMPAT is defined before including this header file, 51178476Sjb then none of the API changes above take place, and the API is the 52178476Sjb one defined by the PKCS #11 standard. */ 53178476Sjb 54178476Sjb#ifndef PKCS11_H 55178476Sjb#define PKCS11_H 1 56178476Sjb 57178476Sjb#if defined(__cplusplus) 58178476Sjbextern "C" { 59178476Sjb#endif 60178476Sjb 61178476Sjb 62178476Sjb/* The version of cryptoki we implement. The revision is changed with 63178476Sjb each modification of this file. If you do not use the "official" 64178476Sjb version of this file, please consider deleting the revision macro 65178476Sjb (you may use a macro with a different name to keep track of your 66178476Sjb versions). */ 67178476Sjb#define CRYPTOKI_VERSION_MAJOR 2 68178476Sjb#define CRYPTOKI_VERSION_MINOR 20 69178476Sjb#define CRYPTOKI_VERSION_REVISION 6 70178476Sjb 71178476Sjb 72178476Sjb/* Compatibility interface is default, unless CRYPTOKI_GNU is 73178476Sjb given. */ 74178476Sjb#ifndef CRYPTOKI_GNU 75178476Sjb#ifndef CRYPTOKI_COMPAT 76178476Sjb#define CRYPTOKI_COMPAT 1 77178476Sjb#endif 78178476Sjb#endif 79178476Sjb 80178476Sjb/* System dependencies. */ 81178476Sjb 82178476Sjb#if defined(_WIN32) || defined(CRYPTOKI_FORCE_WIN32) 83178476Sjb 84178476Sjb/* There is a matching pop below. */ 85178476Sjb#pragma pack(push, cryptoki, 1) 86178476Sjb 87178476Sjb#ifdef CRYPTOKI_EXPORTS 88178476Sjb#define CK_SPEC __declspec(dllexport) 89178476Sjb#else 90178476Sjb#define CK_SPEC __declspec(dllimport) 91178476Sjb#endif 92178476Sjb 93178476Sjb#else 94178476Sjb 95178476Sjb#define CK_SPEC 96178476Sjb 97178476Sjb#endif 98178476Sjb 99178476Sjb 100178537Sjb#ifdef CRYPTOKI_COMPAT 101178476Sjb /* If we are in compatibility mode, switch all exposed names to the 102178537Sjb PKCS #11 variant. There are corresponding #undefs below. */ 103178476Sjb 104178476Sjb#define ck_flags_t CK_FLAGS 105178476Sjb#define ck_version _CK_VERSION 106178476Sjb 107178476Sjb#define ck_info _CK_INFO 108178476Sjb#define cryptoki_version cryptokiVersion 109178476Sjb#define manufacturer_id manufacturerID 110178476Sjb#define library_description libraryDescription 111178476Sjb#define library_version libraryVersion 112178476Sjb 113178476Sjb#define ck_notification_t CK_NOTIFICATION 114178476Sjb#define ck_slot_id_t CK_SLOT_ID 115178476Sjb 116178476Sjb#define ck_slot_info _CK_SLOT_INFO 117178537Sjb#define slot_description slotDescription 118178476Sjb#define hardware_version hardwareVersion 119178476Sjb#define firmware_version firmwareVersion 120178476Sjb 121178476Sjb#define ck_token_info _CK_TOKEN_INFO 122178476Sjb#define serial_number serialNumber 123178476Sjb#define max_session_count ulMaxSessionCount 124178476Sjb#define session_count ulSessionCount 125178476Sjb#define max_rw_session_count ulMaxRwSessionCount 126178476Sjb#define rw_session_count ulRwSessionCount 127178476Sjb#define max_pin_len ulMaxPinLen 128178476Sjb#define min_pin_len ulMinPinLen 129178476Sjb#define total_public_memory ulTotalPublicMemory 130178476Sjb#define free_public_memory ulFreePublicMemory 131178476Sjb#define total_private_memory ulTotalPrivateMemory 132178476Sjb#define free_private_memory ulFreePrivateMemory 133178476Sjb#define utc_time utcTime 134178476Sjb 135178476Sjb#define ck_session_handle_t CK_SESSION_HANDLE 136178476Sjb#define ck_user_type_t CK_USER_TYPE 137178476Sjb#define ck_state_t CK_STATE 138178476Sjb 139178476Sjb#define ck_session_info _CK_SESSION_INFO 140178476Sjb#define slot_id slotID 141178476Sjb#define device_error ulDeviceError 142178476Sjb 143178476Sjb#define ck_object_handle_t CK_OBJECT_HANDLE 144178476Sjb#define ck_object_class_t CK_OBJECT_CLASS 145178476Sjb#define ck_hw_feature_type_t CK_HW_FEATURE_TYPE 146178476Sjb#define ck_key_type_t CK_KEY_TYPE 147178476Sjb#define ck_certificate_type_t CK_CERTIFICATE_TYPE 148178476Sjb#define ck_attribute_type_t CK_ATTRIBUTE_TYPE 149178476Sjb 150178476Sjb#define ck_attribute _CK_ATTRIBUTE 151178476Sjb#define value pValue 152178476Sjb#define value_len ulValueLen 153178476Sjb 154178476Sjb#define ck_date _CK_DATE 155178476Sjb 156178476Sjb#define ck_mechanism_type_t CK_MECHANISM_TYPE 157178476Sjb 158178476Sjb#define ck_mechanism _CK_MECHANISM 159178476Sjb#define parameter pParameter 160178476Sjb#define parameter_len ulParameterLen 161178476Sjb 162178476Sjb#define ck_mechanism_info _CK_MECHANISM_INFO 163178476Sjb#define min_key_size ulMinKeySize 164178476Sjb#define max_key_size ulMaxKeySize 165178476Sjb 166178476Sjb#define ck_rv_t CK_RV 167178476Sjb#define ck_notify_t CK_NOTIFY 168178476Sjb 169178476Sjb#define ck_function_list _CK_FUNCTION_LIST 170178476Sjb 171178476Sjb#define ck_createmutex_t CK_CREATEMUTEX 172178476Sjb#define ck_destroymutex_t CK_DESTROYMUTEX 173178476Sjb#define ck_lockmutex_t CK_LOCKMUTEX 174178476Sjb#define ck_unlockmutex_t CK_UNLOCKMUTEX 175178476Sjb 176178476Sjb#define ck_c_initialize_args _CK_C_INITIALIZE_ARGS 177178476Sjb#define create_mutex CreateMutex 178178476Sjb#define destroy_mutex DestroyMutex 179178476Sjb#define lock_mutex LockMutex 180178476Sjb#define unlock_mutex UnlockMutex 181178476Sjb#define reserved pReserved 182178476Sjb 183178476Sjb#endif /* CRYPTOKI_COMPAT */ 184178476Sjb 185178476Sjb 186178476Sjb 187178476Sjbtypedef unsigned long ck_flags_t; 188178476Sjb 189178476Sjbstruct ck_version 190178476Sjb{ 191178476Sjb unsigned char major; 192178476Sjb unsigned char minor; 193178476Sjb}; 194178476Sjb 195178476Sjb 196178476Sjbstruct ck_info 197178476Sjb{ 198178476Sjb struct ck_version cryptoki_version; 199178476Sjb unsigned char manufacturer_id[32]; 200178476Sjb ck_flags_t flags; 201178476Sjb unsigned char library_description[32]; 202178476Sjb struct ck_version library_version; 203178476Sjb}; 204178476Sjb 205178537Sjb 206178537Sjbtypedef unsigned long ck_notification_t; 207178537Sjb 208178537Sjb#define CKN_SURRENDER (0) 209178476Sjb 210178476Sjb 211178476Sjbtypedef unsigned long ck_slot_id_t; 212178476Sjb 213178476Sjb 214178476Sjbstruct ck_slot_info 215178476Sjb{ 216178476Sjb unsigned char slot_description[64]; 217178476Sjb unsigned char manufacturer_id[32]; 218178476Sjb ck_flags_t flags; 219178476Sjb struct ck_version hardware_version; 220178476Sjb struct ck_version firmware_version; 221178476Sjb}; 222178476Sjb 223178476Sjb 224178476Sjb#define CKF_TOKEN_PRESENT (1 << 0) 225178476Sjb#define CKF_REMOVABLE_DEVICE (1 << 1) 226178537Sjb#define CKF_HW_SLOT (1 << 2) 227178537Sjb#define CKF_ARRAY_ATTRIBUTE (1 << 30) 228178537Sjb 229178537Sjb 230178537Sjbstruct ck_token_info 231178476Sjb{ 232178476Sjb unsigned char label[32]; 233178476Sjb unsigned char manufacturer_id[32]; 234178476Sjb unsigned char model[16]; 235178476Sjb unsigned char serial_number[16]; 236178476Sjb ck_flags_t flags; 237178476Sjb unsigned long max_session_count; 238178476Sjb unsigned long session_count; 239178476Sjb unsigned long max_rw_session_count; 240178476Sjb unsigned long rw_session_count; 241178476Sjb unsigned long max_pin_len; 242178476Sjb unsigned long min_pin_len; 243178476Sjb unsigned long total_public_memory; 244178476Sjb unsigned long free_public_memory; 245178476Sjb unsigned long total_private_memory; 246178476Sjb unsigned long free_private_memory; 247178476Sjb struct ck_version hardware_version; 248178476Sjb struct ck_version firmware_version; 249178476Sjb unsigned char utc_time[16]; 250178476Sjb}; 251178476Sjb 252178476Sjb 253178476Sjb#define CKF_RNG (1 << 0) 254178476Sjb#define CKF_WRITE_PROTECTED (1 << 1) 255178476Sjb#define CKF_LOGIN_REQUIRED (1 << 2) 256178476Sjb#define CKF_USER_PIN_INITIALIZED (1 << 3) 257178476Sjb#define CKF_RESTORE_KEY_NOT_NEEDED (1 << 5) 258178476Sjb#define CKF_CLOCK_ON_TOKEN (1 << 6) 259178476Sjb#define CKF_PROTECTED_AUTHENTICATION_PATH (1 << 8) 260178476Sjb#define CKF_DUAL_CRYPTO_OPERATIONS (1 << 9) 261178476Sjb#define CKF_TOKEN_INITIALIZED (1 << 10) 262178476Sjb#define CKF_SECONDARY_AUTHENTICATION (1 << 11) 263178476Sjb#define CKF_USER_PIN_COUNT_LOW (1 << 16) 264178476Sjb#define CKF_USER_PIN_FINAL_TRY (1 << 17) 265178476Sjb#define CKF_USER_PIN_LOCKED (1 << 18) 266178476Sjb#define CKF_USER_PIN_TO_BE_CHANGED (1 << 19) 267178476Sjb#define CKF_SO_PIN_COUNT_LOW (1 << 20) 268178476Sjb#define CKF_SO_PIN_FINAL_TRY (1 << 21) 269178476Sjb#define CKF_SO_PIN_LOCKED (1 << 22) 270178476Sjb#define CKF_SO_PIN_TO_BE_CHANGED (1 << 23) 271178476Sjb 272178476Sjb#define CK_UNAVAILABLE_INFORMATION ((unsigned long) -1) 273178476Sjb#define CK_EFFECTIVELY_INFINITE (0) 274178476Sjb 275178476Sjb 276178476Sjbtypedef unsigned long ck_session_handle_t; 277178476Sjb 278178476Sjb#define CK_INVALID_HANDLE (0) 279178476Sjb 280178476Sjb 281178476Sjbtypedef unsigned long ck_user_type_t; 282178476Sjb 283178476Sjb#define CKU_SO (0) 284178476Sjb#define CKU_USER (1) 285178476Sjb#define CKU_CONTEXT_SPECIFIC (2) 286178476Sjb 287178476Sjb 288178476Sjbtypedef unsigned long ck_state_t; 289178476Sjb 290178476Sjb#define CKS_RO_PUBLIC_SESSION (0) 291178476Sjb#define CKS_RO_USER_FUNCTIONS (1) 292178476Sjb#define CKS_RW_PUBLIC_SESSION (2) 293178476Sjb#define CKS_RW_USER_FUNCTIONS (3) 294178476Sjb#define CKS_RW_SO_FUNCTIONS (4) 295178476Sjb 296178476Sjb 297178476Sjbstruct ck_session_info 298178476Sjb{ 299178476Sjb ck_slot_id_t slot_id; 300178476Sjb ck_state_t state; 301178476Sjb ck_flags_t flags; 302178476Sjb unsigned long device_error; 303178476Sjb}; 304178476Sjb 305178476Sjb#define CKF_RW_SESSION (1 << 1) 306178476Sjb#define CKF_SERIAL_SESSION (1 << 2) 307178476Sjb 308178476Sjb 309178476Sjbtypedef unsigned long ck_object_handle_t; 310178476Sjb 311178476Sjb 312178476Sjbtypedef unsigned long ck_object_class_t; 313178476Sjb 314178476Sjb#define CKO_DATA (0) 315178476Sjb#define CKO_CERTIFICATE (1) 316178476Sjb#define CKO_PUBLIC_KEY (2) 317178476Sjb#define CKO_PRIVATE_KEY (3) 318178476Sjb#define CKO_SECRET_KEY (4) 319178476Sjb#define CKO_HW_FEATURE (5) 320178476Sjb#define CKO_DOMAIN_PARAMETERS (6) 321178476Sjb#define CKO_MECHANISM (7) 322178476Sjb#define CKO_VENDOR_DEFINED ((unsigned long) (1 << 31)) 323178476Sjb 324178476Sjb 325178476Sjbtypedef unsigned long ck_hw_feature_type_t; 326178476Sjb 327178476Sjb#define CKH_MONOTONIC_COUNTER (1) 328178476Sjb#define CKH_CLOCK (2) 329178476Sjb#define CKH_USER_INTERFACE (3) 330178476Sjb#define CKH_VENDOR_DEFINED ((unsigned long) (1 << 31)) 331178476Sjb 332178476Sjb 333178476Sjbtypedef unsigned long ck_key_type_t; 334178476Sjb 335178476Sjb#define CKK_RSA (0) 336178476Sjb#define CKK_DSA (1) 337178476Sjb#define CKK_DH (2) 338178476Sjb#define CKK_ECDSA (3) 339178476Sjb#define CKK_EC (3) 340178476Sjb#define CKK_X9_42_DH (4) 341178476Sjb#define CKK_KEA (5) 342178476Sjb#define CKK_GENERIC_SECRET (0x10) 343178476Sjb#define CKK_RC2 (0x11) 344178476Sjb#define CKK_RC4 (0x12) 345178476Sjb#define CKK_DES (0x13) 346178476Sjb#define CKK_DES2 (0x14) 347178476Sjb#define CKK_DES3 (0x15) 348178476Sjb#define CKK_CAST (0x16) 349178476Sjb#define CKK_CAST3 (0x17) 350178476Sjb#define CKK_CAST128 (0x18) 351178476Sjb#define CKK_RC5 (0x19) 352178476Sjb#define CKK_IDEA (0x1a) 353178476Sjb#define CKK_SKIPJACK (0x1b) 354178476Sjb#define CKK_BATON (0x1c) 355178476Sjb#define CKK_JUNIPER (0x1d) 356178476Sjb#define CKK_CDMF (0x1e) 357178476Sjb#define CKK_AES (0x1f) 358178476Sjb#define CKK_BLOWFISH (0x20) 359178476Sjb#define CKK_TWOFISH (0x21) 360178476Sjb#define CKK_VENDOR_DEFINED ((unsigned long) (1 << 31)) 361178476Sjb 362178476Sjbtypedef unsigned long ck_certificate_type_t; 363178476Sjb 364178476Sjb#define CKC_X_509 (0) 365178476Sjb#define CKC_X_509_ATTR_CERT (1) 366178476Sjb#define CKC_WTLS (2) 367178476Sjb#define CKC_VENDOR_DEFINED ((unsigned long) (1 << 31)) 368178476Sjb 369178476Sjb 370178476Sjbtypedef unsigned long ck_attribute_type_t; 371178476Sjb 372178476Sjb#define CKA_CLASS (0) 373178476Sjb#define CKA_TOKEN (1) 374178476Sjb#define CKA_PRIVATE (2) 375178476Sjb#define CKA_LABEL (3) 376178476Sjb#define CKA_APPLICATION (0x10) 377178476Sjb#define CKA_VALUE (0x11) 378178476Sjb#define CKA_OBJECT_ID (0x12) 379178476Sjb#define CKA_CERTIFICATE_TYPE (0x80) 380178476Sjb#define CKA_ISSUER (0x81) 381178476Sjb#define CKA_SERIAL_NUMBER (0x82) 382178476Sjb#define CKA_AC_ISSUER (0x83) 383178476Sjb#define CKA_OWNER (0x84) 384178476Sjb#define CKA_ATTR_TYPES (0x85) 385178476Sjb#define CKA_TRUSTED (0x86) 386178476Sjb#define CKA_CERTIFICATE_CATEGORY (0x87) 387178476Sjb#define CKA_JAVA_MIDP_SECURITY_DOMAIN (0x88) 388178476Sjb#define CKA_URL (0x89) 389178476Sjb#define CKA_HASH_OF_SUBJECT_PUBLIC_KEY (0x8a) 390178476Sjb#define CKA_HASH_OF_ISSUER_PUBLIC_KEY (0x8b) 391178537Sjb#define CKA_CHECK_VALUE (0x90) 392178476Sjb#define CKA_KEY_TYPE (0x100) 393178476Sjb#define CKA_SUBJECT (0x101) 394178476Sjb#define CKA_ID (0x102) 395178476Sjb#define CKA_SENSITIVE (0x103) 396178476Sjb#define CKA_ENCRYPT (0x104) 397178476Sjb#define CKA_DECRYPT (0x105) 398178476Sjb#define CKA_WRAP (0x106) 399178476Sjb#define CKA_UNWRAP (0x107) 400178476Sjb#define CKA_SIGN (0x108) 401178476Sjb#define CKA_SIGN_RECOVER (0x109) 402178476Sjb#define CKA_VERIFY (0x10a) 403178476Sjb#define CKA_VERIFY_RECOVER (0x10b) 404178476Sjb#define CKA_DERIVE (0x10c) 405178476Sjb#define CKA_START_DATE (0x110) 406178476Sjb#define CKA_END_DATE (0x111) 407178476Sjb#define CKA_MODULUS (0x120) 408178476Sjb#define CKA_MODULUS_BITS (0x121) 409178476Sjb#define CKA_PUBLIC_EXPONENT (0x122) 410178476Sjb#define CKA_PRIVATE_EXPONENT (0x123) 411178476Sjb#define CKA_PRIME_1 (0x124) 412178476Sjb#define CKA_PRIME_2 (0x125) 413178476Sjb#define CKA_EXPONENT_1 (0x126) 414178476Sjb#define CKA_EXPONENT_2 (0x127) 415178476Sjb#define CKA_COEFFICIENT (0x128) 416178476Sjb#define CKA_PRIME (0x130) 417178476Sjb#define CKA_SUBPRIME (0x131) 418178476Sjb#define CKA_BASE (0x132) 419178476Sjb#define CKA_PRIME_BITS (0x133) 420178476Sjb#define CKA_SUB_PRIME_BITS (0x134) 421178476Sjb#define CKA_VALUE_BITS (0x160) 422178476Sjb#define CKA_VALUE_LEN (0x161) 423178476Sjb#define CKA_EXTRACTABLE (0x162) 424178476Sjb#define CKA_LOCAL (0x163) 425178476Sjb#define CKA_NEVER_EXTRACTABLE (0x164) 426178476Sjb#define CKA_ALWAYS_SENSITIVE (0x165) 427178476Sjb#define CKA_KEY_GEN_MECHANISM (0x166) 428178476Sjb#define CKA_MODIFIABLE (0x170) 429178476Sjb#define CKA_ECDSA_PARAMS (0x180) 430178476Sjb#define CKA_EC_PARAMS (0x180) 431178476Sjb#define CKA_EC_POINT (0x181) 432178476Sjb#define CKA_SECONDARY_AUTH (0x200) 433178476Sjb#define CKA_AUTH_PIN_FLAGS (0x201) 434178476Sjb#define CKA_ALWAYS_AUTHENTICATE (0x202) 435178476Sjb#define CKA_WRAP_WITH_TRUSTED (0x210) 436178476Sjb#define CKA_HW_FEATURE_TYPE (0x300) 437178476Sjb#define CKA_RESET_ON_INIT (0x301) 438178476Sjb#define CKA_HAS_RESET (0x302) 439178476Sjb#define CKA_PIXEL_X (0x400) 440178476Sjb#define CKA_PIXEL_Y (0x401) 441178476Sjb#define CKA_RESOLUTION (0x402) 442178476Sjb#define CKA_CHAR_ROWS (0x403) 443178476Sjb#define CKA_CHAR_COLUMNS (0x404) 444178476Sjb#define CKA_COLOR (0x405) 445178476Sjb#define CKA_BITS_PER_PIXEL (0x406) 446178476Sjb#define CKA_CHAR_SETS (0x480) 447178476Sjb#define CKA_ENCODING_METHODS (0x481) 448178476Sjb#define CKA_MIME_TYPES (0x482) 449178476Sjb#define CKA_MECHANISM_TYPE (0x500) 450178476Sjb#define CKA_REQUIRED_CMS_ATTRIBUTES (0x501) 451178476Sjb#define CKA_DEFAULT_CMS_ATTRIBUTES (0x502) 452178476Sjb#define CKA_SUPPORTED_CMS_ATTRIBUTES (0x503) 453178476Sjb#define CKA_WRAP_TEMPLATE (CKF_ARRAY_ATTRIBUTE | 0x211) 454178476Sjb#define CKA_UNWRAP_TEMPLATE (CKF_ARRAY_ATTRIBUTE | 0x212) 455178476Sjb#define CKA_ALLOWED_MECHANISMS (CKF_ARRAY_ATTRIBUTE | 0x600) 456178476Sjb#define CKA_VENDOR_DEFINED ((unsigned long) (1 << 31)) 457178476Sjb 458178476Sjb 459178476Sjbstruct ck_attribute 460178476Sjb{ 461178476Sjb ck_attribute_type_t type; 462178476Sjb void *value; 463178476Sjb unsigned long value_len; 464178476Sjb}; 465178476Sjb 466178476Sjb 467178476Sjbstruct ck_date 468178476Sjb{ 469178476Sjb unsigned char year[4]; 470178476Sjb unsigned char month[2]; 471178476Sjb unsigned char day[2]; 472178476Sjb}; 473178476Sjb 474178476Sjb 475178476Sjbtypedef unsigned long ck_mechanism_type_t; 476178476Sjb 477178476Sjb#define CKM_RSA_PKCS_KEY_PAIR_GEN (0) 478178476Sjb#define CKM_RSA_PKCS (1) 479178476Sjb#define CKM_RSA_9796 (2) 480178476Sjb#define CKM_RSA_X_509 (3) 481178476Sjb#define CKM_MD2_RSA_PKCS (4) 482178476Sjb#define CKM_MD5_RSA_PKCS (5) 483178476Sjb#define CKM_SHA1_RSA_PKCS (6) 484178476Sjb#define CKM_RIPEMD128_RSA_PKCS (7) 485178476Sjb#define CKM_RIPEMD160_RSA_PKCS (8) 486178476Sjb#define CKM_RSA_PKCS_OAEP (9) 487178476Sjb#define CKM_RSA_X9_31_KEY_PAIR_GEN (0xa) 488178476Sjb#define CKM_RSA_X9_31 (0xb) 489178476Sjb#define CKM_SHA1_RSA_X9_31 (0xc) 490178476Sjb#define CKM_RSA_PKCS_PSS (0xd) 491178476Sjb#define CKM_SHA1_RSA_PKCS_PSS (0xe) 492178476Sjb#define CKM_DSA_KEY_PAIR_GEN (0x10) 493178476Sjb#define CKM_DSA (0x11) 494178476Sjb#define CKM_DSA_SHA1 (0x12) 495178476Sjb#define CKM_DH_PKCS_KEY_PAIR_GEN (0x20) 496178476Sjb#define CKM_DH_PKCS_DERIVE (0x21) 497178476Sjb#define CKM_X9_42_DH_KEY_PAIR_GEN (0x30) 498178476Sjb#define CKM_X9_42_DH_DERIVE (0x31) 499178476Sjb#define CKM_X9_42_DH_HYBRID_DERIVE (0x32) 500178476Sjb#define CKM_X9_42_MQV_DERIVE (0x33) 501178476Sjb#define CKM_SHA256_RSA_PKCS (0x40) 502178537Sjb#define CKM_SHA384_RSA_PKCS (0x41) 503178476Sjb#define CKM_SHA512_RSA_PKCS (0x42) 504178476Sjb#define CKM_SHA256_RSA_PKCS_PSS (0x43) 505178476Sjb#define CKM_SHA384_RSA_PKCS_PSS (0x44) 506178476Sjb#define CKM_SHA512_RSA_PKCS_PSS (0x45) 507178476Sjb#define CKM_RC2_KEY_GEN (0x100) 508178476Sjb#define CKM_RC2_ECB (0x101) 509178476Sjb#define CKM_RC2_CBC (0x102) 510178476Sjb#define CKM_RC2_MAC (0x103) 511178476Sjb#define CKM_RC2_MAC_GENERAL (0x104) 512178476Sjb#define CKM_RC2_CBC_PAD (0x105) 513178476Sjb#define CKM_RC4_KEY_GEN (0x110) 514178476Sjb#define CKM_RC4 (0x111) 515178476Sjb#define CKM_DES_KEY_GEN (0x120) 516178476Sjb#define CKM_DES_ECB (0x121) 517178476Sjb#define CKM_DES_CBC (0x122) 518178476Sjb#define CKM_DES_MAC (0x123) 519178476Sjb#define CKM_DES_MAC_GENERAL (0x124) 520178476Sjb#define CKM_DES_CBC_PAD (0x125) 521178476Sjb#define CKM_DES2_KEY_GEN (0x130) 522178476Sjb#define CKM_DES3_KEY_GEN (0x131) 523178476Sjb#define CKM_DES3_ECB (0x132) 524178476Sjb#define CKM_DES3_CBC (0x133) 525178476Sjb#define CKM_DES3_MAC (0x134) 526178476Sjb#define CKM_DES3_MAC_GENERAL (0x135) 527178476Sjb#define CKM_DES3_CBC_PAD (0x136) 528178476Sjb#define CKM_CDMF_KEY_GEN (0x140) 529178476Sjb#define CKM_CDMF_ECB (0x141) 530178476Sjb#define CKM_CDMF_CBC (0x142) 531178476Sjb#define CKM_CDMF_MAC (0x143) 532178476Sjb#define CKM_CDMF_MAC_GENERAL (0x144) 533178476Sjb#define CKM_CDMF_CBC_PAD (0x145) 534178476Sjb#define CKM_MD2 (0x200) 535178476Sjb#define CKM_MD2_HMAC (0x201) 536178476Sjb#define CKM_MD2_HMAC_GENERAL (0x202) 537178476Sjb#define CKM_MD5 (0x210) 538178476Sjb#define CKM_MD5_HMAC (0x211) 539178476Sjb#define CKM_MD5_HMAC_GENERAL (0x212) 540178476Sjb#define CKM_SHA_1 (0x220) 541178476Sjb#define CKM_SHA_1_HMAC (0x221) 542178476Sjb#define CKM_SHA_1_HMAC_GENERAL (0x222) 543178476Sjb#define CKM_RIPEMD128 (0x230) 544178476Sjb#define CKM_RIPEMD128_HMAC (0x231) 545178476Sjb#define CKM_RIPEMD128_HMAC_GENERAL (0x232) 546178476Sjb#define CKM_RIPEMD160 (0x240) 547178476Sjb#define CKM_RIPEMD160_HMAC (0x241) 548178476Sjb#define CKM_RIPEMD160_HMAC_GENERAL (0x242) 549178476Sjb#define CKM_SHA256 (0x250) 550178476Sjb#define CKM_SHA256_HMAC (0x251) 551178476Sjb#define CKM_SHA256_HMAC_GENERAL (0x252) 552178476Sjb#define CKM_SHA384 (0x260) 553178476Sjb#define CKM_SHA384_HMAC (0x261) 554178476Sjb#define CKM_SHA384_HMAC_GENERAL (0x262) 555178476Sjb#define CKM_SHA512 (0x270) 556178476Sjb#define CKM_SHA512_HMAC (0x271) 557178476Sjb#define CKM_SHA512_HMAC_GENERAL (0x272) 558178476Sjb#define CKM_CAST_KEY_GEN (0x300) 559178476Sjb#define CKM_CAST_ECB (0x301) 560178476Sjb#define CKM_CAST_CBC (0x302) 561178476Sjb#define CKM_CAST_MAC (0x303) 562178476Sjb#define CKM_CAST_MAC_GENERAL (0x304) 563178476Sjb#define CKM_CAST_CBC_PAD (0x305) 564178476Sjb#define CKM_CAST3_KEY_GEN (0x310) 565178476Sjb#define CKM_CAST3_ECB (0x311) 566178476Sjb#define CKM_CAST3_CBC (0x312) 567178476Sjb#define CKM_CAST3_MAC (0x313) 568178476Sjb#define CKM_CAST3_MAC_GENERAL (0x314) 569178476Sjb#define CKM_CAST3_CBC_PAD (0x315) 570178476Sjb#define CKM_CAST5_KEY_GEN (0x320) 571178476Sjb#define CKM_CAST128_KEY_GEN (0x320) 572178476Sjb#define CKM_CAST5_ECB (0x321) 573178476Sjb#define CKM_CAST128_ECB (0x321) 574178476Sjb#define CKM_CAST5_CBC (0x322) 575178476Sjb#define CKM_CAST128_CBC (0x322) 576178476Sjb#define CKM_CAST5_MAC (0x323) 577178476Sjb#define CKM_CAST128_MAC (0x323) 578178476Sjb#define CKM_CAST5_MAC_GENERAL (0x324) 579178476Sjb#define CKM_CAST128_MAC_GENERAL (0x324) 580178476Sjb#define CKM_CAST5_CBC_PAD (0x325) 581178476Sjb#define CKM_CAST128_CBC_PAD (0x325) 582178476Sjb#define CKM_RC5_KEY_GEN (0x330) 583178476Sjb#define CKM_RC5_ECB (0x331) 584178476Sjb#define CKM_RC5_CBC (0x332) 585178476Sjb#define CKM_RC5_MAC (0x333) 586178476Sjb#define CKM_RC5_MAC_GENERAL (0x334) 587178476Sjb#define CKM_RC5_CBC_PAD (0x335) 588178476Sjb#define CKM_IDEA_KEY_GEN (0x340) 589178476Sjb#define CKM_IDEA_ECB (0x341) 590178476Sjb#define CKM_IDEA_CBC (0x342) 591178476Sjb#define CKM_IDEA_MAC (0x343) 592178476Sjb#define CKM_IDEA_MAC_GENERAL (0x344) 593178476Sjb#define CKM_IDEA_CBC_PAD (0x345) 594178476Sjb#define CKM_GENERIC_SECRET_KEY_GEN (0x350) 595178476Sjb#define CKM_CONCATENATE_BASE_AND_KEY (0x360) 596178476Sjb#define CKM_CONCATENATE_BASE_AND_DATA (0x362) 597178476Sjb#define CKM_CONCATENATE_DATA_AND_BASE (0x363) 598178476Sjb#define CKM_XOR_BASE_AND_DATA (0x364) 599178476Sjb#define CKM_EXTRACT_KEY_FROM_KEY (0x365) 600178476Sjb#define CKM_SSL3_PRE_MASTER_KEY_GEN (0x370) 601178476Sjb#define CKM_SSL3_MASTER_KEY_DERIVE (0x371) 602178476Sjb#define CKM_SSL3_KEY_AND_MAC_DERIVE (0x372) 603178476Sjb#define CKM_SSL3_MASTER_KEY_DERIVE_DH (0x373) 604178476Sjb#define CKM_TLS_PRE_MASTER_KEY_GEN (0x374) 605178476Sjb#define CKM_TLS_MASTER_KEY_DERIVE (0x375) 606178476Sjb#define CKM_TLS_KEY_AND_MAC_DERIVE (0x376) 607178476Sjb#define CKM_TLS_MASTER_KEY_DERIVE_DH (0x377) 608178476Sjb#define CKM_SSL3_MD5_MAC (0x380) 609178476Sjb#define CKM_SSL3_SHA1_MAC (0x381) 610178476Sjb#define CKM_MD5_KEY_DERIVATION (0x390) 611178476Sjb#define CKM_MD2_KEY_DERIVATION (0x391) 612178476Sjb#define CKM_SHA1_KEY_DERIVATION (0x392) 613178476Sjb#define CKM_PBE_MD2_DES_CBC (0x3a0) 614178476Sjb#define CKM_PBE_MD5_DES_CBC (0x3a1) 615178476Sjb#define CKM_PBE_MD5_CAST_CBC (0x3a2) 616178476Sjb#define CKM_PBE_MD5_CAST3_CBC (0x3a3) 617178476Sjb#define CKM_PBE_MD5_CAST5_CBC (0x3a4) 618178476Sjb#define CKM_PBE_MD5_CAST128_CBC (0x3a4) 619178476Sjb#define CKM_PBE_SHA1_CAST5_CBC (0x3a5) 620178476Sjb#define CKM_PBE_SHA1_CAST128_CBC (0x3a5) 621178476Sjb#define CKM_PBE_SHA1_RC4_128 (0x3a6) 622178476Sjb#define CKM_PBE_SHA1_RC4_40 (0x3a7) 623178476Sjb#define CKM_PBE_SHA1_DES3_EDE_CBC (0x3a8) 624178476Sjb#define CKM_PBE_SHA1_DES2_EDE_CBC (0x3a9) 625178476Sjb#define CKM_PBE_SHA1_RC2_128_CBC (0x3aa) 626178476Sjb#define CKM_PBE_SHA1_RC2_40_CBC (0x3ab) 627178476Sjb#define CKM_PKCS5_PBKD2 (0x3b0) 628178476Sjb#define CKM_PBA_SHA1_WITH_SHA1_HMAC (0x3c0) 629178476Sjb#define CKM_KEY_WRAP_LYNKS (0x400) 630178476Sjb#define CKM_KEY_WRAP_SET_OAEP (0x401) 631178476Sjb#define CKM_SKIPJACK_KEY_GEN (0x1000) 632178537Sjb#define CKM_SKIPJACK_ECB64 (0x1001) 633178476Sjb#define CKM_SKIPJACK_CBC64 (0x1002) 634178476Sjb#define CKM_SKIPJACK_OFB64 (0x1003) 635178476Sjb#define CKM_SKIPJACK_CFB64 (0x1004) 636178476Sjb#define CKM_SKIPJACK_CFB32 (0x1005) 637178476Sjb#define CKM_SKIPJACK_CFB16 (0x1006) 638178476Sjb#define CKM_SKIPJACK_CFB8 (0x1007) 639178537Sjb#define CKM_SKIPJACK_WRAP (0x1008) 640178537Sjb#define CKM_SKIPJACK_PRIVATE_WRAP (0x1009) 641178537Sjb#define CKM_SKIPJACK_RELAYX (0x100a) 642178537Sjb#define CKM_KEA_KEY_PAIR_GEN (0x1010) 643178537Sjb#define CKM_KEA_KEY_DERIVE (0x1011) 644178537Sjb#define CKM_FORTEZZA_TIMESTAMP (0x1020) 645178537Sjb#define CKM_BATON_KEY_GEN (0x1030) 646178537Sjb#define CKM_BATON_ECB128 (0x1031) 647178537Sjb#define CKM_BATON_ECB96 (0x1032) 648178537Sjb#define CKM_BATON_CBC128 (0x1033) 649178537Sjb#define CKM_BATON_COUNTER (0x1034) 650178537Sjb#define CKM_BATON_SHUFFLE (0x1035) 651178537Sjb#define CKM_BATON_WRAP (0x1036) 652178476Sjb#define CKM_ECDSA_KEY_PAIR_GEN (0x1040) 653178476Sjb#define CKM_EC_KEY_PAIR_GEN (0x1040) 654178476Sjb#define CKM_ECDSA (0x1041) 655178476Sjb#define CKM_ECDSA_SHA1 (0x1042) 656178476Sjb#define CKM_ECDH1_DERIVE (0x1050) 657178476Sjb#define CKM_ECDH1_COFACTOR_DERIVE (0x1051) 658178476Sjb#define CKM_ECMQV_DERIVE (0x1052) 659178476Sjb#define CKM_JUNIPER_KEY_GEN (0x1060) 660178476Sjb#define CKM_JUNIPER_ECB128 (0x1061) 661178476Sjb#define CKM_JUNIPER_CBC128 (0x1062) 662178476Sjb#define CKM_JUNIPER_COUNTER (0x1063) 663178476Sjb#define CKM_JUNIPER_SHUFFLE (0x1064) 664178476Sjb#define CKM_JUNIPER_WRAP (0x1065) 665178476Sjb#define CKM_FASTHASH (0x1070) 666178476Sjb#define CKM_AES_KEY_GEN (0x1080) 667178476Sjb#define CKM_AES_ECB (0x1081) 668178476Sjb#define CKM_AES_CBC (0x1082) 669178476Sjb#define CKM_AES_MAC (0x1083) 670178476Sjb#define CKM_AES_MAC_GENERAL (0x1084) 671178476Sjb#define CKM_AES_CBC_PAD (0x1085) 672178476Sjb#define CKM_DSA_PARAMETER_GEN (0x2000) 673178476Sjb#define CKM_DH_PKCS_PARAMETER_GEN (0x2001) 674178476Sjb#define CKM_X9_42_DH_PARAMETER_GEN (0x2002) 675178476Sjb#define CKM_VENDOR_DEFINED ((unsigned long) (1 << 31)) 676178476Sjb 677178476Sjb 678178476Sjbstruct ck_mechanism 679178476Sjb{ 680178476Sjb ck_mechanism_type_t mechanism; 681178476Sjb void *parameter; 682178476Sjb unsigned long parameter_len; 683178476Sjb}; 684178476Sjb 685178476Sjb 686178476Sjbstruct ck_mechanism_info 687178476Sjb{ 688178476Sjb unsigned long min_key_size; 689178476Sjb unsigned long max_key_size; 690178476Sjb ck_flags_t flags; 691178476Sjb}; 692178476Sjb 693178476Sjb#define CKF_HW (1 << 0) 694178476Sjb#define CKF_ENCRYPT (1 << 8) 695178476Sjb#define CKF_DECRYPT (1 << 9) 696178476Sjb#define CKF_DIGEST (1 << 10) 697178476Sjb#define CKF_SIGN (1 << 11) 698178476Sjb#define CKF_SIGN_RECOVER (1 << 12) 699178476Sjb#define CKF_VERIFY (1 << 13) 700178476Sjb#define CKF_VERIFY_RECOVER (1 << 14) 701178476Sjb#define CKF_GENERATE (1 << 15) 702178476Sjb#define CKF_GENERATE_KEY_PAIR (1 << 16) 703178476Sjb#define CKF_WRAP (1 << 17) 704178476Sjb#define CKF_UNWRAP (1 << 18) 705178476Sjb#define CKF_DERIVE (1 << 19) 706178476Sjb#define CKF_EXTENSION ((unsigned long) (1 << 31)) 707178476Sjb 708178476Sjb 709178476Sjb/* Flags for C_WaitForSlotEvent. */ 710178476Sjb#define CKF_DONT_BLOCK (1) 711178476Sjb 712178476Sjb 713178476Sjbtypedef unsigned long ck_rv_t; 714178476Sjb 715178476Sjb 716178476Sjbtypedef ck_rv_t (*ck_notify_t) (ck_session_handle_t session, 717178476Sjb ck_notification_t event, void *application); 718178476Sjb 719178476Sjb/* Forward reference. */ 720178476Sjbstruct ck_function_list; 721178476Sjb 722178476Sjb#define _CK_DECLARE_FUNCTION(name, args) \ 723178476Sjbtypedef ck_rv_t (*CK_ ## name) args; \ 724178476Sjbck_rv_t CK_SPEC name args 725178476Sjb 726178476Sjb_CK_DECLARE_FUNCTION (C_Initialize, (void *init_args)); 727178476Sjb_CK_DECLARE_FUNCTION (C_Finalize, (void *reserved)); 728178476Sjb_CK_DECLARE_FUNCTION (C_GetInfo, (struct ck_info *info)); 729178476Sjb_CK_DECLARE_FUNCTION (C_GetFunctionList, 730178476Sjb (struct ck_function_list **function_list)); 731178476Sjb 732178476Sjb_CK_DECLARE_FUNCTION (C_GetSlotList, 733178476Sjb (unsigned char token_present, ck_slot_id_t *slot_list, 734178476Sjb unsigned long *count)); 735178476Sjb_CK_DECLARE_FUNCTION (C_GetSlotInfo, 736178476Sjb (ck_slot_id_t slot_id, struct ck_slot_info *info)); 737178476Sjb_CK_DECLARE_FUNCTION (C_GetTokenInfo, 738178476Sjb (ck_slot_id_t slot_id, struct ck_token_info *info)); 739178476Sjb_CK_DECLARE_FUNCTION (C_WaitForSlotEvent, 740178476Sjb (ck_flags_t flags, ck_slot_id_t *slot, void *reserved)); 741178476Sjb_CK_DECLARE_FUNCTION (C_GetMechanismList, 742178476Sjb (ck_slot_id_t slot_id, 743178476Sjb ck_mechanism_type_t *mechanism_list, 744178476Sjb unsigned long *count)); 745178476Sjb_CK_DECLARE_FUNCTION (C_GetMechanismInfo, 746178476Sjb (ck_slot_id_t slot_id, ck_mechanism_type_t type, 747178476Sjb struct ck_mechanism_info *info)); 748178476Sjb_CK_DECLARE_FUNCTION (C_InitToken, 749178476Sjb (ck_slot_id_t slot_id, unsigned char *pin, 750178476Sjb unsigned long pin_len, unsigned char *label)); 751178476Sjb_CK_DECLARE_FUNCTION (C_InitPIN, 752178476Sjb (ck_session_handle_t session, unsigned char *pin, 753178476Sjb unsigned long pin_len)); 754178476Sjb_CK_DECLARE_FUNCTION (C_SetPIN, 755178476Sjb (ck_session_handle_t session, unsigned char *old_pin, 756178476Sjb unsigned long old_len, unsigned char *new_pin, 757178476Sjb unsigned long new_len)); 758178476Sjb 759178476Sjb_CK_DECLARE_FUNCTION (C_OpenSession, 760178476Sjb (ck_slot_id_t slot_id, ck_flags_t flags, 761178476Sjb void *application, ck_notify_t notify, 762178476Sjb ck_session_handle_t *session)); 763178476Sjb_CK_DECLARE_FUNCTION (C_CloseSession, (ck_session_handle_t session)); 764178476Sjb_CK_DECLARE_FUNCTION (C_CloseAllSessions, (ck_slot_id_t slot_id)); 765178476Sjb_CK_DECLARE_FUNCTION (C_GetSessionInfo, 766178476Sjb (ck_session_handle_t session, 767178476Sjb struct ck_session_info *info)); 768178476Sjb_CK_DECLARE_FUNCTION (C_GetOperationState, 769178476Sjb (ck_session_handle_t session, 770178476Sjb unsigned char *operation_state, 771178476Sjb unsigned long *operation_state_len)); 772178476Sjb_CK_DECLARE_FUNCTION (C_SetOperationState, 773178476Sjb (ck_session_handle_t session, 774178476Sjb unsigned char *operation_state, 775178476Sjb unsigned long operation_state_len, 776178537Sjb ck_object_handle_t encryption_key, 777178537Sjb ck_object_handle_t authentiation_key)); 778178476Sjb_CK_DECLARE_FUNCTION (C_Login, 779178476Sjb (ck_session_handle_t session, ck_user_type_t user_type, 780178476Sjb unsigned char *pin, unsigned long pin_len)); 781178476Sjb_CK_DECLARE_FUNCTION (C_Logout, (ck_session_handle_t session)); 782178476Sjb 783178476Sjb_CK_DECLARE_FUNCTION (C_CreateObject, 784178476Sjb (ck_session_handle_t session, 785178476Sjb struct ck_attribute *templ, 786178476Sjb unsigned long count, ck_object_handle_t *object)); 787178476Sjb_CK_DECLARE_FUNCTION (C_CopyObject, 788178476Sjb (ck_session_handle_t session, ck_object_handle_t object, 789178476Sjb struct ck_attribute *templ, unsigned long count, 790178476Sjb ck_object_handle_t *new_object)); 791178476Sjb_CK_DECLARE_FUNCTION (C_DestroyObject, 792178476Sjb (ck_session_handle_t session, 793178476Sjb ck_object_handle_t object)); 794178476Sjb_CK_DECLARE_FUNCTION (C_GetObjectSize, 795178476Sjb (ck_session_handle_t session, 796178476Sjb ck_object_handle_t object, 797178476Sjb unsigned long *size)); 798178476Sjb_CK_DECLARE_FUNCTION (C_GetAttributeValue, 799178476Sjb (ck_session_handle_t session, 800178476Sjb ck_object_handle_t object, 801178476Sjb struct ck_attribute *templ, 802178476Sjb unsigned long count)); 803178476Sjb_CK_DECLARE_FUNCTION (C_SetAttributeValue, 804178476Sjb (ck_session_handle_t session, 805178476Sjb ck_object_handle_t object, 806178476Sjb struct ck_attribute *templ, 807178476Sjb unsigned long count)); 808178476Sjb_CK_DECLARE_FUNCTION (C_FindObjectsInit, 809178476Sjb (ck_session_handle_t session, 810178476Sjb struct ck_attribute *templ, 811178476Sjb unsigned long count)); 812178476Sjb_CK_DECLARE_FUNCTION (C_FindObjects, 813178476Sjb (ck_session_handle_t session, 814178476Sjb ck_object_handle_t *object, 815178537Sjb unsigned long max_object_count, 816178476Sjb unsigned long *object_count)); 817178476Sjb_CK_DECLARE_FUNCTION (C_FindObjectsFinal, 818178476Sjb (ck_session_handle_t session)); 819178476Sjb 820178476Sjb_CK_DECLARE_FUNCTION (C_EncryptInit, 821178476Sjb (ck_session_handle_t session, 822178476Sjb struct ck_mechanism *mechanism, 823178476Sjb ck_object_handle_t key)); 824178476Sjb_CK_DECLARE_FUNCTION (C_Encrypt, 825178476Sjb (ck_session_handle_t session, 826178476Sjb unsigned char *data, unsigned long data_len, 827178476Sjb unsigned char *encrypted_data, 828178476Sjb unsigned long *encrypted_data_len)); 829178476Sjb_CK_DECLARE_FUNCTION (C_EncryptUpdate, 830178476Sjb (ck_session_handle_t session, 831178476Sjb unsigned char *part, unsigned long part_len, 832178476Sjb unsigned char *encrypted_part, 833178476Sjb unsigned long *encrypted_part_len)); 834178476Sjb_CK_DECLARE_FUNCTION (C_EncryptFinal, 835178476Sjb (ck_session_handle_t session, 836178476Sjb unsigned char *last_encrypted_part, 837178476Sjb unsigned long *last_encrypted_part_len)); 838178476Sjb 839178476Sjb_CK_DECLARE_FUNCTION (C_DecryptInit, 840178476Sjb (ck_session_handle_t session, 841178476Sjb struct ck_mechanism *mechanism, 842178476Sjb ck_object_handle_t key)); 843178476Sjb_CK_DECLARE_FUNCTION (C_Decrypt, 844178476Sjb (ck_session_handle_t session, 845178476Sjb unsigned char *encrypted_data, 846178476Sjb unsigned long encrypted_data_len, 847178476Sjb unsigned char *data, unsigned long *data_len)); 848178476Sjb_CK_DECLARE_FUNCTION (C_DecryptUpdate, 849178476Sjb (ck_session_handle_t session, 850178476Sjb unsigned char *encrypted_part, 851178476Sjb unsigned long encrypted_part_len, 852178476Sjb unsigned char *part, unsigned long *part_len)); 853178476Sjb_CK_DECLARE_FUNCTION (C_DecryptFinal, 854178476Sjb (ck_session_handle_t session, 855178476Sjb unsigned char *last_part, 856178476Sjb unsigned long *last_part_len)); 857178476Sjb 858178476Sjb_CK_DECLARE_FUNCTION (C_DigestInit, 859178476Sjb (ck_session_handle_t session, 860178476Sjb struct ck_mechanism *mechanism)); 861178476Sjb_CK_DECLARE_FUNCTION (C_Digest, 862178476Sjb (ck_session_handle_t session, 863178476Sjb unsigned char *data, unsigned long data_len, 864178476Sjb unsigned char *digest, 865178476Sjb unsigned long *digest_len)); 866178476Sjb_CK_DECLARE_FUNCTION (C_DigestUpdate, 867178476Sjb (ck_session_handle_t session, 868178476Sjb unsigned char *part, unsigned long part_len)); 869178476Sjb_CK_DECLARE_FUNCTION (C_DigestKey, 870178476Sjb (ck_session_handle_t session, ck_object_handle_t key)); 871178476Sjb_CK_DECLARE_FUNCTION (C_DigestFinal, 872178476Sjb (ck_session_handle_t session, 873178476Sjb unsigned char *digest, 874178476Sjb unsigned long *digest_len)); 875178476Sjb 876178476Sjb_CK_DECLARE_FUNCTION (C_SignInit, 877178476Sjb (ck_session_handle_t session, 878178476Sjb struct ck_mechanism *mechanism, 879178476Sjb ck_object_handle_t key)); 880178476Sjb_CK_DECLARE_FUNCTION (C_Sign, 881178476Sjb (ck_session_handle_t session, 882178476Sjb unsigned char *data, unsigned long data_len, 883178476Sjb unsigned char *signature, 884178476Sjb unsigned long *signature_len)); 885178476Sjb_CK_DECLARE_FUNCTION (C_SignUpdate, 886178476Sjb (ck_session_handle_t session, 887178476Sjb unsigned char *part, unsigned long part_len)); 888178476Sjb_CK_DECLARE_FUNCTION (C_SignFinal, 889178476Sjb (ck_session_handle_t session, 890178476Sjb unsigned char *signature, 891178476Sjb unsigned long *signature_len)); 892178476Sjb_CK_DECLARE_FUNCTION (C_SignRecoverInit, 893178476Sjb (ck_session_handle_t session, 894178476Sjb struct ck_mechanism *mechanism, 895178476Sjb ck_object_handle_t key)); 896178476Sjb_CK_DECLARE_FUNCTION (C_SignRecover, 897178476Sjb (ck_session_handle_t session, 898178476Sjb unsigned char *data, unsigned long data_len, 899178476Sjb unsigned char *signature, 900178476Sjb unsigned long *signature_len)); 901178476Sjb 902178476Sjb_CK_DECLARE_FUNCTION (C_VerifyInit, 903178476Sjb (ck_session_handle_t session, 904178476Sjb struct ck_mechanism *mechanism, 905178476Sjb ck_object_handle_t key)); 906178476Sjb_CK_DECLARE_FUNCTION (C_Verify, 907178476Sjb (ck_session_handle_t session, 908178476Sjb unsigned char *data, unsigned long data_len, 909178476Sjb unsigned char *signature, 910178476Sjb unsigned long signature_len)); 911178476Sjb_CK_DECLARE_FUNCTION (C_VerifyUpdate, 912178476Sjb (ck_session_handle_t session, 913178476Sjb unsigned char *part, unsigned long part_len)); 914178476Sjb_CK_DECLARE_FUNCTION (C_VerifyFinal, 915178476Sjb (ck_session_handle_t session, 916178476Sjb unsigned char *signature, 917178476Sjb unsigned long signature_len)); 918178476Sjb_CK_DECLARE_FUNCTION (C_VerifyRecoverInit, 919178476Sjb (ck_session_handle_t session, 920178476Sjb struct ck_mechanism *mechanism, 921178476Sjb ck_object_handle_t key)); 922178476Sjb_CK_DECLARE_FUNCTION (C_VerifyRecover, 923178476Sjb (ck_session_handle_t session, 924178476Sjb unsigned char *signature, 925178476Sjb unsigned long signature_len, 926178476Sjb unsigned char *data, 927178476Sjb unsigned long *data_len)); 928178476Sjb 929178476Sjb_CK_DECLARE_FUNCTION (C_DigestEncryptUpdate, 930178476Sjb (ck_session_handle_t session, 931178476Sjb unsigned char *part, unsigned long part_len, 932178476Sjb unsigned char *encrypted_part, 933178476Sjb unsigned long *encrypted_part_len)); 934178476Sjb_CK_DECLARE_FUNCTION (C_DecryptDigestUpdate, 935178476Sjb (ck_session_handle_t session, 936178476Sjb unsigned char *encrypted_part, 937178476Sjb unsigned long encrypted_part_len, 938178476Sjb unsigned char *part, 939178476Sjb unsigned long *part_len)); 940178476Sjb_CK_DECLARE_FUNCTION (C_SignEncryptUpdate, 941178476Sjb (ck_session_handle_t session, 942178476Sjb unsigned char *part, unsigned long part_len, 943178476Sjb unsigned char *encrypted_part, 944178476Sjb unsigned long *encrypted_part_len)); 945178476Sjb_CK_DECLARE_FUNCTION (C_DecryptVerifyUpdate, 946178476Sjb (ck_session_handle_t session, 947178476Sjb unsigned char *encrypted_part, 948178476Sjb unsigned long encrypted_part_len, 949178476Sjb unsigned char *part, 950178476Sjb unsigned long *part_len)); 951178476Sjb 952178476Sjb_CK_DECLARE_FUNCTION (C_GenerateKey, 953178476Sjb (ck_session_handle_t session, 954178476Sjb struct ck_mechanism *mechanism, 955178476Sjb struct ck_attribute *templ, 956178476Sjb unsigned long count, 957178476Sjb ck_object_handle_t *key)); 958178476Sjb_CK_DECLARE_FUNCTION (C_GenerateKeyPair, 959178476Sjb (ck_session_handle_t session, 960178476Sjb struct ck_mechanism *mechanism, 961178476Sjb struct ck_attribute *public_key_template, 962178476Sjb unsigned long public_key_attribute_count, 963178476Sjb struct ck_attribute *private_key_template, 964178476Sjb unsigned long private_key_attribute_count, 965178476Sjb ck_object_handle_t *public_key, 966178476Sjb ck_object_handle_t *private_key)); 967178476Sjb_CK_DECLARE_FUNCTION (C_WrapKey, 968178476Sjb (ck_session_handle_t session, 969178476Sjb struct ck_mechanism *mechanism, 970178476Sjb ck_object_handle_t wrapping_key, 971178476Sjb ck_object_handle_t key, 972178476Sjb unsigned char *wrapped_key, 973178476Sjb unsigned long *wrapped_key_len)); 974178476Sjb_CK_DECLARE_FUNCTION (C_UnwrapKey, 975178476Sjb (ck_session_handle_t session, 976178476Sjb struct ck_mechanism *mechanism, 977178476Sjb ck_object_handle_t unwrapping_key, 978178476Sjb unsigned char *wrapped_key, 979178476Sjb unsigned long wrapped_key_len, 980178476Sjb struct ck_attribute *templ, 981178476Sjb unsigned long attribute_count, 982178476Sjb ck_object_handle_t *key)); 983178476Sjb_CK_DECLARE_FUNCTION (C_DeriveKey, 984178476Sjb (ck_session_handle_t session, 985178476Sjb struct ck_mechanism *mechanism, 986178476Sjb ck_object_handle_t base_key, 987178476Sjb struct ck_attribute *templ, 988178476Sjb unsigned long attribute_count, 989178476Sjb ck_object_handle_t *key)); 990178476Sjb 991178476Sjb_CK_DECLARE_FUNCTION (C_SeedRandom, 992178476Sjb (ck_session_handle_t session, unsigned char *seed, 993178476Sjb unsigned long seed_len)); 994178476Sjb_CK_DECLARE_FUNCTION (C_GenerateRandom, 995178476Sjb (ck_session_handle_t session, 996178476Sjb unsigned char *random_data, 997178476Sjb unsigned long random_len)); 998178476Sjb 999178476Sjb_CK_DECLARE_FUNCTION (C_GetFunctionStatus, (ck_session_handle_t session)); 1000178476Sjb_CK_DECLARE_FUNCTION (C_CancelFunction, (ck_session_handle_t session)); 1001178476Sjb 1002178476Sjb 1003178476Sjbstruct ck_function_list 1004178476Sjb{ 1005178476Sjb struct ck_version version; 1006178476Sjb CK_C_Initialize C_Initialize; 1007178476Sjb CK_C_Finalize C_Finalize; 1008178476Sjb CK_C_GetInfo C_GetInfo; 1009178476Sjb CK_C_GetFunctionList C_GetFunctionList; 1010178476Sjb CK_C_GetSlotList C_GetSlotList; 1011178476Sjb CK_C_GetSlotInfo C_GetSlotInfo; 1012178476Sjb CK_C_GetTokenInfo C_GetTokenInfo; 1013178476Sjb CK_C_GetMechanismList C_GetMechanismList; 1014178476Sjb CK_C_GetMechanismInfo C_GetMechanismInfo; 1015178476Sjb CK_C_InitToken C_InitToken; 1016178476Sjb CK_C_InitPIN C_InitPIN; 1017178476Sjb CK_C_SetPIN C_SetPIN; 1018178476Sjb CK_C_OpenSession C_OpenSession; 1019178476Sjb CK_C_CloseSession C_CloseSession; 1020178476Sjb CK_C_CloseAllSessions C_CloseAllSessions; 1021178476Sjb CK_C_GetSessionInfo C_GetSessionInfo; 1022178476Sjb CK_C_GetOperationState C_GetOperationState; 1023178476Sjb CK_C_SetOperationState C_SetOperationState; 1024178476Sjb CK_C_Login C_Login; 1025178476Sjb CK_C_Logout C_Logout; 1026178476Sjb CK_C_CreateObject C_CreateObject; 1027178476Sjb CK_C_CopyObject C_CopyObject; 1028178476Sjb CK_C_DestroyObject C_DestroyObject; 1029178476Sjb CK_C_GetObjectSize C_GetObjectSize; 1030178476Sjb CK_C_GetAttributeValue C_GetAttributeValue; 1031178476Sjb CK_C_SetAttributeValue C_SetAttributeValue; 1032178476Sjb CK_C_FindObjectsInit C_FindObjectsInit; 1033178476Sjb CK_C_FindObjects C_FindObjects; 1034178476Sjb CK_C_FindObjectsFinal C_FindObjectsFinal; 1035178476Sjb CK_C_EncryptInit C_EncryptInit; 1036178476Sjb CK_C_Encrypt C_Encrypt; 1037178476Sjb CK_C_EncryptUpdate C_EncryptUpdate; 1038178476Sjb CK_C_EncryptFinal C_EncryptFinal; 1039178476Sjb CK_C_DecryptInit C_DecryptInit; 1040178476Sjb CK_C_Decrypt C_Decrypt; 1041178476Sjb CK_C_DecryptUpdate C_DecryptUpdate; 1042178476Sjb CK_C_DecryptFinal C_DecryptFinal; 1043178476Sjb CK_C_DigestInit C_DigestInit; 1044178476Sjb CK_C_Digest C_Digest; 1045178476Sjb CK_C_DigestUpdate C_DigestUpdate; 1046178476Sjb CK_C_DigestKey C_DigestKey; 1047178476Sjb CK_C_DigestFinal C_DigestFinal; 1048178476Sjb CK_C_SignInit C_SignInit; 1049178476Sjb CK_C_Sign C_Sign; 1050178476Sjb CK_C_SignUpdate C_SignUpdate; 1051178476Sjb CK_C_SignFinal C_SignFinal; 1052178476Sjb CK_C_SignRecoverInit C_SignRecoverInit; 1053178476Sjb CK_C_SignRecover C_SignRecover; 1054178476Sjb CK_C_VerifyInit C_VerifyInit; 1055178476Sjb CK_C_Verify C_Verify; 1056178476Sjb CK_C_VerifyUpdate C_VerifyUpdate; 1057178476Sjb CK_C_VerifyFinal C_VerifyFinal; 1058178476Sjb CK_C_VerifyRecoverInit C_VerifyRecoverInit; 1059178476Sjb CK_C_VerifyRecover C_VerifyRecover; 1060178476Sjb CK_C_DigestEncryptUpdate C_DigestEncryptUpdate; 1061178476Sjb CK_C_DecryptDigestUpdate C_DecryptDigestUpdate; 1062178476Sjb CK_C_SignEncryptUpdate C_SignEncryptUpdate; 1063178476Sjb CK_C_DecryptVerifyUpdate C_DecryptVerifyUpdate; 1064178476Sjb CK_C_GenerateKey C_GenerateKey; 1065178476Sjb CK_C_GenerateKeyPair C_GenerateKeyPair; 1066178476Sjb CK_C_WrapKey C_WrapKey; 1067178476Sjb CK_C_UnwrapKey C_UnwrapKey; 1068178476Sjb CK_C_DeriveKey C_DeriveKey; 1069178476Sjb CK_C_SeedRandom C_SeedRandom; 1070178476Sjb CK_C_GenerateRandom C_GenerateRandom; 1071178476Sjb CK_C_GetFunctionStatus C_GetFunctionStatus; 1072178476Sjb CK_C_CancelFunction C_CancelFunction; 1073178476Sjb CK_C_WaitForSlotEvent C_WaitForSlotEvent; 1074178476Sjb}; 1075178476Sjb 1076178476Sjb 1077178476Sjbtypedef ck_rv_t (*ck_createmutex_t) (void **mutex); 1078178476Sjbtypedef ck_rv_t (*ck_destroymutex_t) (void *mutex); 1079178476Sjbtypedef ck_rv_t (*ck_lockmutex_t) (void *mutex); 1080178476Sjbtypedef ck_rv_t (*ck_unlockmutex_t) (void *mutex); 1081178476Sjb 1082178476Sjb 1083178476Sjbstruct ck_c_initialize_args 1084178476Sjb{ 1085178476Sjb ck_createmutex_t create_mutex; 1086178476Sjb ck_destroymutex_t destroy_mutex; 1087178476Sjb ck_lockmutex_t lock_mutex; 1088178476Sjb ck_unlockmutex_t unlock_mutex; 1089178476Sjb ck_flags_t flags; 1090178476Sjb void *reserved; 1091178476Sjb}; 1092178476Sjb 1093178476Sjb 1094178476Sjb#define CKF_LIBRARY_CANT_CREATE_OS_THREADS (1 << 0) 1095178476Sjb#define CKF_OS_LOCKING_OK (1 << 1) 1096178476Sjb 1097178476Sjb#define CKR_OK (0) 1098178476Sjb#define CKR_CANCEL (1) 1099178476Sjb#define CKR_HOST_MEMORY (2) 1100178476Sjb#define CKR_SLOT_ID_INVALID (3) 1101178476Sjb#define CKR_GENERAL_ERROR (5) 1102178476Sjb#define CKR_FUNCTION_FAILED (6) 1103178476Sjb#define CKR_ARGUMENTS_BAD (7) 1104178476Sjb#define CKR_NO_EVENT (8) 1105178476Sjb#define CKR_NEED_TO_CREATE_THREADS (9) 1106178476Sjb#define CKR_CANT_LOCK (0xa) 1107178476Sjb#define CKR_ATTRIBUTE_READ_ONLY (0x10) 1108178476Sjb#define CKR_ATTRIBUTE_SENSITIVE (0x11) 1109178476Sjb#define CKR_ATTRIBUTE_TYPE_INVALID (0x12) 1110178476Sjb#define CKR_ATTRIBUTE_VALUE_INVALID (0x13) 1111178476Sjb#define CKR_DATA_INVALID (0x20) 1112178476Sjb#define CKR_DATA_LEN_RANGE (0x21) 1113178476Sjb#define CKR_DEVICE_ERROR (0x30) 1114178476Sjb#define CKR_DEVICE_MEMORY (0x31) 1115178476Sjb#define CKR_DEVICE_REMOVED (0x32) 1116178476Sjb#define CKR_ENCRYPTED_DATA_INVALID (0x40) 1117178476Sjb#define CKR_ENCRYPTED_DATA_LEN_RANGE (0x41) 1118178476Sjb#define CKR_FUNCTION_CANCELED (0x50) 1119178476Sjb#define CKR_FUNCTION_NOT_PARALLEL (0x51) 1120178476Sjb#define CKR_FUNCTION_NOT_SUPPORTED (0x54) 1121178476Sjb#define CKR_KEY_HANDLE_INVALID (0x60) 1122178476Sjb#define CKR_KEY_SIZE_RANGE (0x62) 1123178476Sjb#define CKR_KEY_TYPE_INCONSISTENT (0x63) 1124178476Sjb#define CKR_KEY_NOT_NEEDED (0x64) 1125178476Sjb#define CKR_KEY_CHANGED (0x65) 1126178476Sjb#define CKR_KEY_NEEDED (0x66) 1127178476Sjb#define CKR_KEY_INDIGESTIBLE (0x67) 1128178476Sjb#define CKR_KEY_FUNCTION_NOT_PERMITTED (0x68) 1129178476Sjb#define CKR_KEY_NOT_WRAPPABLE (0x69) 1130178476Sjb#define CKR_KEY_UNEXTRACTABLE (0x6a) 1131178476Sjb#define CKR_MECHANISM_INVALID (0x70) 1132178476Sjb#define CKR_MECHANISM_PARAM_INVALID (0x71) 1133178476Sjb#define CKR_OBJECT_HANDLE_INVALID (0x82) 1134178476Sjb#define CKR_OPERATION_ACTIVE (0x90) 1135178476Sjb#define CKR_OPERATION_NOT_INITIALIZED (0x91) 1136178476Sjb#define CKR_PIN_INCORRECT (0xa0) 1137178476Sjb#define CKR_PIN_INVALID (0xa1) 1138178476Sjb#define CKR_PIN_LEN_RANGE (0xa2) 1139178476Sjb#define CKR_PIN_EXPIRED (0xa3) 1140178476Sjb#define CKR_PIN_LOCKED (0xa4) 1141178476Sjb#define CKR_SESSION_CLOSED (0xb0) 1142178476Sjb#define CKR_SESSION_COUNT (0xb1) 1143178476Sjb#define CKR_SESSION_HANDLE_INVALID (0xb3) 1144178476Sjb#define CKR_SESSION_PARALLEL_NOT_SUPPORTED (0xb4) 1145178476Sjb#define CKR_SESSION_READ_ONLY (0xb5) 1146178476Sjb#define CKR_SESSION_EXISTS (0xb6) 1147178476Sjb#define CKR_SESSION_READ_ONLY_EXISTS (0xb7) 1148178476Sjb#define CKR_SESSION_READ_WRITE_SO_EXISTS (0xb8) 1149178476Sjb#define CKR_SIGNATURE_INVALID (0xc0) 1150178476Sjb#define CKR_SIGNATURE_LEN_RANGE (0xc1) 1151178476Sjb#define CKR_TEMPLATE_INCOMPLETE (0xd0) 1152178476Sjb#define CKR_TEMPLATE_INCONSISTENT (0xd1) 1153178476Sjb#define CKR_TOKEN_NOT_PRESENT (0xe0) 1154178476Sjb#define CKR_TOKEN_NOT_RECOGNIZED (0xe1) 1155178476Sjb#define CKR_TOKEN_WRITE_PROTECTED (0xe2) 1156178476Sjb#define CKR_UNWRAPPING_KEY_HANDLE_INVALID (0xf0) 1157178476Sjb#define CKR_UNWRAPPING_KEY_SIZE_RANGE (0xf1) 1158178476Sjb#define CKR_UNWRAPPING_KEY_TYPE_INCONSISTENT (0xf2) 1159178476Sjb#define CKR_USER_ALREADY_LOGGED_IN (0x100) 1160178476Sjb#define CKR_USER_NOT_LOGGED_IN (0x101) 1161178476Sjb#define CKR_USER_PIN_NOT_INITIALIZED (0x102) 1162178476Sjb#define CKR_USER_TYPE_INVALID (0x103) 1163178476Sjb#define CKR_USER_ANOTHER_ALREADY_LOGGED_IN (0x104) 1164178476Sjb#define CKR_USER_TOO_MANY_TYPES (0x105) 1165178476Sjb#define CKR_WRAPPED_KEY_INVALID (0x110) 1166178476Sjb#define CKR_WRAPPED_KEY_LEN_RANGE (0x112) 1167178476Sjb#define CKR_WRAPPING_KEY_HANDLE_INVALID (0x113) 1168178476Sjb#define CKR_WRAPPING_KEY_SIZE_RANGE (0x114) 1169178476Sjb#define CKR_WRAPPING_KEY_TYPE_INCONSISTENT (0x115) 1170178476Sjb#define CKR_RANDOM_SEED_NOT_SUPPORTED (0x120) 1171178476Sjb#define CKR_RANDOM_NO_RNG (0x121) 1172178476Sjb#define CKR_DOMAIN_PARAMS_INVALID (0x130) 1173178476Sjb#define CKR_BUFFER_TOO_SMALL (0x150) 1174178476Sjb#define CKR_SAVED_STATE_INVALID (0x160) 1175178476Sjb#define CKR_INFORMATION_SENSITIVE (0x170) 1176178476Sjb#define CKR_STATE_UNSAVEABLE (0x180) 1177178476Sjb#define CKR_CRYPTOKI_NOT_INITIALIZED (0x190) 1178178476Sjb#define CKR_CRYPTOKI_ALREADY_INITIALIZED (0x191) 1179178476Sjb#define CKR_MUTEX_BAD (0x1a0) 1180178476Sjb#define CKR_MUTEX_NOT_LOCKED (0x1a1) 1181178476Sjb#define CKR_FUNCTION_REJECTED (0x200) 1182178476Sjb#define CKR_VENDOR_DEFINED ((unsigned long) (1 << 31)) 1183178476Sjb 1184178476Sjb 1185178476Sjb 1186178476Sjb/* Compatibility layer. */ 1187178476Sjb 1188178476Sjb#ifdef CRYPTOKI_COMPAT 1189178476Sjb 1190178476Sjb#undef CK_DEFINE_FUNCTION 1191178476Sjb#define CK_DEFINE_FUNCTION(retval, name) retval CK_SPEC name 1192178476Sjb 1193178476Sjb/* For NULL. */ 1194178476Sjb#include <stddef.h> 1195178476Sjb 1196178476Sjbtypedef unsigned char CK_BYTE; 1197178537Sjbtypedef unsigned char CK_CHAR; 1198178476Sjbtypedef unsigned char CK_UTF8CHAR; 1199178537Sjbtypedef unsigned char CK_BBOOL; 1200178537Sjbtypedef unsigned long int CK_ULONG; 1201178476Sjbtypedef long int CK_LONG; 1202178476Sjbtypedef CK_BYTE *CK_BYTE_PTR; 1203178476Sjbtypedef CK_CHAR *CK_CHAR_PTR; 1204178476Sjbtypedef CK_UTF8CHAR *CK_UTF8CHAR_PTR; 1205178476Sjbtypedef CK_ULONG *CK_ULONG_PTR; 1206178476Sjbtypedef void *CK_VOID_PTR; 1207178476Sjbtypedef void **CK_VOID_PTR_PTR; 1208178476Sjb#define CK_FALSE 0 1209178476Sjb#define CK_TRUE 1 1210178476Sjb#ifndef CK_DISABLE_TRUE_FALSE 1211178476Sjb#ifndef FALSE 1212178476Sjb#define FALSE 0 1213178476Sjb#endif 1214178476Sjb#ifndef TRUE 1215178476Sjb#define TRUE 1 1216178476Sjb#endif 1217178476Sjb#endif 1218178476Sjb 1219178476Sjbtypedef struct ck_version CK_VERSION; 1220178476Sjbtypedef struct ck_version *CK_VERSION_PTR; 1221178476Sjb 1222178476Sjbtypedef struct ck_info CK_INFO; 1223178476Sjbtypedef struct ck_info *CK_INFO_PTR; 1224178476Sjb 1225178476Sjbtypedef ck_slot_id_t *CK_SLOT_ID_PTR; 1226178476Sjb 1227178537Sjbtypedef struct ck_slot_info CK_SLOT_INFO; 1228178476Sjbtypedef struct ck_slot_info *CK_SLOT_INFO_PTR; 1229178476Sjb 1230178476Sjbtypedef struct ck_token_info CK_TOKEN_INFO; 1231178476Sjbtypedef struct ck_token_info *CK_TOKEN_INFO_PTR; 1232178476Sjb 1233178476Sjbtypedef ck_session_handle_t *CK_SESSION_HANDLE_PTR; 1234178476Sjb 1235178476Sjbtypedef struct ck_session_info CK_SESSION_INFO; 1236178476Sjbtypedef struct ck_session_info *CK_SESSION_INFO_PTR; 1237178476Sjb 1238178476Sjbtypedef ck_object_handle_t *CK_OBJECT_HANDLE_PTR; 1239178476Sjb 1240178476Sjbtypedef ck_object_class_t *CK_OBJECT_CLASS_PTR; 1241178476Sjb 1242178476Sjbtypedef struct ck_attribute CK_ATTRIBUTE; 1243178476Sjbtypedef struct ck_attribute *CK_ATTRIBUTE_PTR; 1244178476Sjb 1245178476Sjbtypedef struct ck_date CK_DATE; 1246178476Sjbtypedef struct ck_date *CK_DATE_PTR; 1247178476Sjb 1248178476Sjbtypedef ck_mechanism_type_t *CK_MECHANISM_TYPE_PTR; 1249178476Sjb 1250178476Sjbtypedef struct ck_mechanism CK_MECHANISM; 1251178476Sjbtypedef struct ck_mechanism *CK_MECHANISM_PTR; 1252178476Sjb 1253178476Sjbtypedef struct ck_mechanism_info CK_MECHANISM_INFO; 1254178476Sjbtypedef struct ck_mechanism_info *CK_MECHANISM_INFO_PTR; 1255178476Sjb 1256178476Sjbtypedef struct ck_function_list CK_FUNCTION_LIST; 1257178476Sjbtypedef struct ck_function_list *CK_FUNCTION_LIST_PTR; 1258178476Sjbtypedef struct ck_function_list **CK_FUNCTION_LIST_PTR_PTR; 1259178476Sjb 1260178476Sjbtypedef struct ck_c_initialize_args CK_C_INITIALIZE_ARGS; 1261178476Sjbtypedef struct ck_c_initialize_args *CK_C_INITIALIZE_ARGS_PTR; 1262178476Sjb 1263178476Sjb#define NULL_PTR NULL 1264178476Sjb 1265178476Sjb/* Delete the helper macros defined at the top of the file. */ 1266178476Sjb#undef ck_flags_t 1267178476Sjb#undef ck_version 1268178476Sjb 1269178476Sjb#undef ck_info 1270178476Sjb#undef cryptoki_version 1271178476Sjb#undef manufacturer_id 1272178476Sjb#undef library_description 1273178476Sjb#undef library_version 1274178476Sjb 1275178476Sjb#undef ck_notification_t 1276178476Sjb#undef ck_slot_id_t 1277178476Sjb 1278178476Sjb#undef ck_slot_info 1279178476Sjb#undef slot_description 1280178476Sjb#undef hardware_version 1281178476Sjb#undef firmware_version 1282178476Sjb 1283178476Sjb#undef ck_token_info 1284178476Sjb#undef serial_number 1285178476Sjb#undef max_session_count 1286178476Sjb#undef session_count 1287178476Sjb#undef max_rw_session_count 1288178476Sjb#undef rw_session_count 1289178476Sjb#undef max_pin_len 1290178476Sjb#undef min_pin_len 1291178476Sjb#undef total_public_memory 1292178476Sjb#undef free_public_memory 1293178476Sjb#undef total_private_memory 1294178476Sjb#undef free_private_memory 1295178476Sjb#undef utc_time 1296178476Sjb 1297178476Sjb#undef ck_session_handle_t 1298178476Sjb#undef ck_user_type_t 1299178476Sjb#undef ck_state_t 1300178476Sjb 1301178476Sjb#undef ck_session_info 1302178476Sjb#undef slot_id 1303178476Sjb#undef device_error 1304178476Sjb 1305178476Sjb#undef ck_object_handle_t 1306178476Sjb#undef ck_object_class_t 1307178476Sjb#undef ck_hw_feature_type_t 1308178476Sjb#undef ck_key_type_t 1309178476Sjb#undef ck_certificate_type_t 1310178476Sjb#undef ck_attribute_type_t 1311178476Sjb 1312178476Sjb#undef ck_attribute 1313178476Sjb#undef value 1314178476Sjb#undef value_len 1315178476Sjb 1316178476Sjb#undef ck_date 1317178476Sjb 1318178476Sjb#undef ck_mechanism_type_t 1319178476Sjb 1320178476Sjb#undef ck_mechanism 1321178476Sjb#undef parameter 1322178476Sjb#undef parameter_len 1323178476Sjb 1324178476Sjb#undef ck_mechanism_info 1325178476Sjb#undef min_key_size 1326178476Sjb#undef max_key_size 1327178476Sjb 1328178476Sjb#undef ck_rv_t 1329178476Sjb#undef ck_notify_t 1330178476Sjb 1331178476Sjb#undef ck_function_list 1332178476Sjb 1333178476Sjb#undef ck_createmutex_t 1334178476Sjb#undef ck_destroymutex_t 1335178476Sjb#undef ck_lockmutex_t 1336178476Sjb#undef ck_unlockmutex_t 1337178476Sjb 1338178476Sjb#undef ck_c_initialize_args 1339178476Sjb#undef create_mutex 1340178476Sjb#undef destroy_mutex 1341178476Sjb#undef lock_mutex 1342178476Sjb#undef unlock_mutex 1343178476Sjb#undef reserved 1344178476Sjb 1345178476Sjb#endif /* CRYPTOKI_COMPAT */ 1346178476Sjb 1347178476Sjb 1348178476Sjb/* System dependencies. */ 1349178476Sjb#if defined(_WIN32) || defined(CRYPTOKI_FORCE_WIN32) 1350178476Sjb#pragma pack(pop, cryptoki) 1351178476Sjb#endif 1352178476Sjb 1353178476Sjb#if defined(__cplusplus) 1354178476Sjb} 1355178476Sjb#endif 1356178476Sjb 1357178476Sjb#endif /* PKCS11_H */ 1358178476Sjb