/gecko_api/include/pkcs11t.h
C++ Header | 1774 lines | 984 code | 338 blank | 452 comment | 0 complexity | 9bc0bd3a9436ab739fbf7c3a626e4812 MD5 | raw file
Large files files are truncated, but you can click here to view the full file
1/* ***** BEGIN LICENSE BLOCK ***** 2 * Version: MPL 1.1/GPL 2.0/LGPL 2.1 3 * 4 * The contents of this file are subject to the Mozilla Public License Version 5 * 1.1 (the "License"); you may not use this file except in compliance with 6 * the License. You may obtain a copy of the License at 7 * http://www.mozilla.org/MPL/ 8 * 9 * Software distributed under the License is distributed on an "AS IS" basis, 10 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License 11 * for the specific language governing rights and limitations under the 12 * License. 13 * 14 * The Original Code is the Netscape security libraries. 15 * 16 * The Initial Developer of the Original Code is 17 * RSA Security, Inc. 18 * Portions created by the Initial Developer are Copyright (C) 1994-2000 19 * the Initial Developer. All Rights Reserved. 20 * 21 * Contributor(s): 22 * Dr Vipul Gupta <vipul.gupta@sun.com>, Sun Microsystems Laboratories 23 * 24 * Alternatively, the contents of this file may be used under the terms of 25 * either the GNU General Public License Version 2 or later (the "GPL"), or 26 * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), 27 * in which case the provisions of the GPL or the LGPL are applicable instead 28 * of those above. If you wish to allow use of your version of this file only 29 * under the terms of either the GPL or the LGPL, and not to allow others to 30 * use your version of this file under the terms of the MPL, indicate your 31 * decision by deleting the provisions above and replace them with the notice 32 * and other provisions required by the GPL or the LGPL. If you do not delete 33 * the provisions above, a recipient may use your version of this file under 34 * the terms of any one of the MPL, the GPL or the LGPL. 35 * 36 * ***** END LICENSE BLOCK ***** */ 37/* License to copy and use this software is granted provided that it is 38 * identified as "RSA Security Inc. PKCS #11 Cryptographic Token Interface 39 * (Cryptoki)" in all material mentioning or referencing this software. 40 41 * License is also granted to make and use derivative works provided that 42 * such works are identified as "derived from the RSA Security Inc. PKCS #11 43 * Cryptographic Token Interface (Cryptoki)" in all material mentioning or 44 * referencing the derived work. 45 46 * RSA Security Inc. makes no representations concerning either the 47 * merchantability of this software or the suitability of this software for 48 * any particular purpose. It is provided "as is" without express or implied 49 * warranty of any kind. 50 */ 51 52 53#ifndef _PKCS11T_H_ 54#define _PKCS11T_H_ 1 55 56#define CK_TRUE 1 57#define CK_FALSE 0 58 59#include "prtypes.h" 60 61#define CK_PTR * 62#define CK_NULL_PTR 0 63#define CK_CALLBACK_FUNCTION(rv,func) rv (PR_CALLBACK * func) 64#define CK_DECLARE_FUNCTION(rv,func) PR_EXTERN(rv) func 65#define CK_DECLARE_FUNCTION_POINTER(rv,func) rv (PR_CALLBACK * func) 66 67#define CK_INVALID_SESSION 0 68 69/* an unsigned 8-bit value */ 70typedef unsigned char CK_BYTE; 71 72/* an unsigned 8-bit character */ 73typedef CK_BYTE CK_CHAR; 74 75/* an 8-bit UTF-8 character */ 76typedef CK_BYTE CK_UTF8CHAR; 77 78/* a BYTE-sized Boolean flag */ 79typedef CK_BYTE CK_BBOOL; 80 81/* an unsigned value, at least 32 bits long */ 82typedef unsigned long int CK_ULONG; 83 84/* a signed value, the same size as a CK_ULONG */ 85/* CK_LONG is new for v2.0 */ 86typedef long int CK_LONG; 87 88/* at least 32 bits; each bit is a Boolean flag */ 89typedef CK_ULONG CK_FLAGS; 90 91 92/* some special values for certain CK_ULONG variables */ 93#define CK_UNAVAILABLE_INFORMATION (~0UL) 94#define CK_EFFECTIVELY_INFINITE 0 95 96 97typedef CK_BYTE CK_PTR CK_BYTE_PTR; 98typedef CK_CHAR CK_PTR CK_CHAR_PTR; 99typedef CK_UTF8CHAR CK_PTR CK_UTF8CHAR_PTR; 100typedef CK_ULONG CK_PTR CK_ULONG_PTR; 101typedef void CK_PTR CK_VOID_PTR; 102 103/* Pointer to a CK_VOID_PTR-- i.e., pointer to pointer to void */ 104typedef CK_VOID_PTR CK_PTR CK_VOID_PTR_PTR; 105 106 107/* The following value is always invalid if used as a session */ 108/* handle or object handle */ 109#define CK_INVALID_HANDLE 0 110 111 112/* pack */ 113#include "pkcs11p.h" 114 115typedef struct CK_VERSION { 116 CK_BYTE major; /* integer portion of version number */ 117 CK_BYTE minor; /* 1/100ths portion of version number */ 118} CK_VERSION; 119 120typedef CK_VERSION CK_PTR CK_VERSION_PTR; 121 122 123typedef struct CK_INFO { 124 /* manufacturerID and libraryDecription have been changed from 125 * CK_CHAR to CK_UTF8CHAR for v2.10 */ 126 CK_VERSION cryptokiVersion; /* PKCS #11 interface ver */ 127 CK_UTF8CHAR manufacturerID[32]; /* blank padded */ 128 CK_FLAGS flags; /* must be zero */ 129 130 /* libraryDescription and libraryVersion are new for v2.0 */ 131 CK_UTF8CHAR libraryDescription[32]; /* blank padded */ 132 CK_VERSION libraryVersion; /* version of library */ 133} CK_INFO; 134 135typedef CK_INFO CK_PTR CK_INFO_PTR; 136 137 138/* CK_NOTIFICATION enumerates the types of notifications that 139 * PKCS #11 provides to an application */ 140/* CK_NOTIFICATION has been changed from an enum to a CK_ULONG 141 * for v2.0 */ 142typedef CK_ULONG CK_NOTIFICATION; 143#define CKN_SURRENDER 0 144 145 146typedef CK_ULONG CK_SLOT_ID; 147 148typedef CK_SLOT_ID CK_PTR CK_SLOT_ID_PTR; 149 150 151/* CK_SLOT_INFO provides information about a slot */ 152typedef struct CK_SLOT_INFO { 153 /* slotDescription and manufacturerID have been changed from 154 * CK_CHAR to CK_UTF8CHAR for v2.10 */ 155 CK_UTF8CHAR slotDescription[64]; /* blank padded */ 156 CK_UTF8CHAR manufacturerID[32]; /* blank padded */ 157 CK_FLAGS flags; 158 159 /* hardwareVersion and firmwareVersion are new for v2.0 */ 160 CK_VERSION hardwareVersion; /* version of hardware */ 161 CK_VERSION firmwareVersion; /* version of firmware */ 162} CK_SLOT_INFO; 163 164/* flags: bit flags that provide capabilities of the slot 165 * Bit Flag Mask Meaning 166 */ 167#define CKF_TOKEN_PRESENT 0x00000001 /* a token is there */ 168#define CKF_REMOVABLE_DEVICE 0x00000002 /* removable devices*/ 169#define CKF_HW_SLOT 0x00000004 /* hardware slot */ 170 171typedef CK_SLOT_INFO CK_PTR CK_SLOT_INFO_PTR; 172 173 174/* CK_TOKEN_INFO provides information about a token */ 175typedef struct CK_TOKEN_INFO { 176 /* label, manufacturerID, and model have been changed from 177 * CK_CHAR to CK_UTF8CHAR for v2.10 */ 178 CK_UTF8CHAR label[32]; /* blank padded */ 179 CK_UTF8CHAR manufacturerID[32]; /* blank padded */ 180 CK_UTF8CHAR model[16]; /* blank padded */ 181 CK_CHAR serialNumber[16]; /* blank padded */ 182 CK_FLAGS flags; /* see below */ 183 184 /* ulMaxSessionCount, ulSessionCount, ulMaxRwSessionCount, 185 * ulRwSessionCount, ulMaxPinLen, and ulMinPinLen have all been 186 * changed from CK_USHORT to CK_ULONG for v2.0 */ 187 CK_ULONG ulMaxSessionCount; /* max open sessions */ 188 CK_ULONG ulSessionCount; /* sess. now open */ 189 CK_ULONG ulMaxRwSessionCount; /* max R/W sessions */ 190 CK_ULONG ulRwSessionCount; /* R/W sess. now open */ 191 CK_ULONG ulMaxPinLen; /* in bytes */ 192 CK_ULONG ulMinPinLen; /* in bytes */ 193 CK_ULONG ulTotalPublicMemory; /* in bytes */ 194 CK_ULONG ulFreePublicMemory; /* in bytes */ 195 CK_ULONG ulTotalPrivateMemory; /* in bytes */ 196 CK_ULONG ulFreePrivateMemory; /* in bytes */ 197 198 /* hardwareVersion, firmwareVersion, and time are new for 199 * v2.0 */ 200 CK_VERSION hardwareVersion; /* version of hardware */ 201 CK_VERSION firmwareVersion; /* version of firmware */ 202 CK_CHAR utcTime[16]; /* time */ 203} CK_TOKEN_INFO; 204 205/* The flags parameter is defined as follows: 206 * Bit Flag Mask Meaning 207 */ 208#define CKF_RNG 0x00000001 /* has random # 209 * generator */ 210#define CKF_WRITE_PROTECTED 0x00000002 /* token is 211 * write- 212 * protected */ 213#define CKF_LOGIN_REQUIRED 0x00000004 /* user must 214 * login */ 215#define CKF_USER_PIN_INITIALIZED 0x00000008 /* normal user's 216 * PIN is set */ 217 218/* CKF_RESTORE_KEY_NOT_NEEDED is new for v2.0. If it is set, 219 * that means that *every* time the state of cryptographic 220 * operations of a session is successfully saved, all keys 221 * needed to continue those operations are stored in the state */ 222#define CKF_RESTORE_KEY_NOT_NEEDED 0x00000020 223 224/* CKF_CLOCK_ON_TOKEN is new for v2.0. If it is set, that means 225 * that the token has some sort of clock. The time on that 226 * clock is returned in the token info structure */ 227#define CKF_CLOCK_ON_TOKEN 0x00000040 228 229/* CKF_PROTECTED_AUTHENTICATION_PATH is new for v2.0. If it is 230 * set, that means that there is some way for the user to login 231 * without sending a PIN through the PKCS #11 library itself */ 232#define CKF_PROTECTED_AUTHENTICATION_PATH 0x00000100 233 234/* CKF_DUAL_CRYPTO_OPERATIONS is new for v2.0. If it is true, 235 * that means that a single session with the token can perform 236 * dual simultaneous cryptographic operations (digest and 237 * encrypt; decrypt and digest; sign and encrypt; and decrypt 238 * and sign) */ 239#define CKF_DUAL_CRYPTO_OPERATIONS 0x00000200 240 241/* CKF_TOKEN_INITIALIZED if new for v2.10. If it is true, the 242 * token has been initialized using C_InitializeToken or an 243 * equivalent mechanism outside the scope of PKCS #11. 244 * Calling C_InitializeToken when this flag is set will cause 245 * the token to be reinitialized. */ 246#define CKF_TOKEN_INITIALIZED 0x00000400 247 248/* CKF_SECONDARY_AUTHENTICATION if new for v2.10. If it is 249 * true, the token supports secondary authentication for 250 * private key objects. This flag is deprecated in v2.11 and 251 onwards. */ 252#define CKF_SECONDARY_AUTHENTICATION 0x00000800 253 254/* CKF_USER_PIN_COUNT_LOW if new for v2.10. If it is true, an 255 * incorrect user login PIN has been entered at least once 256 * since the last successful authentication. */ 257#define CKF_USER_PIN_COUNT_LOW 0x00010000 258 259/* CKF_USER_PIN_FINAL_TRY if new for v2.10. If it is true, 260 * supplying an incorrect user PIN will it to become locked. */ 261#define CKF_USER_PIN_FINAL_TRY 0x00020000 262 263/* CKF_USER_PIN_LOCKED if new for v2.10. If it is true, the 264 * user PIN has been locked. User login to the token is not 265 * possible. */ 266#define CKF_USER_PIN_LOCKED 0x00040000 267 268/* CKF_USER_PIN_TO_BE_CHANGED if new for v2.10. If it is true, 269 * the user PIN value is the default value set by token 270 * initialization or manufacturing, or the PIN has been 271 * expired by the card. */ 272#define CKF_USER_PIN_TO_BE_CHANGED 0x00080000 273 274/* CKF_SO_PIN_COUNT_LOW if new for v2.10. If it is true, an 275 * incorrect SO login PIN has been entered at least once since 276 * the last successful authentication. */ 277#define CKF_SO_PIN_COUNT_LOW 0x00100000 278 279/* CKF_SO_PIN_FINAL_TRY if new for v2.10. If it is true, 280 * supplying an incorrect SO PIN will it to become locked. */ 281#define CKF_SO_PIN_FINAL_TRY 0x00200000 282 283/* CKF_SO_PIN_LOCKED if new for v2.10. If it is true, the SO 284 * PIN has been locked. SO login to the token is not possible. 285 */ 286#define CKF_SO_PIN_LOCKED 0x00400000 287 288/* CKF_SO_PIN_TO_BE_CHANGED if new for v2.10. If it is true, 289 * the SO PIN value is the default value set by token 290 * initialization or manufacturing, or the PIN has been 291 * expired by the card. */ 292#define CKF_SO_PIN_TO_BE_CHANGED 0x00800000 293 294typedef CK_TOKEN_INFO CK_PTR CK_TOKEN_INFO_PTR; 295 296 297/* CK_SESSION_HANDLE is a PKCS #11-assigned value that 298 * identifies a session */ 299typedef CK_ULONG CK_SESSION_HANDLE; 300 301typedef CK_SESSION_HANDLE CK_PTR CK_SESSION_HANDLE_PTR; 302 303 304/* CK_USER_TYPE enumerates the types of PKCS #11 users */ 305/* CK_USER_TYPE has been changed from an enum to a CK_ULONG for 306 * v2.0 */ 307typedef CK_ULONG CK_USER_TYPE; 308/* Security Officer */ 309#define CKU_SO 0 310/* Normal user */ 311#define CKU_USER 1 312/* Context specific (added in v2.20) */ 313#define CKU_CONTEXT_SPECIFIC 2 314 315/* CK_STATE enumerates the session states */ 316/* CK_STATE has been changed from an enum to a CK_ULONG for 317 * v2.0 */ 318typedef CK_ULONG CK_STATE; 319#define CKS_RO_PUBLIC_SESSION 0 320#define CKS_RO_USER_FUNCTIONS 1 321#define CKS_RW_PUBLIC_SESSION 2 322#define CKS_RW_USER_FUNCTIONS 3 323#define CKS_RW_SO_FUNCTIONS 4 324 325 326/* CK_SESSION_INFO provides information about a session */ 327typedef struct CK_SESSION_INFO { 328 CK_SLOT_ID slotID; 329 CK_STATE state; 330 CK_FLAGS flags; /* see below */ 331 332 /* ulDeviceError was changed from CK_USHORT to CK_ULONG for 333 * v2.0 */ 334 CK_ULONG ulDeviceError; /* device-dependent error code */ 335} CK_SESSION_INFO; 336 337/* The flags are defined in the following table: 338 * Bit Flag Mask Meaning 339 */ 340#define CKF_RW_SESSION 0x00000002 /* session is r/w */ 341#define CKF_SERIAL_SESSION 0x00000004 /* no parallel */ 342 343typedef CK_SESSION_INFO CK_PTR CK_SESSION_INFO_PTR; 344 345 346/* CK_OBJECT_HANDLE is a token-specific identifier for an 347 * object */ 348typedef CK_ULONG CK_OBJECT_HANDLE; 349 350typedef CK_OBJECT_HANDLE CK_PTR CK_OBJECT_HANDLE_PTR; 351 352 353/* CK_OBJECT_CLASS is a value that identifies the classes (or 354 * types) of objects that PKCS #11 recognizes. It is defined 355 * as follows: */ 356/* CK_OBJECT_CLASS was changed from CK_USHORT to CK_ULONG for 357 * v2.0 */ 358typedef CK_ULONG CK_OBJECT_CLASS; 359 360/* The following classes of objects are defined: */ 361/* CKO_HW_FEATURE is new for v2.10 */ 362/* CKO_DOMAIN_PARAMETERS is new for v2.11 */ 363/* CKO_MECHANISM is new for v2.20 */ 364#define CKO_DATA 0x00000000 365#define CKO_CERTIFICATE 0x00000001 366#define CKO_PUBLIC_KEY 0x00000002 367#define CKO_PRIVATE_KEY 0x00000003 368#define CKO_SECRET_KEY 0x00000004 369#define CKO_HW_FEATURE 0x00000005 370#define CKO_DOMAIN_PARAMETERS 0x00000006 371#define CKO_MECHANISM 0x00000007 372#define CKO_VENDOR_DEFINED 0x80000000 373 374typedef CK_OBJECT_CLASS CK_PTR CK_OBJECT_CLASS_PTR; 375 376/* CK_HW_FEATURE_TYPE is new for v2.10. CK_HW_FEATURE_TYPE is a 377 * value that identifies the hardware feature type of an object 378 * with CK_OBJECT_CLASS equal to CKO_HW_FEATURE. */ 379typedef CK_ULONG CK_HW_FEATURE_TYPE; 380 381/* The following hardware feature types are defined */ 382/* CKH_USER_INTERFACE is new for v2.20 */ 383#define CKH_MONOTONIC_COUNTER 0x00000001 384#define CKH_CLOCK 0x00000002 385#define CKH_USER_INTERFACE 0x00000003 386#define CKH_VENDOR_DEFINED 0x80000000 387 388/* CK_KEY_TYPE is a value that identifies a key type */ 389/* CK_KEY_TYPE was changed from CK_USHORT to CK_ULONG for v2.0 */ 390typedef CK_ULONG CK_KEY_TYPE; 391 392/* the following key types are defined: */ 393#define CKK_RSA 0x00000000 394#define CKK_DSA 0x00000001 395#define CKK_DH 0x00000002 396 397/* CKK_ECDSA and CKK_KEA are new for v2.0 */ 398/* CKK_ECDSA is deprecated in v2.11, CKK_EC is preferred. */ 399#define CKK_ECDSA 0x00000003 400#define CKK_EC 0x00000003 401#define CKK_X9_42_DH 0x00000004 402#define CKK_KEA 0x00000005 403 404#define CKK_GENERIC_SECRET 0x00000010 405#define CKK_RC2 0x00000011 406#define CKK_RC4 0x00000012 407#define CKK_DES 0x00000013 408#define CKK_DES2 0x00000014 409#define CKK_DES3 0x00000015 410 411/* all these key types are new for v2.0 */ 412#define CKK_CAST 0x00000016 413#define CKK_CAST3 0x00000017 414/* CKK_CAST5 is deprecated in v2.11, CKK_CAST128 is preferred. */ 415#define CKK_CAST5 0x00000018 416#define CKK_CAST128 0x00000018 417#define CKK_RC5 0x00000019 418#define CKK_IDEA 0x0000001A 419#define CKK_SKIPJACK 0x0000001B 420#define CKK_BATON 0x0000001C 421#define CKK_JUNIPER 0x0000001D 422#define CKK_CDMF 0x0000001E 423#define CKK_AES 0x0000001F 424 425/* BlowFish and TwoFish are new for v2.20 */ 426#define CKK_BLOWFISH 0x00000020 427#define CKK_TWOFISH 0x00000021 428 429/* Camellia is proposed for v2.20 Amendment 3 */ 430#define CKK_CAMELLIA 0x00000025 431 432#define CKK_VENDOR_DEFINED 0x80000000 433 434 435/* CK_CERTIFICATE_TYPE is a value that identifies a certificate 436 * type */ 437/* CK_CERTIFICATE_TYPE was changed from CK_USHORT to CK_ULONG 438 * for v2.0 */ 439typedef CK_ULONG CK_CERTIFICATE_TYPE; 440 441/* The following certificate types are defined: */ 442/* CKC_X_509_ATTR_CERT is new for v2.10 */ 443/* CKC_WTLS is new for v2.20 */ 444#define CKC_X_509 0x00000000 445#define CKC_X_509_ATTR_CERT 0x00000001 446#define CKC_WTLS 0x00000002 447#define CKC_VENDOR_DEFINED 0x80000000 448 449 450/* CK_ATTRIBUTE_TYPE is a value that identifies an attribute 451 * type */ 452/* CK_ATTRIBUTE_TYPE was changed from CK_USHORT to CK_ULONG for 453 * v2.0 */ 454typedef CK_ULONG CK_ATTRIBUTE_TYPE; 455 456/* The CKF_ARRAY_ATTRIBUTE flag identifies an attribute which 457 consists of an array of values. */ 458#define CKF_ARRAY_ATTRIBUTE 0x40000000 459 460/* The following attribute types are defined: */ 461#define CKA_CLASS 0x00000000 462#define CKA_TOKEN 0x00000001 463#define CKA_PRIVATE 0x00000002 464#define CKA_LABEL 0x00000003 465#define CKA_APPLICATION 0x00000010 466#define CKA_VALUE 0x00000011 467 468/* CKA_OBJECT_ID is new for v2.10 */ 469#define CKA_OBJECT_ID 0x00000012 470 471#define CKA_CERTIFICATE_TYPE 0x00000080 472#define CKA_ISSUER 0x00000081 473#define CKA_SERIAL_NUMBER 0x00000082 474 475/* CKA_AC_ISSUER, CKA_OWNER, and CKA_ATTR_TYPES are new 476 * for v2.10 */ 477#define CKA_AC_ISSUER 0x00000083 478#define CKA_OWNER 0x00000084 479#define CKA_ATTR_TYPES 0x00000085 480 481/* CKA_TRUSTED is new for v2.11 */ 482#define CKA_TRUSTED 0x00000086 483 484/* CKA_CERTIFICATE_CATEGORY ... 485 * CKA_CHECK_VALUE are new for v2.20 */ 486#define CKA_CERTIFICATE_CATEGORY 0x00000087 487#define CKA_JAVA_MIDP_SECURITY_DOMAIN 0x00000088 488#define CKA_URL 0x00000089 489#define CKA_HASH_OF_SUBJECT_PUBLIC_KEY 0x0000008A 490#define CKA_HASH_OF_ISSUER_PUBLIC_KEY 0x0000008B 491#define CKA_CHECK_VALUE 0x00000090 492 493#define CKA_KEY_TYPE 0x00000100 494#define CKA_SUBJECT 0x00000101 495#define CKA_ID 0x00000102 496#define CKA_SENSITIVE 0x00000103 497#define CKA_ENCRYPT 0x00000104 498#define CKA_DECRYPT 0x00000105 499#define CKA_WRAP 0x00000106 500#define CKA_UNWRAP 0x00000107 501#define CKA_SIGN 0x00000108 502#define CKA_SIGN_RECOVER 0x00000109 503#define CKA_VERIFY 0x0000010A 504#define CKA_VERIFY_RECOVER 0x0000010B 505#define CKA_DERIVE 0x0000010C 506#define CKA_START_DATE 0x00000110 507#define CKA_END_DATE 0x00000111 508#define CKA_MODULUS 0x00000120 509#define CKA_MODULUS_BITS 0x00000121 510#define CKA_PUBLIC_EXPONENT 0x00000122 511#define CKA_PRIVATE_EXPONENT 0x00000123 512#define CKA_PRIME_1 0x00000124 513#define CKA_PRIME_2 0x00000125 514#define CKA_EXPONENT_1 0x00000126 515#define CKA_EXPONENT_2 0x00000127 516#define CKA_COEFFICIENT 0x00000128 517#define CKA_PRIME 0x00000130 518#define CKA_SUBPRIME 0x00000131 519#define CKA_BASE 0x00000132 520 521/* CKA_PRIME_BITS and CKA_SUB_PRIME_BITS are new for v2.11 */ 522#define CKA_PRIME_BITS 0x00000133 523#define CKA_SUBPRIME_BITS 0x00000134 524#define CKA_SUB_PRIME_BITS CKA_SUBPRIME_BITS 525/* (To retain backwards-compatibility) */ 526 527#define CKA_VALUE_BITS 0x00000160 528#define CKA_VALUE_LEN 0x00000161 529 530/* CKA_EXTRACTABLE, CKA_LOCAL, CKA_NEVER_EXTRACTABLE, 531 * CKA_ALWAYS_SENSITIVE, CKA_MODIFIABLE, CKA_ECDSA_PARAMS, 532 * and CKA_EC_POINT are new for v2.0 */ 533#define CKA_EXTRACTABLE 0x00000162 534#define CKA_LOCAL 0x00000163 535#define CKA_NEVER_EXTRACTABLE 0x00000164 536#define CKA_ALWAYS_SENSITIVE 0x00000165 537 538/* CKA_KEY_GEN_MECHANISM is new for v2.11 */ 539#define CKA_KEY_GEN_MECHANISM 0x00000166 540 541#define CKA_MODIFIABLE 0x00000170 542 543/* CKA_ECDSA_PARAMS is deprecated in v2.11, 544 * CKA_EC_PARAMS is preferred. */ 545#define CKA_ECDSA_PARAMS 0x00000180 546#define CKA_EC_PARAMS 0x00000180 547 548#define CKA_EC_POINT 0x00000181 549 550/* CKA_SECONDARY_AUTH, CKA_AUTH_PIN_FLAGS, 551 * are new for v2.10. Deprecated in v2.11 and onwards. */ 552#define CKA_SECONDARY_AUTH 0x00000200 553#define CKA_AUTH_PIN_FLAGS 0x00000201 554 555/* CKA_ALWAYS_AUTHENTICATE ... 556 * CKA_UNWRAP_TEMPLATE are new for v2.20 */ 557#define CKA_ALWAYS_AUTHENTICATE 0x00000202 558 559#define CKA_WRAP_WITH_TRUSTED 0x00000210 560#define CKA_WRAP_TEMPLATE (CKF_ARRAY_ATTRIBUTE|0x00000211) 561#define CKA_UNWRAP_TEMPLATE (CKF_ARRAY_ATTRIBUTE|0x00000212) 562 563/* CKA_HW_FEATURE_TYPE, CKA_RESET_ON_INIT, and CKA_HAS_RESET 564 * are new for v2.10 */ 565#define CKA_HW_FEATURE_TYPE 0x00000300 566#define CKA_RESET_ON_INIT 0x00000301 567#define CKA_HAS_RESET 0x00000302 568 569/* The following attributes are new for v2.20 */ 570#define CKA_PIXEL_X 0x00000400 571#define CKA_PIXEL_Y 0x00000401 572#define CKA_RESOLUTION 0x00000402 573#define CKA_CHAR_ROWS 0x00000403 574#define CKA_CHAR_COLUMNS 0x00000404 575#define CKA_COLOR 0x00000405 576#define CKA_BITS_PER_PIXEL 0x00000406 577#define CKA_CHAR_SETS 0x00000480 578#define CKA_ENCODING_METHODS 0x00000481 579#define CKA_MIME_TYPES 0x00000482 580#define CKA_MECHANISM_TYPE 0x00000500 581#define CKA_REQUIRED_CMS_ATTRIBUTES 0x00000501 582#define CKA_DEFAULT_CMS_ATTRIBUTES 0x00000502 583#define CKA_SUPPORTED_CMS_ATTRIBUTES 0x00000503 584#define CKA_ALLOWED_MECHANISMS (CKF_ARRAY_ATTRIBUTE|0x00000600) 585 586#define CKA_VENDOR_DEFINED 0x80000000 587 588 589/* CK_ATTRIBUTE is a structure that includes the type, length 590 * and value of an attribute */ 591typedef struct CK_ATTRIBUTE { 592 CK_ATTRIBUTE_TYPE type; 593 CK_VOID_PTR pValue; 594 595 /* ulValueLen went from CK_USHORT to CK_ULONG for v2.0 */ 596 CK_ULONG ulValueLen; /* in bytes */ 597} CK_ATTRIBUTE; 598 599typedef CK_ATTRIBUTE CK_PTR CK_ATTRIBUTE_PTR; 600 601 602/* CK_DATE is a structure that defines a date */ 603typedef struct CK_DATE{ 604 CK_CHAR year[4]; /* the year ("1900" - "9999") */ 605 CK_CHAR month[2]; /* the month ("01" - "12") */ 606 CK_CHAR day[2]; /* the day ("01" - "31") */ 607} CK_DATE; 608 609 610/* CK_MECHANISM_TYPE is a value that identifies a mechanism 611 * type */ 612/* CK_MECHANISM_TYPE was changed from CK_USHORT to CK_ULONG for 613 * v2.0 */ 614typedef CK_ULONG CK_MECHANISM_TYPE; 615 616/* the following mechanism types are defined: */ 617#define CKM_RSA_PKCS_KEY_PAIR_GEN 0x00000000 618#define CKM_RSA_PKCS 0x00000001 619#define CKM_RSA_9796 0x00000002 620#define CKM_RSA_X_509 0x00000003 621 622/* CKM_MD2_RSA_PKCS, CKM_MD5_RSA_PKCS, and CKM_SHA1_RSA_PKCS 623 * are new for v2.0. They are mechanisms which hash and sign */ 624#define CKM_MD2_RSA_PKCS 0x00000004 625#define CKM_MD5_RSA_PKCS 0x00000005 626#define CKM_SHA1_RSA_PKCS 0x00000006 627 628/* CKM_RIPEMD128_RSA_PKCS, CKM_RIPEMD160_RSA_PKCS, and 629 * CKM_RSA_PKCS_OAEP are new for v2.10 */ 630#define CKM_RIPEMD128_RSA_PKCS 0x00000007 631#define CKM_RIPEMD160_RSA_PKCS 0x00000008 632#define CKM_RSA_PKCS_OAEP 0x00000009 633 634/* CKM_RSA_X9_31_KEY_PAIR_GEN, CKM_RSA_X9_31, CKM_SHA1_RSA_X9_31, 635 * CKM_RSA_PKCS_PSS, and CKM_SHA1_RSA_PKCS_PSS are new for v2.11 */ 636#define CKM_RSA_X9_31_KEY_PAIR_GEN 0x0000000A 637#define CKM_RSA_X9_31 0x0000000B 638#define CKM_SHA1_RSA_X9_31 0x0000000C 639#define CKM_RSA_PKCS_PSS 0x0000000D 640#define CKM_SHA1_RSA_PKCS_PSS 0x0000000E 641 642#define CKM_DSA_KEY_PAIR_GEN 0x00000010 643#define CKM_DSA 0x00000011 644#define CKM_DSA_SHA1 0x00000012 645#define CKM_DH_PKCS_KEY_PAIR_GEN 0x00000020 646#define CKM_DH_PKCS_DERIVE 0x00000021 647 648/* CKM_X9_42_DH_KEY_PAIR_GEN, CKM_X9_42_DH_DERIVE, 649 * CKM_X9_42_DH_HYBRID_DERIVE, and CKM_X9_42_MQV_DERIVE are new for 650 * v2.11 */ 651#define CKM_X9_42_DH_KEY_PAIR_GEN 0x00000030 652#define CKM_X9_42_DH_DERIVE 0x00000031 653#define CKM_X9_42_DH_HYBRID_DERIVE 0x00000032 654#define CKM_X9_42_MQV_DERIVE 0x00000033 655 656/* CKM_SHA256/384/512 are new for v2.20 */ 657#define CKM_SHA256_RSA_PKCS 0x00000040 658#define CKM_SHA384_RSA_PKCS 0x00000041 659#define CKM_SHA512_RSA_PKCS 0x00000042 660#define CKM_SHA256_RSA_PKCS_PSS 0x00000043 661#define CKM_SHA384_RSA_PKCS_PSS 0x00000044 662#define CKM_SHA512_RSA_PKCS_PSS 0x00000045 663 664/* CKM_SHA224 new for v2.20 amendment 3 */ 665#define CKM_SHA224_RSA_PKCS 0x00000046 666#define CKM_SHA224_RSA_PKCS_PSS 0x00000047 667 668#define CKM_RC2_KEY_GEN 0x00000100 669#define CKM_RC2_ECB 0x00000101 670#define CKM_RC2_CBC 0x00000102 671#define CKM_RC2_MAC 0x00000103 672 673/* CKM_RC2_MAC_GENERAL and CKM_RC2_CBC_PAD are new for v2.0 */ 674#define CKM_RC2_MAC_GENERAL 0x00000104 675#define CKM_RC2_CBC_PAD 0x00000105 676 677#define CKM_RC4_KEY_GEN 0x00000110 678#define CKM_RC4 0x00000111 679#define CKM_DES_KEY_GEN 0x00000120 680#define CKM_DES_ECB 0x00000121 681#define CKM_DES_CBC 0x00000122 682#define CKM_DES_MAC 0x00000123 683 684/* CKM_DES_MAC_GENERAL and CKM_DES_CBC_PAD are new for v2.0 */ 685#define CKM_DES_MAC_GENERAL 0x00000124 686#define CKM_DES_CBC_PAD 0x00000125 687 688#define CKM_DES2_KEY_GEN 0x00000130 689#define CKM_DES3_KEY_GEN 0x00000131 690#define CKM_DES3_ECB 0x00000132 691#define CKM_DES3_CBC 0x00000133 692#define CKM_DES3_MAC 0x00000134 693 694/* CKM_DES3_MAC_GENERAL, CKM_DES3_CBC_PAD, CKM_CDMF_KEY_GEN, 695 * CKM_CDMF_ECB, CKM_CDMF_CBC, CKM_CDMF_MAC, 696 * CKM_CDMF_MAC_GENERAL, and CKM_CDMF_CBC_PAD are new for v2.0 */ 697#define CKM_DES3_MAC_GENERAL 0x00000135 698#define CKM_DES3_CBC_PAD 0x00000136 699#define CKM_CDMF_KEY_GEN 0x00000140 700#define CKM_CDMF_ECB 0x00000141 701#define CKM_CDMF_CBC 0x00000142 702#define CKM_CDMF_MAC 0x00000143 703#define CKM_CDMF_MAC_GENERAL 0x00000144 704#define CKM_CDMF_CBC_PAD 0x00000145 705 706/* the following four DES mechanisms are new for v2.20 */ 707#define CKM_DES_OFB64 0x00000150 708#define CKM_DES_OFB8 0x00000151 709#define CKM_DES_CFB64 0x00000152 710#define CKM_DES_CFB8 0x00000153 711 712#define CKM_MD2 0x00000200 713 714/* CKM_MD2_HMAC and CKM_MD2_HMAC_GENERAL are new for v2.0 */ 715#define CKM_MD2_HMAC 0x00000201 716#define CKM_MD2_HMAC_GENERAL 0x00000202 717 718#define CKM_MD5 0x00000210 719 720/* CKM_MD5_HMAC and CKM_MD5_HMAC_GENERAL are new for v2.0 */ 721#define CKM_MD5_HMAC 0x00000211 722#define CKM_MD5_HMAC_GENERAL 0x00000212 723 724#define CKM_SHA_1 0x00000220 725 726/* CKM_SHA_1_HMAC and CKM_SHA_1_HMAC_GENERAL are new for v2.0 */ 727#define CKM_SHA_1_HMAC 0x00000221 728#define CKM_SHA_1_HMAC_GENERAL 0x00000222 729 730/* CKM_RIPEMD128, CKM_RIPEMD128_HMAC, 731 * CKM_RIPEMD128_HMAC_GENERAL, CKM_RIPEMD160, CKM_RIPEMD160_HMAC, 732 * and CKM_RIPEMD160_HMAC_GENERAL are new for v2.10 */ 733#define CKM_RIPEMD128 0x00000230 734#define CKM_RIPEMD128_HMAC 0x00000231 735#define CKM_RIPEMD128_HMAC_GENERAL 0x00000232 736#define CKM_RIPEMD160 0x00000240 737#define CKM_RIPEMD160_HMAC 0x00000241 738#define CKM_RIPEMD160_HMAC_GENERAL 0x00000242 739 740/* CKM_SHA256/384/512 are new for v2.20 */ 741#define CKM_SHA256 0x00000250 742#define CKM_SHA256_HMAC 0x00000251 743#define CKM_SHA256_HMAC_GENERAL 0x00000252 744#define CKM_SHA384 0x00000260 745#define CKM_SHA384_HMAC 0x00000261 746#define CKM_SHA384_HMAC_GENERAL 0x00000262 747#define CKM_SHA512 0x00000270 748#define CKM_SHA512_HMAC 0x00000271 749#define CKM_SHA512_HMAC_GENERAL 0x00000272 750 751/* CKM_SHA224 new for v2.20 amendment 3 */ 752#define CKM_SHA224 0x00000255 753#define CKM_SHA224_HMAC 0x00000256 754#define CKM_SHA224_HMAC_GENERAL 0x00000257 755 756/* All of the following mechanisms are new for v2.0 */ 757/* Note that CAST128 and CAST5 are the same algorithm */ 758#define CKM_CAST_KEY_GEN 0x00000300 759#define CKM_CAST_ECB 0x00000301 760#define CKM_CAST_CBC 0x00000302 761#define CKM_CAST_MAC 0x00000303 762#define CKM_CAST_MAC_GENERAL 0x00000304 763#define CKM_CAST_CBC_PAD 0x00000305 764#define CKM_CAST3_KEY_GEN 0x00000310 765#define CKM_CAST3_ECB 0x00000311 766#define CKM_CAST3_CBC 0x00000312 767#define CKM_CAST3_MAC 0x00000313 768#define CKM_CAST3_MAC_GENERAL 0x00000314 769#define CKM_CAST3_CBC_PAD 0x00000315 770#define CKM_CAST5_KEY_GEN 0x00000320 771#define CKM_CAST128_KEY_GEN 0x00000320 772#define CKM_CAST5_ECB 0x00000321 773#define CKM_CAST128_ECB 0x00000321 774#define CKM_CAST5_CBC 0x00000322 775#define CKM_CAST128_CBC 0x00000322 776#define CKM_CAST5_MAC 0x00000323 777#define CKM_CAST128_MAC 0x00000323 778#define CKM_CAST5_MAC_GENERAL 0x00000324 779#define CKM_CAST128_MAC_GENERAL 0x00000324 780#define CKM_CAST5_CBC_PAD 0x00000325 781#define CKM_CAST128_CBC_PAD 0x00000325 782#define CKM_RC5_KEY_GEN 0x00000330 783#define CKM_RC5_ECB 0x00000331 784#define CKM_RC5_CBC 0x00000332 785#define CKM_RC5_MAC 0x00000333 786#define CKM_RC5_MAC_GENERAL 0x00000334 787#define CKM_RC5_CBC_PAD 0x00000335 788#define CKM_IDEA_KEY_GEN 0x00000340 789#define CKM_IDEA_ECB 0x00000341 790#define CKM_IDEA_CBC 0x00000342 791#define CKM_IDEA_MAC 0x00000343 792#define CKM_IDEA_MAC_GENERAL 0x00000344 793#define CKM_IDEA_CBC_PAD 0x00000345 794#define CKM_GENERIC_SECRET_KEY_GEN 0x00000350 795#define CKM_CONCATENATE_BASE_AND_KEY 0x00000360 796#define CKM_CONCATENATE_BASE_AND_DATA 0x00000362 797#define CKM_CONCATENATE_DATA_AND_BASE 0x00000363 798#define CKM_XOR_BASE_AND_DATA 0x00000364 799#define CKM_EXTRACT_KEY_FROM_KEY 0x00000365 800#define CKM_SSL3_PRE_MASTER_KEY_GEN 0x00000370 801#define CKM_SSL3_MASTER_KEY_DERIVE 0x00000371 802#define CKM_SSL3_KEY_AND_MAC_DERIVE 0x00000372 803 804/* CKM_SSL3_MASTER_KEY_DERIVE_DH, CKM_TLS_PRE_MASTER_KEY_GEN, 805 * CKM_TLS_MASTER_KEY_DERIVE, CKM_TLS_KEY_AND_MAC_DERIVE, and 806 * CKM_TLS_MASTER_KEY_DERIVE_DH are new for v2.11 */ 807#define CKM_SSL3_MASTER_KEY_DERIVE_DH 0x00000373 808#define CKM_TLS_PRE_MASTER_KEY_GEN 0x00000374 809#define CKM_TLS_MASTER_KEY_DERIVE 0x00000375 810#define CKM_TLS_KEY_AND_MAC_DERIVE 0x00000376 811#define CKM_TLS_MASTER_KEY_DERIVE_DH 0x00000377 812 813/* CKM_TLS_PRF is new for v2.20 */ 814#define CKM_TLS_PRF 0x00000378 815 816#define CKM_SSL3_MD5_MAC 0x00000380 817#define CKM_SSL3_SHA1_MAC 0x00000381 818#define CKM_MD5_KEY_DERIVATION 0x00000390 819#define CKM_MD2_KEY_DERIVATION 0x00000391 820#define CKM_SHA1_KEY_DERIVATION 0x00000392 821 822/* CKM_SHA256/384/512 are new for v2.20 */ 823#define CKM_SHA256_KEY_DERIVATION 0x00000393 824#define CKM_SHA384_KEY_DERIVATION 0x00000394 825#define CKM_SHA512_KEY_DERIVATION 0x00000395 826 827/* CKM_SHA224 new for v2.20 amendment 3 */ 828#define CKM_SHA224_KEY_DERIVATION 0x00000396 829 830#define CKM_PBE_MD2_DES_CBC 0x000003A0 831#define CKM_PBE_MD5_DES_CBC 0x000003A1 832#define CKM_PBE_MD5_CAST_CBC 0x000003A2 833#define CKM_PBE_MD5_CAST3_CBC 0x000003A3 834#define CKM_PBE_MD5_CAST5_CBC 0x000003A4 835#define CKM_PBE_MD5_CAST128_CBC 0x000003A4 836#define CKM_PBE_SHA1_CAST5_CBC 0x000003A5 837#define CKM_PBE_SHA1_CAST128_CBC 0x000003A5 838#define CKM_PBE_SHA1_RC4_128 0x000003A6 839#define CKM_PBE_SHA1_RC4_40 0x000003A7 840#define CKM_PBE_SHA1_DES3_EDE_CBC 0x000003A8 841#define CKM_PBE_SHA1_DES2_EDE_CBC 0x000003A9 842#define CKM_PBE_SHA1_RC2_128_CBC 0x000003AA 843#define CKM_PBE_SHA1_RC2_40_CBC 0x000003AB 844 845/* CKM_PKCS5_PBKD2 is new for v2.10 */ 846#define CKM_PKCS5_PBKD2 0x000003B0 847 848#define CKM_PBA_SHA1_WITH_SHA1_HMAC 0x000003C0 849 850/* WTLS mechanisms are new for v2.20 */ 851#define CKM_WTLS_PRE_MASTER_KEY_GEN 0x000003D0 852#define CKM_WTLS_MASTER_KEY_DERIVE 0x000003D1 853#define CKM_WTLS_MASTER_KEY_DERIVE_DH_ECC 0x000003D2 854#define CKM_WTLS_PRF 0x000003D3 855#define CKM_WTLS_SERVER_KEY_AND_MAC_DERIVE 0x000003D4 856#define CKM_WTLS_CLIENT_KEY_AND_MAC_DERIVE 0x000003D5 857 858#define CKM_KEY_WRAP_LYNKS 0x00000400 859#define CKM_KEY_WRAP_SET_OAEP 0x00000401 860 861/* CKM_CMS_SIG is new for v2.20 */ 862#define CKM_CMS_SIG 0x00000500 863 864/* Fortezza mechanisms */ 865#define CKM_SKIPJACK_KEY_GEN 0x00001000 866#define CKM_SKIPJACK_ECB64 0x00001001 867#define CKM_SKIPJACK_CBC64 0x00001002 868#define CKM_SKIPJACK_OFB64 0x00001003 869#define CKM_SKIPJACK_CFB64 0x00001004 870#define CKM_SKIPJACK_CFB32 0x00001005 871#define CKM_SKIPJACK_CFB16 0x00001006 872#define CKM_SKIPJACK_CFB8 0x00001007 873#define CKM_SKIPJACK_WRAP 0x00001008 874#define CKM_SKIPJACK_PRIVATE_WRAP 0x00001009 875#define CKM_SKIPJACK_RELAYX 0x0000100a 876#define CKM_KEA_KEY_PAIR_GEN 0x00001010 877#define CKM_KEA_KEY_DERIVE 0x00001011 878#define CKM_FORTEZZA_TIMESTAMP 0x00001020 879#define CKM_BATON_KEY_GEN 0x00001030 880#define CKM_BATON_ECB128 0x00001031 881#define CKM_BATON_ECB96 0x00001032 882#define CKM_BATON_CBC128 0x00001033 883#define CKM_BATON_COUNTER 0x00001034 884#define CKM_BATON_SHUFFLE 0x00001035 885#define CKM_BATON_WRAP 0x00001036 886 887/* CKM_ECDSA_KEY_PAIR_GEN is deprecated in v2.11, 888 * CKM_EC_KEY_PAIR_GEN is preferred */ 889#define CKM_ECDSA_KEY_PAIR_GEN 0x00001040 890#define CKM_EC_KEY_PAIR_GEN 0x00001040 891 892#define CKM_ECDSA 0x00001041 893#define CKM_ECDSA_SHA1 0x00001042 894 895/* CKM_ECDH1_DERIVE, CKM_ECDH1_COFACTOR_DERIVE, and CKM_ECMQV_DERIVE 896 * are new for v2.11 */ 897#define CKM_ECDH1_DERIVE 0x00001050 898#define CKM_ECDH1_COFACTOR_DERIVE 0x00001051 899#define CKM_ECMQV_DERIVE 0x00001052 900 901#define CKM_JUNIPER_KEY_GEN 0x00001060 902#define CKM_JUNIPER_ECB128 0x00001061 903#define CKM_JUNIPER_CBC128 0x00001062 904#define CKM_JUNIPER_COUNTER 0x00001063 905#define CKM_JUNIPER_SHUFFLE 0x00001064 906#define CKM_JUNIPER_WRAP 0x00001065 907#define CKM_FASTHASH 0x00001070 908 909/* CKM_AES_KEY_GEN, CKM_AES_ECB, CKM_AES_CBC, CKM_AES_MAC, 910 * CKM_AES_MAC_GENERAL, CKM_AES_CBC_PAD, CKM_DSA_PARAMETER_GEN, 911 * CKM_DH_PKCS_PARAMETER_GEN, and CKM_X9_42_DH_PARAMETER_GEN are 912 * new for v2.11 */ 913#define CKM_AES_KEY_GEN 0x00001080 914#define CKM_AES_ECB 0x00001081 915#define CKM_AES_CBC 0x00001082 916#define CKM_AES_MAC 0x00001083 917#define CKM_AES_MAC_GENERAL 0x00001084 918#define CKM_AES_CBC_PAD 0x00001085 919 920/* BlowFish and TwoFish are new for v2.20 */ 921#define CKM_BLOWFISH_KEY_GEN 0x00001090 922#define CKM_BLOWFISH_CBC 0x00001091 923#define CKM_TWOFISH_KEY_GEN 0x00001092 924#define CKM_TWOFISH_CBC 0x00001093 925 926/* Camellia is proposed for v2.20 Amendment 3 */ 927#define CKM_CAMELLIA_KEY_GEN 0x00000550 928#define CKM_CAMELLIA_ECB 0x00000551 929#define CKM_CAMELLIA_CBC 0x00000552 930#define CKM_CAMELLIA_MAC 0x00000553 931#define CKM_CAMELLIA_MAC_GENERAL 0x00000554 932#define CKM_CAMELLIA_CBC_PAD 0x00000555 933#define CKM_CAMELLIA_ECB_ENCRYPT_DATA 0x00000556 934#define CKM_CAMELLIA_CBC_ENCRYPT_DATA 0x00000557 935 936/* CKM_xxx_ENCRYPT_DATA mechanisms are new for v2.20 */ 937#define CKM_DES_ECB_ENCRYPT_DATA 0x00001100 938#define CKM_DES_CBC_ENCRYPT_DATA 0x00001101 939#define CKM_DES3_ECB_ENCRYPT_DATA 0x00001102 940#define CKM_DES3_CBC_ENCRYPT_DATA 0x00001103 941#define CKM_AES_ECB_ENCRYPT_DATA 0x00001104 942#define CKM_AES_CBC_ENCRYPT_DATA 0x00001105 943 944#define CKM_DSA_PARAMETER_GEN 0x00002000 945#define CKM_DH_PKCS_PARAMETER_GEN 0x00002001 946#define CKM_X9_42_DH_PARAMETER_GEN 0x00002002 947 948#define CKM_VENDOR_DEFINED 0x80000000 949 950typedef CK_MECHANISM_TYPE CK_PTR CK_MECHANISM_TYPE_PTR; 951 952 953/* CK_MECHANISM is a structure that specifies a particular 954 * mechanism */ 955typedef struct CK_MECHANISM { 956 CK_MECHANISM_TYPE mechanism; 957 CK_VOID_PTR pParameter; 958 959 /* ulParameterLen was changed from CK_USHORT to CK_ULONG for 960 * v2.0 */ 961 CK_ULONG ulParameterLen; /* in bytes */ 962} CK_MECHANISM; 963 964typedef CK_MECHANISM CK_PTR CK_MECHANISM_PTR; 965 966 967/* CK_MECHANISM_INFO provides information about a particular 968 * mechanism */ 969typedef struct CK_MECHANISM_INFO { 970 CK_ULONG ulMinKeySize; 971 CK_ULONG ulMaxKeySize; 972 CK_FLAGS flags; 973} CK_MECHANISM_INFO; 974 975/* The flags are defined as follows: 976 * Bit Flag Mask Meaning */ 977#define CKF_HW 0x00000001 /* performed by HW */ 978 979/* The flags CKF_ENCRYPT, CKF_DECRYPT, CKF_DIGEST, CKF_SIGN, 980 * CKG_SIGN_RECOVER, CKF_VERIFY, CKF_VERIFY_RECOVER, 981 * CKF_GENERATE, CKF_GENERATE_KEY_PAIR, CKF_WRAP, CKF_UNWRAP, 982 * and CKF_DERIVE are new for v2.0. They specify whether or not 983 * a mechanism can be used for a particular task */ 984#define CKF_ENCRYPT 0x00000100 985#define CKF_DECRYPT 0x00000200 986#define CKF_DIGEST 0x00000400 987#define CKF_SIGN 0x00000800 988#define CKF_SIGN_RECOVER 0x00001000 989#define CKF_VERIFY 0x00002000 990#define CKF_VERIFY_RECOVER 0x00004000 991#define CKF_GENERATE 0x00008000 992#define CKF_GENERATE_KEY_PAIR 0x00010000 993#define CKF_WRAP 0x00020000 994#define CKF_UNWRAP 0x00040000 995#define CKF_DERIVE 0x00080000 996 997/* CKF_EC_F_P, CKF_EC_F_2M, CKF_EC_ECPARAMETERS, CKF_EC_NAMEDCURVE, 998 * CKF_EC_UNCOMPRESS, and CKF_EC_COMPRESS are new for v2.11. They 999 * describe a token's EC capabilities not available in mechanism 1000 * information. */ 1001#define CKF_EC_F_P 0x00100000 1002#define CKF_EC_F_2M 0x00200000 1003#define CKF_EC_ECPARAMETERS 0x00400000 1004#define CKF_EC_NAMEDCURVE 0x00800000 1005#define CKF_EC_UNCOMPRESS 0x01000000 1006#define CKF_EC_COMPRESS 0x02000000 1007 1008#define CKF_EXTENSION 0x80000000 /* FALSE for this version */ 1009 1010typedef CK_MECHANISM_INFO CK_PTR CK_MECHANISM_INFO_PTR; 1011 1012 1013/* CK_RV is a value that identifies the return value of a 1014 * PKCS #11 function */ 1015/* CK_RV was changed from CK_USHORT to CK_ULONG for v2.0 */ 1016typedef CK_ULONG CK_RV; 1017 1018#define CKR_OK 0x00000000 1019#define CKR_CANCEL 0x00000001 1020#define CKR_HOST_MEMORY 0x00000002 1021#define CKR_SLOT_ID_INVALID 0x00000003 1022 1023/* CKR_FLAGS_INVALID was removed for v2.0 */ 1024 1025/* CKR_GENERAL_ERROR and CKR_FUNCTION_FAILED are new for v2.0 */ 1026#define CKR_GENERAL_ERROR 0x00000005 1027#define CKR_FUNCTION_FAILED 0x00000006 1028 1029/* CKR_ARGUMENTS_BAD, CKR_NO_EVENT, CKR_NEED_TO_CREATE_THREADS, 1030 * and CKR_CANT_LOCK are new for v2.01 */ 1031#define CKR_ARGUMENTS_BAD 0x00000007 1032#define CKR_NO_EVENT 0x00000008 1033#define CKR_NEED_TO_CREATE_THREADS 0x00000009 1034#define CKR_CANT_LOCK 0x0000000A 1035 1036#define CKR_ATTRIBUTE_READ_ONLY 0x00000010 1037#define CKR_ATTRIBUTE_SENSITIVE 0x00000011 1038#define CKR_ATTRIBUTE_TYPE_INVALID 0x00000012 1039#define CKR_ATTRIBUTE_VALUE_INVALID 0x00000013 1040#define CKR_DATA_INVALID 0x00000020 1041#define CKR_DATA_LEN_RANGE 0x00000021 1042#define CKR_DEVICE_ERROR 0x00000030 1043#define CKR_DEVICE_MEMORY 0x00000031 1044#define CKR_DEVICE_REMOVED 0x00000032 1045#define CKR_ENCRYPTED_DATA_INVALID 0x00000040 1046#define CKR_ENCRYPTED_DATA_LEN_RANGE 0x00000041 1047#define CKR_FUNCTION_CANCELED 0x00000050 1048#define CKR_FUNCTION_NOT_PARALLEL 0x00000051 1049 1050/* CKR_FUNCTION_NOT_SUPPORTED is new for v2.0 */ 1051#define CKR_FUNCTION_NOT_SUPPORTED 0x00000054 1052 1053#define CKR_KEY_HANDLE_INVALID 0x00000060 1054 1055/* CKR_KEY_SENSITIVE was removed for v2.0 */ 1056 1057#define CKR_KEY_SIZE_RANGE 0x00000062 1058#define CKR_KEY_TYPE_INCONSISTENT 0x00000063 1059 1060/* CKR_KEY_NOT_NEEDED, CKR_KEY_CHANGED, CKR_KEY_NEEDED, 1061 * CKR_KEY_INDIGESTIBLE, CKR_KEY_FUNCTION_NOT_PERMITTED, 1062 * CKR_KEY_NOT_WRAPPABLE, and CKR_KEY_UNEXTRACTABLE are new for 1063 * v2.0 */ 1064#define CKR_KEY_NOT_NEEDED 0x00000064 1065#define CKR_KEY_CHANGED 0x00000065 1066#define CKR_KEY_NEEDED 0x00000066 1067#define CKR_KEY_INDIGESTIBLE 0x00000067 1068#define CKR_KEY_FUNCTION_NOT_PERMITTED 0x00000068 1069#define CKR_KEY_NOT_WRAPPABLE 0x00000069 1070#define CKR_KEY_UNEXTRACTABLE 0x0000006A 1071 1072#define CKR_MECHANISM_INVALID 0x00000070 1073#define CKR_MECHANISM_PARAM_INVALID 0x00000071 1074 1075/* CKR_OBJECT_CLASS_INCONSISTENT and CKR_OBJECT_CLASS_INVALID 1076 * were removed for v2.0 */ 1077#define CKR_OBJECT_HANDLE_INVALID 0x00000082 1078#define CKR_OPERATION_ACTIVE 0x00000090 1079#define CKR_OPERATION_NOT_INITIALIZED 0x00000091 1080#define CKR_PIN_INCORRECT 0x000000A0 1081#define CKR_PIN_INVALID 0x000000A1 1082#define CKR_PIN_LEN_RANGE 0x000000A2 1083 1084/* CKR_PIN_EXPIRED and CKR_PIN_LOCKED are new for v2.0 */ 1085#define CKR_PIN_EXPIRED 0x000000A3 1086#define CKR_PIN_LOCKED 0x000000A4 1087 1088#define CKR_SESSION_CLOSED 0x000000B0 1089#define CKR_SESSION_COUNT 0x000000B1 1090#define CKR_SESSION_HANDLE_INVALID 0x000000B3 1091#define CKR_SESSION_PARALLEL_NOT_SUPPORTED 0x000000B4 1092#define CKR_SESSION_READ_ONLY 0x000000B5 1093#define CKR_SESSION_EXISTS 0x000000B6 1094 1095/* CKR_SESSION_READ_ONLY_EXISTS and 1096 * CKR_SESSION_READ_WRITE_SO_EXISTS are new for v2.0 */ 1097#define CKR_SESSION_READ_ONLY_EXISTS 0x000000B7 1098#define CKR_SESSION_READ_WRITE_SO_EXISTS 0x000000B8 1099 1100#define CKR_SIGNATURE_INVALID 0x000000C0 1101#define CKR_SIGNATURE_LEN_RANGE 0x000000C1 1102#define CKR_TEMPLATE_INCOMPLETE 0x000000D0 1103#define CKR_TEMPLATE_INCONSISTENT 0x000000D1 1104#define CKR_TOKEN_NOT_PRESENT 0x000000E0 1105#define CKR_TOKEN_NOT_RECOGNIZED 0x000000E1 1106#define CKR_TOKEN_WRITE_PROTECTED 0x000000E2 1107#define CKR_UNWRAPPING_KEY_HANDLE_INVALID 0x000000F0 1108#define CKR_UNWRAPPING_KEY_SIZE_RANGE 0x000000F1 1109#define CKR_UNWRAPPING_KEY_TYPE_INCONSISTENT 0x000000F2 1110#define CKR_USER_ALREADY_LOGGED_IN 0x00000100 1111#define CKR_USER_NOT_LOGGED_IN 0x00000101 1112#define CKR_USER_PIN_NOT_INITIALIZED 0x00000102 1113#define CKR_USER_TYPE_INVALID 0x00000103 1114 1115/* CKR_USER_ANOTHER_ALREADY_LOGGED_IN and CKR_USER_TOO_MANY_TYPES 1116 * are new to v2.01 */ 1117#define CKR_USER_ANOTHER_ALREADY_LOGGED_IN 0x00000104 1118#define CKR_USER_TOO_MANY_TYPES 0x00000105 1119 1120#define CKR_WRAPPED_KEY_INVALID 0x00000110 1121#define CKR_WRAPPED_KEY_LEN_RANGE 0x00000112 1122#define CKR_WRAPPING_KEY_HANDLE_INVALID 0x00000113 1123#define CKR_WRAPPING_KEY_SIZE_RANGE 0x00000114 1124#define CKR_WRAPPING_KEY_TYPE_INCONSISTENT 0x00000115 1125#define CKR_RANDOM_SEED_NOT_SUPPORTED 0x00000120 1126 1127/* These are new to v2.0 */ 1128#define CKR_RANDOM_NO_RNG 0x00000121 1129 1130/* These are new to v2.11 */ 1131#define CKR_DOMAIN_PARAMS_INVALID 0x00000130 1132 1133/* These are new to v2.0 */ 1134#define CKR_BUFFER_TOO_SMALL 0x00000150 1135#define CKR_SAVED_STATE_INVALID 0x00000160 1136#define CKR_INFORMATION_SENSITIVE 0x00000170 1137#define CKR_STATE_UNSAVEABLE 0x00000180 1138 1139/* These are new to v2.01 */ 1140#define CKR_CRYPTOKI_NOT_INITIALIZED 0x00000190 1141#define CKR_CRYPTOKI_ALREADY_INITIALIZED 0x00000191 1142#define CKR_MUTEX_BAD 0x000001A0 1143#define CKR_MUTEX_NOT_LOCKED 0x000001A1 1144 1145/* This is new to v2.20 */ 1146#define CKR_FUNCTION_REJECTED 0x00000200 1147 1148#define CKR_VENDOR_DEFINED 0x80000000 1149 1150 1151/* CK_NOTIFY is an application callback that processes events */ 1152typedef CK_CALLBACK_FUNCTION(CK_RV, CK_NOTIFY)( 1153 CK_SESSION_HANDLE hSession, /* the session's handle */ 1154 CK_NOTIFICATION event, 1155 CK_VOID_PTR pApplication /* passed to C_OpenSession */ 1156); 1157 1158 1159/* CK_FUNCTION_LIST is a structure holding a PKCS #11 spec 1160 * version and pointers of appropriate types to all the 1161 * PKCS #11 functions */ 1162/* CK_FUNCTION_LIST is new for v2.0 */ 1163typedef struct CK_FUNCTION_LIST CK_FUNCTION_LIST; 1164 1165typedef CK_FUNCTION_LIST CK_PTR CK_FUNCTION_LIST_PTR; 1166 1167typedef CK_FUNCTION_LIST_PTR CK_PTR CK_FUNCTION_LIST_PTR_PTR; 1168 1169 1170/* CK_CREATEMUTEX is an application callback for creating a 1171 * mutex object */ 1172typedef CK_CALLBACK_FUNCTION(CK_RV, CK_CREATEMUTEX)( 1173 CK_VOID_PTR_PTR ppMutex /* location to receive ptr to mutex */ 1174); 1175 1176 1177/* CK_DESTROYMUTEX is an application callback for destroying a 1178 * mutex object */ 1179typedef CK_CALLBACK_FUNCTION(CK_RV, CK_DESTROYMUTEX)( 1180 CK_VOID_PTR pMutex /* pointer to mutex */ 1181); 1182 1183 1184/* CK_LOCKMUTEX is an application callback for locking a mutex */ 1185typedef CK_CALLBACK_FUNCTION(CK_RV, CK_LOCKMUTEX)( 1186 CK_VOID_PTR pMutex /* pointer to mutex */ 1187); 1188 1189 1190/* CK_UNLOCKMUTEX is an application callback for unlocking a 1191 * mutex */ 1192typedef CK_CALLBACK_FUNCTION(CK_RV, CK_UNLOCKMUTEX)( 1193 CK_VOID_PTR pMutex /* pointer to mutex */ 1194); 1195 1196 1197/* CK_C_INITIALIZE_ARGS provides the optional arguments to 1198 * C_Initialize */ 1199typedef struct CK_C_INITIALIZE_ARGS { 1200 CK_CREATEMUTEX CreateMutex; 1201 CK_DESTROYMUTEX DestroyMutex; 1202 CK_LOCKMUTEX LockMutex; 1203 CK_UNLOCKMUTEX UnlockMutex; 1204 CK_FLAGS flags; 1205 /* The official PKCS #11 spec does not have a 'LibraryParameters' field, but 1206 * a reserved field. NSS needs a way to pass instance-specific information 1207 * to the library (like where to find its config files, etc). This 1208 * information is usually provided by the installer and passed uninterpreted 1209 * by NSS to the library, though NSS does know the specifics of the softoken 1210 * version of this parameter. Most compliant PKCS#11 modules expect this 1211 * parameter to be NULL, and will return CKR_ARGUMENTS_BAD from 1212 * C_Initialize if Library parameters is supplied. */ 1213 CK_CHAR_PTR *LibraryParameters; 1214 /* This field is only present if the LibraryParameters is not NULL. It must 1215 * be NULL in all cases */ 1216 CK_VOID_PTR pReserved; 1217} CK_C_INITIALIZE_ARGS; 1218 1219/* flags: bit flags that provide capabilities of the slot 1220 * Bit Flag Mask Meaning 1221 */ 1222#define CKF_LIBRARY_CANT_CREATE_OS_THREADS 0x00000001 1223#define CKF_OS_LOCKING_OK 0x00000002 1224 1225typedef CK_C_INITIALIZE_ARGS CK_PTR CK_C_INITIALIZE_ARGS_PTR; 1226 1227 1228/* additional flags for parameters to functions */ 1229 1230/* CKF_DONT_BLOCK is for the function C_WaitForSlotEvent */ 1231#define CKF_DONT_BLOCK 1 1232 1233/* CK_RSA_PKCS_OAEP_MGF_TYPE is new for v2.10. 1234 * CK_RSA_PKCS_OAEP_MGF_TYPE is used to indicate the Message 1235 * Generation Function (MGF) applied to a message block when 1236 * formatting a message block for the PKCS #1 OAEP encryption 1237 * scheme. */ 1238typedef CK_ULONG CK_RSA_PKCS_MGF_TYPE; 1239 1240typedef CK_RSA_PKCS_MGF_TYPE CK_PTR CK_RSA_PKCS_MGF_TYPE_PTR; 1241 1242/* The following MGFs are defined */ 1243/* CKG_MGF1_SHA256, CKG_MGF1_SHA384, and CKG_MGF1_SHA512 1244 * are new for v2.20 */ 1245#define CKG_MGF1_SHA1 0x00000001 1246#define CKG_MGF1_SHA256 0x00000002 1247#define CKG_MGF1_SHA384 0x00000003 1248#define CKG_MGF1_SHA512 0x00000004 1249 1250/* v2.20 amendment 3 */ 1251#define CKG_MGF1_SHA224 0x00000005 1252 1253/* CK_RSA_PKCS_OAEP_SOURCE_TYPE is new for v2.10. 1254 * CK_RSA_PKCS_OAEP_SOURCE_TYPE is used to indicate the source 1255 * of the encoding parameter when formatting a message block 1256 * for the PKCS #1 OAEP encryption scheme. */ 1257typedef CK_ULONG CK_RSA_PKCS_OAEP_SOURCE_TYPE; 1258 1259typedef CK_RSA_PKCS_OAEP_SOURCE_TYPE CK_PTR CK_RSA_PKCS_OAEP_SOURCE_TYPE_PTR; 1260 1261/* The following encoding parameter sources are defined */ 1262#define CKZ_DATA_SPECIFIED 0x00000001 1263 1264/* CK_RSA_PKCS_OAEP_PARAMS is new for v2.10. 1265 * CK_RSA_PKCS_OAEP_PARAMS provides the parameters to the 1266 * CKM_RSA_PKCS_OAEP mechanism. */ 1267typedef struct CK_RSA_PKCS_OAEP_PARAMS { 1268 CK_MECHANISM_TYPE hashAlg; 1269 CK_RSA_PKCS_MGF_TYPE mgf; 1270 CK_RSA_PKCS_OAEP_SOURCE_TYPE source; 1271 CK_VOID_PTR pSourceData; 1272 CK_ULONG ulSourceDataLen; 1273} CK_RSA_PKCS_OAEP_PARAMS; 1274 1275typedef CK_RSA_PKCS_OAEP_PARAMS CK_PTR CK_RSA_PKCS_OAEP_PARAMS_PTR; 1276 1277/* CK_RSA_PKCS_PSS_PARAMS is new for v2.11. 1278 * CK_RSA_PKCS_PSS_PARAMS provides the parameters to the 1279 * CKM_RSA_PKCS_PSS mechanism(s). */ 1280typedef struct CK_RSA_PKCS_PSS_PARAMS { 1281 CK_MECHANISM_TYPE hashAlg; 1282 CK_RSA_PKCS_MGF_TYPE mgf;…
Large files files are truncated, but you can click here to view the full file