pkcs11n.h (31219B)
1 /* This Source Code Form is subject to the terms of the Mozilla Public 2 * License, v. 2.0. If a copy of the MPL was not distributed with this 3 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 4 5 #ifndef _PKCS11N_H_ 6 #define _PKCS11N_H_ 7 8 /* "friendly" macros to allow us to deprecate certain #defines */ 9 #if defined(__GNUC__) && (__GNUC__ > 3) && !defined(NSS_SKIP_DEPRECATION_WARNING) 10 /* make GCC warn when we use these #defines */ 11 /* 12 * This is really painful because GCC doesn't allow us to mark random 13 * #defines as deprecated. We can only mark the following: 14 * functions, variables, and types. 15 * const variables will create extra storage for everyone including this 16 * header file, so it's undesirable. 17 * functions could be inlined to prevent storage creation, but will fail 18 * when constant values are expected (like switch statements). 19 * enum types do not seem to pay attention to the deprecated attribute. 20 * 21 * That leaves typedefs. We declare new types that we then deprecate, then 22 * cast the resulting value to the deprecated type in the #define, thus 23 * producting the warning when the #define is used. 24 * 25 * To make this work with the C preprocessor, we first include a 26 * _NSS_DEPRECATE_DEFINE_TYPE(type, name, message) declaration in our code 27 * with: 28 * 'type' being the base type that the #define is for (CK_TRUST, 29 * CK_MECHANISM_TTYPE, CK_KEY_TYPE etc.) 30 * 'name' being a unique name for the type (usually the name of the 31 * #define) 32 * 'message' is the string to print out when the compilier warns about 33 * the deprecated object. This only works in GCC >= 4.5 and 34 * is ignored on all other platforms. 35 * We then do a normal #define with _NSS_DEPRECATED_DEFINE_TYPE(name, value) 36 * as the value with: 37 * 'name' the same unique name used in _NSS_DEPRECATE_DEFINE_TYPE 38 * 'value' what you would normally place in the value. 39 * 40 * Just deprecating structs are easier, if the struct isn't already aliased 41 * to some other struct, make your own alias for it, then use 42 * 43 * _NSS_DEPRECATE_STRUCT(alias, name, message) 44 * with: 45 * 'alias' the alias structure. 46 * 'name' the name of the deprecated structure 47 * 'message' is the string to print out when the compilier warns about 48 * the deprecated object. This only works in GCC >= 4.5 and 49 * is ignored on all other platforms. 50 * 51 * 52 */ 53 #if (__GNUC__ == 4) && (__GNUC_MINOR__ < 5) 54 /* The mac doesn't like the friendlier deprecate messages. I'm assuming this 55 * is a gcc version issue rather than mac or ppc specific */ 56 #define _NSS_DEPRECATE_DEFINE_TYPE(type, name, message) \ 57 typedef type __deprecate_##name __attribute__((deprecated)); 58 #define _NSS_DEPRECATE_DEFINE_VALUE(name, value) ((__deprecate_##name)(value)) 59 60 #define _NSS_DEPRECATE_STRUCT(alias, name, message) \ 61 typedef alias name __attribute__((deprecated)); 62 63 #else /*__GNUC__ >= 4.5 */ 64 65 #define _NSS_DEPRECATE_DEFINE_TYPE(type, name, message) \ 66 typedef type __deprecate_##name __attribute__((deprecated(message))); 67 #define _NSS_DEPRECATE_DEFINE_VALUE(name, value) ((__deprecate_##name)(value)) 68 69 #define _NSS_DEPRECATE_STRUCT(alias, name, message) \ 70 typedef alias name __attribute__((deprecated(message))); 71 72 #endif /* __GNUC__ < 4.5 */ 73 #else /* !__GNUC__ */ 74 #if defined(_WIN32) && !defined(NSS_SKIP_DEPRECATION_WARNING) 75 /* windows, we just use pragma deprecated(identifier) */ 76 77 #define _NSS_DEPRECATE_DEFINE_TYPE(type, name, message) 78 /* #pragma deprecated(name) */ 79 #define _NSS_DEPRECATE_DEFINE_VALUE(name, value) (value) 80 81 #define _NSS_DEPRECATE_STRUCT(alias, name, message) \ 82 /* #pragma deprecated(name) */ typedef alias name; 83 84 #else /* not WIN or GNUC, just define the structure */ 85 86 /* fall back to just defining the thing we want without a deprecation warning */ 87 #define _NSS_DEPRECATE_DEFINE_TYPE(type, name, message) 88 #define _NSS_DEPRECATE_DEFINE_VALUE(name, value) (value) 89 #define _NSS_DEPRECATE_STRUCT(alias, name, message) \ 90 typedef alias name; 91 92 #endif /* !_WIN32 */ 93 #endif /*!__GNUC__ */ 94 95 /* 96 * pkcs11n.h 97 * 98 * This file contains the NSS-specific type definitions for Cryptoki 99 * (PKCS#11). 100 */ 101 102 /* 103 * NSSCK_VENDOR_NSS 104 * 105 * Cryptoki reserves the high half of all the number spaces for 106 * vendor-defined use. I'd like to keep all of our NSS- 107 * specific values together, but not in the oh-so-obvious 108 * 0x80000001, 0x80000002, etc. area. So I've picked an offset, 109 * and constructed values for the beginnings of our spaces. 110 * 111 * Note that some "historical" Netscape values don't fall within 112 * this range. 113 */ 114 #define NSSCK_VENDOR_NSS 0x4E534350 /* NSCP */ 115 116 /* 117 * NSS-defined object classes 118 * 119 */ 120 #define CKO_NSS (CKO_VENDOR_DEFINED | NSSCK_VENDOR_NSS) 121 122 #define CKO_NSS_CRL (CKO_NSS + 1) 123 #define CKO_NSS_SMIME (CKO_NSS + 2) 124 #define CKO_NSS_TRUST (CKO_NSS + 3) 125 #define CKO_NSS_BUILTIN_ROOT_LIST (CKO_NSS + 4) 126 #define CKO_NSS_NEWSLOT (CKO_NSS + 5) 127 #define CKO_NSS_DELSLOT (CKO_NSS + 6) 128 #define CKO_NSS_VALIDATION (CKO_NSS + 7) 129 130 #define CKV_NSS_FIPS_140 (CKO_NSS + 1) 131 132 /* 133 * NSS-defined key types 134 * 135 */ 136 #define CKK_NSS (CKK_VENDOR_DEFINED | NSSCK_VENDOR_NSS) 137 138 #define CKK_NSS_PKCS8 (CKK_NSS + 1) 139 140 #define CKK_NSS_JPAKE_ROUND1 (CKK_NSS + 2) 141 #define CKK_NSS_JPAKE_ROUND2 (CKK_NSS + 3) 142 143 #define CKK_NSS_CHACHA20 (CKK_NSS + 4) 144 145 #define CKK_NSS_KYBER (CKK_NSS + 5) 146 #define CKK_NSS_ML_KEM (CKK_NSS + 6) 147 148 /* 149 * NSS-defined certificate types 150 * 151 */ 152 #define CKC_NSS (CKC_VENDOR_DEFINED | NSSCK_VENDOR_NSS) 153 154 /* FAKE PKCS #11 defines */ 155 /* These are used internally in the pk11wrap layer as operations and should not 156 * be passed to softoken or any other PKCS#11 module as actual attributes */ 157 #define CKA_DIGEST 0x81000000L 158 #define CKA_NSS_MESSAGE 0x82000000L 159 #define CKA_NSS_SIGNATURE 0x83000000L 160 #define CKA_NSS_MESSAGE_MASK 0xff000000L 161 #define CKA_FLAGS_ONLY 0 /* CKA_CLASS */ 162 #define CKA_NSS_VERIFY_SIGNATURE (CKA_NSS_SIGNATURE | CKA_VERIFY) 163 164 /* 165 * NSS-defined object attributes 166 * 167 */ 168 #define CKA_NSS (CKA_VENDOR_DEFINED | NSSCK_VENDOR_NSS) 169 170 #define CKA_NSS_URL (CKA_NSS + 1) 171 #define CKA_NSS_EMAIL (CKA_NSS + 2) 172 #define CKA_NSS_SMIME_INFO (CKA_NSS + 3) 173 #define CKA_NSS_SMIME_TIMESTAMP (CKA_NSS + 4) 174 #define CKA_NSS_PKCS8_SALT (CKA_NSS + 5) 175 #define CKA_NSS_PASSWORD_CHECK (CKA_NSS + 6) 176 #define CKA_NSS_EXPIRES (CKA_NSS + 7) 177 #define CKA_NSS_KRL (CKA_NSS + 8) 178 179 #define CKA_NSS_PQG_COUNTER (CKA_NSS + 20) 180 #define CKA_NSS_PQG_SEED (CKA_NSS + 21) 181 #define CKA_NSS_PQG_H (CKA_NSS + 22) 182 #define CKA_NSS_PQG_SEED_BITS (CKA_NSS + 23) 183 #define CKA_NSS_MODULE_SPEC (CKA_NSS + 24) 184 #define CKA_NSS_OVERRIDE_EXTENSIONS (CKA_NSS + 25) 185 186 #define CKA_NSS_JPAKE_SIGNERID (CKA_NSS + 26) 187 #define CKA_NSS_JPAKE_PEERID (CKA_NSS + 27) 188 #define CKA_NSS_JPAKE_GX1 (CKA_NSS + 28) 189 #define CKA_NSS_JPAKE_GX2 (CKA_NSS + 29) 190 #define CKA_NSS_JPAKE_GX3 (CKA_NSS + 30) 191 #define CKA_NSS_JPAKE_GX4 (CKA_NSS + 31) 192 #define CKA_NSS_JPAKE_X2 (CKA_NSS + 32) 193 #define CKA_NSS_JPAKE_X2S (CKA_NSS + 33) 194 195 #define CKA_NSS_MOZILLA_CA_POLICY (CKA_NSS + 34) 196 #define CKA_NSS_SERVER_DISTRUST_AFTER (CKA_NSS + 35) 197 #define CKA_NSS_EMAIL_DISTRUST_AFTER (CKA_NSS + 36) 198 199 #define CKA_NSS_VALIDATION_TYPE (CKA_NSS + 36) 200 #define CKA_NSS_VALIDATION_VERSION (CKA_NSS + 37) 201 #define CKA_NSS_VALIDATION_LEVEL (CKA_NSS + 38) 202 #define CKA_NSS_VALIDATION_MODULE_ID (CKA_NSS + 39) 203 204 #define CKA_NSS_PARAMETER_SET (CKA_NSS + 40) 205 /* this is an intern NSS signalling attribute, you'll 206 * never see it in an application accessible object */ 207 #define CKA_NSS_SEED_OK (CKA_NSS + 41) 208 209 /* 210 * Trust attributes: 211 * 212 * If trust attributes are now standard, but we didn't use 213 * NSS specific names, so the CKA_ names collide with the standard 214 * names. We'll update NSS to use specific names, and applications 215 * can use The #NSS_USE_STANDARD_TRUST define to select which values 216 * the CKA_TRUST_XXX names should map to. 217 * 218 * In our code we'll expect CKA_NSS_TRUST_xxx attributes in 219 * CKO_NSS_TRUST objects and CKA_PKCS_TRUST attributes in 220 * CKO_TRUST objects. 221 */ 222 #define CKA_NSS_TRUST_BASE (CKA_NSS + 0x2000) 223 224 /* "Usage" key information */ 225 #define CKA_NSS_TRUST_DIGITAL_SIGNATURE (CKA_NSS_TRUST_BASE + 1) 226 #define CKA_NSS_TRUST_NON_REPUDIATION (CKA_NSS_TRUST_BASE + 2) 227 #define CKA_NSS_TRUST_KEY_ENCIPHERMENT (CKA_NSS_TRUST_BASE + 3) 228 #define CKA_NSS_TRUST_DATA_ENCIPHERMENT (CKA_NSS_TRUST_BASE + 4) 229 #define CKA_NSS_TRUST_KEY_AGREEMENT (CKA_NSS_TRUST_BASE + 5) 230 #define CKA_NSS_TRUST_KEY_CERT_SIGN (CKA_NSS_TRUST_BASE + 6) 231 #define CKA_NSS_TRUST_CRL_SIGN (CKA_NSS_TRUST_BASE + 7) 232 233 /* "Purpose" trust information */ 234 #define CKA_NSS_TRUST_SERVER_AUTH (CKA_NSS_TRUST_BASE + 8) 235 #define CKA_NSS_TRUST_CLIENT_AUTH (CKA_NSS_TRUST_BASE + 9) 236 #define CKA_NSS_TRUST_CODE_SIGNING (CKA_NSS_TRUST_BASE + 10) 237 #define CKA_NSS_TRUST_EMAIL_PROTECTION (CKA_NSS_TRUST_BASE + 11) 238 #define CKA_NSS_TRUST_IPSEC_END_SYSTEM (CKA_NSS_TRUST_BASE + 12) 239 #define CKA_NSS_TRUST_IPSEC_TUNNEL (CKA_NSS_TRUST_BASE + 13) 240 #define CKA_NSS_TRUST_IPSEC_USER (CKA_NSS_TRUST_BASE + 14) 241 #define CKA_NSS_TRUST_TIME_STAMPING (CKA_NSS_TRUST_BASE + 15) 242 #define CKA_NSS_TRUST_STEP_UP_APPROVED (CKA_NSS_TRUST_BASE + 16) 243 244 #define CKA_NSS_CERT_SHA1_HASH (CKA_NSS_TRUST_BASE + 100) 245 #define CKA_NSS_CERT_MD5_HASH (CKA_NSS_TRUST_BASE + 101) 246 247 #ifdef NSS_USE_STANDARD_TRUST 248 /* Names take on the PKCS #11 standard values */ 249 #define CKA_TRUST_SERVER_AUTH CKA_PKCS_TRUST_SERVER_AUTH 250 #define CKA_TRUST_CLIENT_AUTH CKA_PKCS_TRUST_CLIENT_AUTH 251 #define CKA_TRUST_CODE_SIGNING CKA_PKCS_TRUST_CODE_SIGNING 252 #define CKA_TRUST_EMAIL_PROTECTION CKA_PKCS_TRUST_EMAIL_PROTECTION 253 #define CKA_TRUST_TIME_STAMPING CKA_PKCS_TRUST_TIME_STAMPING 254 #define CKA_TRUST_OCSP_SIGNING CKA_PKCS_TRUST_OCSP_SIGNING 255 #else 256 /* Names take on the legacy NSS values */ 257 /* NOTE these don't actually colide with the PKCS #11 standard values 258 * but we want to rename to with the NSS in them anyway. When 259 * you set NSS_USE_STANDARD_TRUST, the non _NSS_ names will 260 * go away */ 261 #define CKA_TRUST CKA_NSS_TRUST_BASE 262 #define CKA_TRUST_DIGITAL_SIGNATURE CKA_NSS_TRUST_DIGITAL_SIGNATURE 263 #define CKA_TRUST_NON_REPUDIATION CKA_NSS_TRUST_NON_REPUDIATION 264 #define CKA_TRUST_KEY_ENCIPHERMENT CKA_NSS_TRUST_KEY_ENCIPHERMENT 265 #define CKA_TRUST_DATA_ENCIPHERMENT CKA_NSS_TRUST_DATA_ENCIPHERMENT 266 #define CKA_TRUST_KEY_AGREEMENT CKA_NSS_TRUST_KEY_AGREEMENT 267 #define CKA_TRUST_KEY_CERT_SIGN CKA_NSS_TRUST_KEY_CERT_SIGN 268 #define CKA_TRUST_CRL_SIGN CKA_NSS_TRUST_CRL_SIGN 269 #define CKA_TRUST_EMAIL_PROTECTION CKA_NSS_TRUST_EMAIL_PROTECTION 270 #define CKA_TRUST_IPSEC_END_SYSTEM CKA_NSS_TRUST_IPSEC_END_SYSTEM 271 #define CKA_TRUST_IPSEC_TUNNEL CKA_NSS_TRUST_IPSEC_TUNNEL 272 #define CKA_TRUST_IPSEC_USER CKA_NSS_TRUST_IPSEC_USER 273 #define CKA_TRUST_STEP_UP_APPROVED CKA_NSS_TRUST_STEP_UP_APPROVED 274 #define CKA_CERT_SHA1_HASH CKA_NSS_CERT_SHA1_HASH 275 #define CKA_CERT_MD5_HASH CKA_NSS_CERT_MD5_HASH 276 277 /* These names collide with pkcs #11 standard names */ 278 #define CKA_TRUST_SERVER_AUTH CKA_NSS_TRUST_SERVER_AUTH 279 #define CKA_TRUST_CLIENT_AUTH CKA_NSS_TRUST_CLIENT_AUTH 280 #define CKA_TRUST_CODE_SIGNING CKA_NSS_TRUST_CODE_SIGNING 281 #define CKA_TRUST_TIME_STAMPING CKA_NSS_TRUST_TIME_STAMPING 282 #endif 283 284 /* NSS trust stuff */ 285 286 /* HISTORICAL: define used to pass in the database key for DSA private keys */ 287 #define CKA_NSS_DB 0xD5A0DB00L 288 #define CKA_NSS_TRUST 0x80000001L 289 290 /* FAKE PKCS #11 defines */ 291 #define CKM_FAKE_RANDOM 0x80000efeUL 292 #define CKM_INVALID_MECHANISM 0xffffffffUL 293 #define CKT_INVALID_TYPE 0xffffffffUL 294 295 /* 296 * NSS-defined crypto mechanisms 297 * 298 */ 299 #define CKM_NSS (CKM_VENDOR_DEFINED | NSSCK_VENDOR_NSS) 300 301 #define CKM_NSS_AES_KEY_WRAP (CKM_NSS + 1) 302 #define CKM_NSS_AES_KEY_WRAP_PAD (CKM_NSS + 2) 303 304 /* HKDF key derivation mechanisms. See CK_NSS_HKDFParams for documentation. */ 305 #define CKM_NSS_HKDF_SHA1 (CKM_NSS + 3) 306 #define CKM_NSS_HKDF_SHA256 (CKM_NSS + 4) 307 #define CKM_NSS_HKDF_SHA384 (CKM_NSS + 5) 308 #define CKM_NSS_HKDF_SHA512 (CKM_NSS + 6) 309 310 /* J-PAKE round 1 key generation mechanisms. 311 * 312 * Required template attributes: CKA_PRIME, CKA_SUBPRIME, CKA_BASE, 313 * CKA_NSS_JPAKE_SIGNERID 314 * Output key type: CKK_NSS_JPAKE_ROUND1 315 * Output key class: CKO_PRIVATE_KEY 316 * Parameter type: CK_NSS_JPAKERound1Params 317 * 318 */ 319 #define CKM_NSS_JPAKE_ROUND1_SHA1 (CKM_NSS + 7) 320 #define CKM_NSS_JPAKE_ROUND1_SHA256 (CKM_NSS + 8) 321 #define CKM_NSS_JPAKE_ROUND1_SHA384 (CKM_NSS + 9) 322 #define CKM_NSS_JPAKE_ROUND1_SHA512 (CKM_NSS + 10) 323 324 /* J-PAKE round 2 key derivation mechanisms. 325 * 326 * Required template attributes: CKA_NSS_JPAKE_PEERID 327 * Input key type: CKK_NSS_JPAKE_ROUND1 328 * Output key type: CKK_NSS_JPAKE_ROUND2 329 * Output key class: CKO_PRIVATE_KEY 330 * Parameter type: CK_NSS_JPAKERound2Params 331 */ 332 #define CKM_NSS_JPAKE_ROUND2_SHA1 (CKM_NSS + 11) 333 #define CKM_NSS_JPAKE_ROUND2_SHA256 (CKM_NSS + 12) 334 #define CKM_NSS_JPAKE_ROUND2_SHA384 (CKM_NSS + 13) 335 #define CKM_NSS_JPAKE_ROUND2_SHA512 (CKM_NSS + 14) 336 337 /* J-PAKE final key material derivation mechanisms 338 * 339 * Input key type: CKK_NSS_JPAKE_ROUND2 340 * Output key type: CKK_GENERIC_SECRET 341 * Output key class: CKO_SECRET_KEY 342 * Parameter type: CK_NSS_JPAKEFinalParams 343 * 344 * You must apply a KDF (e.g. CKM_NSS_HKDF_*) to resultant keying material 345 * to get a key with uniformly distributed bits. 346 */ 347 #define CKM_NSS_JPAKE_FINAL_SHA1 (CKM_NSS + 15) 348 #define CKM_NSS_JPAKE_FINAL_SHA256 (CKM_NSS + 16) 349 #define CKM_NSS_JPAKE_FINAL_SHA384 (CKM_NSS + 17) 350 #define CKM_NSS_JPAKE_FINAL_SHA512 (CKM_NSS + 18) 351 352 /* Constant-time MAC mechanisms: 353 * 354 * These operations verify a padded, MAC-then-encrypt block of data in 355 * constant-time. Because of the order of operations, the padding bytes are not 356 * protected by the MAC. However, disclosing the value of the padding bytes 357 * gives an attacker the ability to decrypt ciphertexts. Such disclosure can be 358 * as subtle as taking slightly less time to perform the MAC when the padding 359 * is one byte longer. See https://www.isg.rhul.ac.uk/tls/ 360 * 361 * CKM_NSS_HMAC_CONSTANT_TIME: performs an HMAC authentication. 362 * CKM_NSS_SSL3_MAC_CONSTANT_TIME: performs an authentication with SSLv3 MAC. 363 * 364 * Parameter type: CK_NSS_MAC_CONSTANT_TIME_PARAMS 365 */ 366 #define CKM_NSS_HMAC_CONSTANT_TIME (CKM_NSS + 19) 367 #define CKM_NSS_SSL3_MAC_CONSTANT_TIME (CKM_NSS + 20) 368 369 /* TLS 1.2 mechanisms */ 370 #define CKM_NSS_TLS_PRF_GENERAL_SHA256 (CKM_NSS + 21) 371 #define CKM_NSS_TLS_MASTER_KEY_DERIVE_SHA256 (CKM_NSS + 22) 372 #define CKM_NSS_TLS_KEY_AND_MAC_DERIVE_SHA256 (CKM_NSS + 23) 373 #define CKM_NSS_TLS_MASTER_KEY_DERIVE_DH_SHA256 (CKM_NSS + 24) 374 375 /* TLS extended master secret derivation */ 376 #define CKM_NSS_TLS_EXTENDED_MASTER_KEY_DERIVE (CKM_NSS + 25) 377 #define CKM_NSS_TLS_EXTENDED_MASTER_KEY_DERIVE_DH (CKM_NSS + 26) 378 379 #define CKM_NSS_CHACHA20_KEY_GEN (CKM_NSS + 27) 380 #define CKM_NSS_CHACHA20_POLY1305 (CKM_NSS + 28) 381 382 /* Additional PKCS #12 PBE algorithms defined in v1.1 */ 383 #define CKM_NSS_PKCS12_PBE_SHA224_HMAC_KEY_GEN (CKM_NSS + 29) 384 #define CKM_NSS_PKCS12_PBE_SHA256_HMAC_KEY_GEN (CKM_NSS + 30) 385 #define CKM_NSS_PKCS12_PBE_SHA384_HMAC_KEY_GEN (CKM_NSS + 31) 386 #define CKM_NSS_PKCS12_PBE_SHA512_HMAC_KEY_GEN (CKM_NSS + 32) 387 388 #define CKM_NSS_CHACHA20_CTR (CKM_NSS + 33) 389 390 /* IKE mechanisms now defined in PKCS #11, use those instead now */ 391 #define CKM_NSS_IKE_PRF_PLUS_DERIVE (CKM_NSS + 34) 392 #define CKM_NSS_IKE_PRF_DERIVE (CKM_NSS + 35) 393 #define CKM_NSS_IKE1_PRF_DERIVE (CKM_NSS + 36) 394 #define CKM_NSS_IKE1_APP_B_PRF_DERIVE (CKM_NSS + 37) 395 396 #define CKM_NSS_PUB_FROM_PRIV (CKM_NSS + 40) 397 398 /* SP800-108 NSS mechanism with support for data object derivation */ 399 #define CKM_NSS_SP800_108_COUNTER_KDF_DERIVE_DATA (CKM_NSS + 42) 400 #define CKM_NSS_SP800_108_FEEDBACK_KDF_DERIVE_DATA (CKM_NSS + 43) 401 #define CKM_NSS_SP800_108_DOUBLE_PIPELINE_KDF_DERIVE_DATA (CKM_NSS + 44) 402 403 /* Kyber */ 404 #define CKM_NSS_KYBER_KEY_PAIR_GEN (CKM_NSS + 45) 405 #define CKM_NSS_KYBER (CKM_NSS + 46) 406 407 /* TLS ECDHE key pair generation. This is used to indicate that a key pair is 408 * for use in a single TLS handshake, so NIST SP 800-56A pairwise consistency 409 * checks can be skipped. It is otherwise identical to CKM_EC_KEY_PAIR_GEN. 410 */ 411 #define CKM_NSS_ECDHE_NO_PAIRWISE_CHECK_KEY_PAIR_GEN (CKM_NSS + 47) 412 413 /* ML-KEM */ 414 #define CKM_NSS_ML_KEM_KEY_PAIR_GEN (CKM_NSS + 48) 415 #define CKM_NSS_ML_KEM (CKM_NSS + 49) 416 417 /* 418 * HISTORICAL: 419 * Do not attempt to use these. They are only used by NSS's internal 420 * PKCS #11 interface. Most of these are place holders for other mechanism 421 * and will change in the future. 422 */ 423 #define CKM_NSS_PBE_SHA1_DES_CBC 0x80000002UL 424 #define CKM_NSS_PBE_SHA1_TRIPLE_DES_CBC 0x80000003UL 425 #define CKM_NSS_PBE_SHA1_40_BIT_RC2_CBC 0x80000004UL 426 #define CKM_NSS_PBE_SHA1_128_BIT_RC2_CBC 0x80000005UL 427 #define CKM_NSS_PBE_SHA1_40_BIT_RC4 0x80000006UL 428 #define CKM_NSS_PBE_SHA1_128_BIT_RC4 0x80000007UL 429 #define CKM_NSS_PBE_SHA1_FAULTY_3DES_CBC 0x80000008UL 430 #define CKM_NSS_PBE_SHA1_HMAC_KEY_GEN 0x80000009UL 431 #define CKM_NSS_PBE_MD5_HMAC_KEY_GEN 0x8000000aUL 432 #define CKM_NSS_PBE_MD2_HMAC_KEY_GEN 0x8000000bUL 433 434 #define CKM_TLS_PRF_GENERAL 0x80000373UL 435 436 /* Parameter set identifiers */ 437 #define CKP_NSS (CKM_VENDOR_DEFINED | NSSCK_VENDOR_NSS) 438 #define CKP_NSS_KYBER_768_ROUND3 (CKP_NSS + 1) 439 #define CKP_NSS_ML_KEM_768 (CKP_NSS + 2) 440 441 /* FIPS Indicator defines */ 442 #define CKS_NSS_UNINITIALIZED 0xffffffffUL 443 #define CKS_NSS_FIPS_NOT_OK 0UL 444 #define CKS_NSS_FIPS_OK 1UL 445 446 #define CKT_NSS_SESSION_CHECK 1UL 447 #define CKT_NSS_OBJECT_CHECK 2UL 448 #define CKT_NSS_BOTH_CHECK 3UL 449 #define CKT_NSS_SESSION_LAST_CHECK 4UL 450 451 typedef struct CK_NSS_JPAKEPublicValue { 452 CK_BYTE *pGX; 453 CK_ULONG ulGXLen; 454 CK_BYTE *pGV; 455 CK_ULONG ulGVLen; 456 CK_BYTE *pR; 457 CK_ULONG ulRLen; 458 } CK_NSS_JPAKEPublicValue; 459 460 typedef struct CK_NSS_JPAKERound1Params { 461 CK_NSS_JPAKEPublicValue gx1; /* out */ 462 CK_NSS_JPAKEPublicValue gx2; /* out */ 463 } CK_NSS_JPAKERound1Params; 464 465 typedef struct CK_NSS_JPAKERound2Params { 466 CK_BYTE *pSharedKey; /* in */ 467 CK_ULONG ulSharedKeyLen; /* in */ 468 CK_NSS_JPAKEPublicValue gx3; /* in */ 469 CK_NSS_JPAKEPublicValue gx4; /* in */ 470 CK_NSS_JPAKEPublicValue A; /* out */ 471 } CK_NSS_JPAKERound2Params; 472 473 typedef struct CK_NSS_JPAKEFinalParams { 474 CK_NSS_JPAKEPublicValue B; /* in */ 475 } CK_NSS_JPAKEFinalParams; 476 477 /* macAlg: the MAC algorithm to use. This determines the hash function used in 478 * the HMAC/SSLv3 MAC calculations. 479 * ulBodyTotalLen: the total length of the data, including padding bytes and 480 * padding length. 481 * pHeader: points to a block of data that contains additional data to 482 * authenticate. For TLS this includes the sequence number etc. For SSLv3, 483 * this also includes the initial padding bytes. 484 * 485 * NOTE: the softoken's implementation of CKM_NSS_HMAC_CONSTANT_TIME and 486 * CKM_NSS_SSL3_MAC_CONSTANT_TIME requires that the sum of ulBodyTotalLen 487 * and ulHeaderLen be much smaller than 2^32 / 8 bytes because it uses an 488 * unsigned int variable to represent the length in bits. This should not 489 * be a problem because the SSL/TLS protocol limits the size of an SSL 490 * record to something considerably less than 2^32 bytes. 491 */ 492 typedef struct CK_NSS_MAC_CONSTANT_TIME_PARAMS { 493 CK_MECHANISM_TYPE macAlg; /* in */ 494 CK_ULONG ulBodyTotalLen; /* in */ 495 CK_BYTE *pHeader; /* in */ 496 CK_ULONG ulHeaderLen; /* in */ 497 } CK_NSS_MAC_CONSTANT_TIME_PARAMS; 498 499 typedef struct CK_NSS_AEAD_PARAMS { 500 CK_BYTE_PTR pNonce; 501 CK_ULONG ulNonceLen; 502 CK_BYTE_PTR pAAD; 503 CK_ULONG ulAADLen; 504 CK_ULONG ulTagLen; 505 } CK_NSS_AEAD_PARAMS; 506 507 /* 508 * NSS-defined return values 509 * 510 */ 511 #define CKR_NSS (CKM_VENDOR_DEFINED | NSSCK_VENDOR_NSS) 512 513 #define CKR_NSS_CERTDB_FAILED (CKR_NSS + 1) 514 #define CKR_NSS_KEYDB_FAILED (CKR_NSS + 2) 515 516 /* NSS specific types */ 517 typedef CK_ULONG CK_NSS_VALIDATION_TYPE; 518 519 typedef CK_ULONG CK_NSS_KEM_PARAMETER_SET_TYPE; 520 521 /* Mandatory parameter for the CKM_NSS_HKDF_* key deriviation mechanisms. 522 See RFC 5869. 523 524 bExtract: If set, HKDF-Extract will be applied to the input key. If 525 the optional salt is given, it is used; otherwise, the salt is 526 set to a sequence of zeros equal in length to the HMAC output. 527 If bExpand is not set, then the key template given to 528 C_DeriveKey must indicate an output key size less than or equal 529 to the output size of the HMAC. 530 531 bExpand: If set, HKDF-Expand will be applied to the input key (if 532 bExtract is not set) or to the result of HKDF-Extract (if 533 bExtract is set). Any info given in the optional pInfo field will 534 be included in the calculation. 535 536 The size of the output key must be specified in the template passed to 537 C_DeriveKey. 538 */ 539 typedef struct CK_NSS_HKDFParams { 540 CK_BBOOL bExtract; 541 CK_BYTE_PTR pSalt; 542 CK_ULONG ulSaltLen; 543 CK_BBOOL bExpand; 544 CK_BYTE_PTR pInfo; 545 CK_ULONG ulInfoLen; 546 } CK_NSS_HKDFParams; 547 548 /* 549 * CK_NSS_IKE_PRF_PLUS_PARAMS is a structure that provides the parameters to 550 * the CKM_NSS_IKE_PRF_PLUS_DERIVE mechanism. 551 * It is now standardized, so The struct is just an alias for the standard 552 * struct in pkcs11t.h. 553 */ 554 typedef struct CK_IKE2_PRF_PLUS_DERIVE_PARAMS CK_NSS_IKE_PRF_PLUS_DERIVE_PARAMS; 555 556 /* CK_NSS_IKE_PRF_DERIVE_PARAMS is a structure that provides the parameters to 557 * the CKM_NSS_IKE_PRF_DERIVE mechanism. 558 * It is now standardized, so The struct is just an alias for the standard 559 * struct in pkcs11t.h. 560 */ 561 typedef struct CK_IKE_PRF_DERIVE_PARAMS CK_NSS_IKE_PRF_DERIVE_PARAMS; 562 563 /* CK_NSS_IKE1_PRF_DERIVE_PARAMS is a structure that provides the parameters 564 * to the CKM_NSS_IKE_PRF_DERIVE mechanism. 565 * It is now standardized, so The struct is just an alias for the standard 566 * struct in pkcs11t.h. 567 */ 568 typedef struct CK_IKE1_PRF_DERIVE_PARAMS CK_NSS_IKE1_PRF_DERIVE_PARAMS; 569 570 /* CK_NSS_IKE1_APP_B_PRF_DERIVE_PARAMS is a structure that provides the 571 * parameters to the CKM_NSS_IKE_APP_B_PRF_DERIVE mechanism. 572 * It is now standardized, so The struct is just an alias for the standard 573 * struct in pkcs11t.h. 574 */ 575 typedef struct CK_IKE1_EXTENDED_DERIVE_PARAMS CK_NSS_IKE1_APP_B_PRF_DERIVE_PARAMS; 576 577 /* 578 * Parameter for the TLS extended master secret key derivation mechanisms: 579 * 580 * * CKM_NSS_TLS_EXTENDED_MASTER_KEY_DERIVE 581 * * CKM_NSS_TLS_EXTENDED_MASTER_KEY_DERIVE_DH 582 * 583 * For the TLS 1.2 PRF, the prfHashMechanism parameter determines the hash 584 * function used. For earlier versions of the PRF, set the prfHashMechanism 585 * value to CKM_TLS_PRF. 586 * It is now standardized, so The struct is just an alias for the standard 587 * struct in pkcs11t.h. */ 588 typedef struct CK_TLS12_EXTENDED_MASTER_KEY_DERIVE_PARAMS 589 CK_NSS_TLS_EXTENDED_MASTER_KEY_DERIVE_PARAMS; 590 591 /* 592 * Trust info 593 * 594 * This now part of the Cryptoki standard , These are all the 595 * old vendor defined symbols. 596 */ 597 598 /* The following trust types are defined: */ 599 #define CKT_VENDOR_DEFINED 0x80000000 600 601 #define CKT_NSS (CKT_VENDOR_DEFINED | NSSCK_VENDOR_NSS) 602 603 /* If trust goes standard, these'll probably drop out of vendor space. */ 604 #define CKT_NSS_TRUSTED (CKT_NSS + 1) 605 #define CKT_NSS_TRUSTED_DELEGATOR (CKT_NSS + 2) 606 #define CKT_NSS_MUST_VERIFY_TRUST (CKT_NSS + 3) 607 #define CKT_NSS_NOT_TRUSTED (CKT_NSS + 10) 608 #define CKT_NSS_TRUST_UNKNOWN (CKT_NSS + 5) /* default */ 609 610 /* 611 * These may well remain NSS-specific; I'm only using them 612 * to cache resolution data. 613 */ 614 #define CKT_NSS_VALID_DELEGATOR (CKT_NSS + 11) 615 616 /* 617 * old definitions. They still exist, but the plain meaning of the 618 * labels have never been accurate to what was really implemented. 619 * The new labels correctly reflect what the values effectively mean. 620 */ 621 _NSS_DEPRECATE_DEFINE_TYPE(CK_TRUST, CKT_NSS_UNTRUSTED, 622 "CKT_NSS_UNTRUSTED really means CKT_NSS_MUST_VERIFY_TRUST") 623 #define CKT_NSS_UNTRUSTED \ 624 _NSS_DEPRECATE_DEFINE_VALUE(CKT_NSS_UNTRUSTED, CKT_NSS_MUST_VERIFY_TRUST) 625 _NSS_DEPRECATE_DEFINE_TYPE(CK_TRUST, CKT_NSS_VALID, 626 "CKT_NSS_VALID really means CKT_NSS_NOT_TRUSTED") 627 #define CKT_NSS_VALID \ 628 _NSS_DEPRECATE_DEFINE_VALUE(CKT_NSS_VALID, CKT_NSS_NOT_TRUSTED) 629 _NSS_DEPRECATE_DEFINE_TYPE(CK_TRUST, CKT_NSS_MUST_VERIFY, 630 "CKT_NSS_MUST_VERIFY really functions as CKT_NSS_TRUST_UNKNOWN") 631 #define CKT_NSS_MUST_VERIFY \ 632 _NSS_DEPRECATE_DEFINE_VALUE(CKT_NSS_MUST_VERIFY, CKT_NSS_TRUST_UNKNOWN) 633 634 /* 635 * These are not really PKCS #11 values specifically. They are the 'loadable' 636 * module spec NSS uses. They are available for others to use as well, but not 637 * part of the formal PKCS #11 spec. 638 * 639 * The function 'FIND' returns an array of PKCS #11 initialization strings 640 * The function 'ADD' takes a PKCS #11 initialization string and stores it. 641 * The function 'DEL' takes a 'name= library=' value and deletes the associated 642 * string. 643 * The function 'RELEASE' frees the array returned by 'FIND' 644 */ 645 #define SECMOD_MODULE_DB_FUNCTION_FIND 0 646 #define SECMOD_MODULE_DB_FUNCTION_ADD 1 647 #define SECMOD_MODULE_DB_FUNCTION_DEL 2 648 #define SECMOD_MODULE_DB_FUNCTION_RELEASE 3 649 typedef char **(PR_CALLBACK *SECMODModuleDBFunc)(unsigned long function, 650 char *parameters, void *moduleSpec); 651 652 /* softoken slot ID's */ 653 #define SFTK_MIN_USER_SLOT_ID 4 654 #define SFTK_MAX_USER_SLOT_ID 100 655 #define SFTK_MIN_FIPS_USER_SLOT_ID 101 656 #define SFTK_MAX_FIPS_USER_SLOT_ID 127 657 658 /* Module Interface. This is the old NSS private module interface, now exported 659 * as a PKCS #11 v3 interface. It's interface name is 660 * "Vendor NSS Module Interface" */ 661 typedef char **(*CK_NSS_ModuleDBFunc)(unsigned long function, 662 char *parameters, void *args); 663 typedef struct CK_NSS_MODULE_FUNCTIONS { 664 CK_VERSION version; 665 CK_NSS_ModuleDBFunc NSC_ModuleDBFunc; 666 } CK_NSS_MODULE_FUNCTIONS; 667 668 /* FIPS Indicator Interface. This may move to the normal PKCS #11 table 669 * in the future. For now it's called "Vendor NSS FIPS Interface" */ 670 typedef CK_RV (*CK_NSS_GetFIPSStatus)(CK_SESSION_HANDLE hSession, 671 CK_OBJECT_HANDLE hObject, 672 CK_ULONG ulOperationType, 673 CK_ULONG *pulFIPSStatus); 674 675 typedef struct CK_NSS_FIPS_FUNCTIONS { 676 CK_VERSION version; 677 CK_NSS_GetFIPSStatus NSC_NSSGetFIPSStatus; 678 } CK_NSS_FIPS_FUNCTIONS; 679 680 /* KEM interface. This may move to the normal PKCS #11 table in the future. For 681 * now it's called "Vendor NSS KEM Interface" */ 682 typedef CK_RV (*CK_NSS_Encapsulate)(CK_SESSION_HANDLE hSession, 683 CK_MECHANISM_PTR pMechanism, 684 CK_OBJECT_HANDLE hPublicKey, 685 CK_ATTRIBUTE_PTR pTemplate, 686 CK_ULONG ulAttributeCount, 687 CK_OBJECT_HANDLE_PTR phKey, 688 CK_BYTE_PTR pCiphertext, 689 CK_ULONG_PTR pulCiphertextLen); 690 691 typedef CK_RV (*CK_NSS_Decapsulate)(CK_SESSION_HANDLE hSession, 692 CK_MECHANISM_PTR pMechanism, 693 CK_OBJECT_HANDLE hPrivateKey, 694 CK_BYTE_PTR pCiphertext, 695 CK_ULONG ulCiphertextLen, 696 CK_ATTRIBUTE_PTR pTemplate, 697 CK_ULONG ulAttributeCount, 698 CK_OBJECT_HANDLE_PTR phKey); 699 700 typedef struct CK_NSS_KEM_FUNCTIONS { 701 CK_VERSION version; 702 CK_NSS_Encapsulate C_Encapsulate; 703 CK_NSS_Decapsulate C_Decapsulate; 704 } CK_NSS_KEM_FUNCTIONS; 705 706 /* There was an inconsistency between the spec and the header file in defining 707 * the CK_GCM_PARAMS structure. The authoritative reference is the header file, 708 * but NSS used the spec when adding it to its own header. In V3 we've 709 * corrected it, but we need to handle the old case for devices that followed 710 * us in using the incorrect specification. */ 711 typedef struct CK_NSS_GCM_PARAMS { 712 CK_BYTE_PTR pIv; 713 CK_ULONG ulIvLen; 714 CK_BYTE_PTR pAAD; 715 CK_ULONG ulAADLen; 716 CK_ULONG ulTagBits; 717 } CK_NSS_GCM_PARAMS; 718 719 typedef CK_NSS_GCM_PARAMS CK_PTR CK_NSS_GCM_PARAMS_PTR; 720 721 /* deprecated #defines. Drop in future NSS releases */ 722 #ifdef NSS_PKCS11_2_0_COMPAT 723 724 /* defines that were changed between NSS's PKCS #11 and the Oasis headers */ 725 #define CKF_EC_FP CKF_EC_F_P 726 #define CKO_KG_PARAMETERS CKO_DOMAIN_PARAMETERS 727 #define CK_INVALID_SESSION CK_INVALID_HANDLE 728 #define CKR_KEY_PARAMS_INVALID 0x0000006B 729 730 /* use the old wrong CK_GCM_PARAMS if NSS_PCKS11_2_0_COMPAT is defined */ 731 typedef struct CK_NSS_GCM_PARAMS CK_GCM_PARAMS; 732 typedef CK_NSS_GCM_PARAMS CK_PTR CK_GCM_PARAMS_PTR; 733 734 /* don't leave old programs in a lurch just yet, give them the old NETSCAPE 735 * synonym if NSS_PKCS11_2_0_COMPAT is defined*/ 736 #define CKO_NETSCAPE_CRL CKO_NSS_CRL 737 #define CKO_NETSCAPE_SMIME CKO_NSS_SMIME 738 #define CKO_NETSCAPE_TRUST CKO_NSS_TRUST 739 #define CKO_NETSCAPE_BUILTIN_ROOT_LIST CKO_NSS_BUILTIN_ROOT_LIST 740 #define CKO_NETSCAPE_NEWSLOT CKO_NSS_NEWSLOT 741 #define CKO_NETSCAPE_DELSLOT CKO_NSS_DELSLOT 742 #define CKK_NETSCAPE_PKCS8 CKK_NSS_PKCS8 743 #define CKA_NETSCAPE_URL CKA_NSS_URL 744 #define CKA_NETSCAPE_EMAIL CKA_NSS_EMAIL 745 #define CKA_NETSCAPE_SMIME_INFO CKA_NSS_SMIME_INFO 746 #define CKA_NETSCAPE_SMIME_TIMESTAMP CKA_NSS_SMIME_TIMESTAMP 747 #define CKA_NETSCAPE_PKCS8_SALT CKA_NSS_PKCS8_SALT 748 #define CKA_NETSCAPE_PASSWORD_CHECK CKA_NSS_PASSWORD_CHECK 749 #define CKA_NETSCAPE_EXPIRES CKA_NSS_EXPIRES 750 #define CKA_NETSCAPE_KRL CKA_NSS_KRL 751 #define CKA_NETSCAPE_PQG_COUNTER CKA_NSS_PQG_COUNTER 752 #define CKA_NETSCAPE_PQG_SEED CKA_NSS_PQG_SEED 753 #define CKA_NETSCAPE_PQG_H CKA_NSS_PQG_H 754 #define CKA_NETSCAPE_PQG_SEED_BITS CKA_NSS_PQG_SEED_BITS 755 #define CKA_NETSCAPE_MODULE_SPEC CKA_NSS_MODULE_SPEC 756 #define CKA_NETSCAPE_DB CKA_NSS_DB 757 #define CKA_NETSCAPE_TRUST CKA_NSS_TRUST 758 #define CKM_NETSCAPE_AES_KEY_WRAP CKM_NSS_AES_KEY_WRAP 759 #define CKM_NETSCAPE_AES_KEY_WRAP_PAD CKM_NSS_AES_KEY_WRAP_PAD 760 #define CKM_NETSCAPE_PBE_SHA1_DES_CBC CKM_NSS_PBE_SHA1_DES_CBC 761 #define CKM_NETSCAPE_PBE_SHA1_TRIPLE_DES_CBC CKM_NSS_PBE_SHA1_TRIPLE_DES_CBC 762 #define CKM_NETSCAPE_PBE_SHA1_40_BIT_RC2_CBC CKM_NSS_PBE_SHA1_40_BIT_RC2_CBC 763 #define CKM_NETSCAPE_PBE_SHA1_128_BIT_RC2_CBC CKM_NSS_PBE_SHA1_128_BIT_RC2_CBC 764 #define CKM_NETSCAPE_PBE_SHA1_40_BIT_RC4 CKM_NSS_PBE_SHA1_40_BIT_RC4 765 #define CKM_NETSCAPE_PBE_SHA1_128_BIT_RC4 CKM_NSS_PBE_SHA1_128_BIT_RC4 766 #define CKM_NETSCAPE_PBE_SHA1_FAULTY_3DES_CBC CKM_NSS_PBE_SHA1_FAULTY_3DES_CBC 767 #define CKM_NETSCAPE_PBE_SHA1_HMAC_KEY_GEN CKM_NSS_PBE_SHA1_HMAC_KEY_GEN 768 #define CKM_NETSCAPE_PBE_MD5_HMAC_KEY_GEN CKM_NSS_PBE_MD5_HMAC_KEY_GEN 769 #define CKM_NETSCAPE_PBE_MD2_HMAC_KEY_GEN CKM_NSS_PBE_MD2_HMAC_KEY_GEN 770 #define CKR_NETSCAPE_CERTDB_FAILED CKR_NSS_CERTDB_FAILED 771 #define CKR_NETSCAPE_KEYDB_FAILED CKR_NSS_KEYDB_FAILED 772 773 #define CKT_NETSCAPE_TRUSTED CKT_NSS_TRUSTED 774 #define CKT_NETSCAPE_TRUSTED_DELEGATOR CKT_NSS_TRUSTED_DELEGATOR 775 #define CKT_NETSCAPE_UNTRUSTED CKT_NSS_UNTRUSTED 776 #define CKT_NETSCAPE_MUST_VERIFY CKT_NSS_MUST_VERIFY 777 #define CKT_NETSCAPE_TRUST_UNKNOWN CKT_NSS_TRUST_UNKNOWN 778 #define CKT_NETSCAPE_VALID CKT_NSS_VALID 779 #define CKT_NETSCAPE_VALID_DELEGATOR CKT_NSS_VALID_DELEGATOR 780 #else 781 /* use the new CK_GCM_PARAMS if NSS_PKCS11_2_0_COMPAT is not defined */ 782 typedef struct CK_GCM_PARAMS_V3 CK_GCM_PARAMS; 783 typedef CK_GCM_PARAMS_V3 CK_PTR CK_GCM_PARAMS_PTR; 784 #endif 785 786 #endif /* _PKCS11N_H_ */