| 1 |
/* |
| 2 |
* (C) Copyright IBM Corp. 2012, 2025 |
| 3 |
* |
| 4 |
* This program is provided under the terms of the Common Public License, |
| 5 |
* version 1.0 (CPL-1.0). Any use, reproduction or distribution for this |
| 6 |
* software constitutes recipient's acceptance of CPL-1.0 terms which can be |
| 7 |
* found in the file LICENSE file or at |
| 8 |
* https://opensource.org/licenses/cpl1.0.php |
| 9 |
* |
| 10 |
*---------------------------------------------------------------------- |
| 11 |
* EP11 service mail address: [email protected] |
| 12 |
* |
| 13 |
* Use this e-mail address for Bugs and Comments with the EP11 product. |
| 14 |
*----------------------------------------------------------------------*/ |
| 15 |
|
| 16 |
#if !defined(XCP_H__) |
| 17 |
#define XCP_H__ |
| 18 |
|
| 19 |
#define XCP_API_VERSION 0x0906 |
| 20 |
#if !defined(CKR_OK) |
| 21 |
#include "pkcs11.h" |
| 22 |
#endif |
| 23 |
|
| 24 |
#if !defined(INT64_MIN) |
| 25 |
#error "We need 64-bit <stdint.h> types, please include before this file." |
| 26 |
#endif |
| 27 |
|
| 28 |
// |
| 29 |
// used for internal and external paths/addresses |
| 30 |
#define MAX_FNAME_CHARS 256 |
| 31 |
|
| 32 |
// Error Values for functions that do not return CK_RV |
| 33 |
// general errors |
| 34 |
#define XCP_OK 0 /* function successful |
| 35 |
*/ |
| 36 |
#define XCP_EINTERNAL -1 /* host library internal error. |
| 37 |
* host library is in an inconsistent state |
| 38 |
* shutdown and new init is needed |
| 39 |
*/ |
| 40 |
#define XCP_EARG -2 /* Argument is invalid |
| 41 |
*/ |
| 42 |
#define XCP_ETARGET -3 /* Target argument is invalid |
| 43 |
*/ |
| 44 |
#define XCP_EMEMORY -4 /* could not allocate memory |
| 45 |
*/ |
| 46 |
#define XCP_EMUTEX -5 /* Mutex is invalid |
| 47 |
*/ |
| 48 |
#define XCP_EINIT -6 /* Could not initialize library |
| 49 |
*/ |
| 50 |
#define XCP_EDEVICE -7 /* The channel that is used to communicate |
| 51 |
* with the backend is not available or |
| 52 |
* invalid |
| 53 |
*/ |
| 54 |
#define XCP_EGROUP -8 /* Target group is unusable or invalid |
| 55 |
*/ |
| 56 |
#define XCP_ESIZE -9 /* invalid size |
| 57 |
*/ |
| 58 |
#define XCP_EINVALID -10 /* invalid content of parameter |
| 59 |
*/ |
| 60 |
#define XCP_ERESPONSE -11 /* bad response from module. Sometimes |
| 61 |
* it is not possible to return the CK_RV |
| 62 |
* value directly and we can only say that |
| 63 |
* something failed. |
| 64 |
*/ |
| 65 |
#define XCP_EAPI -12 /* incompatible/invalid api |
| 66 |
*/ |
| 67 |
// module specific errors |
| 68 |
#define XCP_MOD_EOBSOLETE -101 /* past feature has been obsoleted, |
| 69 |
* no longer available. check notes on |
| 70 |
* future-compatibility. |
| 71 |
*/ |
| 72 |
#define XCP_MOD_EVERSION -102 /* library predates caller, does not |
| 73 |
* support requested API version |
| 74 |
*/ |
| 75 |
#define XCP_MOD_EFLAGS -103 /* library does not support all requested |
| 76 |
* flags, even if call/struct is otherwise |
| 77 |
* API-compatible. expect this only when |
| 78 |
* device-specific details (module |
| 79 |
* selection, communication/channel type) |
| 80 |
* are not supported by the backend. |
| 81 |
*/ |
| 82 |
#define XCP_MOD_EMODULE -104 /* library does not support this module |
| 83 |
* number (a real one, not virtual ones). |
| 84 |
* typical error when locally attached |
| 85 |
* modules' count has an upper bound. |
| 86 |
*/ |
| 87 |
#define XCP_MOD_EDOMAIN -105 /* the targeted module does not support |
| 88 |
* the requested domain. |
| 89 |
*/ |
| 90 |
#define XCP_MOD_EINIT -106 /* the targeted module is not initialized |
| 91 |
* typical error for socket attached |
| 92 |
* modules, because adding this modules |
| 93 |
* on the fly is not possible |
| 94 |
*/ |
| 95 |
#define XCP_MOD_EPROBE -107 /* probe did fail for all defined domains. |
| 96 |
* This is an error even when the strict |
| 97 |
* flag is not active |
| 98 |
*/ |
| 99 |
|
| 100 |
/*--------------------------------------------------------------------------*/ |
| 101 |
#define XCP_COMMON_PUBLIC_H__ |
| 102 |
|
| 103 |
#ifndef XCP_H__ |
| 104 |
#define CK_DISABLE_TRUE_FALSE |
| 105 |
#endif |
| 106 |
|
| 107 |
#define XCP_API_VERSION_Z16 0x0827 /* major[8] minor[8] */ |
| 108 |
#define XCP_API_VERSION_Z17 0x0906 /* major[8] minor[8] */ |
| 109 |
#define XCP_API_ORDINAL 0x0006 |
| 110 |
/* increment this with every major/minor change */ |
| 111 |
|
| 112 |
#define XCP_HOST_API_VER 0x040200 /* major[8] minor[8] fixpack[8] */ |
| 113 |
|
| 114 |
/* HSM connection information; not for PKCS11 user consumption */ |
| 115 |
#define XCP_HSM_AGENT_ID 0x5843 /* ASCII "XC" */ |
| 116 |
#define XCP_HSM_USERDEF32 0x01234567 |
| 117 |
|
| 118 |
// protected key requires API ordinal greater or equal to 4 |
| 119 |
#define XCP_API_ALLOW_PROTKEY 0x0004 |
| 120 |
|
| 121 |
// Support for extended FIPS2021 attributes |
| 122 |
// |
| 123 |
// Requests for card/domain attributes (XCP_ADMQ_ATTRS/XCP_ADMQ_DOM_ATTRS) |
| 124 |
// will contain the extended attributes (key-types, adm FIPS2021 compliance) |
| 125 |
// only with API ordinal 5 (or higher) for compatibility reasons. |
| 126 |
// Also, the module sub-queries CK_IBM_XCPMSQ_ATTRLIST, CK_IBM_XCPMSQ_ATTRS |
| 127 |
// and CK_IBM_XCPMSQ_ATTRCOUNT will contain the information related to the |
| 128 |
// extended attributes only with this API ordinal. |
| 129 |
#define XCP_API_ALLOW_FIPS2021 0x0005 |
| 130 |
|
| 131 |
|
| 132 |
// function sub-variants |
| 133 |
// 0 means regular request |
| 134 |
typedef enum { |
| 135 |
XCP_FNVAR_SIZEQUERY = 1, /* sizequery: databytes[64]->resp.bytes[64] */ |
| 136 |
XCP_FNVAR_MULTIDATA = 2, /* multi-data request */ |
| 137 |
XCP_FNVAR_MULTISIZEQ = 3 /* multi-data request, size query */ |
| 138 |
} XCP_FNVariant_t; |
| 139 |
|
| 140 |
|
| 141 |
// XCP-specific return codes |
| 142 |
// |
| 143 |
#define CKR_IBM_WKID_MISMATCH (CKR_VENDOR_DEFINED +0x10001) |
| 144 |
#define CKR_IBM_INTERNAL_ERROR (CKR_VENDOR_DEFINED +0x10002) |
| 145 |
#define CKR_IBM_TRANSPORT_ERROR (CKR_VENDOR_DEFINED +0x10003) |
| 146 |
#define CKR_IBM_BLOB_ERROR (CKR_VENDOR_DEFINED +0x10004) |
| 147 |
/* WK setup changed during the execution of a single request, |
| 148 |
* preventing return of encrypted data to the host. (i.e., |
| 149 |
* an administrative operation changed WKs before the |
| 150 |
* function could re-wrap data to pass back to the host) |
| 151 |
*/ |
| 152 |
#define CKR_IBM_BLOBKEY_CONFLICT (CKR_VENDOR_DEFINED +0x10005) |
| 153 |
#define CKR_IBM_MODE_CONFLICT (CKR_VENDOR_DEFINED +0x10006) |
| 154 |
/* an RSA key in non-CRT form is encountered which is not |
| 155 |
* supported by this hardware/engine configuration, if the |
| 156 |
* setup has non/CRT-specific size restrictions. |
| 157 |
* in essence, a more specific sub-division of |
| 158 |
* the standard CKR_KEY_SIZE_RANGE, and MAY be |
| 159 |
* safely mapped to that by host libraries. |
| 160 |
*/ |
| 161 |
#define CKR_IBM_NONCRT_KEY_SIZE (CKR_VENDOR_DEFINED +0x10008) |
| 162 |
#define CKR_IBM_WK_NOT_INITIALIZED (CKR_VENDOR_DEFINED +0x10009) |
| 163 |
/* unexpected/consistency error of CA operations of the |
| 164 |
* hosting HSM, if not otherwise classified. |
| 165 |
*/ |
| 166 |
#define CKR_IBM_OA_API_ERROR (CKR_VENDOR_DEFINED +0x1000a) |
| 167 |
/* potentially long-running request, such as those involving |
| 168 |
* prime generation, did not complete in a 'reasonable' |
| 169 |
* number of iterations. supported to prevent timeout- |
| 170 |
* triggered module resets, such as mainframe firmware |
| 171 |
* resetting modules 'stuck in infinite loops' (as perceived |
| 172 |
* by the host) |
| 173 |
*/ |
| 174 |
#define CKR_IBM_REQ_TIMEOUT (CKR_VENDOR_DEFINED +0x1000b) |
| 175 |
/* backend in read-only state, rejecting state-changing |
| 176 |
* operations: |
| 177 |
*/ |
| 178 |
#define CKR_IBM_READONLY (CKR_VENDOR_DEFINED +0x1000c) |
| 179 |
/* backend/policy may not be configured to accept request. |
| 180 |
* this is the permanent form of policy failure |
| 181 |
* (which is mapped to standard CKR_FUNCTION_CANCELED) |
| 182 |
*/ |
| 183 |
#define CKR_IBM_STATIC_POLICY (CKR_VENDOR_DEFINED +0x1000d) |
| 184 |
|
| 185 |
|
| 186 |
/* backend not allowed to return requested nr of bytes: */ |
| 187 |
#define CKR_IBM_TRANSPORT_LIMIT (CKR_VENDOR_DEFINED +0x10010) |
| 188 |
// |
| 189 |
// use CKR_IBM_TRANSPORT_ERROR for errors introduced between ep11.h and backend |
| 190 |
// CKR_IBM_TRANSPORT_LIMIT for errors on return path |
| 191 |
// CKR_ARGUMENTS_BAD or specific one for bad data passed through ep11.h |
| 192 |
|
| 193 |
#define CKR_IBM_FCV_NOT_SET (CKR_VENDOR_DEFINED +0x10011) |
| 194 |
|
| 195 |
// Error returned by check if the performance category has not been set |
| 196 |
#define CKR_IBM_PERF_CATEGORY_INVALID (CKR_VENDOR_DEFINED +0x10012) |
| 197 |
|
| 198 |
// API ORDINAL number is unknown or function id is in illegal range |
| 199 |
#define CKR_IBM_API_MISMATCH (CKR_VENDOR_DEFINED +0x10013) |
| 200 |
|
| 201 |
// target token is invalid |
| 202 |
#define CKR_IBM_TARGET_INVALID (CKR_VENDOR_DEFINED +0x10030) |
| 203 |
|
| 204 |
|
| 205 |
#define CKR_IBM_PQC_PARAMS_NOT_SUPPORTED (CKR_VENDOR_DEFINED +0x10031) |
| 206 |
|
| 207 |
#define CKR_IBM_PARAM_NOT_SUPPORTED (CKR_VENDOR_DEFINED +0x10032) |
| 208 |
|
| 209 |
#define CKR_IBM_SESSION_IMMUTABLE (CKR_VENDOR_DEFINED +0x10033) |
| 210 |
|
| 211 |
// Error returned if internal verification of crypto engines fail |
| 212 |
#define CKR_IBM_ERROR_STATE (CKR_VENDOR_DEFINED +0x10101) |
| 213 |
|
| 214 |
|
| 215 |
/*--- mechanisms ---------------------------------------------------------*/ |
| 216 |
#define CKM_IBM_SHA3_224 (CKM_VENDOR_DEFINED +0x10001) |
| 217 |
#define CKM_IBM_SHA3_256 (CKM_VENDOR_DEFINED +0x10002) |
| 218 |
#define CKM_IBM_SHA3_384 (CKM_VENDOR_DEFINED +0x10003) |
| 219 |
#define CKM_IBM_SHA3_512 (CKM_VENDOR_DEFINED +0x10004) |
| 220 |
|
| 221 |
#define CKM_IBM_CMAC (CKM_VENDOR_DEFINED +0x10007) |
| 222 |
// |
| 223 |
// non-SHA-1 ECDSA: no standard mechansims pre-v2.40 |
| 224 |
#define CKM_IBM_ECDSA_SHA224 (CKM_VENDOR_DEFINED +0x10008) |
| 225 |
#define CKM_IBM_ECDSA_SHA256 (CKM_VENDOR_DEFINED +0x10009) |
| 226 |
#define CKM_IBM_ECDSA_SHA384 (CKM_VENDOR_DEFINED +0x1000a) |
| 227 |
#define CKM_IBM_ECDSA_SHA512 (CKM_VENDOR_DEFINED +0x1000b) |
| 228 |
|
| 229 |
// EC point multiply |
| 230 |
#define CKM_IBM_EC_MULTIPLY (CKM_VENDOR_DEFINED +0x1000c) |
| 231 |
|
| 232 |
|
| 233 |
// EAC (machine-readable travel document: passport, DL, ID card PKI) |
| 234 |
// |
| 235 |
// derive secure messaging, a class of functions |
| 236 |
#define CKM_IBM_EAC (CKM_VENDOR_DEFINED +0x1000d) |
| 237 |
#define XCP_EAC_NONCE_MAX_BYTES 64 /* salt/nonce */ |
| 238 |
#define XCP_EAC_INFO_MAX_BYTES 64 /* other auxiliary data */ |
| 239 |
// |
| 240 |
// variants within EAC |
| 241 |
typedef enum { |
| 242 |
EACV_IBM_KEK_V101 = 1, // secret -> secure msg KEK (EAC v1.01) |
| 243 |
EACV_IBM_MACK_V101 = 2, // secret -> secure msg MACK (EAC v1.01) |
| 244 |
EACV_IBM_PWD_V200 = 3, // passphrase -> secure msg KEK (EAC v2.00) |
| 245 |
EACV_IBM_HKDF = 4, // HKDF( base-key, mechanism-attached salt ) |
| 246 |
// salt is supplied with mechanism parameter |
| 247 |
// output bytecount specified as attribute |
| 248 |
// of derived key |
| 249 |
EACV_IBM_BCHAIN_TCERT0 |
| 250 |
= 5 // blockchain: derive tcert from base EC key |
| 251 |
// and additive cleartext [potentially insecure] |
| 252 |
} EAC_Var_t; |
| 253 |
|
| 254 |
// test access |
| 255 |
|
| 256 |
#define CKM_IBM_TESTCODE (CKM_VENDOR_DEFINED +0x1000e) |
| 257 |
|
| 258 |
|
| 259 |
// SHA-512 derivatives later than PKCS#11 v2.20, SHA-512/256 and SHA-512/224 |
| 260 |
// see pkcs11add.h (since v2.40 drafts)(since v2.40 drafts)(since v2.40 drafts)(since v2.40 drafts) |
| 261 |
// |
| 262 |
#define CKM_IBM_SHA512_256 (CKM_VENDOR_DEFINED +0x10012) |
| 263 |
#define CKM_IBM_SHA512_224 (CKM_VENDOR_DEFINED +0x10013) |
| 264 |
#define CKM_IBM_SHA512_256_HMAC (CKM_VENDOR_DEFINED +0x10014) |
| 265 |
#define CKM_IBM_SHA512_224_HMAC (CKM_VENDOR_DEFINED +0x10015) |
| 266 |
// |
| 267 |
|
| 268 |
// curve25519, key agreement |
| 269 |
#define CKM_IBM_EC_X25519 (CKM_VENDOR_DEFINED +0x1001b) |
| 270 |
// |
| 271 |
// eddsa/25519 signatures, with SHA-512, no prehashing |
| 272 |
#define CKM_IBM_ED25519_SHA512 (CKM_VENDOR_DEFINED +0x1001c) |
| 273 |
// curve448 ('Goldilocks'), key agreement |
| 274 |
#define CKM_IBM_EC_X448 (CKM_VENDOR_DEFINED +0x1001e) |
| 275 |
// |
| 276 |
// ed448 signatures, with SHA-3/XOF, no prehashing |
| 277 |
#define CKM_IBM_ED448_SHA3 (CKM_VENDOR_DEFINED +0x1001f) |
| 278 |
|
| 279 |
|
| 280 |
// round counts are passed as mechanism parameters |
| 281 |
#define CKM_IBM_SIPHASH (CKM_VENDOR_DEFINED +0x10021) |
| 282 |
|
| 283 |
|
| 284 |
// these need a strength definition |
| 285 |
// XCP_U32_VALUE_BITS/CKA_VALUE_BITS would be sufficient; strength->K/L mapping |
| 286 |
// |
| 287 |
// umbrella mech for PQC/Crystals variants |
| 288 |
#define CKM_IBM_DILITHIUM (CKM_VENDOR_DEFINED +0x10023) |
| 289 |
// ^^^ sign/verify plus keygen only |
| 290 |
#define CKM_IBM_KYBER (CKM_VENDOR_DEFINED +0x10024) |
| 291 |
// ^^^ en/decrypt, keygen, key transport, and (hybrid) key derivation |
| 292 |
|
| 293 |
// SHA-3 HMAC variants |
| 294 |
#define CKM_IBM_SHA3_224_HMAC (CKM_VENDOR_DEFINED +0x10025) |
| 295 |
#define CKM_IBM_SHA3_256_HMAC (CKM_VENDOR_DEFINED +0x10026) |
| 296 |
#define CKM_IBM_SHA3_384_HMAC (CKM_VENDOR_DEFINED +0x10027) |
| 297 |
#define CKM_IBM_SHA3_512_HMAC (CKM_VENDOR_DEFINED +0x10028) |
| 298 |
|
| 299 |
// curve25519, key agreement (using KEK) |
| 300 |
#define CKM_IBM_EC_X25519_RAW (CKM_VENDOR_DEFINED +0x10029) |
| 301 |
|
| 302 |
// curve448 ('Goldilocks'), key agreement (using KEK) |
| 303 |
#define CKM_IBM_EC_X448_RAW (CKM_VENDOR_DEFINED +0x10030) |
| 304 |
|
| 305 |
#define CKM_IBM_ECDSA_OTHER (CKM_VENDOR_DEFINED +0x10031) |
| 306 |
|
| 307 |
|
| 308 |
typedef enum { |
| 309 |
|
| 310 |
ECSG_IBM_ECSDSA_S256 = 3, |
| 311 |
// [Randomized] Schnorr signatures |
| 312 |
// BSI TR03111 ECSDSA |
| 313 |
// no prehashing; SHA-256 only |
| 314 |
ECSG_IBM_ECSDSA_COMPR_MULTI = 5, |
| 315 |
// [Randomized] Schnorr signatures |
| 316 |
// BSI TR-03111 @2012, working on |
| 317 |
// compressed public key format and |
| 318 |
// including signers public key |
| 319 |
|
| 320 |
ECSG_IBM_BLS = 6, |
| 321 |
// Boneh-Lynn-Shacham signatures |
| 322 |
// RFC draft-irtf-cfrg-bls-signature-05 |
| 323 |
|
| 324 |
|
| 325 |
ECSG_IBM_MAX = ECSG_IBM_BLS, |
| 326 |
} ECSG_Var_t; |
| 327 |
|
| 328 |
|
| 329 |
#define CKM_IBM_EC_AGGREGATE (CKM_VENDOR_DEFINED +0x10034) |
| 330 |
|
| 331 |
typedef enum { |
| 332 |
EC_AGG_BLS12_381_SIGN = 1, // size of signature is sufficient indicator |
| 333 |
EC_AGG_BLS12_381_PKEY = 2, |
| 334 |
EC_AGG_BLS12_381_MAX = EC_AGG_BLS12_381_PKEY, |
| 335 |
} ECAgg_Var_t; |
| 336 |
|
| 337 |
#define CK_IBM_EC_AGG_BLS12_381_SIGN EC_AGG_BLS12_381_SIGN |
| 338 |
#define CK_IBM_EC_AGG_BLS12_381_PKEY EC_AGG_BLS12_381_PKEY |
| 339 |
|
| 340 |
typedef struct XCP_EC_AGGREGATE_PARAMS { |
| 341 |
CK_ULONG version; |
| 342 |
CK_ULONG mode; |
| 343 |
CK_ULONG perElementSize; |
| 344 |
CK_BYTE_PTR pElements; |
| 345 |
CK_ULONG ulElementsLen; |
| 346 |
} XCP_EC_AGGREGATE_PARAMS; |
| 347 |
|
| 348 |
|
| 349 |
#define CK_IBM_ECSG_IBM_ECSDSA_S256 ECSG_IBM_ECSDSA_S256 |
| 350 |
#define CK_IBM_ECSG_IBM_ECDSA_COMPR_MULTI_S256 ECSG_IBM_ECDSA_COMPR_MULTI_S256 |
| 351 |
#define CK_IBM_ECSG_IBM_BLS ECSG_IBM_BLS |
| 352 |
#define CK_IBM_ECSG_IBM_MAX ECSG_IBM_MAX |
| 353 |
|
| 354 |
#define CKM_IBM_ML_DSA_KEY_PAIR_GEN (CKM_VENDOR_DEFINED +0x10035) |
| 355 |
#define CKM_IBM_ML_DSA (CKM_VENDOR_DEFINED +0x10036) |
| 356 |
// ^^^ sign/verify only |
| 357 |
#define CKM_IBM_ML_KEM_KEY_PAIR_GEN (CKM_VENDOR_DEFINED +0x10037) |
| 358 |
#define CKM_IBM_ML_KEM (CKM_VENDOR_DEFINED +0x10038) |
| 359 |
// ^^^ key transport, and (hybrid) key derivation |
| 360 |
|
| 361 |
|
| 362 |
//--- transport additions -------------------------------------------------- |
| 363 |
#define CKM_IBM_CLEARKEY_TRANSPORT (CKM_VENDOR_DEFINED +0x20001) |
| 364 |
// key+attributes bound format (ignores other attributes) |
| 365 |
#define CKM_IBM_ATTRIBUTEBOUND_WRAP (CKM_VENDOR_DEFINED +0x20004) |
| 366 |
// operations related to key cloning |
| 367 |
#define CKM_IBM_TRANSPORTKEY (CKM_VENDOR_DEFINED +0x20005) |
| 368 |
|
| 369 |
// EC/DH equivalents: derive key, then return encrypted under |
| 370 |
// KEK supplied as auxiliary data |
| 371 |
// (does not resemble regular PKCS11 mechanisms) |
| 372 |
// |
| 373 |
#define CKM_IBM_DH_PKCS_DERIVE_RAW (CKM_VENDOR_DEFINED +0x20006) |
| 374 |
#define CKM_IBM_ECDH1_DERIVE_RAW (CKM_VENDOR_DEFINED +0x20007) |
| 375 |
|
| 376 |
// none of these have PKCS11 constants (as of 2018-02) |
| 377 |
|
| 378 |
|
| 379 |
// |
| 380 |
// allow direct access to mechanism's wireform |
| 381 |
// parameter of this mechanism is used as wire form |
| 382 |
#define CKM_IBM_WIRETEST (CKM_VENDOR_DEFINED +0x30004) |
| 383 |
|
| 384 |
|
| 385 |
//--- separate infrastructure-related mechs -------------------------------- |
| 386 |
// to generate/refill semi-retained keys |
| 387 |
// see also CKA_IBM_RETAINKEY |
| 388 |
// |
| 389 |
#define CKM_IBM_RETAINKEY (CKM_VENDOR_DEFINED +0x40001) |
| 390 |
|
| 391 |
|
| 392 |
|
| 393 |
// IBM protkey data key import mechanism (WrapKey) |
| 394 |
#define CKM_IBM_CPACF_WRAP (CKM_VENDOR_DEFINED +0x60001) |
| 395 |
|
| 396 |
|
| 397 |
// bitcoin key derivation |
| 398 |
#define CKM_IBM_BTC_DERIVE (CKM_VENDOR_DEFINED +0x70001) |
| 399 |
|
| 400 |
// etherium key derivation |
| 401 |
#define CKM_IBM_ETH_DERIVE (CKM_VENDOR_DEFINED +0x70002) |
| 402 |
|
| 403 |
/*--- attributes ---------------------------------------------------------*/ |
| 404 |
|
| 405 |
// object may have rights removed, but not added (subset of modifiability) |
| 406 |
#define CKA_IBM_RESTRICTABLE (CKA_VENDOR_DEFINED +0x10001) |
| 407 |
|
| 408 |
// object was created non-MODIFIABLE |
| 409 |
#define CKA_IBM_NEVER_MODIFIABLE (CKA_VENDOR_DEFINED +0x10002) |
| 410 |
|
| 411 |
// object is HSM-resident (handle instead of full token) |
| 412 |
// has a single parameter, usage count |
| 413 |
#define CKA_IBM_RETAINKEY (CKA_VENDOR_DEFINED +0x10003) |
| 414 |
|
| 415 |
// object must be transported with attributes, never separated |
| 416 |
// note: incompatible with pure-PKCS#11 un/wrap |
| 417 |
#define CKA_IBM_ATTRBOUND (CKA_VENDOR_DEFINED +0x10004) |
| 418 |
|
| 419 |
// symbolic key type in other hierarchies (CK_ULONG) |
| 420 |
// XCP stores but ignores it |
| 421 |
#define CKA_IBM_KEYTYPE (CKA_VENDOR_DEFINED +0x10005) |
| 422 |
|
| 423 |
// restrictions inherited from other type systems |
| 424 |
// XCP stores and partially interprets it |
| 425 |
#define CKA_IBM_CV (CKA_VENDOR_DEFINED +0x10006) |
| 426 |
|
| 427 |
// attribute containing MAC key handle, or blob, for authenticated key transport |
| 428 |
#define CKA_IBM_MACKEY (CKA_VENDOR_DEFINED +0x10007) |
| 429 |
|
| 430 |
// object may be used as base data of other ops, i.e., hashing or key derivation |
| 431 |
// |
| 432 |
#define CKA_IBM_USE_AS_DATA (CKA_VENDOR_DEFINED +0x10008) |
| 433 |
|
| 434 |
// DSA/DH parameters as ALGID structure (PKCS#3) |
| 435 |
#define CKA_IBM_STRUCT_PARAMS (CKA_VENDOR_DEFINED +0x10009) |
| 436 |
|
| 437 |
// compliance mode, bitfield within 32-bit (CK_ULONG) parameter |
| 438 |
#define CKA_IBM_STD_COMPLIANCE1 (CKA_VENDOR_DEFINED +0x1000a) |
| 439 |
|
| 440 |
|
| 441 |
// key is extractable only as protected key |
| 442 |
#define CKA_IBM_PROTKEY_EXTRACTABLE (CKA_VENDOR_DEFINED +0x1000c) |
| 443 |
|
| 444 |
// key is never extractable as protected key |
| 445 |
#define CKA_IBM_PROTKEY_NEVER_EXTRACTABLE (CKA_VENDOR_DEFINED +0x1000d) |
| 446 |
|
| 447 |
#define CKA_IBM_PQC_PARAMS (CKA_VENDOR_DEFINED +0x1000e) |
| 448 |
|
| 449 |
// query or modify login session an object is bound to |
| 450 |
#define CKA_IBM_LOGIN_SESSION (CKA_VENDOR_DEFINED +0x1000f) |
| 451 |
|
| 452 |
// query or modify login session an object is bound to |
| 453 |
#define CKA_IBM_LOGIN_SESSION (CKA_VENDOR_DEFINED +0x1000f) |
| 454 |
|
| 455 |
#define CKA_IBM_PARAMETER_SET (CKA_VENDOR_DEFINED +0x10010) |
| 456 |
|
| 457 |
// query MAC'd spki from a private key |
| 458 |
#define CKA_IBM_MACED_PUBLIC_KEY_INFO (CKA_VENDOR_DEFINED +0x20002) |
| 459 |
|
| 460 |
// direct access to attributes' wire form |
| 461 |
// parameters of this attribute, if it's the only one present, |
| 462 |
// inserted verbatim into request package |
| 463 |
#define CKA_IBM_WIRETEST (CKA_VENDOR_DEFINED +0x20001) |
| 464 |
|
| 465 |
|
| 466 |
// matches the key type constant for clear key Dilithium with ICSF |
| 467 |
#define CKK_IBM_PQC_DILITHIUM (CKK_VENDOR_DEFINED +0x10023) |
| 468 |
|
| 469 |
#define CKK_IBM_PQC_KYBER (CKK_VENDOR_DEFINED +0x10024) |
| 470 |
|
| 471 |
#define CKK_IBM_ML_DSA (CKK_VENDOR_DEFINED +0x10025) |
| 472 |
|
| 473 |
#define CKK_IBM_ML_KEM (CKK_VENDOR_DEFINED +0x10026) |
| 474 |
|
| 475 |
|
| 476 |
|
| 477 |
|
| 478 |
|
| 479 |
#define XCP_MOD_ERROR_STATE_OFF 0x00000000 |
| 480 |
#define XCP_MOD_ERROR_STATE_MODULE_SELFTEST 0x00000001 |
| 481 |
#define XCP_MOD_ERROR_STATE_KEYPAIR_GEN_PCT 0x00000002 |
| 482 |
#define XCP_MOD_ERROR_STATE_SYSTEST_CMD 0x00000003 |
| 483 |
#define XCP_MOD_ERROR_STATE_TRNG_HEALTH 0x00000004 |
| 484 |
|
| 485 |
|
| 486 |
/*---------------------------------------------------------------------------- |
| 487 |
* sizes related to blobs and host-visible entities |
| 488 |
* |
| 489 |
* Cast as many to size_t/unsigned types as possible, to minimize the number |
| 490 |
* of 'mixed un/signed types' warnings. Unfortunately, this does not work |
| 491 |
* for those which are used by preprocessor math (XCP_WK_BYTES, for example), |
| 492 |
* since the preprocessor can not deal with typed arithmetic. |
| 493 |
*/ |
| 494 |
#define XCP_HMAC_BYTES ((size_t) (256 /8)) /* SHA-256 */ |
| 495 |
#define XCP_FWID_BYTES ((size_t) (256 /8)) /* SHA-256 */ |
| 496 |
#define XCP_WK_BYTES ((size_t) (256 /8)) /* keypart and session sizes */ |
| 497 |
/* are identical */ |
| 498 |
#define XCP_WKID_BYTES ((size_t) (128 /8)) /* truncated hash */ |
| 499 |
#define XCP_BLOBCLRATTR_BYTES 8 /* clear blob attr's bytecount */ |
| 500 |
/* keep in sync with objattr_t */ |
| 501 |
#define XCP_BLOBCLRMODE_BYTES 8 /* clear blob modefield bytecount */ |
| 502 |
#define XCP_WRAP_BLOCKSIZE ((size_t) (128 /8)) /* blob crypt block bytecount */ |
| 503 |
#define XCP_MACKEY_BYTES (256 /8) /* derived from controlling WK */ |
| 504 |
// |
| 505 |
#define XCP_PIN_SALT_BYTES XCP_WRAP_BLOCKSIZE |
| 506 |
#define XCP_PINBLOB_BYTES \ |
| 507 |
(XCP_WK_BYTES +XCP_PIN_SALT_BYTES +XCP_HMAC_BYTES) |
| 508 |
#define XCP_SESSION_SALT_BYTES ((size_t) 128 /8) |
| 509 |
/* salt used in PIN blob rewrapping */ |
| 510 |
#define XCP_SESSION_TCTR_BYTES ((size_t) (128/8)) /* transaction counter */ |
| 511 |
#define XCP_SESSION_MAC1_BYTES ((size_t) 64 /8) /* AES/KW MAC */ |
| 512 |
// |
| 513 |
// full v1 (FIPS/2021) PIN, AESKW/pad ciphertext size |
| 514 |
#define XCP_PINBLOB_V1_BYTES \ |
| 515 |
(XCP_WK_BYTES +XCP_SESSION_SALT_BYTES +XCP_SESSION_MAC1_BYTES) |
| 516 |
|
| 517 |
#define XCP_PBE_TYPE_CLEAR 0 /* clear passphrase */ |
| 518 |
#define XCP_PBE_TYPE_BLOB 1 /* passphrase as generic secretkey */ |
| 519 |
#define XCP_PBE_TYPE_MAX (XCP_PBE_TYPE_BLOB) |
| 520 |
// |
| 521 |
#define XCP_PBE_HDR_BYTES 16 /* fixed part of PBE wire struct */ |
| 522 |
#define XCP_PBE_PWD_MAX_BYTES 1024 |
| 523 |
#define XCP_PBE_SALT_MAX_BYTES 256 |
| 524 |
// currently, these are the largest possible param structs |
| 525 |
#define XCP_MECH_WIRE_PRM_BYTES ((size_t) 4) /* CK_ULONG(mech) on wire */ |
| 526 |
#define XCP_MECH_PRM_MAX_BYTES \ |
| 527 |
(XCP_MECH_WIRE_PRM_BYTES +XCP_PBE_HDR_BYTES \ |
| 528 |
+XCP_PBE_PWD_MAX_BYTES +XCP_PBE_SALT_MAX_BYTES) |
| 529 |
|
| 530 |
// wire-encoded file header: file ID, start/offset, bytecount |
| 531 |
// return path fills in fields, plus may supply data slice |
| 532 |
#define XCP_WIRE_FILEHDR_BYTES ((size_t) (4+4+4)) |
| 533 |
|
| 534 |
// currently, PBE iteration count limit is global |
| 535 |
// the limit may increase, but not decrease, in the future |
| 536 |
#define XCP_PBE_ITER_MAX (64*1024) |
| 537 |
|
| 538 |
|
| 539 |
// SYS_TEST-only, configuration query size |
| 540 |
#define XCP_CSP_CONFIG_BYTES 40 |
| 541 |
|
| 542 |
|
| 543 |
#define XCP_SESSIONBLOB_SALT_BYTES 16 |
| 544 |
#define XCP_SESSIONBLOB_BYTES \ |
| 545 |
(XCP_WK_BYTES +XCP_SESSIONBLOB_SALT_BYTES +XCP_HMAC_BYTES) |
| 546 |
|
| 547 |
#define XCP_SIZEQ_WIRE_BYTES 8 /* wire size of data/response bytecounts */ |
| 548 |
|
| 549 |
|
| 550 |
#define XCP_PSS_WIRE_BYTES (4+4+4) /* hash[32] || MGF[32] || salt bytes[32] */ |
| 551 |
// |
| 552 |
// infer value from mechanism/hash function |
| 553 |
#define XCP_PSS_DEFAULT_VALUE 0xffffffff |
| 554 |
|
| 555 |
#define XCP_OAEP_MIN_WIRE_BYTES (4+4+4) /* hash[32] || MGF[32] || src[32] */ |
| 556 |
|
| 557 |
#define XCP_OAEP_MAX_SOURCE_BYTES 1024 |
| 558 |
/* limit encoding parameter length to a sane number of Bytes */ |
| 559 |
|
| 560 |
#define XCP_SHAKE_WIRE_BYTES 4 /* XOF Bytes[32] */ |
| 561 |
|
| 562 |
#define XCP_ECDH1_DERIVE_MIN_WIRE_BYTES (4+4+4) /* kdf[32] || |
| 563 |
SharedDataLen[32] || |
| 564 |
PublicDataLen[32] */ |
| 565 |
|
| 566 |
#define XCP_BTC_MIN_WIRE_BYTES (4+4+4+4) /* type[32] || |
| 567 |
childKeyIndex[32] || |
| 568 |
chaincode[32] |
| 569 |
version[32] */ |
| 570 |
|
| 571 |
#define XCP_BIP0032_CHAINCODE_BYTES 32 |
| 572 |
|
| 573 |
#define XCP_BTC_VERSION 1 |
| 574 |
|
| 575 |
#define XCP_ETH_MIN_WIRE_BYTES (4+4+4+4+4) /* type[32] || |
| 576 |
childKeyIndex[32] || |
| 577 |
KeyInfo[32] || |
| 578 |
version[32] || |
| 579 |
sigVersion[32] */ |
| 580 |
#define XCP_EIP2333_KEYINFO_BYTES 32 |
| 581 |
|
| 582 |
#define XCP_ETH_VERSION 1 |
| 583 |
|
| 584 |
#define XCP_ETH_SIG_VERSION 4 |
| 585 |
|
| 586 |
#define XCP_KYBER_KEM_VERSION 0 |
| 587 |
|
| 588 |
#define XCP_KYBER_KEM_MIN_WIRE_BYTES (4 + 4 + 4 + 4 + 4 + 4) /* version[32] || |
| 589 |
kdf[32] || |
| 590 |
mode[32] || |
| 591 |
cphr[32] || |
| 592 |
shrd[32] || |
| 593 |
blob [32] */ |
| 594 |
|
| 595 |
#define XCP_KYBER_RAW_BYTES 32 |
| 596 |
|
| 597 |
|
| 598 |
#define XCP_ECDH1_DERIVE_MAX_PUBLIC_BYTES 1024 /* limit public data length to |
| 599 |
reasonable number of bytes */ |
| 600 |
// |
| 601 |
#define XCP_ECDH1_DERIVE_MAX_SHARED_BYTES 1024 /* limit shared data length to |
| 602 |
reasonable number of bytes */ |
| 603 |
// |
| 604 |
// full RK ID (handle) |
| 605 |
#define XCP_RETAINID_BYTES (XCP_HMAC_BYTES +XCP_HMAC_BYTES) |
| 606 |
// |
| 607 |
// RK label (name, other human-readable information) |
| 608 |
#define XCP_RETAINLABEL_BYTES ((size_t) 64) |
| 609 |
// |
| 610 |
// truncated form |
| 611 |
#define XCP_RETAINID_SHORT_BYTES 4 |
| 612 |
|
| 613 |
|
| 614 |
/*--- infrastructure -----------------------------------------------------*/ |
| 615 |
typedef enum { |
| 616 |
CKF_IBM_HW_EXTWNG = 1, // module monitors removal from its slot. |
| 617 |
CKF_IBM_HW_ATTEST = 2, // module has hardware-assisted attestation |
| 618 |
CKF_IBM_HW_BATTERY = 4, // module has battery, may raise warnings |
| 619 |
CKF_IBM_HW_SYSTEST = 8, // module supports insecure test functions |
| 620 |
CKF_IBM_HW_RETAIN = 0x10, // module may retain hardware-internal keys |
| 621 |
CKF_IBM_HW_AUDIT = 0x40, // module supports audit-event logging |
| 622 |
CKF_IBM_HW_ADM_DOMIMPORT |
| 623 |
= 0x0200, // module supports domain import |
| 624 |
// see also related extended capability |
| 625 |
// (CK_IBM_XCPXQ_DOMIMPORT_VER) |
| 626 |
|
| 627 |
CKF_IBM_HW_PROTKEY_TOLERATION |
| 628 |
= 0x0400, // module tolerates blob attributes |
| 629 |
// related to the protected-key capability |
| 630 |
// see also CKA_IBM_PROTKEY_* description |
| 631 |
|
| 632 |
CKF_IBM_HW_DUAL_OA = 0x1000, // module supports dual OA certs/signatures |
| 633 |
// see CK_IBM_XCPXQ_OA_CAP for more details |
| 634 |
CKF_IBM_HW_RSA_IMPLICIT_REJECTION |
| 635 |
= 0x2000, // module performs implicit rejection of |
| 636 |
// data with invalid RSA PKCS 1.5 padding |
| 637 |
} XCP_CK_EXTFLAGS_t; |
| 638 |
|
| 639 |
// these numbers apply to current version, subject to change |
| 640 |
// |
| 641 |
#define XCP_MAX_MODULES 256 /* number of targetable backends */ |
| 642 |
|
| 643 |
#define XCP_SERIALNR_CHARS 8 |
| 644 |
#define XCP_DOMAIN_INSTANCE_BYTES 4 |
| 645 |
#define XCP_DOMAIN_NUMBER_BYTES 4 |
| 646 |
#define XCP_DOMAIN_REVISION_BYTES 4 |
| 647 |
#define XCP_DOMAIN_FLAGS_BYTES 4 |
| 648 |
|
| 649 |
#define XCP_WRAPKEY_BYTES 32 /* keep integer blocks of blob cipher */ |
| 650 |
|
| 651 |
#define XCP_SPKISALT_BYTES 8 /* in MACed SPKIs (public key objs) */ |
| 652 |
#define XCP_DOMAINS 256 /* keep multiple of 8 */ |
| 653 |
#define XCP_DOMAIN_BYTES 4 /* wire-encoding bytecount */ |
| 654 |
#define XCP_MAX_ADMINS 8 /* per domain; card has +1 */ |
| 655 |
#define XCP_MAX_KEYPARTS 20 /* per export/import call */ |
| 656 |
|
| 657 |
#define XCP_MIN_PINBYTES 8 |
| 658 |
#define XCP_MAX_PINBYTES 16 |
| 659 |
// |
| 660 |
// v1 PINs, LoginExtended(FIPS/2021), specific limits |
| 661 |
#define XCP_MIN_ALG1_PINBYTES ((size_t) 8) |
| 662 |
#define XCP_MAX_ALG1_PINBYTES ((size_t) 64) |
| 663 |
#define XCP_MAX_LXTD_CONTEXT_BYTES ((size_t) 128) /* addl.context */ |
| 664 |
|
| 665 |
// |
| 666 |
// max(...all possible PIN sizes...) |
| 667 |
#define XCP_MAX_ANY_PINBYTES XCP_MAX_ALG1_PINBYTES |
| 668 |
|
| 669 |
// ~arbitrary limit on acceptable admin. certificates |
| 670 |
// additional limits, such as transport-bytecount, may restrict further |
| 671 |
#define XCP_CERT_MAX_BYTES ((size_t) 12288) /* fits dil certs (8k + meta) */ |
| 672 |
#define XCP_CERTHASH_BYTES (256/8) |
| 673 |
/* hash or SKI of public key, or other hash-identified things; SHA-256 */ |
| 674 |
|
| 675 |
#define XCP_ADMCTR_BYTES ((size_t) (128/8)) |
| 676 |
/* card/domain admin transaction ctrs */ |
| 677 |
#define XCP_KEYCSUM_BYTES (256/8) /* full size of verification pattern */ |
| 678 |
|
| 679 |
/* maximum coordinate bytecount, NIST P or BP curves */ |
| 680 |
#define XCP_MAX_EC_COORD_BYTES ((size_t) 66) /* P-521-> 512+9 bits */ |
| 681 |
#define XCP_MIN_EC_CURVE_BITS 192 |
| 682 |
/* ^^^ increase this when policy moves beyond shorter curves */ |
| 683 |
#define XCP_MAX_EC_CURVE_BITS 521 |
| 684 |
|
| 685 |
#define XCP_MAX_DIL_SIGNATURE_BYTES 4668 /* max. length of dil. 8-7 sigs */ |
| 686 |
#define XCP_MAX_SINFO_META_BYTES 100 /* signer info framework bytes */ |
| 687 |
|
| 688 |
/* bytecount of raw (generic) keys, not key schedules */ |
| 689 |
#define MOD_MAX_SYMMKEY_BYTES 256 |
| 690 |
|
| 691 |
#define XCP_FCV_PUBLIC_BYTES ((size_t) 76) /* raw struct without signature */ |
| 692 |
/**/ |
| 693 |
/* note: entire signed packet, w/o key info, before Sentry */ |
| 694 |
/* Sentry and beyond, key info is no longer passed to card */ |
| 695 |
/**/ |
| 696 |
typedef enum { |
| 697 |
XCP_FCV_RSA_BYTES = (76+ 4096/8), /* RSA/4096 signature */ |
| 698 |
XCP_FCV_EC_BYTES = (76+ 2*66), /* ECDSA/P-521 */ |
| 699 |
XCP_FCV_MAX_BYTES = XCP_FCV_RSA_BYTES |
| 700 |
} XCP_FCV_Bytes_t; |
| 701 |
|
| 702 |
|
| 703 |
#define PKCS11_CHECKSUM_BYTES ((size_t) 3) |
| 704 |
#define XCP_KEYBITS_FIELD_BYTES ((size_t) 4) |
| 705 |
/* trailing big-endian bitcount field after UnwrapKey() checksum */ |
| 706 |
|
| 707 |
/* card(OA) signature bytecount: SKI-identified SignerInfo, |
| 708 |
* Non quantum safe: Must contain space for either: |
| 709 |
* - 4096-bit RSA signature, hash OID, encr. OID and SKI |
| 710 |
* - EC-P521 signature, hash OID, encr. OID and SKI |
| 711 |
*/ |
| 712 |
#define XCP_RSPSIG_RSA (4096 / 8) |
| 713 |
#define XCP_RSPSIG_MAX_BYTES (XCP_MAX_SINFO_META_BYTES + \ |
| 714 |
XCP_RSPSIG_RSA) |
| 715 |
|
| 716 |
/* card(OA) signature bytecount: SKI-identified SignerInfo, |
| 717 |
* Quantum safe: Must contain space for: |
| 718 |
* - DIL signature, hash OID, encr. OID and SKI |
| 719 |
*/ |
| 720 |
#define XCP_RSPSIG_QS_MAX_BYTES (XCP_MAX_SINFO_META_BYTES + \ |
| 721 |
XCP_MAX_DIL_SIGNATURE_BYTES) |
| 722 |
|
| 723 |
/* minimal padding for raw RSA enc/dec/sign/ver/wr/unwr |
| 724 |
* Used for example in CKM_RSA_PKCS. See RFC 2313 chapter 8 for a complete |
| 725 |
* description */ |
| 726 |
#define XCP_RSA_PKCS_MIN_PAD 11 |
| 727 |
|
| 728 |
/*=== audit events =======================================================*/ |
| 729 |
|
| 730 |
#define XCP_LOG_STATE_BYTES (256 /8) /* SHA-256-based hash chain */ |
| 731 |
|
| 732 |
#define XCP_LOG_HEADER_BYTE 0x42 /* event-record header, v0 */ |
| 733 |
|
| 734 |
#define XCP_LOGEV_SPEC (0xffff0000) |
| 735 |
/* indicates particular events, not generic event types/categories, */ |
| 736 |
/* if bits in this region are non-zero */ |
| 737 |
|
| 738 |
/* functionality categories: keep within uint16_t range */ |
| 739 |
#define XCP_LOGEV_QUERY 0 |
| 740 |
#define XCP_LOGEV_FUNCTION 1 |
| 741 |
#define XCP_LOGEV_ADMFUNCTION 2 |
| 742 |
#define XCP_LOGEV_STARTUP 3 |
| 743 |
#define XCP_LOGEV_SHUTDOWN 4 |
| 744 |
#define XCP_LOGEV_SELFTEST 5 |
| 745 |
#define XCP_LOGEV_DOM_IMPORT 6 /* import sec-relevant data to */ |
| 746 |
/* domain */ |
| 747 |
#define XCP_LOGEV_DOM_EXPORT 7 /* export sec-relevant data from */ |
| 748 |
/* domain */ |
| 749 |
#define XCP_LOGEV_FAILURE 8 |
| 750 |
#define XCP_LOGEV_GENERATE 9 |
| 751 |
#define XCP_LOGEV_REMOVE 10 |
| 752 |
#define XCP_LOGEV_SPECIFIC 11 /* obtain meaning elsewhere */ |
| 753 |
#define XCP_LOGEV_STATE_IMPORT 12 /* import to card/multiple domains */ |
| 754 |
#define XCP_LOGEV_STATE_EXPORT 13 /* export from card/multiple */ |
| 755 |
/* domains */ |
| 756 |
/* [after successful export] */ |
| 757 |
#define XCP_LOGEV_IMPORT 14 /* key/state import (UnwrapKey) */ |
| 758 |
/* fields provide more context */ |
| 759 |
#define XCP_LOGEV_EXPORT 15 /* key/state import (WrapKey) */ |
| 760 |
/* fields provide more context */ |
| 761 |
|
| 762 |
/*--- specific events (any including XCP_LOGEV_SPEC) ---------*/ |
| 763 |
|
| 764 |
#define XCP_LOGSPEV_TRANSACT_ZEROIZE (XCP_LOGEV_SPEC +1) |
| 765 |
/* zeroize card by transaction */ |
| 766 |
|
| 767 |
#define XCP_LOGSPEV_KAT_FAILED (XCP_LOGEV_SPEC +2) |
| 768 |
/* algorithm selftest failed */ |
| 769 |
|
| 770 |
#define XCP_LOGSPEV_KAT_COMPLETED (XCP_LOGEV_SPEC +3) |
| 771 |
/* algorithm selftests completed */ |
| 772 |
/* redundant; logged only to */ |
| 773 |
/* provide specific event */ |
| 774 |
|
| 775 |
#define XCP_LOGSPEV_EARLY_Q_START (XCP_LOGEV_SPEC +4) |
| 776 |
/* subsequent events were found */ |
| 777 |
/* in the early-event queue. */ |
| 778 |
/* their timestamps are only */ |
| 779 |
/* approximate; order is correct */ |
| 780 |
|
| 781 |
#define XCP_LOGSPEV_EARLY_Q_END (XCP_LOGEV_SPEC +5) |
| 782 |
/* early-even queue processing ends. */ |
| 783 |
/* subsequent events are through */ |
| 784 |
/* regular auditing, with valid */ |
| 785 |
/* timestamps and ordering. */ |
| 786 |
|
| 787 |
#define XCP_LOGSPEV_AUDIT_NEWCHAIN (XCP_LOGEV_SPEC +6) |
| 788 |
/* audit state is corrupted; removed. */ |
| 789 |
/* generating new instance and start */ |
| 790 |
/* new chain as a replacement */ |
| 791 |
|
| 792 |
#define XCP_LOGSPEV_TIMECHG_BEFORE (XCP_LOGEV_SPEC +7) |
| 793 |
/* time change: original time */ |
| 794 |
|
| 795 |
#define XCP_LOGSPEV_TIMECHG_AFTER (XCP_LOGEV_SPEC +8) |
| 796 |
/* time change: updated time */ |
| 797 |
|
| 798 |
#define XCP_LOGSPEV_MODSTIMPORT_START (XCP_LOGEV_SPEC +9) |
| 799 |
/* accepted full-state import */ |
| 800 |
/* data structure */ |
| 801 |
/* starting update procedure */ |
| 802 |
|
| 803 |
#define XCP_LOGSPEV_MODSTIMPORT_FAIL (XCP_LOGEV_SPEC +10) |
| 804 |
/* rejected import structure */ |
| 805 |
/* issued after initial verify; */ |
| 806 |
/* indicates some inconsistency */ |
| 807 |
/* of import data structures */ |
| 808 |
|
| 809 |
#define XCP_LOGSPEV_MODSTIMPORT_END (XCP_LOGEV_SPEC +11) |
| 810 |
/* completed full-state import */ |
| 811 |
|
| 812 |
#define XCP_LOGSPEV_MODSTEXPORT_START (XCP_LOGEV_SPEC +12) |
| 813 |
/* started full-state export */ |
| 814 |
/* see also: XCP_LOGEV_STATE_EXPORT */ |
| 815 |
|
| 816 |
#define XCP_LOGSPEV_MODSTEXPORT_FAIL (XCP_LOGEV_SPEC +13) |
| 817 |
|
| 818 |
|
| 819 |
typedef enum { |
| 820 |
XCP_LOGSYS_AUDIT = 1, /* audit infrastructure itself */ |
| 821 |
XCP_LOGSYS_CRYPTTEST = 2, /* cryptographic test operations */ |
| 822 |
/* such as known-answer tests */ |
| 823 |
XCP_LOGSYS_SELFTEST = 3, /* non-crypto tests */ |
| 824 |
XCP_LOGSYS_FULL = 4, /* full module functionality */ |
| 825 |
XCP_LOGSYS_WK = 5, /* one wrapping key (WK) */ |
| 826 |
XCP_LOGSYS_STATE = 6 /* all transportable module state */ |
| 827 |
} XCP_LogSystem_t; |
| 828 |
|
| 829 |
/* bitmask of audit-event flags (mainly optional fields) */ |
| 830 |
#define XCP_LOGFL_WK_PRESENT 0x80000000 |
| 831 |
#define XCP_LOGFL_COMPLIANCE_PRESENT 0x40000000 /* ...of hosting domain */ |
| 832 |
#define XCP_LOGFL_FINALWK_PRESENT 0x20000000 |
| 833 |
#define XCP_LOGFL_KEYREC0_PRESENT 0x10000000 |
| 834 |
#define XCP_LOGFL_KEYREC0_COMPL 0x08000000 /* key0 compliance */ |
| 835 |
#define XCP_LOGFL_KEYREC1_PRESENT 0x04000000 |
| 836 |
#define XCP_LOGFL_KEYREC2_PRESENT 0x02000000 |
| 837 |
#define XCP_LOGFL_FINTIME_PRESENT 0x01000000 |
| 838 |
#define XCP_LOGFL_SALT0_PRESENT 0x00800000 |
| 839 |
#define XCP_LOGFL_SALT1_PRESENT 0x00400000 |
| 840 |
#define XCP_LOGFL_SALT2_PRESENT 0x00200000 |
| 841 |
#define XCP_LOGFL_REASON_PRESENT 0x00100000 |
| 842 |
#define XCP_LOGFL_SEQPRF_PRESENT 0x00080000 |
| 843 |
|
| 844 |
|
| 845 |
|
| 846 |
//--- importer PK types ---------------------------------------------------- |
| 847 |
typedef enum { |
| 848 |
XCP_IMPRKEY_RSA_2048 = 0, |
| 849 |
XCP_IMPRKEY_RSA_4096 = 1, |
| 850 |
XCP_IMPRKEY_EC_P256 = 2, /* EC, NIST P-256 */ |
| 851 |
XCP_IMPRKEY_EC_P521 = 3, /* EC, NIST P-521 */ |
| 852 |
XCP_IMPRKEY_EC_BP256r = 4, /* EC, Brainpool BP-256r */ |
| 853 |
XCP_IMPRKEY_EC_BP320r = 5, /* EC, Brainpool BP-320r */ |
| 854 |
XCP_IMPRKEY_EC_BP512r = 6, /* EC, Brainpool BP-512r */ |
| 855 |
XCP_IMPRKEY_RSA_3072 = 7, |
| 856 |
XCP_IMPRKEY_EC_P521_TKE = 8, /* EC, NIST P-521 (TKE propr. sign.) */ |
| 857 |
XCP_IMPRKEY_MAX = XCP_IMPRKEY_EC_P521_TKE |
| 858 |
} XCP_IMPRKEY_t; |
| 859 |
|
| 860 |
|
| 861 |
//--- OA key types ---------------------------------------------------- |
| 862 |
typedef enum { |
| 863 |
XCP_OAKEY_RSA_4096 = 1, /* RSA 4096 bit */ |
| 864 |
XCP_OAKEY_ECC_P521 = 2, /* ECC NIST P-521 */ |
| 865 |
XCP_OAKEY_DIL_87R2 = 3, /* DIL 8-7 R2 */ |
| 866 |
XCP_OAKEY_MAX = XCP_OAKEY_DIL_87R2 |
| 867 |
} XCP_OAKEY_t; |
| 868 |
|
| 869 |
|
| 870 |
|
| 871 |
//--- retained key structures --------------------------- |
| 872 |
// initial loading: |
| 873 |
// NULL rkData means no refills; invalid with 0 credits |
| 874 |
// |
| 875 |
// serialized as: |
| 876 |
// nothing if structure is missing (i.e., no restrictions) |
| 877 |
// |
| 878 |
// credits [be32] if structure is present |
| 879 |
// rkdata [var ] |
| 880 |
// |
| 881 |
typedef struct CK_RETAINEDKEY_PARAMS { |
| 882 |
CK_ULONG credits; |
| 883 |
CK_VOID_PTR rkData; |
| 884 |
CK_ULONG rkdLen; |
| 885 |
} CK_RETAINEDKEY_PARAMS; |
| 886 |
|
| 887 |
|
| 888 |
|
| 889 |
|
| 890 |
//--- operation categories (perf. measurement) ----------------------------- |
| 891 |
typedef enum { |
| 892 |
XCP_OPCAT_ASYMM_SLOW = 1, |
| 893 |
XCP_OPCAT_ASYMM_FAST = 2, |
| 894 |
XCP_OPCAT_SYMM_PARTIAL = 3, /* including hashing */ |
| 895 |
XCP_OPCAT_SYMM_FULL = 4, /* including key generation/derivation */ |
| 896 |
XCP_OPCAT_ASYMM_GEN = 5, |
| 897 |
XCP_OPCAT_ASYMM_MAX = XCP_OPCAT_ASYMM_GEN |
| 898 |
} XCP_OPCAT_t; |
| 899 |
// |
| 900 |
|
| 901 |
|
| 902 |
//--- query sub-types ------------------------------------------------------ |
| 903 |
typedef enum { |
| 904 |
CK_IBM_XCPQ_API = 0, /* API and build identifier */ |
| 905 |
CK_IBM_XCPQ_MODULE = 1, /* module-level information */ |
| 906 |
CK_IBM_XCPQ_DOMAINS = 2, /* list active domains & WK IDs */ |
| 907 |
CK_IBM_XCPQ_DOMAIN = 3, |
| 908 |
CK_IBM_XCPQ_SELFTEST = 4, /* integrity & algorithm tests */ |
| 909 |
CK_IBM_XCPQ_EXT_CAPS = 5, /* extended capabilities, count */ |
| 910 |
CK_IBM_XCPQ_EXT_CAPLIST = 6, /* extended capabilities, list */ |
| 911 |
CK_IBM_XCPQ_AUDITLOG = 8, /* audit record or records */ |
| 912 |
/* 9 not used ----------------- */ |
| 913 |
CK_IBM_XCPQ_EC_CURVES = 10, /* supported elliptic curves, */ |
| 914 |
/* individual curves, bitmask */ |
| 915 |
/* see: XCP_ECcurve_t */ |
| 916 |
CK_IBM_XCPQ_COMPAT = 11, /* domains' compatibility modes */ |
| 917 |
CK_IBM_XCPQ_EC_CURVEGRPS |
| 918 |
= 12, /* supported elliptic curves, */ |
| 919 |
/* groups/categories, bitmask */ |
| 920 |
/* see: CK_IBM_ECCURVEQ_t */ |
| 921 |
CK_IBM_XCPQ_CP_BLACKLIST |
| 922 |
= 13, /* control point blacklist: */ |
| 923 |
/* control points which may */ |
| 924 |
/* never be enabled due to */ |
| 925 |
/* policy-minimum restrictions. */ |
| 926 |
|
| 927 |
CK_IBM_XCPQ_PQC_STRENGTHS |
| 928 |
= 14, /* supported quantum safe levels*/ |
| 929 |
/* of strength */ |
| 930 |
/* see: XCP_PQCStrength_t */ |
| 931 |
|
| 932 |
CK_IBM_XCPQ_LOGIN_IMPORTER |
| 933 |
= 15, /* current session importer key */ |
| 934 |
/* and it's transaction counter */ |
| 935 |
/* for given curve type */ |
| 936 |
/* see: XCP_ECCurve_t and */ |
| 937 |
/* CK_IBM_XCPXQ_LOGIN_KEYTYPES */ |
| 938 |
|
| 939 |
CK_IBM_XCPQ_COMPAT_ADM = 16, /* domains' administrative */ |
| 940 |
/* compatibility modes */ |
| 941 |
|
| 942 |
CK_IBM_XCPQ_MAX = CK_IBM_XCPQ_COMPAT_ADM |
| 943 |
} CK_IBM_XCPQUERY_t; |
| 944 |
|
| 945 |
//--- module sub-query sub-types -------------------------------------------- |
| 946 |
typedef enum { |
| 947 |
CK_IBM_XCPMSQ_DEFAULT = 0, /* zero indicates no sub-query */ |
| 948 |
CK_IBM_XCPMSQ_DESCRTEXT = 1, /* human-readable text/tokens */ |
| 949 |
CK_IBM_XCPMSQ_FNLIST = 2, /* supported function id bitmask*/ |
| 950 |
CK_IBM_XCPMSQ_FNS = 3, /* count of fn ids */ |
| 951 |
CK_IBM_XCPMSQ_MOD_V1 = 4, /* add version one fields to */ |
| 952 |
/* module query */ |
| 953 |
CK_IBM_XCPMSQ_ATTRLIST = 5, /* supported administrative */ |
| 954 |
/* attributes bitmask */ |
| 955 |
CK_IBM_XCPMSQ_ATTRS = 6, /* list of supported attribute */ |
| 956 |
/* bits (1 byte / attribute) */ |
| 957 |
/* administrative attributes */ |
| 958 |
CK_IBM_XCPMSQ_MOD_V2 = 7, /* add version two fields to */ |
| 959 |
/* module query */ |
| 960 |
CK_IBM_XCPMSQ_ATTRCOUNT = 8, /* number of supported */ |
| 961 |
/* administrative attributes */ |
| 962 |
CK_IBM_XCPMSQ_MAX = CK_IBM_XCPMSQ_ATTRCOUNT |
| 963 |
} CK_IBM_XCPMSUBQUERY_t; |
| 964 |
|
| 965 |
|
| 966 |
//--- selftest sub-query sub-types ------------------------------------------ |
| 967 |
typedef enum { |
| 968 |
CK_IBM_XCPSSQ_DEFAULT = 0, /* run non-failing POST tests */ |
| 969 |
CK_IBM_XCPSSQ_POST_F = 1, /* run failing POST tests */ |
| 970 |
} CK_IBM_XCPSSUBQUERY_t; |
| 971 |
|
| 972 |
|
| 973 |
// byte sizes of queries which are not represented as structures |
| 974 |
#define XCP_MSQ_FNLIST_SIZE 16 |
| 975 |
#define XCP_XCPMSQ_FNS_SIZE 1 |
| 976 |
#define XCP_XCPMSQ_ATTRCOUNT_SIZE 4 |
| 977 |
|
| 978 |
|
| 979 |
|
| 980 |
#define CK_IBM_XCP_HOSTQ_IDX 0xff000000 /* host-only queries index, min. */ |
| 981 |
|
| 982 |
#define CK_IBM_XCPHQ_COUNT 0xff000000 /* number of host-query indexes */ |
| 983 |
/* including this type itself */ |
| 984 |
#define CK_IBM_XCPHQ_VERSION 0xff000001 /* host-specific package version */ |
| 985 |
/* such as packaging library ID */ |
| 986 |
#define CK_IBM_XCPHQ_VERSION_HASH 0xff000002 |
| 987 |
/* assumed-unique identifier of */ |
| 988 |
/* host code, such as version- */ |
| 989 |
/* identifying cryptographic hash*/ |
| 990 |
/* (library signature field...) */ |
| 991 |
#define CK_IBM_XCPHQ_DIAGS 0xff000003 /* host code diagnostic level */ |
| 992 |
/* 0 if non-diagnostics host code*/ |
| 993 |
#define CK_IBM_XCPHQ_HVERSION 0xff000004 /* human-readable host version */ |
| 994 |
/* identification (recommended: */ |
| 995 |
/* UTF-8 string) */ |
| 996 |
#define CK_IBM_XCPHQ_TGT_MODE 0xff000005 /* host targeting modes */ |
| 997 |
/* returns supported target modes*/ |
| 998 |
/* as bitmask */ |
| 999 |
/* if not available only compat */ |
| 1000 |
/* target mode is in use */ |
| 1001 |
/* See CK_IBM_XCPHQ_TGT_MODES_t */ |
| 1002 |
#define CK_IBM_XCPHQ_ECDH_DERPRM 0xff000006 |
| 1003 |
/* ECDH DeriveKey parameter usage*/ |
| 1004 |
/* is being enforced with hostlib*/ |
| 1005 |
/* version */ |
| 1006 |
/**/ |
| 1007 |
|
| 1008 |
#define CK__IBM_XCPHQ_MAX CK_IBM_XCPHQ_TGT_MODE |
| 1009 |
|
| 1010 |
|
| 1011 |
typedef enum { |
| 1012 |
CK_IBM_XCPHQ_TGT_MODES_TGTGRP = 1, /* target groups are supported */ |
| 1013 |
CK_IBM_XCPHQ_TGT_MODES_MAX = CK_IBM_XCPHQ_TGT_MODES_TGTGRP |
| 1014 |
} CK_IBM_XCPHQ_TGT_MODES_t; |
| 1015 |
|
| 1016 |
|
| 1017 |
typedef enum { |
| 1018 |
CK_IBM_XCPXQ_AUDIT_EV_BYTES = 2, /* largest audit event, bytecount */ |
| 1019 |
CK_IBM_XCPXQ_AUDIT_ENTRIES = 3, /* max. size of event history */ |
| 1020 |
CK_IBM_XCPXQ_DEBUGLVL_MAX = 4, /* backend diagnostics granularity */ |
| 1021 |
CK_IBM_XCPXQ_ERRINJECT_FREQ = 5, /* error-inject frequency N */ |
| 1022 |
/* N calls fail in a million */ |
| 1023 |
/* 0 for production releases, */ |
| 1024 |
/* which do not error-injection */ |
| 1025 |
CK_IBM_XCPXQ_MULTIDATA_N = 6, /* maximum number of supported */ |
| 1026 |
/* sub-fields in multi-data */ |
| 1027 |
/* requests. 0 if not supported, */ |
| 1028 |
/* all-1's if no predefined limit. */ |
| 1029 |
CK_IBM_XCPXQ_IMPEXP_CAPS = 7, /* capability for WK and state */ |
| 1030 |
/* export / import. See 8.7.1.1.1 */ |
| 1031 |
/* for more info */ |
| 1032 |
CK_IBM_XCPXQ_CERT_MAXBYTES = 8, /* bytecount of largest accepted */ |
| 1033 |
/* administrative certificate, if */ |
| 1034 |
/* there is an upper limit. 0 if */ |
| 1035 |
/* the backend does not enforce */ |
| 1036 |
/* any specific limit of its own. */ |
| 1037 |
CK_IBM_XCPXQ_MOD_COUNTERS = 9, /* number of module-internal dev */ |
| 1038 |
/* counters supported, 0 if none */ |
| 1039 |
|
| 1040 |
|
| 1041 |
CK_IBM_XCPXQ_MAX_SESSIONS = 12, |
| 1042 |
CK_IBM_XCPXQ_AVAIL_SESSIONS = 13, /* maximum, currently available */ |
| 1043 |
/* number of backend sessions */ |
| 1044 |
CK_IBM_XCPXQ_BTC_CAP = 14, /* bit field for bitcoin related */ |
| 1045 |
/* additions */ |
| 1046 |
|
| 1047 |
CK_IBM_XCPXQ_ECDSA_OTHER = 15, /* bitmask of supported, other EC |
| 1048 |
signing mechanisms */ |
| 1049 |
CK_IBM_XCPXQ_OA_CAP = 16, /* bitmask of supported outbound |
| 1050 |
authority signing mechanisms */ |
| 1051 |
|
| 1052 |
CK_IBM_XCPXQ_LOGIN_ALG = 18, /* bitmask of login algorithms */ |
| 1053 |
/* supported with LoginExtended */ |
| 1054 |
CK_IBM_XCPXQ_LOGIN_ATTR0 = 19, /* bitmask of supported session */ |
| 1055 |
/* attributes with Login Extended */ |
| 1056 |
/* first double-word */ |
| 1057 |
CK_IBM_XCPXQ_LOGIN_ATTR1 = 20, /* session attributes, 2nd DW */ |
| 1058 |
#if 0 |
| 1059 |
CK_IBM_XCPXQ_LOGIN_ATTR2 = 21, /* session attributes, 3rd DW */ |
| 1060 |
CK_IBM_XCPXQ_LOGIN_ATTR3 = 22, /* session attributes, 4th DW */ |
| 1061 |
#endif |
| 1062 |
CK_IBM_XCPXQ_LOGIN_KEYTYPES = 23, /* bitmask of Login importer types */ |
| 1063 |
/* supported for PIN encryption */ |
| 1064 |
|
| 1065 |
CK_IBM_XCPXQ_MAXIDX = CK_IBM_XCPXQ_LOGIN_KEYTYPES, |
| 1066 |
} CK_IBM_XCPEXTCAP_t; |
| 1067 |
|
| 1068 |
|
| 1069 |
#define CK_IBM_DOM_ADMIND 1 /* administrators present */ |
| 1070 |
#define CK_IBM_DOM_CURR_WK 2 /* domain has current WK */ |
| 1071 |
#define CK_IBM_DOM_NEXT_WK 4 /* domain has pending/next WK */ |
| 1072 |
#define CK_IBM_DOM_COMMITTED_NWK 8 /* next WK is active(committed) */ |
| 1073 |
#define CK_IBM_DOM_IMPRINTED 0x10 /* has left imprint mode */ |
| 1074 |
#define CK_IBM_DOM_IMPRINTS 0x80000000 /* enforces imprint mode */ |
| 1075 |
#define CK_IBM_DOM_PROTKEY_ALLOW 0x20 /* policies allow protected key */ |
| 1076 |
// |
| 1077 |
// note: CK_IBM_DOM_IMPRINTS will go away |
| 1078 |
|
| 1079 |
#define CK_IBM_DOM_ACTIVE \ |
| 1080 |
(CK_IBM_DOM_ADMIND | \ |
| 1081 |
CK_IBM_DOM_CURR_WK | \ |
| 1082 |
CK_IBM_DOM_NEXT_WK | \ |
| 1083 |
CK_IBM_DOM_COMMITTED_NWK | \ |
| 1084 |
CK_IBM_DOM_IMPRINTED) |
| 1085 |
|
| 1086 |
typedef enum { |
| 1087 |
CK_IBM_ECCURVE_NIST = 1, /* NIST P-curves P-192 to P-521 */ |
| 1088 |
CK_IBM_ECCURVE_BPOOL = 2, /* Brainpool curves, regular+twisted */ |
| 1089 |
/* BP160R to BP512T */ |
| 1090 |
CK_IBM_ECCURVE_S256K1 = 4, /* secp256k1 (Bitcoin default) */ |
| 1091 |
CK_IBM_ECCURVE_25519 = 8, /* curve25519 */ |
| 1092 |
/* ECDH/sign vars (isomorphic curves) */ |
| 1093 |
/* are not reported separately */ |
| 1094 |
CK_IBM_ECCURVE_ED448 = 0x20, /* ed448 (Goldilocks) Edwards curve */ |
| 1095 |
} CK_IBM_ECCURVEQ_t; |
| 1096 |
|
| 1097 |
|
| 1098 |
typedef struct CK_IBM_XCPAPI_INFO { |
| 1099 |
CK_ULONG firmwareApi; |
| 1100 |
CK_ULONG firmwareConfig; /* truncated firmware hash */ |
| 1101 |
} CK_IBM_XCPAPI_INFO; |
| 1102 |
|
| 1103 |
typedef CK_IBM_XCPAPI_INFO CK_PTR CK_IBM_XCPAPI_INFO_PTR; |
| 1104 |
|
| 1105 |
#define CK_IBM_XCP_INFO_MEMBERS_V0 \ |
| 1106 |
CK_ULONG firmwareApi; /* API ordinal number */ \ |
| 1107 |
/* major+minor pairs */ \ |
| 1108 |
CK_ULONG firmwareId; /* truncated firmwareConfig */ \ |
| 1109 |
CK_VERSION firmwareVersion; /* xcp only, matches xcpConfig below */ \ |
| 1110 |
CK_VERSION cspVersion; \ |
| 1111 |
/* hashes, possibly truncated */ \ |
| 1112 |
CK_BYTE firmwareConfig[ 32 ]; \ |
| 1113 |
CK_BYTE xcpConfig[ 32 ]; \ |
| 1114 |
CK_BYTE cspConfig[ 32 ]; \ |
| 1115 |
CK_CHAR serialNumber[ 16 ]; /* device || instance */ \ |
| 1116 |
CK_CHAR utcTime[ 16 ]; \ |
| 1117 |
CK_ULONG opMode2; /* currently, reserved 0 */ \ |
| 1118 |
CK_ULONG opMode1; /* operational mode, card-level */ \ |
| 1119 |
CK_FLAGS flags; /* PKCS#11 capabilities */ \ |
| 1120 |
CK_FLAGS extflags; /* non-PKCS#11 capabilities */ \ |
| 1121 |
CK_ULONG domains; \ |
| 1122 |
CK_ULONG symmStateBytes; \ |
| 1123 |
CK_ULONG digestStateBytes; \ |
| 1124 |
CK_ULONG pinBlockBytes; \ |
| 1125 |
CK_ULONG symmKeyBytes; \ |
| 1126 |
CK_ULONG spkiBytes; \ |
| 1127 |
CK_ULONG prvkeyBytes; \ |
| 1128 |
CK_ULONG maxPayloadBytes; \ |
| 1129 |
CK_ULONG cpProfileBytes; \ |
| 1130 |
CK_ULONG controlPoints; |
| 1131 |
|
| 1132 |
#define CK_IBM_XCP_DESCINFO_MEMBER \ |
| 1133 |
CK_CHAR manufacturerID[ 32 ]; \ |
| 1134 |
CK_CHAR model[ 16 ]; |
| 1135 |
|
| 1136 |
#define CK_IBM_XCP_ADMATTRLIST_MEMBER \ |
| 1137 |
CK_BYTE perm_modes[ 8 ]; \ |
| 1138 |
CK_BYTE infra_modes[ 8 ]; \ |
| 1139 |
CK_BYTE comp_modes[ 8 ]; |
| 1140 |
|
| 1141 |
#define CK_IBM_XCP_ADMATTRCOUNT_MEMBER \ |
| 1142 |
CK_BYTE perm_count; \ |
| 1143 |
CK_BYTE infra_count; \ |
| 1144 |
CK_BYTE comp_count; |
| 1145 |
|
| 1146 |
#define CK_IBM_XCP_ADMATTRLIST_MEMBER_V2 \ |
| 1147 |
CK_BYTE perm_ext01_modes[ 8 ]; |
| 1148 |
|
| 1149 |
#define CK_IBM_XCP_ADMATTRCOUNT_MEMBER_V2 \ |
| 1150 |
CK_BYTE perm_ext01_count; |
| 1151 |
|
| 1152 |
#define CK_IBM_XCP_ADMATTRLIST_MEMBER_EXT \ |
| 1153 |
CK_BYTE gen_ktype_modes[ 8 ]; \ |
| 1154 |
CK_BYTE ecc_ktype_modes[ 8 ]; \ |
| 1155 |
CK_BYTE dil_ktype_modes[ 8 ]; \ |
| 1156 |
CK_BYTE adm_compl_modes[ 8 ]; |
| 1157 |
|
| 1158 |
#define CK_IBM_XCP_ADMATTRCOUNT_MEMBER_EXT \ |
| 1159 |
CK_BYTE gen_ktype_count; \ |
| 1160 |
CK_BYTE ecc_ktype_count; \ |
| 1161 |
CK_BYTE dil_ktype_count; \ |
| 1162 |
CK_BYTE adm_compl_count; |
| 1163 |
|
| 1164 |
// see chapter 5.1.1. in the wire spec |
| 1165 |
typedef struct CK_IBM_XCP_INFO { |
| 1166 |
CK_IBM_XCP_INFO_MEMBERS_V0 |
| 1167 |
} CK_IBM_XCP_INFO; |
| 1168 |
// |
| 1169 |
// see chapter 5.1.1. in the wire spec |
| 1170 |
typedef struct CK_IBM_XCP_INFO_V1 { |
| 1171 |
CK_IBM_XCP_INFO_MEMBERS_V0 |
| 1172 |
CK_IBM_XCP_DESCINFO_MEMBER |
| 1173 |
CK_BYTE fnid_mask[ 16 ]; |
| 1174 |
CK_BYTE fnid_count; |
| 1175 |
CK_IBM_XCP_ADMATTRLIST_MEMBER |
| 1176 |
CK_IBM_XCP_ADMATTRCOUNT_MEMBER |
| 1177 |
} CK_IBM_XCP_INFO_V1; |
| 1178 |
// |
| 1179 |
// see chapter 5.1.1. in the wire spec |
| 1180 |
typedef struct CK_IBM_XCP_INFO_V2 { |
| 1181 |
CK_IBM_XCP_INFO_MEMBERS_V0 |
| 1182 |
CK_IBM_XCP_DESCINFO_MEMBER |
| 1183 |
CK_BYTE fnid_mask[ 16 ]; |
| 1184 |
CK_BYTE fnid_count; |
| 1185 |
CK_IBM_XCP_ADMATTRLIST_MEMBER |
| 1186 |
CK_IBM_XCP_ADMATTRCOUNT_MEMBER |
| 1187 |
CK_IBM_XCP_ADMATTRLIST_MEMBER_V2 |
| 1188 |
CK_IBM_XCP_ADMATTRCOUNT_MEMBER_V2 |
| 1189 |
} CK_IBM_XCP_INFO_V2; |
| 1190 |
// |
| 1191 |
// see chapter 5.1.1.1. in the wire spec |
| 1192 |
typedef struct CK_IBM_XCP_DESCINFO { |
| 1193 |
CK_IBM_XCP_DESCINFO_MEMBER |
| 1194 |
} CK_IBM_XCP_DESCINFO; |
| 1195 |
// |
| 1196 |
// see chapter 5.1.1.3. in the wire spec |
| 1197 |
typedef struct CK_IBM_XCP_ATTRLIST { |
| 1198 |
CK_IBM_XCP_ADMATTRLIST_MEMBER |
| 1199 |
CK_IBM_XCP_ADMATTRLIST_MEMBER_V2 |
| 1200 |
CK_IBM_XCP_ADMATTRLIST_MEMBER_EXT |
| 1201 |
} CK_IBM_XCP_ATTRLIST; |
| 1202 |
// |
| 1203 |
// see chapter 5.1.1.3. in the wire spec |
| 1204 |
typedef struct CK_IBM_XCP_ATTRCOUNT { |
| 1205 |
CK_IBM_XCP_ADMATTRCOUNT_MEMBER |
| 1206 |
CK_IBM_XCP_ADMATTRCOUNT_MEMBER_V2 |
| 1207 |
CK_IBM_XCP_ADMATTRCOUNT_MEMBER_EXT |
| 1208 |
} CK_IBM_XCP_ATTRCOUNT; |
| 1209 |
|
| 1210 |
typedef struct CK_IBM_XCP_ATTRLIST_LGC { |
| 1211 |
CK_IBM_XCP_ADMATTRLIST_MEMBER |
| 1212 |
CK_IBM_XCP_ADMATTRLIST_MEMBER_V2 |
| 1213 |
} CK_IBM_XCP_ATTRLIST_LGC; |
| 1214 |
|
| 1215 |
typedef struct CK_IBM_XCP_ATTRCOUNT_LGC { |
| 1216 |
CK_IBM_XCP_ADMATTRCOUNT_MEMBER |
| 1217 |
CK_IBM_XCP_ADMATTRCOUNT_MEMBER_V2 |
| 1218 |
} CK_IBM_XCP_ATTRCOUNT_LGC; |
| 1219 |
|
| 1220 |
|
| 1221 |
/**/ |
| 1222 |
#define CK_IBM_XCP_INFO_INIT0 \ |
| 1223 |
{ 0,0, {0,0,},{0,0,}, {0,},{0,},{0,}, {0,},{0,}, \ |
| 1224 |
0,0, 0,0, 0,0,0,0,0,0,0, 0,0,0, } |
| 1225 |
|
| 1226 |
#define CK_IBM_XCP_INFO_V2_INIT0 \ |
| 1227 |
{ 0,0, {0,0,},{0,0,}, {0,},{0,},{0,}, {0,},{0,}, \ |
| 1228 |
0,0, 0,0, 0,0,0,0,0,0,0, 0,0,0, \ |
| 1229 |
{0}, {0}, {0}, 0, {0}, {0}, {0}, 0, 0, 0, \ |
| 1230 |
{0}, 0} |
| 1231 |
|
| 1232 |
typedef CK_IBM_XCP_INFO CK_PTR CK_IBM_XCP_INFO_PTR; |
| 1233 |
typedef CK_IBM_XCP_INFO_V1 CK_PTR CK_IBM_XCP_INFO_V1_PTR; |
| 1234 |
typedef CK_IBM_XCP_INFO_V2 CK_PTR CK_IBM_XCP_INFO_V2_PTR; |
| 1235 |
typedef CK_IBM_XCP_DESCINFO CK_PTR CK_IBM_XCP_DESCINFO_PTR; |
| 1236 |
typedef CK_IBM_XCP_ATTRLIST CK_PTR CK_IBM_XCP_ATTRLIST_PTR; |
| 1237 |
typedef CK_IBM_XCP_ATTRCOUNT CK_PTR CK_IBM_XCP_ATTRCOUNT_PTR; |
| 1238 |
|
| 1239 |
typedef struct CK_IBM_DOMAIN_INFO { |
| 1240 |
CK_ULONG domain; |
| 1241 |
CK_BYTE wk[ XCP_KEYCSUM_BYTES ]; |
| 1242 |
CK_BYTE nextwk[ XCP_KEYCSUM_BYTES ]; |
| 1243 |
CK_ULONG flags; |
| 1244 |
CK_BYTE mode[ 8 ]; |
| 1245 |
} CK_IBM_DOMAIN_INFO; |
| 1246 |
/**/ |
| 1247 |
#define CK_IBM_DOMAIN_INFO_INIT0 { 0, { 0, }, { 0, }, 0, { 0, } } |
| 1248 |
|
| 1249 |
|
| 1250 |
typedef CK_IBM_DOMAIN_INFO CK_PTR CK_IBM_DOMAIN_INFO_PTR; |
| 1251 |
|
| 1252 |
|
| 1253 |
//--- BTC mechparams -------------------------------------------------- |
| 1254 |
typedef struct CK_IBM_BTC_DERIVE_PARAMS { |
| 1255 |
CK_ULONG type; |
| 1256 |
CK_ULONG childKeyIndex; |
| 1257 |
CK_BYTE_PTR pChainCode; |
| 1258 |
CK_ULONG ulChainCodeLen; |
| 1259 |
CK_ULONG version; |
| 1260 |
} CK_IBM_BTC_DERIVE_PARAMS; |
| 1261 |
|
| 1262 |
typedef CK_IBM_BTC_DERIVE_PARAMS CK_PTR CK_IBM_BTC_DERIVE_PARAMS_PTR; |
| 1263 |
|
| 1264 |
// key index flag; hardened, i.e., keys cannot be used for pub2pub derivation |
| 1265 |
#define CK_IBM_BIP0032_HARDENED (0x80000000) |
| 1266 |
|
| 1267 |
// sub-variants of BIP-0032 key derivation |
| 1268 |
typedef enum { |
| 1269 |
CK_IBM_BIP0032_PRV2PRV = 1, |
| 1270 |
CK_IBM_BIP0032_PRV2PUB = 2, |
| 1271 |
CK_IBM_BIP0032_PUB2PUB = 3, |
| 1272 |
CK_IBM_BIP0032_MASTERK = 4, |
| 1273 |
CK_IBM_SLIP0010_PRV2PRV = 5, |
| 1274 |
CK_IBM_SLIP0010_PRV2PUB = 6, |
| 1275 |
CK_IBM_SLIP0010_PUB2PUB = 7, |
| 1276 |
CK_IBM_SLIP0010_MASTERK = 8, |
| 1277 |
} CK_IBM_BTC_t; |
| 1278 |
|
| 1279 |
//--- ETH mechparams -------------------------------------------------- |
| 1280 |
typedef struct CK_IBM_ETH_DERIVE_PARAMS { |
| 1281 |
CK_ULONG version; |
| 1282 |
CK_ULONG sigVersion; |
| 1283 |
CK_ULONG type; |
| 1284 |
CK_ULONG childKeyIndex; |
| 1285 |
CK_BYTE_PTR pKeyInfo; |
| 1286 |
CK_ULONG ulKeyInfoLen; |
| 1287 |
} CK_IBM_ETH_DERIVE_PARAMS; |
| 1288 |
|
| 1289 |
typedef CK_IBM_ETH_DERIVE_PARAMS CK_PTR CK_IBM_ETH_DERIVE_PARAMS_PTR; |
| 1290 |
|
| 1291 |
// sub-variants of EIP-2333 key derivation |
| 1292 |
typedef enum { |
| 1293 |
CK_IBM_EIP2333_PRV2PRV = 1, |
| 1294 |
CK_IBM_EIP2333_PRV2PUB = 2, |
| 1295 |
CK_IBM_EIP2333_MASTERK = 3, |
| 1296 |
} CK_IBM_ETH_t; |
| 1297 |
|
| 1298 |
|
| 1299 |
typedef enum { |
| 1300 |
XCP_KEM_ENCAPSULATE = 1, |
| 1301 |
XCP_KEM_DECAPSULATE = 2, |
| 1302 |
} XCP_KEM_t; |
| 1303 |
|
| 1304 |
typedef CK_ULONG CK_IBM_KEM_MODE; |
| 1305 |
|
| 1306 |
#define XCP_ML_KEM_DSA_MAX_SEED_BYTES 64 |
| 1307 |
|
| 1308 |
#define CK_IBM_KEM_ENCAPSULATE XCP_KEM_ENCAPSULATE |
| 1309 |
#define CK_IBM_KEM_DECAPSULATE XCP_KEM_DECAPSULATE |
| 1310 |
|
| 1311 |
typedef struct XCP_KYBER_KEM_PARAMS { |
| 1312 |
CK_ULONG version; |
| 1313 |
CK_IBM_KEM_MODE mode; |
| 1314 |
CK_ULONG kdf; |
| 1315 |
CK_BBOOL prepend; |
| 1316 |
CK_BYTE *pCipher; |
| 1317 |
CK_ULONG ulCipherLen; |
| 1318 |
CK_BYTE *pSharedData; |
| 1319 |
CK_ULONG ulSharedDataLen; |
| 1320 |
CK_BYTE *pBlob; |
| 1321 |
CK_ULONG ulBlobLen; |
| 1322 |
} XCP_KYBER_KEM_PARAMS_t; |
| 1323 |
|
| 1324 |
|
| 1325 |
//--- Login Extended Information ------------------------------------------- |
| 1326 |
// data types and constants related to LoginExtended and LogoutExtended |
| 1327 |
// see wire spec 6.19 |
| 1328 |
|
| 1329 |
// currently known Login Algorithms for Session ID calculation |
| 1330 |
typedef enum XCP_LoginAlgorithm { |
| 1331 |
XCP_LOGIN_ALG_PRE_F2021 = 0, |
| 1332 |
XCP_LOGIN_ALG_F2021 = 2, |
| 1333 |
XCP_LOGIN_ALG_MAX = XCP_LOGIN_ALG_F2021 |
| 1334 |
} XCP_LoginAlgorithm_t; |
| 1335 |
|
| 1336 |
typedef CK_ULONG CK_IBM_LOGIN_ALG; |
| 1337 |
|
| 1338 |
#define CK_IBM_LOGIN_ALG_PRE_F2021 XCP_LOGIN_ALG_PRE_F2021 |
| 1339 |
#define CK_IBM_LOGIN_ALG_F2021 XCP_LOGIN_ALG_F2021 |
| 1340 |
|
| 1341 |
// currently known Login importer key types for encrypted PIN transport |
| 1342 |
typedef enum XCP_LoginImporter { |
| 1343 |
XCP_LOGIN_IMPR_EC_P256 = 1, /* EC, NIST P-256 */ |
| 1344 |
XCP_LOGIN_IMPR_EC_P521 = 2, /* EC, NIST P-521 */ |
| 1345 |
} XCP_LoginImporter_t; |
| 1346 |
|
| 1347 |
// maximum size of login importer structure, assuming DER encoding |
| 1348 |
// and EC P-521 as maximum key |
| 1349 |
// |
| 1350 |
#define XCP_LOGIN_IMPR_MAX_SIZE (3 + (2 + XCP_CERTHASH_BYTES) \ |
| 1351 |
+ (3 + 158) \ |
| 1352 |
+ (2 + XCP_SESSION_TCTR_BYTES) ) |
| 1353 |
|
| 1354 |
// login session attributes, bit index |
| 1355 |
typedef enum XCP_LoginAttribute { |
| 1356 |
XCP_LOGIN_ATTR_SUPERVISOR = 0, |
| 1357 |
XCP_LOGIN_ATTR_MIGRATION = 1, |
| 1358 |
XCP_LOGIN_ATTR_VOLATILE = 2, |
| 1359 |
XCP_LOGIN_ATTR_MAX = XCP_LOGIN_ATTR_VOLATILE, |
| 1360 |
} XCP_LoginAttribute_t; |
| 1361 |
|
| 1362 |
#define CK_IBM_LOGIN_ATTR_SUPERVISOR XCP_LOGIN_ATTR_SUPERVISOR |
| 1363 |
#define CK_IBM_LOGIN_ATTR_MIGRATION XCP_LOGIN_ATTR_MIGRATION |
| 1364 |
#define CK_IBM_LOGIN_ATTR_VOLATILE XCP_LOGIN_ATTR_VOLATILE |
| 1365 |
#define CK_IBM_LOGIN_ATTR_MAX XCP_LOGIN_ATTR_VOLATILE |
| 1366 |
|
| 1367 |
// login recipient structure |
| 1368 |
typedef struct XCP_LoginRecipient { |
| 1369 |
CK_BYTE recipient_ski[ XCP_CERTHASH_BYTES ]; |
| 1370 |
CK_BYTE sender_spki; |
| 1371 |
CK_ULONG spkilen; |
| 1372 |
} XCP_LoginRecipient_t; |
| 1373 |
|
| 1374 |
// extended login information structure |
| 1375 |
typedef struct XCP_LoginExtendedInfo { |
| 1376 |
CK_BYTE *version; |
| 1377 |
CK_ULONG verlen; |
| 1378 |
CK_IBM_LOGIN_ALG algorithm; |
| 1379 |
CK_BYTE parent[ XCP_WK_BYTES ]; |
| 1380 |
XCP_LoginRecipient_t *recepient; |
| 1381 |
CK_ULONG attributes; |
| 1382 |
CK_BYTE context; |
| 1383 |
CK_ULONG contlen; |
| 1384 |
} XCP_LoginExtendedInfo_t; |
| 1385 |
|
| 1386 |
|
| 1387 |
//--- attribute constants -------------------------------------------------- |
| 1388 |
// |
| 1389 |
typedef enum { |
| 1390 |
XCP_BLOB_EXTRACTABLE = 1, |
| 1391 |
// May be encrypted by other keys. |
| 1392 |
// May not be reset. |
| 1393 |
XCP_BLOB_NEVER_EXTRACTABLE = 2, |
| 1394 |
// set if key was created non-extractable. |
| 1395 |
// Set only initially, may not be |
| 1396 |
// modified. |
| 1397 |
XCP_BLOB_MODIFIABLE = 4, |
| 1398 |
// attributes may be changed |
| 1399 |
XCP_BLOB_NEVER_MODIFIABLE = 8, |
| 1400 |
// object was created read-only. |
| 1401 |
// Set only initially, may not be |
| 1402 |
// modified. |
| 1403 |
XCP_BLOB_RESTRICTABLE = 0x10, |
| 1404 |
// attributes may be removed, but may not be |
| 1405 |
// made more permissive. |
| 1406 |
XCP_BLOB_LOCAL = 0x20, |
| 1407 |
// was created inside this CSP, |
| 1408 |
// was not imported. Set upon object |
| 1409 |
// creation, may not be modified. |
| 1410 |
XCP_BLOB_ATTRBOUND = 0x40, |
| 1411 |
// may be transported only in |
| 1412 |
// attribute-bound formats, |
| 1413 |
// but not pure PKCS11 ones. |
| 1414 |
// May not be modified. |
| 1415 |
XCP_BLOB_USE_AS_DATA = 0x80, |
| 1416 |
// raw key bytes may be input |
| 1417 |
// to other processing as data, |
| 1418 |
// such as hashed, or deriving |
| 1419 |
// keys from them. |
| 1420 |
|
| 1421 |
XCP_BLOB_SIGN = 0x0100, |
| 1422 |
// may generate signatures |
| 1423 |
XCP_BLOB_SIGN_RECOVER = 0x0200, |
| 1424 |
// may generate (asymmetric) |
| 1425 |
// signatures with message recovery |
| 1426 |
XCP_BLOB_DECRYPT = 0x0400, // may decrypt data |
| 1427 |
XCP_BLOB_ENCRYPT = 0x0800, // may encrypt data |
| 1428 |
XCP_BLOB_DERIVE = 0x1000, // may derive other keys |
| 1429 |
XCP_BLOB_UNWRAP = 0x2000, |
| 1430 |
// may decrypt (transport) other keys |
| 1431 |
XCP_BLOB_WRAP = 0x4000, |
| 1432 |
// may encrypt (transport) other keys |
| 1433 |
XCP_BLOB_VERIFY = 0x8000, // may verify signatures |
| 1434 |
XCP_BLOB_VERIFY_RECOVER = 0x010000, |
| 1435 |
// may verify signatures and recover |
| 1436 |
// signed messages |
| 1437 |
|
| 1438 |
XCP_BLOB_TRUSTED = 0x020000, // PKCS11 CKA_TRUSTED key |
| 1439 |
XCP_BLOB_WRAP_W_TRUSTED = 0x040000, // needs CKA_TRUSTED KEK |
| 1440 |
// note: _TRUSTED enforcement does not |
| 1441 |
// provide security guarantees. We only |
| 1442 |
// track it inside the HSM to assist hosts. |
| 1443 |
XCP_BLOB_RETAINED = 0x080000, // blob resides within |
| 1444 |
// backend, not (no longer) on host |
| 1445 |
XCP_BLOB_ALWAYS_RETAINED = 0x100000, // blob has been generated |
| 1446 |
// inside |
| 1447 |
XCP_BLOB_PROTKEY_EXTRACTABLE = 0x200000, |
| 1448 |
// May be imported as protected key. |
| 1449 |
// May not be reset. |
| 1450 |
XCP_BLOB_PROTKEY_NEVER_EXTRACTABLE = 0x400000, |
| 1451 |
// set if key was created non-extractable |
| 1452 |
// as a protected key. |
| 1453 |
// Set only initially, may not be |
| 1454 |
// modified. |
| 1455 |
XCP_BLOB_BIT_MAX = XCP_BLOB_PROTKEY_NEVER_EXTRACTABLE |
| 1456 |
} XCP_Attr_t; |
| 1457 |
|
| 1458 |
|
| 1459 |
//--- control points ------------------------------------------------------- |
| 1460 |
#define XCP_CPID_BYTES 8 /* bytecount in CP profiles */ |
| 1461 |
/* if backend supports them */ |
| 1462 |
|
| 1463 |
#define XCP_CPBLOCK_BITS 128 /* handle CPs in this granularity */ |
| 1464 |
/* CP sets get padded to multiple */ |
| 1465 |
|
| 1466 |
typedef enum { |
| 1467 |
XCP_CPB_ADD_CPBS = 0, // allow activation of CP bits |
| 1468 |
XCP_CPB_DELETE_CPBS = 1, // allow deactivation of CP bits |
| 1469 |
// (remove both ADD_CPBs and DELETE_CPBs |
| 1470 |
// to make unit read-only) |
| 1471 |
|
| 1472 |
XCP_CPB_SIGN_ASYMM = 2, // sign with private keys |
| 1473 |
XCP_CPB_SIGN_SYMM = 3, // sign with HMAC or CMAC |
| 1474 |
XCP_CPB_SIGVERIFY_SYMM = 4, // verify with HMAC or CMAC. |
| 1475 |
// No asymmetric counterpart: one |
| 1476 |
// may not restrict use of public keys. |
| 1477 |
|
| 1478 |
XCP_CPB_ENCRYPT_SYMM = 5, // encrypt with symmetric keys. |
| 1479 |
// No asymmetric counterpart: one |
| 1480 |
// may not restrict use of public keys. |
| 1481 |
|
| 1482 |
XCP_CPB_DECRYPT_ASYMM = 6, // decrypt with private keys |
| 1483 |
XCP_CPB_DECRYPT_SYMM = 7, // decrypt with symmetric keys |
| 1484 |
|
| 1485 |
XCP_CPB_WRAP_ASYMM = 8, // key export with public keys |
| 1486 |
XCP_CPB_WRAP_SYMM = 9, // key export with symmetric keys |
| 1487 |
XCP_CPB_UNWRAP_ASYMM = 10, // key import with private keys |
| 1488 |
XCP_CPB_UNWRAP_SYMM = 11, // key import with symmetric keys |
| 1489 |
|
| 1490 |
XCP_CPB_KEYGEN_ASYMM = 12, // generate asymmetric keypairs |
| 1491 |
// (fn:GenerateKeyPair) |
| 1492 |
XCP_CPB_KEYGEN_SYMM = 13, // generate or derive symmetric keys |
| 1493 |
// including DSA or DH parameters |
| 1494 |
|
| 1495 |
XCP_CPB_RETAINKEYS = 14, // allow backend to save semi-retained keys |
| 1496 |
XCP_CPB_SKIP_KEYTESTS = 15, // disable selftests on new asymmetric keys |
| 1497 |
XCP_CPB_NON_ATTRBOUND = 16, // allow keywrap without attribute-binding |
| 1498 |
XCP_CPB_MODIFY_OBJECTS = 17, // allow changes to objects (Booleans only) |
| 1499 |
XCP_CPB_RNG_SEED = 18, // allow mixing external seed to RNG |
| 1500 |
// backend may restrict further |
| 1501 |
|
| 1502 |
XCP_CPB_ALG_RAW_RSA = 19, // allow RSA private-key use without padding |
| 1503 |
// (highly discouraged) |
| 1504 |
XCP_CPB_ALG_NFIPS2009 = 20, // allow non-FIPS-approved algs (as of 2009) |
| 1505 |
// including non-FIPS keysizes |
| 1506 |
XCP_CPB_ALG_NBSI2009 = 21, // allow non-BSI algorithms (as of 2009) |
| 1507 |
// including non-BSI keysizes |
| 1508 |
XCP_CPB_KEYSZ_HMAC_ANY = 22, // don't enforce minimum keysize on HMAC |
| 1509 |
// (allows keys shorter than half of digest) |
| 1510 |
|
| 1511 |
XCP_CPB_KEYSZ_BELOW80BIT = 23, // allow algorithms below 80-bit strength |
| 1512 |
XCP_CPB_KEYSZ_80BIT = 24, // allow 80 to 111-bit algorithms |
| 1513 |
XCP_CPB_KEYSZ_112BIT = 25, // allow 112 to 127-bit algorithms |
| 1514 |
XCP_CPB_KEYSZ_128BIT = 26, // allow 128 to 191-bit algorithms |
| 1515 |
XCP_CPB_KEYSZ_192BIT = 27, // allow 192 to 255-bit algorithms |
| 1516 |
XCP_CPB_KEYSZ_256BIT = 28, // allow 256-bit algorithms |
| 1517 |
XCP_CPB_KEYSZ_RSA65536 = 29, // allow RSA public exponents below 0x10001 |
| 1518 |
XCP_CPB_ALG_RSA = 30, // RSA private-key or key-encrypt use |
| 1519 |
XCP_CPB_ALG_DSA = 31, // DSA private-key use |
| 1520 |
XCP_CPB_ALG_EC = 32, // EC private-key use (see CP on curves) |
| 1521 |
XCP_CPB_ALG_EC_BPOOLCRV = 33, // Brainpool (E.U.) EC curves |
| 1522 |
XCP_CPB_ALG_EC_NISTCRV = 34, // NIST/SECG EC curves |
| 1523 |
|
| 1524 |
XCP_CPB_ALG_NFIPS2011 = 35, // allow non-FIPS-approved algs (as of 2011) |
| 1525 |
// including non-FIPS keysizes |
| 1526 |
XCP_CPB_ALG_NBSI2011 = 36, // allow non-BSI algorithms (as of 2011) |
| 1527 |
// including non-BSI keysizes |
| 1528 |
|
| 1529 |
XCP_CPB_USER_SET_TRUSTED = 37, // allow non-admin set TRUSTED on blob/SPKI |
| 1530 |
XCP_CPB_ALG_SKIP_CROSSCHK = 38, // do not double-check sign/decrypt ops |
| 1531 |
|
| 1532 |
XCP_CPB_WRAP_CRYPT_KEYS = 39, // allow keys which can en/decrypt data |
| 1533 |
// and also un/wrap other keys |
| 1534 |
// (applies to both generation and use) |
| 1535 |
XCP_CPB_SIGN_CRYPT_KEYS = 40, // allow keys which can en/decrypt data |
| 1536 |
// and also sign/verify |
| 1537 |
// (applies to both generation and use) |
| 1538 |
XCP_CPB_WRAP_SIGN_KEYS = 41, // allow keys which can un/wrap data |
| 1539 |
// and also sign/verify |
| 1540 |
// (applies to both generation and use) |
| 1541 |
|
| 1542 |
XCP_CPB_USER_SET_ATTRBOUND = 42, // allow non-administrators to |
| 1543 |
// mark public key objects ATTRBOUND |
| 1544 |
XCP_CPB_ALLOW_PASSPHRASE = 43, // allow host to pass passprases, such as |
| 1545 |
// PKCS12 data, in the clear |
| 1546 |
XCP_CPB_WRAP_STRONGER_KEY = 44, // allow wrapping of stronger keys |
| 1547 |
// by weaker keys |
| 1548 |
XCP_CPB_WRAP_WITH_RAW_SPKI = 45, // allow wrapping with SPKIs without |
| 1549 |
// MAC and attributes |
| 1550 |
XCP_CPB_ALG_DH = 46, // Diffie-Hellman use (private keys) |
| 1551 |
XCP_CPB_DERIVE = 47, // allow key derivation (symmetric+EC/DH) |
| 1552 |
|
| 1553 |
XCP_CPB_ALLOW_NONSESSION = 48, // allow use of blobs without sessions |
| 1554 |
// i.e., key/session state not bound |
| 1555 |
// to Login/Logout-controlled state |
| 1556 |
XCP_CPB_ALG_EC_25519 = 55, // enable support of curve25519, |
| 1557 |
// c448 and related algorithms |
| 1558 |
// incl. EdDSA (ed25519 and ed448) |
| 1559 |
XCP_CPB_ALG_EC_SECGCRV = 60, // Prime-field SECG EC curves excluding |
| 1560 |
// those shared with NIST P-curves |
| 1561 |
XCP_CPB_ALG_NBSI2017 = 61, // allow non-BSI algorithms (as of 2017) |
| 1562 |
// including non-BSI keysizes |
| 1563 |
// (fn:Sign/RSA) |
| 1564 |
XCP_CPB_CPACF_PK = 64, // support data key generation and import |
| 1565 |
// for protected key |
| 1566 |
|
| 1567 |
XCP_CPB_ALG_PQC = 65, // support for PQ algorithms (top CPB) |
| 1568 |
|
| 1569 |
XCP_CPB_BTC = 66, // enable BTC-related functionality |
| 1570 |
// including blockchain, altcoins, and |
| 1571 |
// digital assets |
| 1572 |
|
| 1573 |
XCP_CPB_ECDSA_OTHER = 67, // enable non-ECDSA/non-EdDSA elliptic |
| 1574 |
// curve signature algorithms |
| 1575 |
XCP_CPB_ALG_NFIPS2021 = 68, // allow non-FIPS-approved algs (2021) |
| 1576 |
|
| 1577 |
XCP_CPB_ALG_NFIPS2024 = 69, // allow non-FIPS-approved algs (2024) |
| 1578 |
|
| 1579 |
XCP_CPB_COMPAT_LEGACY_SHA3 = 70, // allow fall-back to non-standard |
| 1580 |
// SHA3 defaults |
| 1581 |
XCP_CPB_DSA_PARAMETER_GEN = 71, // allow DSA/PQG parameter generation |
| 1582 |
XCP_CPB_DERIVE_NON_AB_KEYS = 72, // allow the derivation of a non-AB or raw |
| 1583 |
// from an AB key. Only relevant if |
| 1584 |
// XCP_CPB_NON_ATTRBOUND |
| 1585 |
XCP_CPB_ALLOW_LOGIN_PRE_F2021 = 73, // allow usage of basic login sessions |
| 1586 |
// or extended login sessions using |
| 1587 |
// pre-FIPS2021-algorithms |
| 1588 |
XCP_CPB_ALG_RSA_OAEP = 74, // allow RSA OAEP |
| 1589 |
XCP_CPB_ALLOW_COMBINED_EXTRACT = 75, // allow creation and usage of keys |
| 1590 |
// with both EXTRACTABLE and |
| 1591 |
// PROTKEY_EXTRACTABLE attributes set |
| 1592 |
XCP_CPB_ALG_EC_PAIRING_FRIENDLY = 76, |
| 1593 |
|
| 1594 |
XCP_CPB_ALG_DILITHIUM = 77, // support for pre-Standard dilithium |
| 1595 |
XCP_CPB_ALG_KYBER = 78, // support for pre-Standard kyber |
| 1596 |
XCP_CPB_ALG_ML_DSA = 79, // support for NIST 204 |
| 1597 |
XCP_CPB_ALG_ML_KEM = 80, // support for NIST 203 |
| 1598 |
|
| 1599 |
XCP_CPBITS_MAX = XCP_CPB_ALG_ML_KEM |
| 1600 |
// marks last used CPB |
| 1601 |
} XCP_CPbit_t; |
| 1602 |
|
| 1603 |
|
| 1604 |
// rounded CP count, multiple of XCP_CPBLOCK_BITS |
| 1605 |
// integer bytes, by construction (CPBLOCK_BITS is) |
| 1606 |
// |
| 1607 |
#define XCP_CPCOUNT \ |
| 1608 |
(((XCP_CPBITS_MAX +XCP_CPBLOCK_BITS-1) /XCP_CPBLOCK_BITS) *XCP_CPBLOCK_BITS) |
| 1609 |
|
| 1610 |
#define XCP_CP_BYTES (XCP_CPCOUNT /8) /* full blocks, incl. unused bits */ |
| 1611 |
|
| 1612 |
#define XCP_CPB__INVERT (XCP_CPCOUNT-1) /* reserve MS CP bit for negation */ |
| 1613 |
|
| 1614 |
|
| 1615 |
/*--- CP checks --------------------*/ |
| 1616 |
// |
| 1617 |
// XCP_CPB_ADD_CPBS |
| 1618 |
// - SetAttribute() |
| 1619 |
// XCP_CPB_DELETE_CPBS |
| 1620 |
// - SetAttribute() -- if attempting to set a previously unset attribute |
| 1621 |
// XCP_CPB_SIGN_ASYMM |
| 1622 |
// - SignSingle() -- private key blobs |
| 1623 |
// - SignInit() -- private key blobs |
| 1624 |
// XCP_CPB_SIGN_SYMM |
| 1625 |
// - SignSingle() -- symmetric blobs |
| 1626 |
// - SignInit() -- symmetric blobs |
| 1627 |
// XCP_CPB_SIGVERIFY_SYMM |
| 1628 |
// - VerifySingle() -- symmetric blobs |
| 1629 |
// - VerifyInit() -- symmetric blobs |
| 1630 |
// XCP_CPB_ENCRYPT_SYMM |
| 1631 |
// - EncryptSingle() -- symmetric blobs |
| 1632 |
// - EncryptInit() -- symmetric blobs |
| 1633 |
// XCP_CPB_DECRYPT_ASYMM |
| 1634 |
// - DecryptSingle() -- private key blobs |
| 1635 |
// - DecryptInit() -- private key blobs |
| 1636 |
// XCP_CPB_DECRYPT_SYMM |
| 1637 |
// - DecryptSingle() -- symmetric blobs |
| 1638 |
// - DecryptInit() -- symmetric blobs |
| 1639 |
// XCP_CPB_WRAP_ASYMM |
| 1640 |
// - WrapKey() -- SPKIs |
| 1641 |
// XCP_CPB_WRAP_SYMM |
| 1642 |
// - WrapKey() -- symmetric blobs |
| 1643 |
// XCP_CPB_UNWRAP_ASYMM |
| 1644 |
// - UnwrapKey() -- private key blobs |
| 1645 |
// XCP_CPB_UNWRAP_SYMM |
| 1646 |
// - UnwrapKey() -- symmetric blobs |
| 1647 |
// XCP_CPB_KEYGEN_ASYMM |
| 1648 |
// - GenerateKeyPair() |
| 1649 |
// XCP_CPB_KEYGEN_SYMM |
| 1650 |
// - GenerateKey() |
| 1651 |
// - UnwrapKey() -- symmetric target |
| 1652 |
// - DeriveKey() -- all targets, except openblockchain t-cert |
| 1653 |
// -- derivation, are symmetric |
| 1654 |
// XCP_CPB_RETAINKEYS |
| 1655 |
// - WrapKey(), the form which turns blob into SRK (handle+object) |
| 1656 |
// XCP_CPB_SKIP_KEYTESTS |
| 1657 |
// - GenerateKeyPair() |
| 1658 |
// - UnwrapKey() |
| 1659 |
// -- note: this functionality can only be verified based on logs |
| 1660 |
// -- it enables cross-checking opaque to the host |
| 1661 |
// XCP_CPB_NON_ATTRBOUND |
| 1662 |
// - WrapKey() -- when wrapping to non-AB form |
| 1663 |
// - UnwrapKey() -- when accepting non-AB form |
| 1664 |
// XCP_CPB_MODIFY_OBJECTS |
| 1665 |
// - SetAttributeValue() -- globally, not just per object |
| 1666 |
// XCP_CPB_RNG_SEED |
| 1667 |
// - SeedRandom() |
| 1668 |
// XCP_CPB_ALG_RAW_RSA |
| 1669 |
// - SignSingle() -- RSA blobs |
| 1670 |
// - Sign() -- RSA blobs |
| 1671 |
// - DecryptSingle() -- RSA blobs |
| 1672 |
// - Decrypt() -- RSA blobs |
| 1673 |
// XCP_CPB_ALG_NFIPS2009 |
| 1674 |
// - see NIST algorithms |
| 1675 |
// XCP_CPB_ALG_NBSI2009 |
| 1676 |
// - see BSI algorithms |
| 1677 |
// XCP_CPB_KEYSZ_HMAC_ANY |
| 1678 |
// - SignSingle() -- symmetric blobs with HMAC mech |
| 1679 |
// - Sign() -- symmetric blobs with HMAC mech |
| 1680 |
// - VerifySingle() -- symmetric blobs with HMAC mech |
| 1681 |
// - Verify() -- symmetric blobs with HMAC mech |
| 1682 |
// XCP_CPB_KEYSZ_BELOW80BIT |
| 1683 |
// - see size restrictions |
| 1684 |
// XCP_CPB_KEYSZ_80BIT |
| 1685 |
// - see size restrictions |
| 1686 |
// XCP_CPB_KEYSZ_112BIT |
| 1687 |
// - see size restrictions |
| 1688 |
// XCP_CPB_KEYSZ_128BIT |
| 1689 |
// - see size restrictions |
| 1690 |
// XCP_CPB_KEYSZ_192BIT |
| 1691 |
// - see size restrictions |
| 1692 |
// XCP_CPB_KEYSZ_256BIT |
| 1693 |
// - see size restrictions |
| 1694 |
// XCP_CPB_KEYSZ_RSA65536 |
| 1695 |
// - GenerateKeyPair() |
| 1696 |
// - UnwrapKey() |
| 1697 |
// XCP_CPB_ALG_RSA |
| 1698 |
// - GenerateKeyPair() -- CKK_RSA |
| 1699 |
// - UnwrapKey() -- CKK_RSA |
| 1700 |
// - SignSingle() -- RSA blobs |
| 1701 |
// - Sign() -- RSA blobs |
| 1702 |
// - VerifySingle() -- RSA blobs |
| 1703 |
// - Verify() -- RSA blobs |
| 1704 |
// XCP_CPB_ALG_DSA |
| 1705 |
// - GenerateKeyPair() -- CKK_DSA |
| 1706 |
// - UnwrapKey() -- CKK_DSA |
| 1707 |
// - SignSingle() -- DSA blobs |
| 1708 |
// - Sign() -- DSA blobs |
| 1709 |
// XCP_CPB_ALG_EC |
| 1710 |
// - GenerateKeyPair() -- CKK_EC |
| 1711 |
// - UnwrapKey() -- CKK_EC |
| 1712 |
// - SignSingle() -- EC blobs |
| 1713 |
// - Sign() -- EC blobs |
| 1714 |
// XCP_CPB_ALG_EC_BPOOLCRV |
| 1715 |
// - GenerateKeyPair() -- CKK_EC with Brainpool curves |
| 1716 |
// - UnwrapKey() -- CKK_EC with Brainpool curves |
| 1717 |
// XCP_CPB_ALG_EC_NISTCRV |
| 1718 |
// - GenerateKeyPair() -- CKK_EC with NIST curves |
| 1719 |
// - UnwrapKey() -- CKK_EC with NIST curves |
| 1720 |
// XCP_CPB_ALG_NFIPS2011 |
| 1721 |
// - see NIST algorithms |
| 1722 |
// XCP_CPB_ALG_NBSI2011 |
| 1723 |
// - see BSI algorithms |
| 1724 |
// XCP_CPB_USER_SET_TRUSTED |
| 1725 |
// - SetAttributeValue() |
| 1726 |
// XCP_CPB_ALG_SKIP_CROSSCHK |
| 1727 |
// XCP_CPB_WRAP_CRYPT_KEYS |
| 1728 |
// - unwrap_blob() -- all blob uses |
| 1729 |
// XCP_CPB_SIGN_CRYPT_KEYS |
| 1730 |
// - unwrap_blob() -- all blob uses |
| 1731 |
// XCP_CPB_WRAP_SIGN_KEYS |
| 1732 |
// - unwrap_blob() -- all blob uses |
| 1733 |
// XCP_CPB_USER_SET_ATTRBOUND |
| 1734 |
// - SetAttributeValue() |
| 1735 |
// XCP_CPB_ALLOW_PASSPHRASE |
| 1736 |
// - DeriveKey() |
| 1737 |
// XCP_CPB_WRAP_STRONGER_KEY |
| 1738 |
// - WrapKey() |
| 1739 |
// - UnwrapKey() |
| 1740 |
// XCP_CPB_WRAP_WITH_RAW_SPKI |
| 1741 |
// - WrapKey() |
| 1742 |
// |
| 1743 |
/*-- /CP checks --------------------*/ |
| 1744 |
|
| 1745 |
|
| 1746 |
/*--- administration -----------------------------------------------------*/ |
| 1747 |
|
| 1748 |
#define XCP_ADM_QUERY 0x10000 |
| 1749 |
|
| 1750 |
typedef enum { |
| 1751 |
XCP_ADM_ADMIN_LOGIN = 1, // add admin certificate |
| 1752 |
XCP_ADM_DOM_ADMIN_LOGIN = 2, // add domain admin certificate |
| 1753 |
XCP_ADM_ADMIN_LOGOUT = 3, // revoke admin certificate |
| 1754 |
XCP_ADM_DOM_ADMIN_LOGOUT = 4, // revoke domain admin certificate |
| 1755 |
XCP_ADM_ADMIN_REPLACE = 5, // transition admin certificate |
| 1756 |
XCP_ADM_DOM_ADMIN_REPLACE = 6, // transition domain admin certificate |
| 1757 |
|
| 1758 |
XCP_ADM_SET_ATTR = 7, // set card attribute/s |
| 1759 |
XCP_ADM_DOM_SET_ATTR = 8, // set domain attribute/ |
| 1760 |
|
| 1761 |
XCP_ADM_GEN_DOM_IMPORTER = 9, // generate new importer (PK) key |
| 1762 |
XCP_ADM_GEN_WK = 10, // create random domain WK |
| 1763 |
XCP_ADM_EXPORT_WK = 11, // wrap+output WK or parts |
| 1764 |
XCP_ADM_EXPORT_NEXT_WK = 38, // wrap+output next WK or parts |
| 1765 |
XCP_ADM_IMPORT_WK = 12, // set (set of) WK (parts) to pending |
| 1766 |
XCP_ADM_COMMIT_WK = 13, // activate pending WK |
| 1767 |
XCP_ADM_FINALIZE_WK = 14, // remove previous WK's |
| 1768 |
|
| 1769 |
XCP_ADM_ZEROIZE = 15, // release CSPs from entire module |
| 1770 |
XCP_ADM_DOM_ZEROIZE = 16, // release CSPs from domain/s |
| 1771 |
|
| 1772 |
XCP_ADM_DOM_CTRLPOINT_SET = 17, // fix domain control points |
| 1773 |
XCP_ADM_DOM_CTRLPOINT_ADD = 18, // enable domain control points |
| 1774 |
XCP_ADM_DOM_CTRLPOINT_DEL = 19, // disable domain control points |
| 1775 |
|
| 1776 |
XCP_ADM_SET_CLOCK = 20, // set module-internal UTC time |
| 1777 |
XCP_ADM_SET_FCV = 21, // set function-control vector |
| 1778 |
|
| 1779 |
XCP_ADM_CTRLPOINT_SET = 22, // fix card control points |
| 1780 |
XCP_ADM_CTRLPOINT_ADD = 23, // enable card control points |
| 1781 |
XCP_ADM_CTRLPOINT_DEL = 24, // disable card control points |
| 1782 |
|
| 1783 |
XCP_ADM_REENCRYPT = 25, // transform blobs to next WK |
| 1784 |
XCP_ADM_RK_REMOVE = 26, // remove (semi-) retained key |
| 1785 |
XCP_ADM_CLEAR_WK = 27, // erase current WK |
| 1786 |
XCP_ADM_CLEAR_NEXT_WK = 28, // erase pending WK |
| 1787 |
XCP_ADM_SYSTEM_ZEROIZE = 29, // card zeroize, preserving system |
| 1788 |
// key, if it is present |
| 1789 |
XCP_ADM_EXPORT_STATE = 30, // create card state backup |
| 1790 |
XCP_ADM_IMPORT_STATE = 31, // import card state backup (part) |
| 1791 |
XCP_ADM_COMMIT_STATE = 32, // activate imported card state |
| 1792 |
XCP_ADM_REMOVE_STATE = 33, // purge import/export state backup |
| 1793 |
XCP_ADM_GEN_MODULE_IMPORTER= 34, // generate new importer (PK) key |
| 1794 |
XCP_ADM_SET_TRUSTED = 35, // activate TRUSTED attribute on |
| 1795 |
// blob/SPKI |
| 1796 |
XCP_ADM_DOMAINS_ZEROIZE = 36, // multi-domain zeroize |
| 1797 |
// XCP_ADM_EXPORT_NEXT_WK = 38, // placeholder, find real entry above |
| 1798 |
XCP_ADM_SESSION_REMOVE = 39, // remove all or selected sessions |
| 1799 |
|
| 1800 |
XCP_ADMQ_ADMIN = 1 | XCP_ADM_QUERY, // admin SKI/cert |
| 1801 |
XCP_ADMQ_DOMADMIN = 2 | XCP_ADM_QUERY, // domain adm. SKI/cert |
| 1802 |
XCP_ADMQ_DEVICE_CERT = 3 | XCP_ADM_QUERY, // module CA (OA) cert |
| 1803 |
XCP_ADMQ_DOM_IMPORTER_CERT = 4 | XCP_ADM_QUERY, // dom WK importer |
| 1804 |
XCP_ADMQ_CTRLPOINTS = 5 | XCP_ADM_QUERY, // card CP |
| 1805 |
XCP_ADMQ_DOM_CTRLPOINTS = 6 | XCP_ADM_QUERY, // domain CP |
| 1806 |
XCP_ADMQ_WK = 7 | XCP_ADM_QUERY, // current WK |
| 1807 |
XCP_ADMQ_NEXT_WK = 8 | XCP_ADM_QUERY, // pending WK |
| 1808 |
XCP_ADMQ_ATTRS = 9 | XCP_ADM_QUERY, // card attributes |
| 1809 |
XCP_ADMQ_DOM_ATTRS = 10 | XCP_ADM_QUERY, // domain attributes |
| 1810 |
XCP_ADMQ_FCV = 11 | XCP_ADM_QUERY, // public parts of FCV |
| 1811 |
XCP_ADMQ_WK_ORIGINS = 12 | XCP_ADM_QUERY, |
| 1812 |
// information on original WK |
| 1813 |
// components (keyparts |
| 1814 |
// verification patterns) |
| 1815 |
XCP_ADMQ_RKLIST = 13 | XCP_ADM_QUERY, |
| 1816 |
// retained-key id list |
| 1817 |
XCP_ADMQ_INTERNAL_STATE = 14 | XCP_ADM_QUERY, |
| 1818 |
// (part of) import/export state(file) |
| 1819 |
XCP_ADMQ_IMPORTER_CERT = 15 | XCP_ADM_QUERY, |
| 1820 |
// current migration importer |
| 1821 |
XCP_ADMQ_AUDIT_STATE = 16 | XCP_ADM_QUERY, |
| 1822 |
// audit state entry or event count |
| 1823 |
XCP_ADMQ_LASTCMD_DOM_MASK = 17 | XCP_ADM_QUERY, |
| 1824 |
// domain-bitmask affected by last |
| 1825 |
// state-related administrative |
| 1826 |
// command (export, import) |
| 1827 |
XCP_ADMQ_SVCADMIN = 18 | XCP_ADM_QUERY, // svc admin SKI/cert |
| 1828 |
XCP_ADMQ_LOGIN_IMPORTER = 19 | XCP_ADM_QUERY, |
| 1829 |
// session importer key |
| 1830 |
} XCP_Admcmd_t; |
| 1831 |
|
| 1832 |
typedef enum { |
| 1833 |
XCP_ADMINT_SIGN_THR = 1, // signature threshold |
| 1834 |
XCP_ADMINT_REVOKE_THR = 2, // revocation (signature) threshold |
| 1835 |
XCP_ADMINT_PERMS = 3, // permissions |
| 1836 |
XCP_ADMINT_MODE = 4, // operating mode |
| 1837 |
XCP_ADMINT_STD = 5, // standards' compliance |
| 1838 |
XCP_ADMINT_PERMS_EXT01 = 6, // permissions (extension #1) |
| 1839 |
XCP_ADMINT_GEN_KTYPES = 7, // generic keytypes |
| 1840 |
XCP_ADMINT_ECC_KTYPES = 8, // ECC curve types |
| 1841 |
XCP_ADMINT_DIL_KTYPES = 9, // Dilithium types |
| 1842 |
XCP_ADMINT_ADM_COMPL = 10, // administrative compliance |
| 1843 |
XCP_ADMINT_IDX_MAX = XCP_ADMINT_ADM_COMPL |
| 1844 |
} XCP_AdmAttr_t; |
| 1845 |
|
| 1846 |
#define XCP_ADMIN_ATTRIBUTE_COUNT XCP_ADMINT_IDX_MAX |
| 1847 |
|
| 1848 |
// init-time value |
| 1849 |
#define XCP_ADM_SIGTHR__DEFAULT 0 |
| 1850 |
#define XCP_ADM_REVTHR__DEFAULT 0 |
| 1851 |
|
| 1852 |
// permissions |
| 1853 |
#define XCP_ADMP_WK_IMPORT 1 // allow WK import |
| 1854 |
#define XCP_ADMP_WK_EXPORT 2 // allow WK export |
| 1855 |
#define XCP_ADMP_WK_1PART 4 // allow WK transport in one part |
| 1856 |
#define XCP_ADMP_WK_RANDOM 8 // allow internally generated WK |
| 1857 |
#define XCP_ADMP_1SIGN 0x10 // allow single-signed administration |
| 1858 |
// (threshold set to 1) |
| 1859 |
#define XCP_ADMP_CP_1SIGN 0x20 // allow single-signed CP modification |
| 1860 |
#define XCP_ADMP_ZERO_1SIGN 0x40 // allow single-signed zeroize |
| 1861 |
// |
| 1862 |
#define XCP_ADMP_NO_DOMAIN_IMPRINT \ |
| 1863 |
0x0080 // prohibit logging in to domains in |
| 1864 |
// imprint mode (card only) |
| 1865 |
#define XCP_ADMP_STATE_IMPORT 0x0100 // allow state (part) import |
| 1866 |
// (ignored by domains) |
| 1867 |
#define XCP_ADMP_STATE_EXPORT 0x0200 // allow state (part) export |
| 1868 |
// (ignored by domains) |
| 1869 |
#define XCP_ADMP_STATE_1PART 0x0400 // allow state transport with 1-part |
| 1870 |
// key (ignored by domains) |
| 1871 |
#define XCP_ADMP_DO_NOT_DISTURB 0x2000 // do not count module-administrator |
| 1872 |
// signatures for domain commands, |
| 1873 |
// other than zeroize commands |
| 1874 |
// (managed but ignored for module- |
| 1875 |
// level attributes) |
| 1876 |
// |
| 1877 |
// if adding other change-control bits, also update: |
| 1878 |
// |
| 1879 |
#define XCP_ADMP_CHG_WK_IMPORT 0x10000 // allow changing WK import flag |
| 1880 |
#define XCP_ADMP_CHG_WK_EXPORT 0x20000 // allow changing WK export flag |
| 1881 |
#define XCP_ADMP_CHG_WK_1PART 0x40000 // allow changing WK 1-part |
| 1882 |
// transport flag |
| 1883 |
#define XCP_ADMP_CHG_WK_RANDOM 0x80000 // allow changing internal WK flag |
| 1884 |
#define XCP_ADMP_CHG_SIGN_THR 0x100000 // allow changing sign threshold |
| 1885 |
#define XCP_ADMP_CHG_REVOKE_THR 0x200000 // allow changing revoke threshold |
| 1886 |
#define XCP_ADMP_CHG_1SIGN 0x400000 // allow changing single-sign |
| 1887 |
// threshold setting |
| 1888 |
#define XCP_ADMP_CHG_CP_1SIGN 0x800000 // allow changing 1-sign (CPs) |
| 1889 |
#define XCP_ADMP_CHG_ZERO_1SIGN \ |
| 1890 |
0x01000000 // allow changing 1-sign (zeroize) |
| 1891 |
#define XCP_ADMP_CHG_ST_IMPORT \ |
| 1892 |
0x02000000 // allow changing state import bit |
| 1893 |
// (ignored by domains) |
| 1894 |
#define XCP_ADMP_CHG_ST_EXPORT \ |
| 1895 |
0x04000000 // allow changing state export bit |
| 1896 |
// (ignored by domains) |
| 1897 |
#define XCP_ADMP_CHG_ST_1PART 0x08000000 // allow changing 1-part encrypt bit |
| 1898 |
// (ignored by domains) |
| 1899 |
#define XCP_ADMP_CHG_DO_NOT_DISTURB \ |
| 1900 |
0x80000000 // allow changing the corresponding |
| 1901 |
// Do Not Disturb bit |
| 1902 |
|
| 1903 |
// |
| 1904 |
// permissions (extension 01) |
| 1905 |
// |
| 1906 |
#define XCP_ADMP_NQS_OA_SIGNATURES 1 // enable non-quantum-safe OA signat. |
| 1907 |
#define XCP_ADMP_QS_OA_SIGNATURES 2 // enable quantum-safe OA signatures |
| 1908 |
#define XCP_ADMP_NQS_ADM_SIGNATURES 4 // enable non-quantum-safe adm signat. |
| 1909 |
#define XCP_ADMP_QS_ADM_SIGNATURES 8 // enable quantum-safe adm signatures |
| 1910 |
|
| 1911 |
#define XCP_ADMP_CHG_NQS_OA_SIGNATURES \ |
| 1912 |
0x10000 // allow changing the corresponding |
| 1913 |
// non-quantum-safe OA signature bit |
| 1914 |
#define XCP_ADMP_CHG_QS_OA_SIGNATURES \ |
| 1915 |
0x20000 // allow changing the corresponding |
| 1916 |
// quantum-safe OA signature bit |
| 1917 |
#define XCP_ADMP_CHG_NQS_ADM_SIGNATURES \ |
| 1918 |
0x40000 // allow changing the corresponding |
| 1919 |
// non-quantum-safe adm signature bit |
| 1920 |
#define XCP_ADMP_CHG_QS_ADM_SIGNATURES \ |
| 1921 |
0x80000 // allow changing the corresponding |
| 1922 |
// quantum-safe adm signature bit |
| 1923 |
|
| 1924 |
// |
| 1925 |
// generic administrative keytypes |
| 1926 |
// |
| 1927 |
#define XCP_ADMK_KTYPE_RSA 1 // enable admin key type RSA |
| 1928 |
#define XCP_ADMK_KTYPE_ECC 2 // enable admin key type EC |
| 1929 |
#define XCP_ADMK_KTYPE_DIL 4 // enable admin key type Dilithium |
| 1930 |
#define XCP_ADMK_CHG_KTYPE_RSA 0x10000 // allow changing the corresponding |
| 1931 |
// adm key type RSA |
| 1932 |
#define XCP_ADMK_CHG_KTYPE_ECC \ |
| 1933 |
0x20000 // allow changing the corresponding |
| 1934 |
// adm key type EC |
| 1935 |
#define XCP_ADMK_CHG_KTYPE_DIL \ |
| 1936 |
0x40000 // allow changing the corresponding |
| 1937 |
// adm key type Dilithium |
| 1938 |
|
| 1939 |
#define XCP_ADMK__ALL \ |
| 1940 |
(XCP_ADMK_KTYPE_RSA | \ |
| 1941 |
XCP_ADMK_KTYPE_ECC | \ |
| 1942 |
XCP_ADMK_KTYPE_DIL) |
| 1943 |
|
| 1944 |
#define XCP_ADMK__CHGBITS \ |
| 1945 |
(XCP_ADMK_CHG_KTYPE_RSA | \ |
| 1946 |
XCP_ADMK_CHG_KTYPE_ECC | \ |
| 1947 |
XCP_ADMK_CHG_KTYPE_DIL) |
| 1948 |
|
| 1949 |
#define XCP_ADMK__DEFAULT \ |
| 1950 |
(XCP_ADMK__CHGBITS | \ |
| 1951 |
XCP_ADMK__ALL) |
| 1952 |
|
| 1953 |
#define XCP__ADMK_SUP XCP_ADMK__DEFAULT |
| 1954 |
|
| 1955 |
// |
| 1956 |
// supported administrative curve types |
| 1957 |
// (depends on XCP_ADMK_KTYPE_ECC) |
| 1958 |
// |
| 1959 |
#define XCP_ADME_KTYPE_ECC_NIST 1 // enable admin key type EC NIST |
| 1960 |
#define XCP_ADME_KTYPE_ECC_BP 2 // enable admin key type EC Brainpool |
| 1961 |
#define XCP_ADME_KTYPE_ECC_ED 4 // enable admin key type EC Edwards |
| 1962 |
#define XCP_ADME_KTYPE_ECC_MG 8 // enable admin key type EC Montgomery |
| 1963 |
#define XCP_ADME_CHG_KTYPE_ECC_NIST \ |
| 1964 |
0x10000 // allow changing the corresponding |
| 1965 |
// adm key type EC NIST |
| 1966 |
#define XCP_ADME_CHG_KTYPE_ECC_BP \ |
| 1967 |
0x20000 // allow changing the corresponding |
| 1968 |
// adm key type EC Brainpool |
| 1969 |
#define XCP_ADME_CHG_KTYPE_ECC_ED \ |
| 1970 |
0x40000 // allow changing the corresponding |
| 1971 |
// adm key type EC Edwards |
| 1972 |
#define XCP_ADME_CHG_KTYPE_ECC_MG \ |
| 1973 |
0x80000 // allow changing the corresponding |
| 1974 |
// adm key type EC Montgomery |
| 1975 |
|
| 1976 |
#define XCP_ADME__ALL \ |
| 1977 |
(XCP_ADME_KTYPE_ECC_NIST | \ |
| 1978 |
XCP_ADME_KTYPE_ECC_BP | \ |
| 1979 |
XCP_ADME_KTYPE_ECC_ED) |
| 1980 |
|
| 1981 |
#define XCP_ADME__CHGBITS \ |
| 1982 |
(XCP_ADME_CHG_KTYPE_ECC_NIST | \ |
| 1983 |
XCP_ADME_CHG_KTYPE_ECC_BP | \ |
| 1984 |
XCP_ADME_CHG_KTYPE_ECC_ED) |
| 1985 |
|
| 1986 |
#define XCP_ADME__DEFAULT \ |
| 1987 |
(XCP_ADME__CHGBITS | \ |
| 1988 |
XCP_ADME__ALL) |
| 1989 |
|
| 1990 |
#define XCP__ADME_SUP XCP_ADME__DEFAULT |
| 1991 |
|
| 1992 |
// |
| 1993 |
// supported administrative DIL types |
| 1994 |
// (depends on XCP_ADMK_KTYPE_DIL) |
| 1995 |
// |
| 1996 |
#define XCP_ADMQ_KTYPE_DIL_R2 1 // enable admin key type Dilithium R2 |
| 1997 |
#define XCP_ADMQ_KTYPE_DIL_R3 2 // enable admin key type Dilithium R3 |
| 1998 |
#define XCP_ADMQ_CHG_KTYPE_DIL_R2 \ |
| 1999 |
0x10000 // allow changing the corresponding |
| 2000 |
// adm key type Dilithium R2 |
| 2001 |
#define XCP_ADMQ_CHG_KTYPE_DIL_R3 \ |
| 2002 |
0x20000 // allow changing the corresponding |
| 2003 |
// adm key type Dilithium R3 |
| 2004 |
|
| 2005 |
#define XCP_ADMQ__ALL \ |
| 2006 |
(XCP_ADMQ_KTYPE_DIL_R2 | \ |
| 2007 |
XCP_ADMQ_KTYPE_DIL_R3) |
| 2008 |
|
| 2009 |
#define XCP_ADMQ__CHGBITS \ |
| 2010 |
(XCP_ADMQ_CHG_KTYPE_DIL_R2 | \ |
| 2011 |
XCP_ADMQ_CHG_KTYPE_DIL_R3) |
| 2012 |
|
| 2013 |
#define XCP_ADMQ__DEFAULT \ |
| 2014 |
(XCP_ADMQ__CHGBITS | \ |
| 2015 |
XCP_ADMQ__ALL) |
| 2016 |
|
| 2017 |
#define XCP__ADMQ_SUP XCP_ADMQ__DEFAULT |
| 2018 |
|
| 2019 |
// |
| 2020 |
// Administrative compliance |
| 2021 |
// |
| 2022 |
#define XCP_ADMC_ADM_FIPS2021 1 // NIST SP800-131A REV.2, 2021.01.01 |
| 2023 |
|
| 2024 |
|
| 2025 |
// |
| 2026 |
// if adding other change-control bits, also update: |
| 2027 |
// prevented_perm_changes() |
| 2028 |
// valid_attr_reactivate() |
| 2029 |
// ...as well as constants below |
| 2030 |
// |
| 2031 |
#define XCP_ADMP__CHGBITS \ |
| 2032 |
(XCP_ADMP_CHG_WK_IMPORT | \ |
| 2033 |
XCP_ADMP_CHG_WK_EXPORT | \ |
| 2034 |
XCP_ADMP_CHG_WK_1PART | \ |
| 2035 |
XCP_ADMP_CHG_WK_RANDOM | \ |
| 2036 |
XCP_ADMP_CHG_SIGN_THR | \ |
| 2037 |
XCP_ADMP_CHG_REVOKE_THR | \ |
| 2038 |
XCP_ADMP_CHG_1SIGN | \ |
| 2039 |
XCP_ADMP_CHG_CP_1SIGN | \ |
| 2040 |
XCP_ADMP_CHG_ZERO_1SIGN | \ |
| 2041 |
XCP_ADMP_CHG_ST_IMPORT | \ |
| 2042 |
XCP_ADMP_CHG_ST_EXPORT | \ |
| 2043 |
XCP_ADMP_CHG_ST_1PART | \ |
| 2044 |
XCP_ADMP_CHG_DO_NOT_DISTURB) |
| 2045 |
// |
| 2046 |
#define XCP_ADMP__PERMS \ |
| 2047 |
(XCP_ADMP_WK_IMPORT | \ |
| 2048 |
XCP_ADMP_WK_EXPORT | \ |
| 2049 |
XCP_ADMP_WK_1PART | \ |
| 2050 |
XCP_ADMP_WK_RANDOM | \ |
| 2051 |
XCP_ADMP_1SIGN | \ |
| 2052 |
XCP_ADMP_CP_1SIGN | \ |
| 2053 |
XCP_ADMP_ZERO_1SIGN | \ |
| 2054 |
XCP_ADMP_NO_DOMAIN_IMPRINT | \ |
| 2055 |
XCP_ADMP_STATE_IMPORT | \ |
| 2056 |
XCP_ADMP_STATE_EXPORT | \ |
| 2057 |
XCP_ADMP_STATE_1PART | \ |
| 2058 |
XCP_ADMP_DO_NOT_DISTURB) |
| 2059 |
// |
| 2060 |
// CHGBITS / PERMS (extension 01) |
| 2061 |
#define XCP_ADMP__CHGBITS_EXT01 \ |
| 2062 |
(XCP_ADMP_CHG_NQS_OA_SIGNATURES | \ |
| 2063 |
XCP_ADMP_CHG_QS_OA_SIGNATURES | \ |
| 2064 |
XCP_ADMP_CHG_NQS_ADM_SIGNATURES | \ |
| 2065 |
XCP_ADMP_CHG_QS_ADM_SIGNATURES) |
| 2066 |
// |
| 2067 |
#define XCP_ADMP__PERMS_EXT01 \ |
| 2068 |
(XCP_ADMP_NQS_OA_SIGNATURES | \ |
| 2069 |
XCP_ADMP_QS_OA_SIGNATURES | \ |
| 2070 |
XCP_ADMP_NQS_ADM_SIGNATURES | \ |
| 2071 |
XCP_ADMP_QS_ADM_SIGNATURES) |
| 2072 |
// |
| 2073 |
#define XCP__ADMP_SUP_EXT01 (XCP_ADMP__PERMS_EXT01 | \ |
| 2074 |
XCP_ADMP__CHGBITS_EXT01) |
| 2075 |
// |
| 2076 |
// |
| 2077 |
#define XCP_ADMP__DEFAULT \ |
| 2078 |
(XCP_ADMP_WK_IMPORT | \ |
| 2079 |
XCP_ADMP_1SIGN | \ |
| 2080 |
XCP_ADMP__CHGBITS) |
| 2081 |
// |
| 2082 |
#define XCP_ADMP__DEFAULT_EXT01 \ |
| 2083 |
(XCP_ADMP__CHGBITS_EXT01 | \ |
| 2084 |
XCP_ADMP_NQS_OA_SIGNATURES | \ |
| 2085 |
XCP_ADMP_QS_OA_SIGNATURES | \ |
| 2086 |
XCP_ADMP_NQS_ADM_SIGNATURES | \ |
| 2087 |
XCP_ADMP_QS_ADM_SIGNATURES) |
| 2088 |
// |
| 2089 |
#define XCPM_ADMP__MODULE_DEFAULTS_MASK \ |
| 2090 |
(XCP_ADMP_DO_NOT_DISTURB | \ |
| 2091 |
XCP_ADMP_CHG_DO_NOT_DISTURB) |
| 2092 |
// |
| 2093 |
#define XCPM_ADMP__MODULE_DEFAULTS_MASK_EXT01 \ |
| 2094 |
(XCP_ADMP_NQS_OA_SIGNATURES | \ |
| 2095 |
XCP_ADMP_CHG_NQS_OA_SIGNATURES | \ |
| 2096 |
XCP_ADMP_QS_OA_SIGNATURES | \ |
| 2097 |
XCP_ADMP_CHG_QS_OA_SIGNATURES | \ |
| 2098 |
XCP_ADMP_NQS_ADM_SIGNATURES | \ |
| 2099 |
XCP_ADMP_CHG_NQS_ADM_SIGNATURES | \ |
| 2100 |
XCP_ADMP_QS_ADM_SIGNATURES | \ |
| 2101 |
XCP_ADMP_CHG_QS_ADM_SIGNATURES) |
| 2102 |
// |
| 2103 |
#define XCP_ADMP__CARD_MASK \ |
| 2104 |
~(XCP_ADMP_WK_IMPORT | \ |
| 2105 |
XCP_ADMP_WK_EXPORT | \ |
| 2106 |
XCP_ADMP_WK_1PART | \ |
| 2107 |
XCP_ADMP_WK_RANDOM | \ |
| 2108 |
XCP_ADMP_CP_1SIGN | \ |
| 2109 |
XCP_ADMP_CHG_WK_IMPORT | \ |
| 2110 |
XCP_ADMP_CHG_WK_EXPORT | \ |
| 2111 |
XCP_ADMP_CHG_WK_1PART | \ |
| 2112 |
XCP_ADMP_CHG_WK_RANDOM | \ |
| 2113 |
XCP_ADMP_CHG_CP_1SIGN) |
| 2114 |
// |
| 2115 |
#define XCP_ADMP__CARD_MASK_EXT01 \ |
| 2116 |
~(0U) |
| 2117 |
// |
| 2118 |
#define XCP_ADMP__DOM_MASK \ |
| 2119 |
~(XCP_ADMP_NO_DOMAIN_IMPRINT | \ |
| 2120 |
XCP_ADMP_STATE_IMPORT | \ |
| 2121 |
XCP_ADMP_STATE_EXPORT | \ |
| 2122 |
XCP_ADMP_STATE_1PART | \ |
| 2123 |
XCP_ADMP_CHG_ST_IMPORT | \ |
| 2124 |
XCP_ADMP_CHG_ST_EXPORT | \ |
| 2125 |
XCP_ADMP_CHG_ST_1PART) |
| 2126 |
// |
| 2127 |
#define XCP_ADMP__DOM_MASK_EXT01 \ |
| 2128 |
~(0U) |
| 2129 |
// |
| 2130 |
|
| 2131 |
#define XCP__ADMP_SUP ((XCP_ADMP__PERMS | XCP_ADMP__CHGBITS) &\ |
| 2132 |
~XCP_ADMP_NOT_SUP) |
| 2133 |
|
| 2134 |
// card modes |
| 2135 |
#define XCP_ADMM_AUTHENTICATED 1U // no longer in imprint mode |
| 2136 |
#define XCP_ADMM_EXTWNG 2U // zeroize if starting w/ ext. |
| 2137 |
// warning included in default setup |
| 2138 |
// |
| 2139 |
// minimum administrator strength |
| 2140 |
#define XCP_ADMM_STR_112BIT 4U // require 112+ bits' admin strength |
| 2141 |
#define XCP_ADMM_STR_128BIT 8U // require 128+ bits' admin strength |
| 2142 |
#define XCP_ADMM_STR_160BIT 0x10U // require 160+ bits' admin strength |
| 2143 |
#define XCP_ADMM_STR_192BIT 0x20U // require 192+ bits' admin strength |
| 2144 |
#define XCP_ADMM_STR_256BIT 0x40U // require 256 bits' admin strength |
| 2145 |
#define XCP_ADMM_WKCLEAN_EXTWNG 0x80U // zeroize WKs if starting with |
| 2146 |
// ext. warning set. Leaves |
| 2147 |
// other parameters unaffected |
| 2148 |
#define XCP_ADMM_BATT_LOW 0x0100U // module reports low battery |
| 2149 |
// (read only) |
| 2150 |
#define XCP_ADMM_API_ACTIVE 0x0200U // remove to disable XCP within card |
| 2151 |
|
| 2152 |
// |
| 2153 |
// change-control bits |
| 2154 |
#define XCP_ADMM_CHG_KEYSTR 0x040000 // change key strength bits (112-256) |
| 2155 |
|
| 2156 |
|
| 2157 |
// |
| 2158 |
#define XCP_ADMM__DEFAULT \ |
| 2159 |
(XCP_ADMM_EXTWNG | \ |
| 2160 |
XCP_ADMM_API_ACTIVE | \ |
| 2161 |
XCP_ADMM_CHG_KEYSTR) |
| 2162 |
// |
| 2163 |
// all defined attributes |
| 2164 |
#define XCP_ADMM__MASK \ |
| 2165 |
(XCP_ADMM_AUTHENTICATED | \ |
| 2166 |
XCP_ADMM_EXTWNG | \ |
| 2167 |
XCP_ADMM_STR_112BIT | \ |
| 2168 |
XCP_ADMM_STR_128BIT | \ |
| 2169 |
XCP_ADMM_STR_160BIT | \ |
| 2170 |
XCP_ADMM_STR_192BIT | \ |
| 2171 |
XCP_ADMM_STR_256BIT | \ |
| 2172 |
XCP_ADMM_WKCLEAN_EXTWNG | \ |
| 2173 |
XCP_ADMM_BATT_LOW | \ |
| 2174 |
XCP_ADMM_API_ACTIVE | \ |
| 2175 |
XCP_ADMM_CHG_KEYSTR) |
| 2176 |
// |
| 2177 |
// infrastructure modes read only on domain level |
| 2178 |
#define XCP_ADMM__CARD_ONLY_ATTR \ |
| 2179 |
(XCP_ADMM_EXTWNG | \ |
| 2180 |
XCP_ADMM_WKCLEAN_EXTWNG | \ |
| 2181 |
XCP_ADMM_API_ACTIVE) |
| 2182 |
// |
| 2183 |
#define XCP_ADMM__READ_ONLY_ATTR \ |
| 2184 |
(XCP_ADMM_AUTHENTICATED | \ |
| 2185 |
XCP_ADMM_BATT_LOW) |
| 2186 |
|
| 2187 |
// strength bits restrict adm key strength |
| 2188 |
#define XCP__ADMM_ADMSTR \ |
| 2189 |
(XCP_ADMM_STR_112BIT | \ |
| 2190 |
XCP_ADMM_STR_128BIT | \ |
| 2191 |
XCP_ADMM_STR_160BIT | \ |
| 2192 |
XCP_ADMM_STR_192BIT | \ |
| 2193 |
XCP_ADMM_STR_256BIT) |
| 2194 |
|
| 2195 |
#define XCP__ADMM_SUP XCP_ADMM__MASK |
| 2196 |
|
| 2197 |
|
| 2198 |
// specific standards' compliance suites |
| 2199 |
#define XCP_ADMS_FIPS2009 1 // NIST, 80+ bits, -2011.01.01. |
| 2200 |
#define XCP_ADMS_BSI2009 2 // BSI , 80+ bits, -2011.01.01. |
| 2201 |
#define XCP_ADMS_FIPS2011 4 // NIST, 112+ bits, 2011.01.01.- |
| 2202 |
#define XCP_ADMS_BSI2011 8 // BSI, 112+ bits, 2011.01.01.- |
| 2203 |
// |
| 2204 |
// two bits reserved but not yet reported |
| 2205 |
#define XCP_ADMS_SIGG_IMPORT 0x10 // .de SigG, key import |
| 2206 |
#define XCP_ADMS_SIGG 0x20 // .de SigG, no key import |
| 2207 |
// |
| 2208 |
#define XCP_ADMS_BSICC2017 0x40 // BSI, EP11 Common Criteria EAL4 2017 |
| 2209 |
// |
| 2210 |
#define XCP_ADMS_FIPS2021 0x80 // NIST SP800-131A REV.2, 2021.01.01 |
| 2211 |
#define XCP_ADMS_FIPS2024 0x100 // NIST SP800-131A REV.2, 2024.01.01 |
| 2212 |
|
| 2213 |
#define XCP_ADMS__ALL \ |
| 2214 |
(XCP_ADMS_FIPS2009 | \ |
| 2215 |
XCP_ADMS_BSI2009 | \ |
| 2216 |
XCP_ADMS_FIPS2011 | \ |
| 2217 |
XCP_ADMS_BSI2011 | \ |
| 2218 |
XCP_ADMS_BSICC2017 | \ |
| 2219 |
XCP_ADMS_FIPS2021 | \ |
| 2220 |
XCP_ADMS_FIPS2024) |
| 2221 |
|
| 2222 |
#define XCP_ADMC__ALL \ |
| 2223 |
(XCP_ADMC_ADM_FIPS2021) |
| 2224 |
|
| 2225 |
// The following 'legacy' defines are used as default 'supported bit masks' |
| 2226 |
// for older devices that do not have native bit masks for that purpose. |
| 2227 |
// Note: If supported bits are not present, the import of these bits are |
| 2228 |
// skipped and the default values will be kept. |
| 2229 |
#define XCP__ADMP_SUP_LEGACY \ |
| 2230 |
(XCP_ADMP_WK_IMPORT | \ |
| 2231 |
XCP_ADMP_WK_EXPORT | \ |
| 2232 |
XCP_ADMP_WK_1PART | \ |
| 2233 |
XCP_ADMP_WK_RANDOM | \ |
| 2234 |
XCP_ADMP_1SIGN | \ |
| 2235 |
XCP_ADMP_CP_1SIGN | \ |
| 2236 |
XCP_ADMP_ZERO_1SIGN | \ |
| 2237 |
XCP_ADMP_NO_DOMAIN_IMPRINT | \ |
| 2238 |
XCP_ADMP_STATE_IMPORT | \ |
| 2239 |
XCP_ADMP_STATE_EXPORT | \ |
| 2240 |
XCP_ADMP_STATE_1PART | \ |
| 2241 |
XCP_ADMP_CHG_WK_IMPORT | \ |
| 2242 |
XCP_ADMP_CHG_WK_EXPORT | \ |
| 2243 |
XCP_ADMP_CHG_WK_1PART | \ |
| 2244 |
XCP_ADMP_CHG_WK_RANDOM | \ |
| 2245 |
XCP_ADMP_CHG_SIGN_THR | \ |
| 2246 |
XCP_ADMP_CHG_REVOKE_THR | \ |
| 2247 |
XCP_ADMP_CHG_1SIGN | \ |
| 2248 |
XCP_ADMP_CHG_CP_1SIGN | \ |
| 2249 |
XCP_ADMP_CHG_ZERO_1SIGN | \ |
| 2250 |
XCP_ADMP_CHG_ST_IMPORT | \ |
| 2251 |
XCP_ADMP_CHG_ST_EXPORT | \ |
| 2252 |
XCP_ADMP_CHG_ST_1PART) |
| 2253 |
|
| 2254 |
#define XCP__ADMM_SUP_LEGACY \ |
| 2255 |
(XCP_ADMM_AUTHENTICATED | \ |
| 2256 |
XCP_ADMM_EXTWNG | \ |
| 2257 |
XCP__ADMM_ADMSTR | \ |
| 2258 |
XCP_ADMM_WKCLEAN_EXTWNG | \ |
| 2259 |
XCP_ADMM_BATT_LOW | \ |
| 2260 |
XCP_ADMM_API_ACTIVE) |
| 2261 |
|
| 2262 |
#define XCP_ADMS__ALL_LEGACY \ |
| 2263 |
(XCP_ADMS_FIPS2009 | \ |
| 2264 |
XCP_ADMS_BSI2009 | \ |
| 2265 |
XCP_ADMS_FIPS2011 | \ |
| 2266 |
XCP_ADMS_BSI2011 | \ |
| 2267 |
XCP_ADMS_BSICC2017) |
| 2268 |
|
| 2269 |
#define XCP__ADMP_SUP_EXT01_LEGACY \ |
| 2270 |
(XCP_ADMP_NQS_OA_SIGNATURES | \ |
| 2271 |
XCP_ADMP_QS_OA_SIGNATURES | \ |
| 2272 |
XCP_ADMP_CHG_NQS_OA_SIGNATURES | \ |
| 2273 |
XCP_ADMP_CHG_QS_OA_SIGNATURES | \ |
| 2274 |
XCP_ADMP_NQS_ADM_SIGNATURES | \ |
| 2275 |
XCP_ADMP_QS_ADM_SIGNATURES | \ |
| 2276 |
XCP_ADMP_CHG_NQS_ADM_SIGNATURES | \ |
| 2277 |
XCP_ADMP_CHG_QS_ADM_SIGNATURES) |
| 2278 |
|
| 2279 |
// has compliance any BSI mode |
| 2280 |
#define XCP_ADMS_IS_BSI(mode) (!!((mode) & (XCP_ADMS_BSI2009 | \ |
| 2281 |
XCP_ADMS_BSI2011 | \ |
| 2282 |
XCP_ADMS_BSICC2017 )) ) |
| 2283 |
// mask of supported import keys |
| 2284 |
// 3k and 4k RSA are not supported |
| 2285 |
#define XCP_ADM_IMPEXP_KEYS__MASK \ |
| 2286 |
((1 << XCP_IMPRKEY_RSA_2048) | \ |
| 2287 |
(1 << XCP_IMPRKEY_EC_P256) | \ |
| 2288 |
(1 << XCP_IMPRKEY_EC_P521) | \ |
| 2289 |
(1 << XCP_IMPRKEY_EC_BP256r) | \ |
| 2290 |
(1 << XCP_IMPRKEY_EC_BP320r) | \ |
| 2291 |
(1 << XCP_IMPRKEY_EC_BP512r) | \ |
| 2292 |
(1 << XCP_IMPRKEY_EC_P521_TKE)) |
| 2293 |
|
| 2294 |
|
| 2295 |
/*--- audit chains -------------------------------------------------------*/ |
| 2296 |
#define XCP_LOG_KEYREC_BYTES 24 |
| 2297 |
#define XCP_LOG_SEQNR_BYTES 6 |
| 2298 |
#define XCP_LOG_INSTANCEID_BYTES 2 |
| 2299 |
#define XCP_LOG_TIMET_BYTES (4+2) /* sec[36](time_t) || msec[12] */ |
| 2300 |
#define XCP_LOG_SEQNR_OFFSET ((size_t) 4) /* in fixed event header */ |
| 2301 |
#define XCP_LOG_SEQPRF_BASE_BYTES \ |
| 2302 |
((size_t) XCP_LOG_SEQNR_BYTES +XCP_LOG_TIMET_BYTES) |
| 2303 |
#define XCP_LOG_COMPLIANCE_BYTES 8 |
| 2304 |
#define XCP_LOG_REASON_BYTES 4 |
| 2305 |
#define XCP_LOG_SALTUNIT_BYTES 4 |
| 2306 |
#define XCP_LOG_SALT_MAX_UNITS 3 |
| 2307 |
#define XCP_LOG_SALT_MAX_BYTES \ |
| 2308 |
(XCP_LOG_SALT_MAX_UNITS * XCP_LOG_SALTUNIT_BYTES) |
| 2309 |
#define XCP_LOG_PRFSALT_BYTES ((size_t) 64/8) /* Siphash-2-4 */ |
| 2310 |
|
| 2311 |
/* event context: fields present in all audit records */ |
| 2312 |
#define XCP_LOG_CONTEXT_BYTES \ |
| 2313 |
(2* XCP_SERIALNR_CHARS+ \ |
| 2314 |
2+2+ /* audit instance, event type */ \ |
| 2315 |
4+4+ /* event type, firmware ID */ \ |
| 2316 |
4+4 /* fn ID, domain, var-len size */ ) |
| 2317 |
|
| 2318 |
/* optional fields, total (see flags) */ |
| 2319 |
#define XCP_LOG_OPTFIELD_MAX_BYTES \ |
| 2320 |
(2* XCP_WK_BYTES + \ |
| 2321 |
XCP_LOG_COMPLIANCE_BYTES + \ |
| 2322 |
3* XCP_LOG_KEYREC_BYTES + \ |
| 2323 |
XCP_LOG_TIMET_BYTES + \ |
| 2324 |
XCP_LOG_COMPLIANCE_BYTES + \ |
| 2325 |
XCP_LOG_REASON_BYTES + \ |
| 2326 |
XCP_LOG_SALT_MAX_BYTES) |
| 2327 |
|
| 2328 |
#define XCP_LOG_HEADER_BYTES \ |
| 2329 |
(1+1+2 + /* type, version, bytecount */ \ |
| 2330 |
XCP_LOG_SEQNR_BYTES + \ |
| 2331 |
XCP_LOG_TIMET_BYTES) |
| 2332 |
|
| 2333 |
/* worst-case full wire-formatted entry, incl. trailing hash */ |
| 2334 |
#define XCP_LOG_ENTRY_MAX_BYTES \ |
| 2335 |
(XCP_LOG_HEADER_BYTES + \ |
| 2336 |
XCP_LOG_STATE_BYTES + /* initial state/hash */ \ |
| 2337 |
XCP_LOG_CONTEXT_BYTES + \ |
| 2338 |
XCP_LOG_OPTFIELD_MAX_BYTES + \ |
| 2339 |
XCP_LOG_STATE_BYTES) |
| 2340 |
|
| 2341 |
|
| 2342 |
/*--- state serialization ------------------------------------------------*/ |
| 2343 |
typedef enum { |
| 2344 |
XCP_STSTYPE_SECTIONCOUNT = 1, // section count +file hash |
| 2345 |
XCP_STSTYPE_DOMAINIDX_MAX = 2, // largest index +total nr of doms |
| 2346 |
XCP_STSTYPE_DOMAINS_MASK = 3, // bitmask of included domains |
| 2347 |
XCP_STSTYPE_SERIALNR = 4, |
| 2348 |
XCP_STSTYPE_CREATE_TIME = 5, // file date/time (UTC) |
| 2349 |
XCP_STSTYPE_FCV = 6, // public parts of originating FCV |
| 2350 |
XCP_STSTYPE_CARD_QUERY = 7, // V0 card state struct (xcp_info) |
| 2351 |
XCP_STSTYPE_CARD_ADM_SKIS = 8, // card admin SKIs, packed |
| 2352 |
XCP_STSTYPE_CARD_ADM_CERTS = 9, // card admin certificates, packed |
| 2353 |
XCP_STSTYPE_DOM_ADM_SKIS = 10, // domain admin SKIs, packed |
| 2354 |
XCP_STSTYPE_DOM_ADM_CERTS = 11, // domain admin certs, packed |
| 2355 |
XCP_STSTYPE_DOM_QUERY = 12, // domain state struct (xcp_info) |
| 2356 |
XCP_STSTYPE_KPH_SKIS = 13, // count and SKIs of targeted KPHs |
| 2357 |
XCP_STSTYPE_CARD_ATTRS = 14, // card attributes |
| 2358 |
XCP_STSTYPE_DOM_ATTRS = 15, // domain attributes |
| 2359 |
XCP_STSTYPE_CARD_TRANSCTR = 16, // card transaction counter |
| 2360 |
XCP_STSTYPE_DOM_TRANSCTR = 17, // domain transaction counter |
| 2361 |
XCP_STSTYPE_WK_ENCR_ALG = 18, |
| 2362 |
XCP_STSTYPE_WK_ENCR_DATA = 19, |
| 2363 |
XCP_STSTYPE_SIG_CERT_COUNT = 20, |
| 2364 |
XCP_STSTYPE_SIG_CERTS = 21, |
| 2365 |
XCP_STSTYPE_FILE_SIG = 22, |
| 2366 |
XCP_STSTYPE_DOM_CPS = 23, // full set of control points |
| 2367 |
XCP_STSTYPE_STATE_SALT = 24, |
| 2368 |
XCP_STSTYPE_KEYPART = 25, // encrypted keypart (RecipientInfo) |
| 2369 |
XCP_STSTYPE_KEYPART_SIG = 26, // signature on encrypted keypart |
| 2370 |
XCP_STSTYPE_KEYPART_COUNT = 27, // total number of keyparts |
| 2371 |
XCP_STSTYPE_KEYPART_LIMIT = 28, // number of keyparts needed to |
| 2372 |
// restore |
| 2373 |
XCP_STSTYPE_KEYPART_CERT = 29, // certificate of keypart holder |
| 2374 |
XCP_STSTYPE_CERT_AUTH = 30, // certificate authority issuing |
| 2375 |
// some of the certificates. This |
| 2376 |
// field contains host-supplied data |
| 2377 |
// and it is ignored by EP11 itself. |
| 2378 |
XCP_STSTYPE_STATE_SCOPE = 31, // restriction on contents of full |
| 2379 |
// state structure |
| 2380 |
XCP_STSTYPE_MULTIIMPORT_MASK = 32, // import only: designate import |
| 2381 |
// request to be replicated into |
| 2382 |
// multiple recipient domains |
| 2383 |
XCP_STSTYPE_CPS_MASK = 33, // bitmask of all CPs supported |
| 2384 |
// by the exporting module |
| 2385 |
XCP_STSTYPE_CARD_QUERY_V1 = 34, // V1 card state struct (xcp_info) |
| 2386 |
XCP_STSTYPE_CARD_QUERY_V2 = 35, // V2 card state struct (xcp_info) |
| 2387 |
XCP_STSTYPE_CARD_EXTADM_SKIS = 36, // ext. card admin SKIs, packed |
| 2388 |
XCP_STSTYPE_CARD_EXTADM_CERTS = 37, // ext. card admin certs, packed |
| 2389 |
XCP_STSTYPE_DOM_EXTADM_SKIS = 38, // ext. dom admin SKIs, packed |
| 2390 |
XCP_STSTYPE_DOM_EXTADM_CERTS = 39, // ext. dom admin certs, packed |
| 2391 |
XCP_STSTYPE_CARD_ATTRS_SUPP = 40, // supported bits of card attributes |
| 2392 |
|
| 2393 |
XCP_STSTYPE_MAX = XCP_STSTYPE_CARD_ATTRS_SUPP |
| 2394 |
} XCP_StateSection_t; |
| 2395 |
|
| 2396 |
|
| 2397 |
typedef enum { |
| 2398 |
XCP_STALG_AES256_CBC = 1 |
| 2399 |
} XCP_StateEncrAlg_t; |
| 2400 |
|
| 2401 |
typedef enum { |
| 2402 |
XCP_FILEID_SAVED_STATE = 1, // serialized state |
| 2403 |
XCP_FILEID_KEYPARTS = 2, // encrypted keyparts |
| 2404 |
XCP_FILEID_TESTDATA = 3, // not supported by production code |
| 2405 |
XCP_FILEID_EXPREQUEST = 4, // export request |
| 2406 |
XCP_FILEID_MAX = XCP_FILEID_EXPREQUEST |
| 2407 |
} XCP_FileId_t; |
| 2408 |
|
| 2409 |
|
| 2410 |
typedef enum { |
| 2411 |
XCP_STDATA_NO_RESTRICTION = 0, // no state restrictions to card |
| 2412 |
// or domain data |
| 2413 |
XCP_STDATA_DOMAIN = 1, // state restricted to domain data |
| 2414 |
// only, excluding card-specific |
| 2415 |
// sections |
| 2416 |
XCP_STDATA_NONSENSITIVE = 2, // serialized state restricted to |
| 2417 |
// non-sensitive sections only |
| 2418 |
XCP_STWK_KP_NO_CERT = 4, // keypart section restricted to |
| 2419 |
// not return KPH certificates |
| 2420 |
XCP_STWK_KP_NO_OA_CHAIN = 8, // keypart section restricted to |
| 2421 |
// not return OA certificate chain |
| 2422 |
XCP_STDATA_NQS = 0x20,// allow use of non-quantum-safe |
| 2423 |
// algorithms in KP export/signature |
| 2424 |
XCP_STDATA_QS = 0x40,// allow use of quantum-safe |
| 2425 |
// algorithms in KP export/signature |
| 2426 |
XCP_STDATA_MAX = ((XCP_STDATA_QS *2) -1) |
| 2427 |
} XCP_StateType_t; |
| 2428 |
|
| 2429 |
// type || identifier prefixes |
| 2430 |
#define XCP_STSTYPE_TYPE_BYTES 2 |
| 2431 |
#define XCP_STSTYPE_TYPEID_BYTES 4 |
| 2432 |
|
| 2433 |
|
| 2434 |
/*--- EC curves ----------------------------------------------------------*/ |
| 2435 |
|
| 2436 |
// NIST/SECG object identifiers |
| 2437 |
#define XCP_EC_P192 "\x06\x08\x2a\x86\x48\xce\x3d\x03\x01\x01" |
| 2438 |
#define XCP_EC_P192_BYTES 10 |
| 2439 |
#define XCP_EC_P224 "\x06\x05\x2b\x81\x04\x00\x21" |
| 2440 |
#define XCP_EC_P224_BYTES 7 |
| 2441 |
#define XCP_EC_P256 "\x06\x08\x2a\x86\x48\xce\x3d\x03\x01\x07" |
| 2442 |
#define XCP_EC_P256_BYTES 10 |
| 2443 |
#define XCP_EC_P384 "\x06\x05\x2b\x81\x04\x00\x22" |
| 2444 |
#define XCP_EC_P384_BYTES 7 |
| 2445 |
#define XCP_EC_P521 "\x06\x05\x2b\x81\x04\x00\x23" |
| 2446 |
#define XCP_EC_P521_BYTES 7 |
| 2447 |
|
| 2448 |
// NIST/SECG, curve names as UTF-8/ASCII strings |
| 2449 |
#define XCP_EC_P192_NAME "\x50\x2d\x31\x39\x32" /* P-192 */ |
| 2450 |
#define XCP_EC_P192_NAME_BYTES 5 |
| 2451 |
#define XCP_EC_P224_NAME "\x50\x2d\x32\x32\x34" /* P-224 */ |
| 2452 |
#define XCP_EC_P224_NAME_BYTES 5 |
| 2453 |
#define XCP_EC_P256_NAME "\x50\x2d\x32\x35\x36" /* P-256 */ |
| 2454 |
#define XCP_EC_P256_NAME_BYTES 5 |
| 2455 |
#define XCP_EC_P384_NAME "\x50\x2d\x33\x38\x34" /* P-384 */ |
| 2456 |
#define XCP_EC_P384_NAME_BYTES 5 |
| 2457 |
#define XCP_EC_P521_NAME "\x50\x2d\x35\x32\x31" /* P-521 */ |
| 2458 |
#define XCP_EC_P521_NAME_BYTES 5 |
| 2459 |
|
| 2460 |
// Brainpool object identifiers |
| 2461 |
#define XCP_EC_BP160R "\x06\x09\x2b\x24\x03\x03\x02\x08\x01\x01\x01" |
| 2462 |
#define XCP_EC_BP160R_BYTES 11 |
| 2463 |
#define XCP_EC_BP160T "\x06\x09\x2b\x24\x03\x03\x02\x08\x01\x01\x02" |
| 2464 |
#define XCP_EC_BP160T_BYTES 11 |
| 2465 |
#define XCP_EC_BP192R "\x06\x09\x2b\x24\x03\x03\x02\x08\x01\x01\x03" |
| 2466 |
#define XCP_EC_BP192R_BYTES 11 |
| 2467 |
#define XCP_EC_BP192T "\x06\x09\x2b\x24\x03\x03\x02\x08\x01\x01\x04" |
| 2468 |
#define XCP_EC_BP192T_BYTES 11 |
| 2469 |
#define XCP_EC_BP224R "\x06\x09\x2b\x24\x03\x03\x02\x08\x01\x01\x05" |
| 2470 |
#define XCP_EC_BP224R_BYTES 11 |
| 2471 |
#define XCP_EC_BP224T "\x06\x09\x2b\x24\x03\x03\x02\x08\x01\x01\x06" |
| 2472 |
#define XCP_EC_BP224T_BYTES 11 |
| 2473 |
#define XCP_EC_BP256R "\x06\x09\x2b\x24\x03\x03\x02\x08\x01\x01\x07" |
| 2474 |
#define XCP_EC_BP256R_BYTES 11 |
| 2475 |
#define XCP_EC_BP256T "\x06\x09\x2b\x24\x03\x03\x02\x08\x01\x01\x08" |
| 2476 |
#define XCP_EC_BP256T_BYTES 11 |
| 2477 |
#define XCP_EC_BP320R "\x06\x09\x2b\x24\x03\x03\x02\x08\x01\x01\x09" |
| 2478 |
#define XCP_EC_BP320R_BYTES 11 |
| 2479 |
#define XCP_EC_BP320T "\x06\x09\x2b\x24\x03\x03\x02\x08\x01\x01\x0a" |
| 2480 |
#define XCP_EC_BP320T_BYTES 11 |
| 2481 |
#define XCP_EC_BP384R "\x06\x09\x2b\x24\x03\x03\x02\x08\x01\x01\x0b" |
| 2482 |
#define XCP_EC_BP384R_BYTES 11 |
| 2483 |
#define XCP_EC_BP384T "\x06\x09\x2b\x24\x03\x03\x02\x08\x01\x01\x0c" |
| 2484 |
#define XCP_EC_BP384T_BYTES 11 |
| 2485 |
#define XCP_EC_BP512R "\x06\x09\x2b\x24\x03\x03\x02\x08\x01\x01\x0d" |
| 2486 |
#define XCP_EC_BP512R_BYTES 11 |
| 2487 |
#define XCP_EC_BP512T "\x06\x09\x2b\x24\x03\x03\x02\x08\x01\x01\x0e" |
| 2488 |
#define XCP_EC_BP512T_BYTES 11 |
| 2489 |
#define XCP_EC_BPOID_BYTES 11 |
| 2490 |
// |
| 2491 |
#define XCP_EC_BPOIDS 14 |
| 2492 |
|
| 2493 |
// Brainpool, curve names as UTF-8/ASCII strings |
| 2494 |
#define XCP_EC_BP160R_NAME "\x42\x50\x2d\x31\x36\x30\x52" /* BP-160R */ |
| 2495 |
#define XCP_EC_BP160R_NAME_BYTES 7 |
| 2496 |
#define XCP_EC_BP160T_NAME "\x42\x50\x2d\x31\x36\x30\x54" /* BP-160T */ |
| 2497 |
#define XCP_EC_BP160T_NAME_BYTES 7 |
| 2498 |
#define XCP_EC_BP192R_NAME "\x42\x50\x2d\x31\x39\x32\x52" /* BP-192R */ |
| 2499 |
#define XCP_EC_BP192R_NAME_BYTES 7 |
| 2500 |
#define XCP_EC_BP192T_NAME "\x42\x50\x2d\x31\x39\x32\x54" /* BP-192T */ |
| 2501 |
#define XCP_EC_BP192T_NAME_BYTES 7 |
| 2502 |
#define XCP_EC_BP224R_NAME "\x42\x50\x2d\x32\x32\x34\x52" /* BP-224R */ |
| 2503 |
#define XCP_EC_BP224R_NAME_BYTES 7 |
| 2504 |
#define XCP_EC_BP224T_NAME "\x42\x50\x2d\x32\x32\x34\x54" /* BP-224T */ |
| 2505 |
#define XCP_EC_BP224T_NAME_BYTES 7 |
| 2506 |
#define XCP_EC_BP256R_NAME "\x42\x50\x2d\x32\x35\x36\x52" /* BP-256R */ |
| 2507 |
#define XCP_EC_BP256R_NAME_BYTES 7 |
| 2508 |
#define XCP_EC_BP256T_NAME "\x42\x50\x2d\x32\x35\x36\x54" /* BP-256T */ |
| 2509 |
#define XCP_EC_BP256T_NAME_BYTES 7 |
| 2510 |
#define XCP_EC_BP320R_NAME "\x42\x50\x2d\x33\x32\x30\x52" /* BP-320R */ |
| 2511 |
#define XCP_EC_BP320R_NAME_BYTES 7 |
| 2512 |
#define XCP_EC_BP320T_NAME "\x42\x50\x2d\x33\x32\x30\x54" /* BP-320T */ |
| 2513 |
#define XCP_EC_BP320T_NAME_BYTES 7 |
| 2514 |
#define XCP_EC_BP384R_NAME "\x42\x50\x2d\x33\x38\x34\x52" /* BP-384R */ |
| 2515 |
#define XCP_EC_BP384R_NAME_BYTES 7 |
| 2516 |
#define XCP_EC_BP384T_NAME "\x42\x50\x2d\x33\x38\x34\x54" /* BP-384T */ |
| 2517 |
#define XCP_EC_BP384T_NAME_BYTES 7 |
| 2518 |
#define XCP_EC_BP512R_NAME "\x42\x50\x2d\x35\x31\x32\x52" /* BP-512R */ |
| 2519 |
#define XCP_EC_BP512R_NAME_BYTES 7 |
| 2520 |
#define XCP_EC_BP512T_NAME "\x42\x50\x2d\x35\x31\x32\x54" /* BP-512T */ |
| 2521 |
#define XCP_EC_BP512T_NAME_BYTES 7 |
| 2522 |
|
| 2523 |
// secp256k1 (Bitcoin default curve) |
| 2524 |
#define XCP_EC_S256K1 "\x06\x05" "\x2b\x81\x04\x00\x0a" |
| 2525 |
#define XCP_EC_S256K1_BYTES 7 |
| 2526 |
#define XCP_EC_S256K1_NAME "\x53\x45\x43\x50\x32\x35\x36\x4b\x31" |
| 2527 |
/* SECP256K1 */ |
| 2528 |
#define XCP_EC_S256K1_NAME_BYTES 9 |
| 2529 |
|
| 2530 |
// curve25519, curve448, related OIDs |
| 2531 |
// |
| 2532 |
// 1.3.101.110: curve25519, allocated by PKIX, ECDH only |
| 2533 |
#define XCP_EC_X25519 "\x06\x03\x2b\x65\x6e" |
| 2534 |
#define XCP_EC_X25519_BYTES 5 |
| 2535 |
#define XCP_EC_X25519_NAME "\x63\x75\x72\x76\x65\x32\x35\x35\x31\x39" |
| 2536 |
/* curve25519 */ |
| 2537 |
#define XCP_EC_X25519_NAME_BYTES 10 |
| 2538 |
// |
| 2539 |
// 1.3.101.111: curve[of-ed]448 'Goldilocks', allocated by PKIX, ECDH only |
| 2540 |
#define XCP_EC_X448 "\x06\x03\x2b\x65\x6f" |
| 2541 |
#define XCP_EC_X448_BYTES 5 |
| 2542 |
#define XCP_EC_X448_NAME "\x78\x34\x34\x38" /* c448, matching RFC8410 */ |
| 2543 |
#define XCP_EC_X448_NAME_BYTES 4 |
| 2544 |
// |
| 2545 |
// 1.3.101.112: EDDSA, 25519 |
| 2546 |
#define XCP_EC_DSA25519 "\x06\x03\x2b\x65\x70" |
| 2547 |
#define XCP_EC_DSA25519_BYTES 5 |
| 2548 |
#define XCP_EC_DSA25519_NAME "\x65\x64\x32\x35\x35\x31\x39" /* ed25519 */ |
| 2549 |
#define XCP_EC_DSA25519_NAME_BYTES 7 |
| 2550 |
// 1.3.101.113: EDDSA/448 (ed448) |
| 2551 |
#define XCP_EC_DSA448 "\x06\x03\x2b\x65\x71" |
| 2552 |
#define XCP_EC_DSA448_BYTES 5 |
| 2553 |
#define XCP_EC_DSA448_NAME "\x65\x64\x34\x34\x38" /* ed448 */ |
| 2554 |
#define XCP_EC_DSA448_NAME_BYTES 5 |
| 2555 |
|
| 2556 |
// 1.3.6.1.4.1.2.267.999.3.2 : 2B0601040102820B87670302 : bls12_381_et |
| 2557 |
#define XCP_EC_BLS12_381_ET "\x6\xC\x2B\x6\x1\x4\x1\x2\x82\xB\x87\x67\x3\x2" |
| 2558 |
#define XCP_EC_BLS12_381_ET_BYTES 14 |
| 2559 |
|
| 2560 |
#define XCP_EC_MAX_ID_BYTES 14 /* fits all EC names/OIDs */ |
| 2561 |
|
| 2562 |
|
| 2563 |
/*------------------------------------*/ |
| 2564 |
typedef enum { |
| 2565 |
XCP_EC_C_NIST_P192 = 1, /* NIST, FP curves */ |
| 2566 |
XCP_EC_C_NIST_P224 = 2, |
| 2567 |
XCP_EC_C_NIST_P256 = 3, |
| 2568 |
XCP_EC_C_NIST_P384 = 4, |
| 2569 |
XCP_EC_C_NIST_P521 = 5, |
| 2570 |
|
| 2571 |
XCP_EC_C_BP160R = 6, /* Brainpool, FP curves */ |
| 2572 |
XCP_EC_C_BP160T = 7, |
| 2573 |
XCP_EC_C_BP192R = 8, |
| 2574 |
XCP_EC_C_BP192T = 9, |
| 2575 |
XCP_EC_C_BP224R = 10, |
| 2576 |
XCP_EC_C_BP224T = 11, |
| 2577 |
XCP_EC_C_BP256R = 12, |
| 2578 |
XCP_EC_C_BP256T = 13, |
| 2579 |
XCP_EC_C_BP320R = 14, |
| 2580 |
XCP_EC_C_BP320T = 15, |
| 2581 |
XCP_EC_C_BP384R = 16, |
| 2582 |
XCP_EC_C_BP384T = 17, |
| 2583 |
XCP_EC_C_BP512R = 18, |
| 2584 |
XCP_EC_C_BP512T = 19, |
| 2585 |
|
| 2586 |
XCP_EC_C_25519 = 20, /* curve25519, FP (2^255-19) */ |
| 2587 |
XCP_EC_C_SECP256K1 = 23, /* secp256k1, Bitcoin default curve */ |
| 2588 |
XCP_EC_C_ED448 = 24, /* ed448 ('Goldilocks') FP(2^448-2^244+1)*/ |
| 2589 |
XCP_EC_C_448 = 25, /* c448/x448, ECDH only */ |
| 2590 |
XCP_EC_C_ED25519 = 26, /* ed25519, EDDSA */ |
| 2591 |
|
| 2592 |
|
| 2593 |
XCP_EC_C_BLS12_381 = 28, /* pairing-friendly BLS12-381 */ |
| 2594 |
XCP_EC_C_MAX = XCP_EC_C_BLS12_381, |
| 2595 |
/* last possible value */ |
| 2596 |
|
| 2597 |
} XCP_ECcurve_t; |
| 2598 |
|
| 2599 |
|
| 2600 |
/*-------------------------------------- |
| 2601 |
* groups of EC curves, without specific OIDs |
| 2602 |
*/ |
| 2603 |
typedef enum { |
| 2604 |
XCP_EC_CG_NIST = 1, /* NIST, FP curves */ |
| 2605 |
XCP_EC_CG_BPOOL = 2, /* Brainpool, FP curves */ |
| 2606 |
XCP_EC_CG_C25519 = 3, /* curve25519, ed25519 */ |
| 2607 |
XCP_EC_CG_SECP256K1 = 4, /* SECP K-curves, */ |
| 2608 |
/* incl. Bitcoin default */ |
| 2609 |
XCP_EC_CG_C448 = 6, /* c448, ed448 ('Goldilocks') */ |
| 2610 |
XCP_EC_CG_PAIRING_FRIENDLY = 7, /* pairing-friendly curves, |
| 2611 |
BLS12-381 */ |
| 2612 |
XCP_EC_CG_MAX = XCP_EC_CG_PAIRING_FRIENDLY |
| 2613 |
} XCP_ECCurveGrp_t; |
| 2614 |
|
| 2615 |
|
| 2616 |
/*--- PQC algorithms ------------------------------------------------------*/ |
| 2617 |
|
| 2618 |
// Dilithium related OIDs |
| 2619 |
// Round 2 Dilithium-3 (5-4) |
| 2620 |
#define XCP_PQC_DILITHIUM_R2_54 "\x6\xb\x2b\x6\x1\x4\x1\x2\x82\xb\x1\x5\x4" |
| 2621 |
#define XCP_PQC_DILITHIUM_R2_54_BYTES 13 |
| 2622 |
// Round 2 Dilithium-4 (6-5) |
| 2623 |
#define XCP_PQC_DILITHIUM_R2_65 "\x6\xb\x2b\x6\x1\x4\x1\x2\x82\xb\x1\x6\x5" |
| 2624 |
#define XCP_PQC_DILITHIUM_R2_65_BYTES 13 |
| 2625 |
// Round 2 Dilithium-5 (8-7) |
| 2626 |
#define XCP_PQC_DILITHIUM_R2_87 "\x6\xb\x2b\x6\x1\x4\x1\x2\x82\xb\x1\x8\x7" |
| 2627 |
#define XCP_PQC_DILITHIUM_R2_87_BYTES 13 |
| 2628 |
// Round 3 Dilithium-2 (4-4) |
| 2629 |
#define XCP_PQC_DILITHIUM_R3_44 "\x6\xb\x2b\x6\x1\x4\x1\x2\x82\xb\x7\x4\x4" |
| 2630 |
#define XCP_PQC_DILITHIUM_R3_44_BYTES 13 |
| 2631 |
// Round 3 Dilithium-3 (6-5) |
| 2632 |
#define XCP_PQC_DILITHIUM_R3_65 "\x6\xb\x2b\x6\x1\x4\x1\x2\x82\xb\x7\x6\x5" |
| 2633 |
#define XCP_PQC_DILITHIUM_R3_65_BYTES 13 |
| 2634 |
// Round 3 Dilithium-5 (8-7) |
| 2635 |
#define XCP_PQC_DILITHIUM_R3_87 "\x6\xb\x2b\x6\x1\x4\x1\x2\x82\xb\x7\x8\x7" |
| 2636 |
#define XCP_PQC_DILITHIUM_R3_87_BYTES 13 |
| 2637 |
|
| 2638 |
// Round 2 Kyber 512 |
| 2639 |
#define XCP_PQC_KYBER_R2_512 "\x6\x9\x2B\x6\x1\x4\x1\x2\x82\xB\x5" |
| 2640 |
#define XCP_PQC_KYBER_R2_512_BYTES 11 |
| 2641 |
|
| 2642 |
// Round 2 Kyber 768 |
| 2643 |
#define XCP_PQC_KYBER_R2_768 "\x6\xB\x2B\x6\x1\x4\x1\x2\x82\xB\x5\x3\x3" |
| 2644 |
#define XCP_PQC_KYBER_R2_768_BYTES 13 |
| 2645 |
|
| 2646 |
// Round 2 Kyber 1024 |
| 2647 |
#define XCP_PQC_KYBER_R2_1024 "\x6\xB\x2B\x6\x1\x4\x1\x2\x82\xB\x5\x4\x4" |
| 2648 |
#define XCP_PQC_KYBER_R2_1024_BYTES 13 |
| 2649 |
|
| 2650 |
// NIST Standards |
| 2651 |
typedef CK_ULONG CK_IBM_ML_DSA_PARAMETER_SET_TYPE; |
| 2652 |
#define CKP_IBM_ML_DSA_44 ((CK_IBM_ML_DSA_PARAMETER_SET_TYPE)1) |
| 2653 |
#define CKP_IBM_ML_DSA_65 ((CK_IBM_ML_DSA_PARAMETER_SET_TYPE)2) |
| 2654 |
#define CKP_IBM_ML_DSA_87 ((CK_IBM_ML_DSA_PARAMETER_SET_TYPE)3) |
| 2655 |
|
| 2656 |
typedef CK_ULONG CK_IBM_ML_KEM_PARAMETER_SET_TYPE; |
| 2657 |
#define CKP_IBM_ML_KEM_512 ((CK_IBM_ML_KEM_PARAMETER_SET_TYPE)1) |
| 2658 |
#define CKP_IBM_ML_KEM_768 ((CK_IBM_ML_KEM_PARAMETER_SET_TYPE)2) |
| 2659 |
#define CKP_IBM_ML_KEM_1024 ((CK_IBM_ML_KEM_PARAMETER_SET_TYPE)3) |
| 2660 |
|
| 2661 |
typedef CK_ULONG CK_IBM_HEDGE_TYPE; |
| 2662 |
#define CKH_IBM_HEDGE_PREFERRED ((CK_IBM_HEDGE_TYPE)1) |
| 2663 |
#define CKH_IBM_HEDGE_REQUIRED ((CK_IBM_HEDGE_TYPE)2) |
| 2664 |
#define CKH_IBM_DETERMINISTIC_REQUIRED ((CK_IBM_HEDGE_TYPE)3) |
| 2665 |
|
| 2666 |
typedef struct CK_IBM_SIGN_ADDITIONAL_CONTEXT { |
| 2667 |
CK_IBM_HEDGE_TYPE hedgeVariant; |
| 2668 |
CK_BYTE_PTR pContext; |
| 2669 |
CK_ULONG ulContextLen; |
| 2670 |
} CK_IBM_SIGN_ADDITIONAL_CONTEXT; |
| 2671 |
|
| 2672 |
/*------------------------------------*/ |
| 2673 |
typedef enum { |
| 2674 |
XCP_PQC_S_DILITHIUM_R2_54 = 1, /* Round-2 Dilithium */ |
| 2675 |
XCP_PQC_S_DILITHIUM_R2_65 = 2, |
| 2676 |
XCP_PQC_S_DILITHIUM_R2_87 = 3, |
| 2677 |
XCP_PQC_S_DILITHIUM_R3_44 = 4, /* Round-3 Dilithium */ |
| 2678 |
XCP_PQC_S_DILITHIUM_R3_65 = 5, |
| 2679 |
XCP_PQC_S_DILITHIUM_R3_87 = 6, |
| 2680 |
XCP_PQC_S_KYBER_R2_512 = 7, /* Round-2 Kyber */ |
| 2681 |
XCP_PQC_S_KYBER_R2_768 = 8, |
| 2682 |
XCP_PQC_S_KYBER_R2_1024 = 9, |
| 2683 |
XCP_PQC_S_ML_DSA_44 = 10, /* NIST Standards */ |
| 2684 |
XCP_PQC_S_ML_DSA_65 = 11, |
| 2685 |
XCP_PQC_S_ML_DSA_87 = 12, |
| 2686 |
XCP_PQC_S_ML_KEM_512 = 13, |
| 2687 |
XCP_PQC_S_ML_KEM_768 = 14, |
| 2688 |
XCP_PQC_S_ML_KEM_1024 = 15, |
| 2689 |
|
| 2690 |
XCP_PQC_MAX = XCP_PQC_S_ML_KEM_1024, |
| 2691 |
} XCP_PQCStrength_t; |
| 2692 |
|
| 2693 |
|
| 2694 |
// binary encoding of function/version query |
| 2695 |
// SEQUENCE { OCTET STRING (0) } |
| 2696 |
// module responds with API version and build ID |
| 2697 |
// |
| 2698 |
#define XCP_VERS_QUERY_REQ 0x30,0x03,0x04,0x01,0x00 /* request body */ |
| 2699 |
#define XCP_VERS_QUERY_REQ_BYTES 5 |
| 2700 |
|
| 2701 |
/*--- development-only test functions ------------------------------------*/ |
| 2702 |
|
| 2703 |
typedef enum { |
| 2704 |
XCP_DEV_SET_WK = 1, // set and activate (imprint) WK |
| 2705 |
XCP_DEV_SET_NEXT_WK = 2, // set+commit next WK (+imprint) |
| 2706 |
XCP_DEV_AES_ENCR_CYCLE = 3, // AES encrypt in loop |
| 2707 |
// (side-channel, other measurements) |
| 2708 |
XCP_DEV_AES_DECR_CYCLE = 4, // AES decrypt in loop |
| 2709 |
XCP_DEV_DES_ENCR_CYCLE = 5, // 1/2/3DES, auto-selected |
| 2710 |
XCP_DEV_DES_DECR_CYCLE = 6, // 1/2/3DES, auto-selected |
| 2711 |
XCP_DEV_ZEROIZE_CARD = 7, |
| 2712 |
XCP_DEV_ZEROIZE_DOMAIN = 8, |
| 2713 |
XCP_DEV_SET_DOMAIN_CPS = 9, // import full set of CPs |
| 2714 |
XCP_DEV_SET_WK_RAW = 10, // set WK without imprinting |
| 2715 |
XCP_DEV_COMMIT_NEXT_WK = 11, // finalizes next WK to current |
| 2716 |
XCP_DEVQ_ADMINLIST = 12, // SKI list, without card signature |
| 2717 |
XCP_DEVQ_DOM_ADMINLIST = 13, // SKI list, without card signature |
| 2718 |
XCP_DEV_SET_NEXT_WK_RAW = 14, // set next WK, does not imprint |
| 2719 |
XCP_DEV_FSMODE = 15, // manage access to filesystems |
| 2720 |
XCP_DEV_ADMSIGN = 16, // admin-sign file in filesystem |
| 2721 |
// used to pass arbitrary bad structs |
| 2722 |
// for verification |
| 2723 |
XCP_DEV_FSWRITE = 17, // write data to temporary file |
| 2724 |
XCP_DEV_DSA_PQG_GEN = 18, |
| 2725 |
XCP_DEVQ_BLOBCONFIG = 19, // blob details: endianness and sizes |
| 2726 |
XCP_DEV_RSA_X931_KEYGEN = 20, // ANSI x9.31 key gen. from prime seeds |
| 2727 |
// returns PKCS8-encoded key, in clear |
| 2728 |
// may be unsupported, depending on CSP |
| 2729 |
// setup |
| 2730 |
XCP_DEV_RNGSTATE = 21, // query or set backend RNG state |
| 2731 |
XCP_DEV_RNG_SEED = 22, // forces immediate RNG re/seeding |
| 2732 |
// recommended before exporting RNG |
| 2733 |
// state, to maximize number of |
| 2734 |
// matching bits after state is restored |
| 2735 |
|
| 2736 |
XCP_DEVQ_ENTROPY = 23, // retrieve raw TRNG output |
| 2737 |
// conditioned entropy, no DRNG |
| 2738 |
// processing a direct-call subset of |
| 2739 |
// XCP_DEV_RNG_TRNG (does not require |
| 2740 |
// background completion) |
| 2741 |
// note that this call changes DRNG |
| 2742 |
// setup during processing, |
| 2743 |
// slowing it down |
| 2744 |
// see also: XCP_DEV_RAWENTROPY |
| 2745 |
|
| 2746 |
XCP_DEVQ_PERFMODE = 24, // query performance/timestamp setup |
| 2747 |
XCP_DEV_PERFMODE = 25, // change performance/timestamp setup |
| 2748 |
|
| 2749 |
XCP_DEV_RSA_DECR_CYCLE = 26, // RSA, raw mod. exponentiation, looped |
| 2750 |
XCP_DEV_RSACRT_DECR_CYCLE = 27, // RSA, private exponent, CRT, looped |
| 2751 |
XCP_DEV_ECMUL_CYCLE = 28, // EC scalar multiplication, looped |
| 2752 |
|
| 2753 |
XCP_DEV_PERFMARK = 29, // add performance-test marker |
| 2754 |
// LS 4 bits included in entry |
| 2755 |
|
| 2756 |
XCP_DEVQ_PERF_LOCK = 30, // raw performance: un/lock cycles, |
| 2757 |
// single thread |
| 2758 |
// test on otherwise quiesced backend |
| 2759 |
XCP_DEVQ_PERF_WAKE = 31, // raw performance: un/lock cycles, |
| 2760 |
// forcing context switching |
| 2761 |
// test on otherwise quiesced backend |
| 2762 |
XCP_DEVQ_PERF_SCALE = 32, // raw performance: add calibrating |
| 2763 |
// timestamp/syslog/etc. entries |
| 2764 |
// to simplify offline scaling of |
| 2765 |
// performance management |
| 2766 |
|
| 2767 |
XCP_DEV_CACHE_MODE = 33, // set or query module-internal cache |
| 2768 |
// state and statistics |
| 2769 |
XCP_DEVQ_CACHE_STATS = 34, // log cache-statistics summary |
| 2770 |
// over syslog etc. (system-dependent) |
| 2771 |
XCP_DEV_DELAY = 35, // NOP: delay the backend thread by |
| 2772 |
// a host-influenced amount of time, |
| 2773 |
// without performing other operations |
| 2774 |
|
| 2775 |
XCP_DEV_COMPRESS = 36, // return 'summarized' version of any |
| 2776 |
// supplied data |
| 2777 |
XCP_DEV_XOR_FF = 37, // returns a copy of data, all bits |
| 2778 |
// flipped (XORed with 0xff) |
| 2779 |
XCP_DEV_PRF = 38, // returns PRF stream from caller- |
| 2780 |
// provided seed and bytecount |
| 2781 |
|
| 2782 |
XCP_DEV_TRANSPORTSTATE1 = 39, // transport-statistics dump |
| 2783 |
// (system-dependent functionality) |
| 2784 |
|
| 2785 |
XCP_DEVQ_CACHEINDEX = 40, // return module-internal blob index |
| 2786 |
// of caller-provided key |
| 2787 |
XCP_DEVQ_CSP_OBJCOUNT = 41, // CSP-object reference counter, |
| 2788 |
// if available |
| 2789 |
|
| 2790 |
XCP_DEV_CSPTYPE = 42, // preferred CSP-object (engine) type |
| 2791 |
|
| 2792 |
XCP_DEV_FCV = 43, // query and/or set current FCV |
| 2793 |
// without signature verification |
| 2794 |
XCP_DEV_CLEAR_FCV = 44, // erase any existing FCV |
| 2795 |
|
| 2796 |
XCP_DEVQ_ASSERTIONS = 45, // verify the consistency of module- |
| 2797 |
// internal data structures, as a |
| 2798 |
// stronger form of assertion-checking |
| 2799 |
|
| 2800 |
XCP_DEV_TEST_LATESTART = 46, // perform any initial test which has |
| 2801 |
// been skipped during backend startup. |
| 2802 |
// not necessary unless running against |
| 2803 |
// the most aggressive SYS_TEST_0START |
| 2804 |
// settings [which trim down backend |
| 2805 |
// testing to a bare minimum]. Safe to |
| 2806 |
// issue, a NOP otherwise. |
| 2807 |
|
| 2808 |
XCP_DEV_ENVSEED = 47, // seed backend with device-unique, |
| 2809 |
// environment-derived, low quality |
| 2810 |
// entropy [augments/replaces real |
| 2811 |
// entropy seeding; added to let |
| 2812 |
// unrelated backends diverge even |
| 2813 |
// when VM-hosted or otherwise lacking |
| 2814 |
// proper initial entropy] |
| 2815 |
|
| 2816 |
XCP_DEVQ_RAWENTROPY = 48, // retrieve raw entropy pool, before |
| 2817 |
// compression, if backend supports |
| 2818 |
// this (see Clic docs for raw-pool |
| 2819 |
// state details) |
| 2820 |
// |
| 2821 |
// see also: XCP_DEV_ENTROPY |
| 2822 |
|
| 2823 |
XCP_DEV_EC_SIGVER_CYCLE = 49, // EC sign/verify in loop |
| 2824 |
// operation derived from supplied blob |
| 2825 |
// (EC private/SPKI) |
| 2826 |
// see also: XCP_DEV_ECMUL_CYCLE |
| 2827 |
|
| 2828 |
XCP_DEV_DRAIN_ENTROPY = 50, // TRNG: force at least one collect |
| 2829 |
// entropy->compression call |
| 2830 |
// [may be more, depends on DRNG state] |
| 2831 |
|
| 2832 |
XCP_DEV_CONV_EC_BLOB = 51, // CLiC blob conversion: Convert a |
| 2833 |
// software Blob to a 4767 hardware blob |
| 2834 |
// At the moment only EC blobs are |
| 2835 |
// supported |
| 2836 |
|
| 2837 |
XCP_DEVQ_COUNTERS = 52, // retrieve coverage counters |
| 2838 |
// these are intentionally not published |
| 2839 |
|
| 2840 |
XCP_DEV_RSACRT_MSG_CYCLE = 53, // RSA, private exponent, CRT, looped |
| 2841 |
// this variant increments message |
| 2842 |
// and returns per-message statistics |
| 2843 |
|
| 2844 |
XCP_DEV_AUDIT_CYCLE = 54, // audit-log, generate log entries |
| 2845 |
// in a loop |
| 2846 |
|
| 2847 |
XCP_DEV_EDDSA = 55, // EC dig.signature forms |
| 2848 |
|
| 2849 |
XCP_DEV_ECDH = 56, // EC Diffie-Hellman/Montgomery forms |
| 2850 |
|
| 2851 |
XCP_DEV_PQC_DILITHIUM = 57, // post-quantum algs: generic call |
| 2852 |
// for Dilithium (from PQ Crystals) |
| 2853 |
|
| 2854 |
XCP_DEV_ABORT = 63, // raise abort signal |
| 2855 |
XCP_DEV_DRNG = 64, // gen non-randomly-seeded DRNG bytes |
| 2856 |
XCP_DEV_DRNG_RESEED = 65, // explicitly set DRNG seed |
| 2857 |
XCP_DEV_FAULT_INJECT = 66, // control fault point injection |
| 2858 |
XCP_DEVQ_FAULTLIST = 67, // list available fault points |
| 2859 |
XCP_DEV_FLIP_ERRORSTATE = 68, // explicitly flip the setting of the |
| 2860 |
// error state of the module |
| 2861 |
XCP_DEV_AESKW = 69, |
| 2862 |
XCP_DEV_KDF_SP108 = 70, // NIST SP800-108 KDF |
| 2863 |
XCP_DEV_KDF_SP56C = 71, // NIST SP800-56C ECDH+KDF(ECIES) |
| 2864 |
XCP_DEV_UNIT_TEST = 72, // run unit tests on module |
| 2865 |
|
| 2866 |
|
| 2867 |
XCP_DEV_MAX_INDEX = XCP_DEV_UNIT_TEST |
| 2868 |
} XCP_DEVcmd_t; |
| 2869 |
// |
| 2870 |
// upper limit on additional data bytes, for SYS-TEST commands with aux. data |
| 2871 |
// (arbitrary limit, commands may restict further) |
| 2872 |
#define XCP_DEV_MAX_DATABYTES ((size_t) 64000) |
| 2873 |
// |
| 2874 |
// iteration-count limit applies to any iterative call |
| 2875 |
// driver[timeout] may interfere; dev-only feature is not otherwise restricted |
| 2876 |
#define XCP_DEV_MAX_ITERATIONS ((unsigned int) 128*1024) |
| 2877 |
|
| 2878 |
#define XCP_DEV_C25519 (unsigned int)255 |
| 2879 |
#define XCP_DEV_C448 (unsigned int)448 |
| 2880 |
#define XCP_DEV_ED25519 ~((unsigned int)255) |
| 2881 |
#define XCP_DEV_ED448 ~((unsigned int)448) |
| 2882 |
#define XCP_DEV_ED25519_2 ~((unsigned int)256) |
| 2883 |
#define XCP_DEV_ED448_2 ~((unsigned int)456) |
| 2884 |
|
| 2885 |
#define XCP_DEV_AESKW_WRAP (unsigned int)1 |
| 2886 |
#define XCP_DEV_AESKW_UNWRAP (unsigned int)2 |
| 2887 |
#define XCP_DEV_AESKW_WRAP_PAD (unsigned int)3 |
| 2888 |
#define XCP_DEV_AESKW_UNWRAP_PAD (unsigned int)4 |
| 2889 |
|
| 2890 |
typedef enum { |
| 2891 |
XCP_DEVC_CACHE_ACTIVE = 1, // blob-cache is available |
| 2892 |
XCP_DEVC_CACHE_INACTIVE = 2, // caching suspended: lookups fail, |
| 2893 |
// new entries are not accepted |
| 2894 |
XCP_DEVC_CACHE_FLUSH = 4, // evict all currently cached objects |
| 2895 |
// available even if cache is suspended |
| 2896 |
} XCP_DEVcache_t; |
| 2897 |
|
| 2898 |
typedef enum { |
| 2899 |
XCP_DEV_RNG_TRNG = 0, // no DRNG involvement |
| 2900 |
XCP_DEV_RNG_DRNG = 1, // DRNG, no reseeding |
| 2901 |
XCP_DEV_RNG_MIXED = 2, // DRNG, with TRNG reseeding |
| 2902 |
XCP_DEV_RNG_SWDRNG = 4, // Software-DRNG |
| 2903 |
XCP_DEV_RNG_TYPE_MAX = XCP_DEV_RNG_SWDRNG |
| 2904 |
} XCP_DEVrng_t; |
| 2905 |
|
| 2906 |
typedef enum { |
| 2907 |
XCP_DEVFS_QUERY = 0, // current state query only |
| 2908 |
XCP_DEVFS_READONLY = 1, // prevent writes |
| 2909 |
XCP_DEVFS_NOACCESS = 2 // prevent all filesystem access |
| 2910 |
} XCP_DEVfs_t; |
| 2911 |
|
| 2912 |
// size of coverage counters |
| 2913 |
#define XCP_DEV_CTR_SIZE 4 |
| 2914 |
#define XCP_DEV_CTR_TYPE uint32_t |
| 2915 |
|
| 2916 |
typedef enum { |
| 2917 |
XCP_DEV_FAULT_EXPR = 1, // evaluate to non-null if triggered |
| 2918 |
XCP_DEV_FAULT_FUNC = 2, // call callback function |
| 2919 |
XCP_DEV_FAULT_MSLEEP = 4, // sleep for msleep ms |
| 2920 |
XCP_DEV_FAULT_RV = 8, // faultpoint returns rv |
| 2921 |
XCP_DEV_FAULT_DBIT = 16, // flip bit at compile-time const offset |
| 2922 |
XCP_DEV_FAULT_DNULL = 32, // faultpoint memsets data to zero |
| 2923 |
XCP_DEV_FAULT_RBIT = 64, // flip bit at random offset |
| 2924 |
} XCP_DEVfault_t; |
| 2925 |
|
| 2926 |
// no vendor extension definition for CKG available yet |
| 2927 |
#if !defined(CKG_VENDOR_DEFINED) |
| 2928 |
#define CKG_VENDOR_DEFINED 0x80000000UL |
| 2929 |
#endif |
| 2930 |
|
| 2931 |
#define CKG_IBM_MGF1_SHA3_224 (CKG_VENDOR_DEFINED +1) |
| 2932 |
#define CKG_IBM_MGF1_SHA3_256 (CKG_VENDOR_DEFINED +2) |
| 2933 |
#define CKG_IBM_MGF1_SHA3_384 (CKG_VENDOR_DEFINED +3) |
| 2934 |
#define CKG_IBM_MGF1_SHA3_512 (CKG_VENDOR_DEFINED +4) |
| 2935 |
|
| 2936 |
#if !defined(CKD_VENDOR_DEFINED) |
| 2937 |
#define CKD_VENDOR_DEFINED 0x80000000UL |
| 2938 |
#endif |
| 2939 |
|
| 2940 |
#define CKD_IBM_HYBRID_NULL (CKD_VENDOR_DEFINED + 0x00000001UL) |
| 2941 |
#define CKD_IBM_HYBRID_SHA1_KDF (CKD_VENDOR_DEFINED + 0x00000002UL) |
| 2942 |
#define CKD_IBM_HYBRID_SHA224_KDF (CKD_VENDOR_DEFINED + 0x00000003UL) |
| 2943 |
#define CKD_IBM_HYBRID_SHA256_KDF (CKD_VENDOR_DEFINED + 0x00000004UL) |
| 2944 |
#define CKD_IBM_HYBRID_SHA384_KDF (CKD_VENDOR_DEFINED + 0x00000005UL) |
| 2945 |
#define CKD_IBM_HYBRID_SHA512_KDF (CKD_VENDOR_DEFINED + 0x00000006UL) |
| 2946 |
|
| 2947 |
#define XCP_MODEL_CEX4P 4 |
| 2948 |
#define XCP_MODEL_CEX5P 5 |
| 2949 |
#define XCP_MODEL_CEX6P 6 |
| 2950 |
#define XCP_MODEL_CEX7P 7 |
| 2951 |
#define XCP_MODEL_CEX8P 8 |
| 2952 |
|
| 2953 |
/*--------------------------------------------------------------------------*/ |
| 2954 |
// max value for target groups |
| 2955 |
#define XCP_MAX_GRPIDX 1024u |
| 2956 |
|
| 2957 |
// |
| 2958 |
// macros for setting/checking and removing domains from (tgt.mgmt) domain mask |
| 2959 |
#define XCPTGTMASK_SET_DOM(mask, domain) \ |
| 2960 |
((mask)[((domain)/8)] |= (1 << (7-(domain)%8))) |
| 2961 |
#define XCPTGTMASK_DOM_IS_SET(mask, domain) \ |
| 2962 |
((mask)[((domain)/8)] & (1 << (7-(domain)%8))) |
| 2963 |
#define XCPTGTMASK_CLR_DOM(mask, domain) \ |
| 2964 |
((mask)[((domain)/8)] &= ~(1 << (7-(domain)%8))) |
| 2965 |
|
| 2966 |
|
| 2967 |
/* flags that can be set for the target tokens |
| 2968 |
* |
| 2969 |
* This flags are domain specific and are therefore called domain flags |
| 2970 |
* |
| 2971 |
* start of flags is >16 Bit. Max value for domains is 0xFF. Should be enough |
| 2972 |
* room for extensions |
| 2973 |
*/ |
| 2974 |
#define XCP_TGTFL_WCAP 0x10000000 /* Capture wire request in output buffer |
| 2975 |
* without sending it to the module |
| 2976 |
*/ |
| 2977 |
#define XCP_TGTFL_WCAP_SQ 0x20000000 /* Size query: Return size of request in |
| 2978 |
* output buffer length field |
| 2979 |
*/ |
| 2980 |
#define XCP_TGTFL_SET_SCMD 0x40000000 /* Protected key special command: Set the |
| 2981 |
* special command flag in the CPRB |
| 2982 |
* header |
| 2983 |
*/ |
| 2984 |
#define XCP_TGTFL_API_CHKD 0x80000000 /* supported API version of modules in |
| 2985 |
* target (group) has been checked |
| 2986 |
*/ |
| 2987 |
|
| 2988 |
#define XCP_TGTFL_NO_LOCK 0x01000000 /* target token ignores sequential locks |
| 2989 |
* for target probing |
| 2990 |
*/ |
| 2991 |
#define XCP_TGTFL_CHK_ATTR 0x02000000 /* reject unknown attribute in attribute |
| 2992 |
* templates with |
| 2993 |
* CKR_TEMPLATE_INCONSISTENT. Default is |
| 2994 |
* to ignore unknown attributes. |
| 2995 |
*/ |
| 2996 |
#define XCP_TGTFL_SET_ACMD 0x04000000 /* add CPRB admin flag to CPRB header */ |
| 2997 |
|
| 2998 |
#define XCP_TGTFL_NO_SPLIT 0x08000000 /* enforce single-shot requests */ |
| 2999 |
|
| 3000 |
//-------------------------------------- |
| 3001 |
// socket use only |
| 3002 |
#define XCP_MAXCONNECTIONS 256 /* max value for active connections */ |
| 3003 |
#define XCP_MAX_PORT 0xffff |
| 3004 |
|
| 3005 |
// hostname and port value fore one module |
| 3006 |
typedef struct XCP_ModuleSocket { |
| 3007 |
char host[ MAX_FNAME_CHARS +1 ]; |
| 3008 |
uint32_t port; |
| 3009 |
} *XCP_ModuleSocket_t ; |
| 3010 |
|
| 3011 |
|
| 3012 |
//-------------------------------------- |
| 3013 |
// diagnostics use only |
| 3014 |
typedef struct XCP_DomainPerf { |
| 3015 |
/* perf value of last request per domain |
| 3016 |
* |
| 3017 |
* At the moment unused |
| 3018 |
* */ |
| 3019 |
unsigned int lastperf[ 256 ]; |
| 3020 |
} *XCP_DomainPerf_t; |
| 3021 |
|
| 3022 |
|
| 3023 |
// current version of XCP_Module structure; host code SHOULD interact with |
| 3024 |
// future/past versions, MUST be set by caller before using m_add_module() |
| 3025 |
// valid versions are all >0 |
| 3026 |
#define XCP_MOD_VERSION 2 |
| 3027 |
//-------------------------------------- |
| 3028 |
// subsequent communications with a module MAY skip infrastructure-specific |
| 3029 |
// fields, such as a query not reporting device handles etc., even if they |
| 3030 |
// have been supplied originally when the module has been registered. |
| 3031 |
// |
| 3032 |
typedef struct XCP_Module { |
| 3033 |
uint32_t version; /* >0 for supported API versions */ |
| 3034 |
|
| 3035 |
uint64_t flags; /* see XCP_Module_Flags */ |
| 3036 |
|
| 3037 |
uint32_t domains; /* max# addressable under this module; |
| 3038 |
* cached from OS |
| 3039 |
* |
| 3040 |
* when callers set domains to 0, the library |
| 3041 |
* returns the module-claimed domain count. |
| 3042 |
*/ |
| 3043 |
|
| 3044 |
unsigned char domainmask[ 256 /8 ]; |
| 3045 |
/* higher domain# through future flags (none |
| 3046 |
* currently defined) which would add things |
| 3047 |
* like 'FLAG_256_1023' etc. at the same time, |
| 3048 |
* we would add domainmask2[] etc. |
| 3049 |
* corresponding new fields. |
| 3050 |
* |
| 3051 |
* new fields would then store mask for |
| 3052 |
* domains 256+ etc. |
| 3053 |
* |
| 3054 |
* domain #0 is bit x80 of 1st byte, |
| 3055 |
* #255 is bit 0x01 of last byte. |
| 3056 |
*/ |
| 3057 |
|
| 3058 |
// when a domainmask is supplied, with bits set beyond |
| 3059 |
// what the module supports, the bitmask is trimmed to |
| 3060 |
// the supported range, but this is NOT reported as an |
| 3061 |
// error, unless XCP_MFL_STRICT is also supplied. |
| 3062 |
// |
| 3063 |
// without XCP_MFL_STRICT, callers are expected to check |
| 3064 |
// at least the returned domain count. |
| 3065 |
|
| 3066 |
/* used only when flags includes XCP_MFL_SOCKET */ |
| 3067 |
struct XCP_ModuleSocket socket; |
| 3068 |
|
| 3069 |
/* used when system exposes modules through an |
| 3070 |
* array of transparent pipes, or similar abstraction |
| 3071 |
* (such as mainframe AP Queues, or other Linux |
| 3072 |
* 'device-minor' numbers etc.). Interpretation |
| 3073 |
* is platform-dependent. |
| 3074 |
* |
| 3075 |
* used only when flags includes XCP_MFL_MODULE |
| 3076 |
*/ |
| 3077 |
uint32_t module_nr; |
| 3078 |
|
| 3079 |
/* used by systems which associate devices with |
| 3080 |
* device handles/structs/etc. persistent state. |
| 3081 |
* opaque pointer, usually a const pointer to |
| 3082 |
* such aux structs, MAY be stored here. |
| 3083 |
* |
| 3084 |
* interpretation is platform-dependent. |
| 3085 |
* used only when flags includes XCP_MFL_MHANDLE |
| 3086 |
*/ |
| 3087 |
void *mhandle; |
| 3088 |
/* diagnostics use only, when XCP_MFL_PERF is set */ |
| 3089 |
struct XCP_DomainPerf perf; |
| 3090 |
//----- end of v1 fields ------------------------------------------- |
| 3091 |
|
| 3092 |
uint32_t api; /* module api version*/ |
| 3093 |
//----- end of v2 fields ------------------------------------------- |
| 3094 |
} *XCP_Module_t ; |
| 3095 |
|
| 3096 |
typedef enum { |
| 3097 |
XCP_MFL_SOCKET = 1, /* backend is socket-attached */ |
| 3098 |
XCP_MFL_MODULE = 2, /* backends identified in |
| 3099 |
array-of-modules */ |
| 3100 |
XCP_MFL_MHANDLE = 4, /* backends uses 'module handle' field */ |
| 3101 |
XCP_MFL_PERF = 8, /* performance statistics collected |
| 3102 |
* for this module, see .perf |
| 3103 |
*/ |
| 3104 |
XCP_MFL_VIRTUAL = 0x10, /* queried 'target' is a load-balancer, |
| 3105 |
* other other group. |
| 3106 |
*/ |
| 3107 |
XCP_MFL_STRICT = 0x20, /* enable aggressive error checking, |
| 3108 |
* see field descriptions for effect |
| 3109 |
*/ |
| 3110 |
XCP_MFL_PROBE = 0x40, /* send api query to module, to check if |
| 3111 |
* target(s) can be used |
| 3112 |
*/ |
| 3113 |
XCP_MFL_ALW_TGT_ADD = 0x80, /* Allows it to use a target in any |
| 3114 |
* functional and admin call without |
| 3115 |
* adding it beforehand with |
| 3116 |
* m_add_module() |
| 3117 |
*/ |
| 3118 |
XCP_MFL_MAX = 0xff |
| 3119 |
} XCP_Module_Flags; |
| 3120 |
|
| 3121 |
typedef uint64_t target_t; |
| 3122 |
|
| 3123 |
#define XCP_TGT_INIT ~0UL |
| 3124 |
|
| 3125 |
#define XCP_TGT_FMT "x%016" PRIx64 |
| 3126 |
|
| 3127 |
int m_add_module(XCP_Module_t module, target_t *target) ; |
| 3128 |
|
| 3129 |
int m_rm_module(XCP_Module_t module, target_t target) ; |
| 3130 |
|
| 3131 |
CK_RV m_admin (unsigned char *response1, size_t *r1len, |
| 3132 |
unsigned char *response2, size_t *r2len, |
| 3133 |
const unsigned char *cmd, size_t clen, |
| 3134 |
const unsigned char *sigs, size_t slen, |
| 3135 |
target_t target) ; |
| 3136 |
|
| 3137 |
/*---------------------------------------------------------------------- |
| 3138 |
* CK_... type arguments correspond to the original PKCS#11 call's |
| 3139 |
* arguments. Standard types mean PKCS#11 objects (session, token etc.) |
| 3140 |
* are mapped to a native type (key blob, mechanism) etc. |
| 3141 |
* |
| 3142 |
* As an example, for _Encrypt and _Decrypt, a session is passed to |
| 3143 |
* the PKCS#11 function. This session needs to be matched to a key blob, |
| 3144 |
* so our _Encrypt interface takes a key/keylen buffer instead of the |
| 3145 |
* session. All other parameters should be passed through unchanged. |
| 3146 |
* |
| 3147 |
* For certain operations, such as _GenerateKey, there are no real |
| 3148 |
* PKCS#11 type parameters at this level. |
| 3149 |
*/ |
| 3150 |
|
| 3151 |
|
| 3152 |
CK_RV m_Login ( CK_UTF8CHAR_PTR pin, CK_ULONG pinlen, |
| 3153 |
const unsigned char *nonce, size_t nlen, |
| 3154 |
unsigned char *pinblob, size_t *pinbloblen, |
| 3155 |
target_t target) ; |
| 3156 |
CK_RV m_Logout ( const unsigned char *pin, size_t len, target_t target) ; |
| 3157 |
|
| 3158 |
CK_RV m_LoginExtended( CK_UTF8CHAR_PTR pin, CK_ULONG pinlen, |
| 3159 |
const unsigned char *nonce, size_t nlen, |
| 3160 |
const unsigned char *xstruct, size_t xslen, |
| 3161 |
unsigned char *pinblob, size_t *pinbloblen, |
| 3162 |
target_t target) ; |
| 3163 |
|
| 3164 |
CK_RV m_LogoutExtended( CK_UTF8CHAR_PTR pin, CK_ULONG pinlen, |
| 3165 |
const unsigned char *nonce, size_t nlen, |
| 3166 |
const unsigned char *xstruct, size_t xslen, |
| 3167 |
target_t target) ; |
| 3168 |
|
| 3169 |
int xcpu_LoginRecipient (uint8_t *result, size_t *rlen, |
| 3170 |
uint32_t version, |
| 3171 |
const uint8_t *rcpt_ski, size_t rslen, |
| 3172 |
const uint8_t *send_spki, size_t slen); |
| 3173 |
|
| 3174 |
CK_RV m_GenerateRandom (CK_BYTE_PTR rnd, CK_ULONG len, target_t target) ; |
| 3175 |
/**/ |
| 3176 |
/* note: external seeding not supported */ |
| 3177 |
CK_RV m_SeedRandom (CK_BYTE_PTR pSeed, CK_ULONG ulSeedLen, |
| 3178 |
target_t target) ; |
| 3179 |
|
| 3180 |
CK_RV m_DigestInit (unsigned char *state, size_t *len, |
| 3181 |
const CK_MECHANISM_PTR pmech, |
| 3182 |
target_t target) ; |
| 3183 |
/**/ |
| 3184 |
CK_RV m_Digest (const unsigned char *state, size_t slen, |
| 3185 |
CK_BYTE_PTR data, CK_ULONG len, |
| 3186 |
CK_BYTE_PTR digest, CK_ULONG_PTR dglen, |
| 3187 |
target_t target) ; |
| 3188 |
CK_RV m_DigestUpdate (unsigned char *state, size_t slen, |
| 3189 |
CK_BYTE_PTR data, CK_ULONG dlen, |
| 3190 |
target_t target) ; |
| 3191 |
CK_RV m_DigestKey (unsigned char *state, size_t slen, |
| 3192 |
const unsigned char *key, size_t klen, |
| 3193 |
target_t target) ; |
| 3194 |
CK_RV m_DigestFinal (const unsigned char *state, size_t slen, |
| 3195 |
CK_BYTE_PTR digest, CK_ULONG_PTR dlen, |
| 3196 |
target_t target) ; |
| 3197 |
CK_RV m_DigestSingle (CK_MECHANISM_PTR pmech, |
| 3198 |
CK_BYTE_PTR data, CK_ULONG len, |
| 3199 |
CK_BYTE_PTR digest, CK_ULONG_PTR dlen, |
| 3200 |
target_t target) ; |
| 3201 |
|
| 3202 |
CK_RV m_GenerateKey (CK_MECHANISM_PTR pmech, |
| 3203 |
CK_ATTRIBUTE_PTR ptempl, CK_ULONG templcount, |
| 3204 |
const unsigned char *pin, size_t pinlen, |
| 3205 |
unsigned char *key, size_t *klen, |
| 3206 |
unsigned char *csum, size_t *clen, |
| 3207 |
target_t target) ; |
| 3208 |
/**/ |
| 3209 |
CK_RV m_GenerateKeyPair (CK_MECHANISM_PTR pmech, |
| 3210 |
CK_ATTRIBUTE_PTR ppublic, CK_ULONG pubattrs, |
| 3211 |
CK_ATTRIBUTE_PTR pprivate, CK_ULONG prvattrs, |
| 3212 |
const unsigned char *pin, size_t pinlen, |
| 3213 |
unsigned char *key, size_t *klen, |
| 3214 |
unsigned char *pubkey, size_t *pklen, |
| 3215 |
target_t target) ; |
| 3216 |
|
| 3217 |
/* mackey is NULL for PKCS#11 formats, not for authenticated ones */ |
| 3218 |
CK_RV m_WrapKey (const unsigned char *key, size_t keylen, |
| 3219 |
const unsigned char *kek, size_t keklen, |
| 3220 |
const unsigned char *mackey, size_t mklen, |
| 3221 |
const CK_MECHANISM_PTR pmech, |
| 3222 |
CK_BYTE_PTR wrapped, CK_ULONG_PTR wlen, |
| 3223 |
target_t target) ; |
| 3224 |
/**/ |
| 3225 |
/* mackey is NULL for PKCS#11 formats, not for authenticated ones */ |
| 3226 |
CK_RV m_UnwrapKey (const CK_BYTE_PTR wrapped, CK_ULONG wlen, |
| 3227 |
const unsigned char *kek, size_t keklen, |
| 3228 |
const unsigned char *mackey, size_t mklen, |
| 3229 |
const unsigned char *pin, size_t pinlen, |
| 3230 |
const CK_MECHANISM_PTR uwmech, |
| 3231 |
const CK_ATTRIBUTE_PTR ptempl, CK_ULONG pcount, |
| 3232 |
unsigned char *unwrapped, size_t *uwlen, |
| 3233 |
CK_BYTE_PTR csum, CK_ULONG *cslen, |
| 3234 |
target_t target) ; |
| 3235 |
|
| 3236 |
CK_RV m_DeriveKey ( CK_MECHANISM_PTR pderivemech, |
| 3237 |
CK_ATTRIBUTE_PTR ptempl, CK_ULONG templcount, |
| 3238 |
const unsigned char *basekey, size_t bklen, |
| 3239 |
const unsigned char *data, size_t dlen, |
| 3240 |
const unsigned char *pin, size_t pinlen, |
| 3241 |
unsigned char *newkey, size_t *nklen, |
| 3242 |
unsigned char *csum, size_t *cslen, |
| 3243 |
target_t target) ; |
| 3244 |
|
| 3245 |
CK_RV m_GetAttributeValue (const unsigned char *obj, size_t olen, |
| 3246 |
CK_ATTRIBUTE_PTR pTemplate, CK_ULONG ulCount, |
| 3247 |
target_t target) ; |
| 3248 |
CK_RV m_SetAttributeValue (unsigned char *obj, size_t olen, |
| 3249 |
CK_ATTRIBUTE_PTR pTemplate, CK_ULONG ulCount, |
| 3250 |
target_t target) ; |
| 3251 |
|
| 3252 |
/**/ |
| 3253 |
CK_RV m_GetMechanismList (CK_SLOT_ID slot, |
| 3254 |
CK_MECHANISM_TYPE_PTR mechs, |
| 3255 |
CK_ULONG_PTR count, |
| 3256 |
target_t target) ; |
| 3257 |
CK_RV m_GetMechanismInfo (CK_SLOT_ID slot, |
| 3258 |
CK_MECHANISM_TYPE mech, |
| 3259 |
CK_MECHANISM_INFO_PTR pmechinfo, |
| 3260 |
target_t target) ; |
| 3261 |
|
| 3262 |
CK_RV m_get_xcp_info (CK_VOID_PTR pinfo, CK_ULONG_PTR infbytes, |
| 3263 |
unsigned int query, |
| 3264 |
unsigned int subquery, |
| 3265 |
target_t target) ; |
| 3266 |
|
| 3267 |
// see also: CK_IBM_XCPQUERY_t |
| 3268 |
|
| 3269 |
CK_RV m_EncryptInit (unsigned char *state, size_t *slen, |
| 3270 |
CK_MECHANISM_PTR pmech, |
| 3271 |
const unsigned char *key, size_t klen, |
| 3272 |
target_t target) ; |
| 3273 |
CK_RV m_DecryptInit (unsigned char *state, size_t *slen, |
| 3274 |
CK_MECHANISM_PTR pmech, |
| 3275 |
const unsigned char *key, size_t klen, |
| 3276 |
target_t target) ; |
| 3277 |
/**/ |
| 3278 |
CK_RV m_EncryptUpdate (unsigned char *state, size_t slen, |
| 3279 |
CK_BYTE_PTR plain, CK_ULONG plen, |
| 3280 |
CK_BYTE_PTR cipher, CK_ULONG_PTR clen, |
| 3281 |
target_t target) ; |
| 3282 |
CK_RV m_DecryptUpdate (unsigned char *state, size_t slen, |
| 3283 |
CK_BYTE_PTR cipher, CK_ULONG clen, |
| 3284 |
CK_BYTE_PTR plain, CK_ULONG_PTR plen, |
| 3285 |
target_t target) ; |
| 3286 |
/**/ |
| 3287 |
/* one-pass en/decrypt with key blob */ |
| 3288 |
CK_RV m_Encrypt (const unsigned char *state, size_t slen, |
| 3289 |
CK_BYTE_PTR plain, CK_ULONG plen, |
| 3290 |
CK_BYTE_PTR cipher, CK_ULONG_PTR clen, |
| 3291 |
target_t target) ; |
| 3292 |
CK_RV m_Decrypt (const unsigned char *state, size_t slen, |
| 3293 |
CK_BYTE_PTR cipher, CK_ULONG clen, |
| 3294 |
CK_BYTE_PTR plain, CK_ULONG_PTR plen, |
| 3295 |
target_t target) ; |
| 3296 |
/**/ |
| 3297 |
CK_RV m_EncryptFinal (const unsigned char *state, size_t slen, |
| 3298 |
CK_BYTE_PTR output, CK_ULONG_PTR len, |
| 3299 |
target_t target) ; |
| 3300 |
CK_RV m_DecryptFinal (const unsigned char *state, size_t slen, |
| 3301 |
CK_BYTE_PTR output, CK_ULONG_PTR len, |
| 3302 |
target_t target) ; |
| 3303 |
/**/ |
| 3304 |
/* en/decrypt directly with key blob */ |
| 3305 |
CK_RV m_EncryptSingle (const unsigned char *key, size_t klen, |
| 3306 |
CK_MECHANISM_PTR mech, |
| 3307 |
CK_BYTE_PTR plain, CK_ULONG plen, |
| 3308 |
CK_BYTE_PTR cipher, CK_ULONG_PTR clen, |
| 3309 |
target_t target) ; |
| 3310 |
CK_RV m_DecryptSingle (const unsigned char *key, size_t klen, |
| 3311 |
CK_MECHANISM_PTR mech, |
| 3312 |
CK_BYTE_PTR cipher, CK_ULONG clen, |
| 3313 |
CK_BYTE_PTR plain, CK_ULONG_PTR plen, |
| 3314 |
target_t target) ; |
| 3315 |
/**/ |
| 3316 |
/* de+encrypt in one pass, without exposing cleartext */ |
| 3317 |
CK_RV m_ReencryptSingle (const unsigned char *dkey, size_t dklen, |
| 3318 |
const unsigned char *ekey, size_t eklen, |
| 3319 |
CK_MECHANISM_PTR pdecrmech, |
| 3320 |
CK_MECHANISM_PTR pencrmech, |
| 3321 |
CK_BYTE_PTR in, CK_ULONG ilen, |
| 3322 |
CK_BYTE_PTR out, CK_ULONG_PTR olen, |
| 3323 |
target_t target) ; |
| 3324 |
|
| 3325 |
CK_RV m_SignInit (unsigned char *state, size_t *slen, |
| 3326 |
CK_MECHANISM_PTR alg, |
| 3327 |
const unsigned char *key, size_t klen, |
| 3328 |
target_t target) ; |
| 3329 |
CK_RV m_VerifyInit (unsigned char *state, size_t *slen, |
| 3330 |
CK_MECHANISM_PTR alg, |
| 3331 |
const unsigned char *key, size_t klen, |
| 3332 |
target_t target) ; |
| 3333 |
/**/ |
| 3334 |
CK_RV m_SignUpdate (unsigned char *state, size_t slen, |
| 3335 |
CK_BYTE_PTR data, CK_ULONG dlen, |
| 3336 |
target_t target) ; |
| 3337 |
CK_RV m_VerifyUpdate (unsigned char *state, size_t slen, |
| 3338 |
CK_BYTE_PTR data, CK_ULONG dlen, |
| 3339 |
target_t target) ; |
| 3340 |
/**/ |
| 3341 |
CK_RV m_SignFinal (const unsigned char *state, size_t stlen, |
| 3342 |
CK_BYTE_PTR sig, CK_ULONG_PTR siglen, |
| 3343 |
target_t target) ; |
| 3344 |
CK_RV m_VerifyFinal (const unsigned char *state, size_t stlen, |
| 3345 |
CK_BYTE_PTR sig, CK_ULONG siglen, |
| 3346 |
target_t target) ; |
| 3347 |
/**/ |
| 3348 |
CK_RV m_Sign (const unsigned char *state, size_t stlen, |
| 3349 |
CK_BYTE_PTR data, CK_ULONG dlen, |
| 3350 |
CK_BYTE_PTR sig, CK_ULONG_PTR siglen, |
| 3351 |
target_t target) ; |
| 3352 |
CK_RV m_Verify (const unsigned char *state, size_t stlen, |
| 3353 |
CK_BYTE_PTR data, CK_ULONG dlen, |
| 3354 |
CK_BYTE_PTR sig, CK_ULONG siglen, |
| 3355 |
target_t target) ; |
| 3356 |
/**/ |
| 3357 |
CK_RV m_SignSingle (const unsigned char *key, size_t klen, |
| 3358 |
CK_MECHANISM_PTR pmech, |
| 3359 |
CK_BYTE_PTR data, CK_ULONG dlen, |
| 3360 |
CK_BYTE_PTR sig, CK_ULONG_PTR slen, |
| 3361 |
target_t target) ; |
| 3362 |
CK_RV m_VerifySingle (const unsigned char *key, size_t klen, |
| 3363 |
CK_MECHANISM_PTR pmech, |
| 3364 |
CK_BYTE_PTR data, CK_ULONG dlen, |
| 3365 |
CK_BYTE_PTR sig, CK_ULONG slen, |
| 3366 |
target_t target) ; |
| 3367 |
|
| 3368 |
// m_wire() by default removes transport headers of responses (CPRB header etc.) |
| 3369 |
// setting to prevent stripping: |
| 3370 |
// |
| 3371 |
#define XCP_CHN_RETURN_RAW 1 /* return raw wire response, w/headers */ |
| 3372 |
#define XCP_CHN_HIGH_PRIORITY 2 /* please note: Not all backends */ |
| 3373 |
#define XCP_CHN_MEDIUM_PRIORITY 4 /* support channel priority mgmt */ |
| 3374 |
#define XCP_CHN_NODEV_LOG_SKIP 8 /* do not log if no device is found */ |
| 3375 |
#define XCP_CHN_PARSE_IRV 0x10 |
| 3376 |
|
| 3377 |
/*-------------------------------------------------------------------------- |
| 3378 |
* direct interface without wire formatting & parsing. |
| 3379 |
*/ |
| 3380 |
CK_RV m_wire (unsigned char *rsp, size_t *rsplen, CK_RV *irv, |
| 3381 |
const unsigned char *req, size_t reqlen, |
| 3382 |
unsigned int flags, |
| 3383 |
target_t target) ; |
| 3384 |
|
| 3385 |
// options allowed within flags |
| 3386 |
#define XCP_W_NO_SEND_CPRB 1 /* data already includes request header */ |
| 3387 |
#define XCP_W_NO_RECV_CPRB 2 /* leave transport header in response */ |
| 3388 |
|
| 3389 |
// initializes the library |
| 3390 |
int m_init(void); |
| 3391 |
// shutting down the library |
| 3392 |
int m_shutdown(void); |
| 3393 |
|
| 3394 |
|
| 3395 |
|
| 3396 |
/*-- build identification ------------------------------------------------*/ |
| 3397 |
|
| 3398 |
#define XCP_BUILD_ID 0x3942f3bb |
| 3399 |
#define XCP_BUILD_DATE 0x20250923 /* UTC */ |
| 3400 |
#define XCP_BUILD_TIME 0x083816 /* UTC */ |
| 3401 |
|
| 3402 |
/*--------------------------------------------------------------------------*/ |
| 3403 |
#define __XCP_REASONCODES_H__ 1 |
| 3404 |
|
| 3405 |
|
| 3406 |
typedef enum { |
| 3407 |
XCP_RSC_NO_IMPORTER = 1, /* targeted domain has no importer private key */ |
| 3408 |
XCP_RSC_NO_KEYPARTS = 2, /* import WK request without keypart SEQUENCEs */ |
| 3409 |
XCP_RSC_IMPR_CMDBLK_BER = 3, /* embedded keyparts' BER envelope invalid */ |
| 3410 |
XCP_RSC_IMPR_CMDBLK_FIELDS = 4, /* command block BER structure (field count) invalid */ |
| 3411 |
XCP_RSC_IMPR_CMDBLK_FIELDCOUNT = 5, /* command block field count invalid */ |
| 3412 |
XCP_RSC_IMPR_EMBEDDED_FN = 6, /* embedded admin request (external) with invalid/non-m_admin() function identifier */ |
| 3413 |
XCP_RSC_IMPR_DOMAIN_DIFF = 7, /* internal block (within import WK) with different targeted domain */ |
| 3414 |
XCP_RSC_IMPR_NO_INT_CMDBLK = 8, /* import internal keypart SEQUENCE without command block */ |
| 3415 |
XCP_RSC_IMPR_NO_INT_SIGNATURE = 9, /* import internal keypart SEQUENCE without signature */ |
| 3416 |
XCP_RSC_IMPR_BAD_CMDBLK_BER = 10, /* import internal keypart SEQUENCE without signature */ |
| 3417 |
XCP_RSC_CMD_EMBEDDED_FN = 11, /* admin command block with invalid function identifier */ |
| 3418 |
XCP_RSC_CMD_DOMAIN_RANGE = 12, /* requested domain index is out of range */ |
| 3419 |
XCP_RSC_DOMAIN_INST_FMT = 13, /* domain instance malformed, or non-zero for card service */ |
| 3420 |
XCP_RSC_DOMAIN_INST_MISMATCH = 14, /* domain instance does not match that of domain */ |
| 3421 |
XCP_RSC_MODULE_INST_FMT = 15, /* module serialnumber/instance malformed */ |
| 3422 |
XCP_RSC_MODULE_INST_MISMATCH = 16, /* module instance does not match that of domain */ |
| 3423 |
XCP_RSC_MODULE_SERNO_MISMATCH = 17, /* module serial number does not match that of module */ |
| 3424 |
XCP_RSC_TCTR_FMT = 18, /* transaction counter malformed (for this service) */ |
| 3425 |
XCP_RSC_TCTR_VALUE = 19, /* transaction counter value invalid (already passed) */ |
| 3426 |
XCP_RSC_DOMAIN_INST_DIFF = 20, /* internal block domain instance (within import WK) differs from external one */ |
| 3427 |
XCP_RSC_SIGS_INSUFFICIENT = 21, /* not enough signatures for requested admin service */ |
| 3428 |
XCP_RSC_SIGS_REJECTED = 22, /* at least one signature has been rejected */ |
| 3429 |
XCP_RSC_RCPTINFO_FMT = 23, /* recipientInfo SEQUENCE malformed */ |
| 3430 |
XCP_RSC_RCPTINFO_ENCRD_SIZE = 24, /* encrypted keypart size invalid */ |
| 3431 |
XCP_RSC_RCPTINFO_ECDH_SRC = 25, /* ECDH failed (possibly invalid originator point) */ |
| 3432 |
XCP_RSC_RCPTINFO_KDF_SHARED = 26, /* ECDH sharedinfo parameters are invalid */ |
| 3433 |
XCP_RSC_RCPTINFO_KDF = 27, /* ECDH key derivation failed */ |
| 3434 |
XCP_RSC_RCPTINFO_KEY_SIZE = 28, /* derived/recovered key size invalid */ |
| 3435 |
XCP_RSC_RCPTINFO_KEY_MIXMODE = 29, /* standalone and full-key keyparts mixed (keyparts both with and without full-key VP) */ |
| 3436 |
XCP_RSC_RCPTINFO_KEY_VPS_DIFF = 30, /* keypart full-key VPs are not identical */ |
| 3437 |
XCP_RSC_RCPTINFO_KEY_VPS_MISMATCH = 31, /* reassembled key VP differs from those within keyparts */ |
| 3438 |
XCP_RSC_SKI_MALFORMED = 32, /* admin key SKI bytecount is invalid */ |
| 3439 |
XCP_RSC_SKI_NOT_FOUND = 33, /* admin key SKI bytecount is not present */ |
| 3440 |
XCP_RSC_MODE_IMPRINT = 34, /* service not available in imprint mode */ |
| 3441 |
XCP_RSC_MODE_NONIMPRINT = 35, /* service not available when no longer in imprint mode */ |
| 3442 |
XCP_RSC_IMPRINT_EXIT_INVD = 36, /* attempt to leave imprint mode is not permitted */ |
| 3443 |
XCP_RSC_CP_MODE_SET = 37, /* activating one or more CP bits is not allowed (operational mode) */ |
| 3444 |
XCP_RSC_SKI_FOUND = 38, /* SKI is already registered, may not be repeatedly logged in */ |
| 3445 |
XCP_RSC_ADMINLIST_FULL = 39, /* no more SKIs may be registered */ |
| 3446 |
XCP_RSC_CERT_FMT = 40, /* certificate not recognized as X.509 one */ |
| 3447 |
XCP_RSC_ATTRS_FMT = 41, /* packed attributes' size is invalid */ |
| 3448 |
XCP_RSC_ATTRS_TYPE_INVALID = 42, /* unsupported attribute (index) specified */ |
| 3449 |
XCP_RSC_ATTRS_REPEAT = 43, /* attribute (index) repeats */ |
| 3450 |
XCP_RSC_CPS_FMT = 44, /* control point set (size) invalid */ |
| 3451 |
XCP_RSC_CPS_SET_INCONSISTENT = 45, /* specified control points are rejected */ |
| 3452 |
XCP_RSC_CPS_PREVENT_ADD = 46, /* policy prevents enabling the specified CP bits */ |
| 3453 |
XCP_RSC_CPS_PREVENT_DEL = 47, /* policy prevents disabling the specified CP bits */ |
| 3454 |
XCP_RSC_WK_MISMATCH = 48, /* indicated WK (verification pattern) is malformed/does not match targeted one */ |
| 3455 |
XCP_RSC_WK_MISSING = 49, /* service requires a WK, while none present */ |
| 3456 |
XCP_RSC_NEXT_WK_MISSING = 50, /* service requires next-WK, while none present */ |
| 3457 |
XCP_RSC_EC_IMPORT_SYMM = 51, /* can not use KDF-derived value as KEK */ |
| 3458 |
XCP_RSC_RANDOM_WK_PROHIBITED = 52, /* use of random WKs and next-WKs prohibited by policy */ |
| 3459 |
XCP_RSC_WKS_PRESENT = 53, /* presence of WK and pending WK prevents random-WK generation */ |
| 3460 |
XCP_RSC_IMPR_FIELD_SIZE = 54, /* invalid importer type (field length) */ |
| 3461 |
XCP_RSC_IMPORTER_INVD_TYPE = 55, /* requested importer type is unknown/unsupported */ |
| 3462 |
XCP_RSC_IMPR_REVOKE_ZERO = 56, /* not allowed to leave imprint mode with revoke threshold of 0 */ |
| 3463 |
XCP_RSC_IMPR_TOOMANY_SIGNERS = 57, /* attempting to set threshold to more than current signers */ |
| 3464 |
XCP_RSC_IMPR_TOOMANY_REVOKERS = 58, /* attempting to set revoke threshold to more than current signers */ |
| 3465 |
XCP_RSC_OAIDX_FIELD_SIZE = 59, /* invalid OA certificate index (field length) */ |
| 3466 |
XCP_RSC_OAIDX_INVALID = 60, /* OA certificate index out of range */ |
| 3467 |
XCP_RSC_FCV_NOT_PRESENT = 61, /* no FCV has been loaded */ |
| 3468 |
XCP_RSC_FCV_FMT = 62, /* FCV size/structure is invalid */ |
| 3469 |
XCP_RSC_FCV_DIFFERS = 63, /* different FCV is already present */ |
| 3470 |
XCP_RSC_COMMITTED_WK_MISSING = 64, /* service requires a committed pending WK, which is not present */ |
| 3471 |
XCP_RSC_IMPR_EMBEDDED_FN_FMT = 65, /* embedded admin request (external) with malformed function identifier (wrong size) */ |
| 3472 |
XCP_RSC_LOGOUT_BELOW_THRESHOLD = 66, /* attempted logout would decrease number of admins below signature or revocation threshold */ |
| 3473 |
XCP_RSC_LOGOUT_NO_SINGLE_SIGN = 67, /* attempted logout of second last admin but single sign not allowed */ |
| 3474 |
XCP_RSC_LOGOUT_LAST_ADMIN = 68, /* attempted logout of last admin */ |
| 3475 |
XCP_RSC_REACTIVATE_RO_ATTRS = 69, /* attempting to enable reset-only attribute/s */ |
| 3476 |
XCP_RSC_CHG_PROTECTED_ATTRS = 70, /* attempting to modify change-protected attribute/s */ |
| 3477 |
XCP_RSC_CHG_PROTECTED_THRESHOLD = 71, /* attempting to modify change-protected signing or revocation threshold */ |
| 3478 |
XCP_RSC_CHG_READONLY_ATTRS = 72, /* attempting to modify read-only attribute/s */ |
| 3479 |
XCP_RSC_INACTIVE_CHG_ATTRS = 73, /* attempting to modify attributes of inactive backend */ |
| 3480 |
XCP_RSC_CHG_ATTRS_PREVENTED = 74, /* attempting to modify attributes prevented by other setting */ |
| 3481 |
XCP_RSC_IMPR_MANY_KEYPARTS = 75, /* too many keyparts are present */ |
| 3482 |
XCP_RSC_LOWERING_SIGNERS_TO_ZERO = 76, /* lowering sign threshold to zero */ |
| 3483 |
XCP_RSC_LOWERING_REVOKERS_TO_ZERO = 77, /* lowering revoke threshold to zero */ |
| 3484 |
XCP_RSC_CHG_SIGNERS_TO_ONE_NO_1SIGN = 78, /* changing sign threshold to one but XCP_ADMP_1SIGN is not set */ |
| 3485 |
XCP_RSC_CHG_REVOKERS_TO_ONE_NO_1SIGN = 79, /* changing revoke threshold to one but XCP_ADMP_1SIGN is not set */ |
| 3486 |
XCP_RSC_IMPORT_WK_PROHIBITED = 80, /* import of WKs prohibited by policy */ |
| 3487 |
XCP_RSC_IMPR_SINGLE_KEYPART = 81, /* import attempted with single keypart, prohibited by policy */ |
| 3488 |
XCP_RSC_IMPR_CSP = 82, /* crypto operation failed during imported WK administration (should not happen) */ |
| 3489 |
XCP_RSC_QUERY_DMASK_VERSION = 83, /* unsupported domain-mask version */ |
| 3490 |
XCP_RSC_QUERY_DMASK_FMT = 84, /* domain-mask field format invalid */ |
| 3491 |
XCP_RSC_LEAVE_DOM_IMPR_CARD_STILL = 85, /* attempting to leave domain imprint mode but card is still in imprint mode */ |
| 3492 |
XCP_RSC_BLOB_REENCRYPT_REJECT = 86, /* blob to re-encrypt is rejected */ |
| 3493 |
XCP_RSC_TOO_MANY_SIGNERINFOS = 87, /* too many signerinfos present */ |
| 3494 |
XCP_RSC_NO_GLOBAL_CONTEXT = 88, /* no initialized global context */ |
| 3495 |
XCP_RSC_ATTRS_TOO_MANY = 89, /* too many attributes (index too high) */ |
| 3496 |
XCP_RSC_CP_SET_INVALID = 90, /* CP set invalid */ |
| 3497 |
XCP_RSC_RK_IDLEN_INVALID = 91, /* retained-key ID size not supported */ |
| 3498 |
XCP_RSC_RK_ID_INVALID = 92, /* retained-key ID not present */ |
| 3499 |
XCP_RSC_FILEID_UNKNOWN = 93, /* file identifier is beyond those recognized by the backend */ |
| 3500 |
XCP_RSC_FILEID_UNSUPPORTED = 94, /* recognized, conditionally present file ID is not supported by this backend */ |
| 3501 |
XCP_RSC_CPS_REJECTED_FCV = 95, /* requested set of control points conflicts with installed FCV */ |
| 3502 |
XCP_RSC_EXPR_KEYPART_LIMIT = 96, /* requested limit and KPH count inconsistent */ |
| 3503 |
XCP_RSC_EXPR_KEYPART_ZEROLIMIT = 97, /* requested nonzero KP reconstruction limit */ |
| 3504 |
XCP_RSC_EXPR_KEYPART_DIFF_LIMIT = 98, /* export: multiple, different KP reconstruction limits specified */ |
| 3505 |
XCP_RSC_EXPR_KEYPART_DIFF_COUNT = 99, /* export: conflicting keypart counts specified */ |
| 3506 |
XCP_RSC_EXPR_DOMMASK_DIFF = 100, /* export: conflicting domain masks specified */ |
| 3507 |
XCP_RSC_EXPR_INDEX_INVALID = 101, /* export: supplied keypart index repeats or is out of range */ |
| 3508 |
XCP_RSC_EXPR_CERT_INVALID = 102, /* export: supplied KPH certificate is not recognized/unsupported */ |
| 3509 |
XCP_RSC_IMPR_STATE_STRUCT = 103, /* import: state file missing, bytecount out of range, or file structure invalid */ |
| 3510 |
XCP_RSC_EXPR_AUTHCERT_INVALID = 104, /* export: supplied MCA certificate is not recognized/unsupported */ |
| 3511 |
XCP_RSC_IMPR_KEYPARTS_STRUCT = 105, /* import: keyparts missing, bytecount out of range, or file structure invalid */ |
| 3512 |
XCP_RSC_IMPR_STATE_REPEAT = 106, /* import: sections repeat with incompatible instances */ |
| 3513 |
XCP_RSC_IMPR_ENCR_ALG = 107, /* import: unsupported encryption algorithm or malformed auxiliary data */ |
| 3514 |
XCP_RSC_IMPR_FILESIG_INFRASTRUCTURE = 108, /* import: sections related to file-signature are missing, malformed or invalid */ |
| 3515 |
XCP_RSC_IMPR_FILESIG = 109, /* import: signature of the file is invalid (infrastructure has been verified) */ |
| 3516 |
XCP_RSC_EXPR_SINGLE_KEYPART = 110, /* export attempted with 1-of-N keypart/s, prohibited by policy */ |
| 3517 |
XCP_RSC_IMPR_KEYPARTS_REASSEMBLY = 111, /* import: reconstructing key from keyparts failed */ |
| 3518 |
XCP_RSC_IMPR_KEYPARTS_CONFLICT = 112, /* import: multiple keyparts present, with type/size conflicts */ |
| 3519 |
XCP_RSC_IMPR_ENCRD_DATA_DIFF = 113, /* import: multiple, conflicting encrypted state fields present */ |
| 3520 |
XCP_RSC_IMPR_ENCRD_DATA_STRUCT = 114, /* import: encrypted state field missing or size invalid */ |
| 3521 |
XCP_RSC_IMPR_ENCR_PARAMS = 115, /* import: encryption parameter (IV) missing */ |
| 3522 |
XCP_RSC_IMPR_ENCRD_CONSISTENCY = 116, /* import: encrypted state/integrity/structure invalid */ |
| 3523 |
XCP_RSC_BLOB_SETTRUST_REJECT = 117, /* blob to mark as TRUSTED is rejected */ |
| 3524 |
XCP_RSC_BLOB_SETCLK_FIELD = 118, /* time field malformed/missing */ |
| 3525 |
XCP_RSC_BLOB_SETCLK_TIME = 119, /* time field (UTC string) contents invalid */ |
| 3526 |
XCP_RSC_EXPR_SCOPE_INVALID = 120, /* export: scope restriction not recognized/unsupported */ |
| 3527 |
XCP_RSC_IMPR_SCOPE_INVALID = 121, /* import: scope restriction not recognized/unsupported */ |
| 3528 |
XCP_RSC_IMPR_SCOPE_DOM_RES_VIOLATION = 122, /* import: domain restricted scope but card sections present */ |
| 3529 |
XCP_RSC_IMPR_AMBIGUOUS_DOMAIN_SOURCE = 123, /* import: multiple exported domains for multi domain import */ |
| 3530 |
XCP_RSC_IMPR_MDOMAIN_IMPORT_MASK_INVALID = 124, /* import: invalid domain mask for multi domain import */ |
| 3531 |
XCP_RSC_IMPR_NO_CARD_IMPORTER = 125, /* import: no card importer key */ |
| 3532 |
XCP_RSC_IMPR_IMPORT_DOM_DATA_FAILED = 126, /* import: importing domain data failed */ |
| 3533 |
XCP_RSC_IMPR_IMPORT_DOM_WKS_FAILED = 127, /* import: importing domain WKs failed */ |
| 3534 |
XCP_RSC_IMPR_IMPORT_TGT_DOM_ZEROIZE_FAILED = 128, /* import: zeroize of target domain failed */ |
| 3535 |
XCP_RSC_AUDIT_QUERY_PAYLOAD_SIZE = 129, /* audit query: size of payload too small */ |
| 3536 |
XCP_RSC_AUDIT_QUERY_INVALID_INDEX = 130, /* audit query: invalid audit history index */ |
| 3537 |
XCP_RSC_EXPORT_WK_PROHIBITED = 131, /* export of WKs prohibited by policy */ |
| 3538 |
XCP_RSC_EXPORT_STATE_PROHIBITED = 132, /* export of state prohibited by policy */ |
| 3539 |
XCP_RSC_IMPORT_STATE_PROHIBITED = 133, /* import of state prohibited by policy */ |
| 3540 |
XCP_RSC_EXPORT_WK_UNAUTHORIZED = 134, /* Card admin attempted to export a DnD domain WK (empty dom admin exp.request?) */ |
| 3541 |
XCP_RSC_OA_SIG_POLICY_VIOLATION = 135, /* invalid OA signature config, at least one OA signature type must be enabled */ |
| 3542 |
XCP_RSC_OA_SIG_NOT_SUPPORTED = 136, /* requested OA signature type not supported/configured */ |
| 3543 |
XCP_RSC_ASN_FMT_INVALID = 137, /* invalid ASN.1 encoded format */ |
| 3544 |
XCP_RSC_CERT_TYPE_INVALID = 138, /* Certificate type invalid */ |
| 3545 |
XCP_RSC_ROLE_ID_INVALID = 139, /* Role ID invalid */ |
| 3546 |
XCP_RSC_ADM_SIG_POLICY_VIOLATION = 140, /* invalid ADM signature config, at least one ADM signature type must be enabled */ |
| 3547 |
XCP_RSC_KEY_STRENGTH_POLICY_VIOLATION = 141, /* invalid key strength configuration, a maximum of only one bit may be enabled */ |
| 3548 |
XCP_RSC_ADM_SIG_CHANGE_PROHIBITED = 142, /* ADM signature configuration change prohibited, not enough remaining admins to meet security */ |
| 3549 |
XCP_RSC_KEY_STRENGTH_CHANGE_PROHIBITED = 143, /* Key strength configuration change prohibited, not enough remaining admins to meet security */ |
| 3550 |
XCP_RSC_ADM_KTYPE_POLICY_VIOLATION = 144, /* invalid ADM key type config, inconsistent sig/key types or no key type enabled at all */ |
| 3551 |
XCP_RSC_ADM_KTYPE_CHANGE_PROHIBITED = 145, /* Key type configuration change prohibited, not enough remaining admins to meet security */ |
| 3552 |
XCP_RSC_ADM_SVC_ADMIN_POLICY_VIOLATION = 146, /* Changing security policy or thresholds prohibited, not enough svc admins to meet security */ |
| 3553 |
XCP_RSC_ADM_EP11_ADMIN_POLICY_VIOLATION = 147, /* Changing security policy or thresholds prohibited, not enough ep11 admins to meet security */ |
| 3554 |
XCP_RSC_CMD_NOT_ALLOWED_IN_INACTIVE_STATE = 148, /* Command rejected, card is in inactive state */ |
| 3555 |
XCP_RSC_MAX = XCP_RSC_CMD_NOT_ALLOWED_IN_INACTIVE_STATE |
| 3556 |
} XCP_ReasonCode_t ; |
| 3557 |
|
| 3558 |
|
| 3559 |
/* function identifiers must be consecutive, between: */ |
| 3560 |
#define __MIN_MOD_FNID 1 |
| 3561 |
#define __MAX_MOD_FNID 44 |
| 3562 |
/* selectively disabled functions within that range reported separately */ |
| 3563 |
|
| 3564 |
#define __FNID_Login 1 |
| 3565 |
#define __FNID_Logout 2 |
| 3566 |
#define __FNID_SeedRandom 3 |
| 3567 |
#define __FNID_GenerateRandom 4 |
| 3568 |
#define __FNID_DigestInit 5 |
| 3569 |
#define __FNID_DigestUpdate 6 |
| 3570 |
#define __FNID_DigestKey 7 |
| 3571 |
#define __FNID_DigestFinal 8 |
| 3572 |
#define __FNID_Digest 9 |
| 3573 |
#define __FNID_DigestSingle 10 |
| 3574 |
#define __FNID_EncryptInit 11 |
| 3575 |
#define __FNID_DecryptInit 12 |
| 3576 |
#define __FNID_EncryptUpdate 13 |
| 3577 |
#define __FNID_DecryptUpdate 14 |
| 3578 |
#define __FNID_EncryptFinal 15 |
| 3579 |
#define __FNID_DecryptFinal 16 |
| 3580 |
#define __FNID_Encrypt 17 |
| 3581 |
#define __FNID_Decrypt 18 |
| 3582 |
#define __FNID_EncryptSingle 19 |
| 3583 |
#define __FNID_DecryptSingle 20 |
| 3584 |
#define __FNID_GenerateKey 21 |
| 3585 |
#define __FNID_GenerateKeyPair 22 |
| 3586 |
#define __FNID_SignInit 23 |
| 3587 |
#define __FNID_SignUpdate 24 |
| 3588 |
#define __FNID_SignFinal 25 |
| 3589 |
#define __FNID_Sign 26 |
| 3590 |
#define __FNID_VerifyInit 27 |
| 3591 |
#define __FNID_VerifyUpdate 28 |
| 3592 |
#define __FNID_VerifyFinal 29 |
| 3593 |
#define __FNID_Verify 30 |
| 3594 |
#define __FNID_SignSingle 31 |
| 3595 |
#define __FNID_VerifySingle 32 |
| 3596 |
#define __FNID_WrapKey 33 |
| 3597 |
#define __FNID_UnwrapKey 34 |
| 3598 |
#define __FNID_DeriveKey 35 |
| 3599 |
#define __FNID_GetMechanismList 36 |
| 3600 |
#define __FNID_GetMechanismInfo 37 |
| 3601 |
#define __FNID_get_xcp_info 38 |
| 3602 |
#define __FNID_GetAttributeValue 39 |
| 3603 |
#define __FNID_SetAttributeValue 40 |
| 3604 |
#define __FNID_admin 41 |
| 3605 |
#define __FNID_ReencryptSingle 42 |
| 3606 |
#define __FNID_LoginExtended 43 |
| 3607 |
#define __FNID_LogoutExtended 44 |
| 3608 |
// |
| 3609 |
#define __FNID_NEXT_AVAILABLE 45 |
| 3610 |
// |
| 3611 |
#define __FNID_MAX __FNID_LogoutExtended |
| 3612 |
|
| 3613 |
|
| 3614 |
// |
| 3615 |
// 64 bit mask. See XCP__FNIDS_DW1 if more bits required (up to 128 bit) |
| 3616 |
#define XCP__FNIDS_BIT0 0x8000000000000000ULL |
| 3617 |
#define XCP__FNIDS_DW0 \ |
| 3618 |
( (XCP__FNIDS_BIT0) |\ |
| 3619 |
(XCP__FNIDS_BIT0 >> __FNID_Login) |\ |
| 3620 |
(XCP__FNIDS_BIT0 >> __FNID_Logout) |\ |
| 3621 |
(XCP__FNIDS_BIT0 >> __FNID_SeedRandom) |\ |
| 3622 |
(XCP__FNIDS_BIT0 >> __FNID_GenerateRandom) |\ |
| 3623 |
(XCP__FNIDS_BIT0 >> __FNID_DigestInit) |\ |
| 3624 |
(XCP__FNIDS_BIT0 >> __FNID_DigestUpdate) |\ |
| 3625 |
/*NOTE: FNID_DigestKey is not supported \ |
| 3626 |
(XCP__FNIDS_BIT0 >> __FNID_DigestKey) |\ |
| 3627 |
*/ \ |
| 3628 |
(XCP__FNIDS_BIT0 >> __FNID_DigestFinal) |\ |
| 3629 |
(XCP__FNIDS_BIT0 >> __FNID_Digest) |\ |
| 3630 |
(XCP__FNIDS_BIT0 >> __FNID_DigestSingle) |\ |
| 3631 |
(XCP__FNIDS_BIT0 >> __FNID_EncryptInit) |\ |
| 3632 |
(XCP__FNIDS_BIT0 >> __FNID_DecryptInit) |\ |
| 3633 |
(XCP__FNIDS_BIT0 >> __FNID_EncryptUpdate) |\ |
| 3634 |
(XCP__FNIDS_BIT0 >> __FNID_DecryptUpdate) |\ |
| 3635 |
(XCP__FNIDS_BIT0 >> __FNID_EncryptFinal) |\ |
| 3636 |
(XCP__FNIDS_BIT0 >> __FNID_DecryptFinal) |\ |
| 3637 |
(XCP__FNIDS_BIT0 >> __FNID_Encrypt) |\ |
| 3638 |
(XCP__FNIDS_BIT0 >> __FNID_Decrypt) |\ |
| 3639 |
(XCP__FNIDS_BIT0 >> __FNID_EncryptSingle) |\ |
| 3640 |
(XCP__FNIDS_BIT0 >> __FNID_DecryptSingle) |\ |
| 3641 |
(XCP__FNIDS_BIT0 >> __FNID_GenerateKey) |\ |
| 3642 |
(XCP__FNIDS_BIT0 >> __FNID_GenerateKeyPair) |\ |
| 3643 |
(XCP__FNIDS_BIT0 >> __FNID_SignInit) |\ |
| 3644 |
(XCP__FNIDS_BIT0 >> __FNID_SignUpdate) |\ |
| 3645 |
(XCP__FNIDS_BIT0 >> __FNID_SignFinal) |\ |
| 3646 |
(XCP__FNIDS_BIT0 >> __FNID_Sign) |\ |
| 3647 |
(XCP__FNIDS_BIT0 >> __FNID_VerifyInit) |\ |
| 3648 |
(XCP__FNIDS_BIT0 >> __FNID_VerifyUpdate) |\ |
| 3649 |
(XCP__FNIDS_BIT0 >> __FNID_VerifyFinal) |\ |
| 3650 |
(XCP__FNIDS_BIT0 >> __FNID_Verify) |\ |
| 3651 |
(XCP__FNIDS_BIT0 >> __FNID_SignSingle) |\ |
| 3652 |
(XCP__FNIDS_BIT0 >> __FNID_VerifySingle) |\ |
| 3653 |
(XCP__FNIDS_BIT0 >> __FNID_WrapKey) |\ |
| 3654 |
(XCP__FNIDS_BIT0 >> __FNID_UnwrapKey) |\ |
| 3655 |
(XCP__FNIDS_BIT0 >> __FNID_DeriveKey) |\ |
| 3656 |
(XCP__FNIDS_BIT0 >> __FNID_GetMechanismList) |\ |
| 3657 |
(XCP__FNIDS_BIT0 >> __FNID_GetMechanismInfo) |\ |
| 3658 |
(XCP__FNIDS_BIT0 >> __FNID_get_xcp_info) |\ |
| 3659 |
(XCP__FNIDS_BIT0 >> __FNID_GetAttributeValue) |\ |
| 3660 |
(XCP__FNIDS_BIT0 >> __FNID_SetAttributeValue) |\ |
| 3661 |
(XCP__FNIDS_BIT0 >> __FNID_admin) |\ |
| 3662 |
(XCP__FNIDS_BIT0 >> __FNID_ReencryptSingle) |\ |
| 3663 |
(XCP__FNIDS_BIT0 >> __FNID_LoginExtended) |\ |
| 3664 |
(XCP__FNIDS_BIT0 >> __FNID_LogoutExtended)) |
| 3665 |
|
| 3666 |
// used for the module query, see CK_IBM_XCPMSQ_FNLIST |
| 3667 |
#define XCP__FNIDS_DW1 0 |
| 3668 |
|
| 3669 |
|
| 3670 |
/* maximum nr of non-system parameters: */ |
| 3671 |
#define __HOST2MOD_DATAPRM 9 |
| 3672 |
#define __MOD2HOST_DATAPRM 2 |
| 3673 |
|
| 3674 |
|
| 3675 |
#endif /* n defined(XCP_H__) */ |
| 3676 |
|