|
294 | 294 | #define PSA_KEY_TYPE_VENDOR_FLAG ((psa_key_type_t)0x8000)
|
295 | 295 |
|
296 | 296 | #define PSA_KEY_TYPE_CATEGORY_MASK ((psa_key_type_t)0x7000)
|
297 |
| -#define PSA_KEY_TYPE_CATEGORY_SYMMETRIC ((psa_key_type_t)0x4000) |
298 |
| -#define PSA_KEY_TYPE_CATEGORY_RAW ((psa_key_type_t)0x5000) |
299 |
| -#define PSA_KEY_TYPE_CATEGORY_PUBLIC_KEY ((psa_key_type_t)0x6000) |
| 297 | +#define PSA_KEY_TYPE_CATEGORY_RAW ((psa_key_type_t)0x1000) |
| 298 | +#define PSA_KEY_TYPE_CATEGORY_SYMMETRIC ((psa_key_type_t)0x2000) |
| 299 | +#define PSA_KEY_TYPE_CATEGORY_PUBLIC_KEY ((psa_key_type_t)0x4000) |
300 | 300 | #define PSA_KEY_TYPE_CATEGORY_KEY_PAIR ((psa_key_type_t)0x7000)
|
301 | 301 |
|
302 |
| -#define PSA_KEY_TYPE_CATEGORY_FLAG_PAIR ((psa_key_type_t)0x1000) |
| 302 | +#define PSA_KEY_TYPE_CATEGORY_FLAG_PAIR ((psa_key_type_t)0x3000) |
303 | 303 |
|
304 | 304 | /** Whether a key type is vendor-defined.
|
305 | 305 | *
|
|
313 | 313 | * This encompasses both symmetric keys and non-key data.
|
314 | 314 | */
|
315 | 315 | #define PSA_KEY_TYPE_IS_UNSTRUCTURED(type) \
|
316 |
| - (((type) & PSA_KEY_TYPE_CATEGORY_MASK & ~(psa_key_type_t)0x1000) == \ |
317 |
| - PSA_KEY_TYPE_CATEGORY_SYMMETRIC) |
| 316 | + (((type) & PSA_KEY_TYPE_CATEGORY_MASK) == PSA_KEY_TYPE_CATEGORY_RAW || \ |
| 317 | + ((type) & PSA_KEY_TYPE_CATEGORY_MASK) == PSA_KEY_TYPE_CATEGORY_SYMMETRIC) |
318 | 318 |
|
319 | 319 | /** Whether a key type is asymmetric: either a key pair or a public key. */
|
320 | 320 | #define PSA_KEY_TYPE_IS_ASYMMETRIC(type) \
|
|
357 | 357 | *
|
358 | 358 | * A "key" of this type cannot be used for any cryptographic operation.
|
359 | 359 | * Applications may use this type to store arbitrary data in the keystore. */
|
360 |
| -#define PSA_KEY_TYPE_RAW_DATA ((psa_key_type_t)0x5001) |
| 360 | +#define PSA_KEY_TYPE_RAW_DATA ((psa_key_type_t)0x1001) |
361 | 361 |
|
362 | 362 | /** HMAC key.
|
363 | 363 | *
|
|
367 | 367 | * HMAC keys should generally have the same size as the underlying hash.
|
368 | 368 | * This size can be calculated with #PSA_HASH_SIZE(\c alg) where
|
369 | 369 | * \c alg is the HMAC algorithm or the underlying hash algorithm. */
|
370 |
| -#define PSA_KEY_TYPE_HMAC ((psa_key_type_t)0x5100) |
| 370 | +#define PSA_KEY_TYPE_HMAC ((psa_key_type_t)0x1100) |
371 | 371 |
|
372 | 372 | /** A secret for key derivation.
|
373 | 373 | *
|
374 | 374 | * The key policy determines which key derivation algorithm the key
|
375 | 375 | * can be used for.
|
376 | 376 | */
|
377 |
| -#define PSA_KEY_TYPE_DERIVE ((psa_key_type_t)0x5200) |
| 377 | +#define PSA_KEY_TYPE_DERIVE ((psa_key_type_t)0x1200) |
378 | 378 |
|
379 | 379 | /** Key for a cipher, AEAD or MAC algorithm based on the AES block cipher.
|
380 | 380 | *
|
381 | 381 | * The size of the key can be 16 bytes (AES-128), 24 bytes (AES-192) or
|
382 | 382 | * 32 bytes (AES-256).
|
383 | 383 | */
|
384 |
| -#define PSA_KEY_TYPE_AES ((psa_key_type_t)0x4402) |
| 384 | +#define PSA_KEY_TYPE_AES ((psa_key_type_t)0x2400) |
385 | 385 |
|
386 | 386 | /** Key for a cipher or MAC algorithm based on DES or 3DES (Triple-DES).
|
387 | 387 | *
|
|
392 | 392 | * deprecated and should only be used to decrypt legacy data. 3-key 3DES
|
393 | 393 | * is weak and deprecated and should only be used in legacy protocols.
|
394 | 394 | */
|
395 |
| -#define PSA_KEY_TYPE_DES ((psa_key_type_t)0x4302) |
| 395 | +#define PSA_KEY_TYPE_DES ((psa_key_type_t)0x2301) |
396 | 396 |
|
397 | 397 | /** Key for a cipher, AEAD or MAC algorithm based on the
|
398 | 398 | * Camellia block cipher. */
|
399 |
| -#define PSA_KEY_TYPE_CAMELLIA ((psa_key_type_t)0x4404) |
| 399 | +#define PSA_KEY_TYPE_CAMELLIA ((psa_key_type_t)0x2403) |
400 | 400 |
|
401 | 401 | /** Key for the RC4 stream cipher.
|
402 | 402 | *
|
403 | 403 | * Note that RC4 is weak and deprecated and should only be used in
|
404 | 404 | * legacy protocols. */
|
405 |
| -#define PSA_KEY_TYPE_ARC4 ((psa_key_type_t)0x4002) |
| 405 | +#define PSA_KEY_TYPE_ARC4 ((psa_key_type_t)0x2002) |
406 | 406 |
|
407 | 407 | /** Key for the ChaCha20 stream cipher or the Chacha20-Poly1305 AEAD algorithm.
|
408 | 408 | *
|
|
411 | 411 | * Implementations must support 12-byte nonces, may support 8-byte nonces,
|
412 | 412 | * and should reject other sizes.
|
413 | 413 | */
|
414 |
| -#define PSA_KEY_TYPE_CHACHA20 ((psa_key_type_t)0x4004) |
| 414 | +#define PSA_KEY_TYPE_CHACHA20 ((psa_key_type_t)0x2004) |
415 | 415 |
|
416 | 416 | /** RSA public key. */
|
417 |
| -#define PSA_KEY_TYPE_RSA_PUBLIC_KEY ((psa_key_type_t)0x6002) |
| 417 | +#define PSA_KEY_TYPE_RSA_PUBLIC_KEY ((psa_key_type_t)0x4001) |
418 | 418 | /** RSA key pair (private and public key). */
|
419 |
| -#define PSA_KEY_TYPE_RSA_KEY_PAIR ((psa_key_type_t)0x7002) |
| 419 | +#define PSA_KEY_TYPE_RSA_KEY_PAIR ((psa_key_type_t)0x7001) |
420 | 420 | /** Whether a key type is an RSA key (pair or public-only). */
|
421 | 421 | #define PSA_KEY_TYPE_IS_RSA(type) \
|
422 | 422 | (PSA_KEY_TYPE_PUBLIC_KEY_OF_KEY_PAIR(type) == PSA_KEY_TYPE_RSA_PUBLIC_KEY)
|
423 | 423 |
|
424 |
| -#define PSA_KEY_TYPE_ECC_PUBLIC_KEY_BASE ((psa_key_type_t)0x6100) |
| 424 | +#define PSA_KEY_TYPE_ECC_PUBLIC_KEY_BASE ((psa_key_type_t)0x4100) |
425 | 425 | #define PSA_KEY_TYPE_ECC_KEY_PAIR_BASE ((psa_key_type_t)0x7100)
|
426 | 426 | #define PSA_KEY_TYPE_ECC_CURVE_MASK ((psa_key_type_t)0x00ff)
|
427 | 427 | /** Elliptic curve key pair.
|
|
466 | 466 | * _SEC 2: Recommended Elliptic Curve Domain Parameters_.
|
467 | 467 | * https://www.secg.org/sec2-v2.pdf
|
468 | 468 | */
|
469 |
| -#define PSA_ECC_CURVE_SECP_K1 ((psa_ecc_curve_t) 0x16) |
| 469 | +#define PSA_ECC_CURVE_SECP_K1 ((psa_ecc_curve_t) 0x17) |
470 | 470 |
|
471 | 471 | /** SEC random curves over prime fields.
|
472 | 472 | *
|
|
478 | 478 | */
|
479 | 479 | #define PSA_ECC_CURVE_SECP_R1 ((psa_ecc_curve_t) 0x12)
|
480 | 480 | /* SECP160R2 (SEC2 v1, obsolete) */
|
481 |
| -#define PSA_ECC_CURVE_SECP_R2 ((psa_ecc_curve_t) 0x1a) |
| 481 | +#define PSA_ECC_CURVE_SECP_R2 ((psa_ecc_curve_t) 0x1b) |
482 | 482 |
|
483 | 483 | /** SEC Koblitz curves over binary fields.
|
484 | 484 | *
|
|
488 | 488 | * _SEC 2: Recommended Elliptic Curve Domain Parameters_.
|
489 | 489 | * https://www.secg.org/sec2-v2.pdf
|
490 | 490 | */
|
491 |
| -#define PSA_ECC_CURVE_SECT_K1 ((psa_ecc_curve_t) 0x26) |
| 491 | +#define PSA_ECC_CURVE_SECT_K1 ((psa_ecc_curve_t) 0x27) |
492 | 492 |
|
493 | 493 | /** SEC random curves over binary fields.
|
494 | 494 | *
|
|
508 | 508 | * _SEC 2: Recommended Elliptic Curve Domain Parameters_.
|
509 | 509 | * https://www.secg.org/sec2-v2.pdf
|
510 | 510 | */
|
511 |
| -#define PSA_ECC_CURVE_SECT_R2 ((psa_ecc_curve_t) 0x2a) |
| 511 | +#define PSA_ECC_CURVE_SECT_R2 ((psa_ecc_curve_t) 0x2b) |
512 | 512 |
|
513 | 513 | /** Brainpool P random curves.
|
514 | 514 | *
|
|
529 | 529 | * _Ed448-Goldilocks, a new elliptic curve_, NIST ECC Workshop, 2015.
|
530 | 530 | * The algorithm #PSA_ALG_ECDH performs X448 when used with this curve.
|
531 | 531 | */
|
532 |
| -#define PSA_ECC_CURVE_XED ((psa_ecc_curve_t) 0x40) |
| 532 | +#define PSA_ECC_CURVE_XED ((psa_ecc_curve_t) 0x41) |
533 | 533 |
|
534 |
| -#define PSA_KEY_TYPE_DH_PUBLIC_KEY_BASE ((psa_key_type_t)0x6200) |
| 534 | +#define PSA_KEY_TYPE_DH_PUBLIC_KEY_BASE ((psa_key_type_t)0x4200) |
535 | 535 | #define PSA_KEY_TYPE_DH_KEY_PAIR_BASE ((psa_key_type_t)0x7200)
|
536 | 536 | #define PSA_KEY_TYPE_DH_GROUP_MASK ((psa_key_type_t)0x00ff)
|
537 | 537 | /** Diffie-Hellman key pair.
|
|
574 | 574 | * 2048, 3072, 4096, 6144, 8192. A given implementation may support
|
575 | 575 | * all of these sizes or only a subset.
|
576 | 576 | */
|
577 |
| -#define PSA_DH_GROUP_RFC7919 ((psa_dh_group_t) 0x02) |
| 577 | +#define PSA_DH_GROUP_RFC7919 ((psa_dh_group_t) 0x03) |
578 | 578 |
|
579 | 579 | #define PSA_GET_KEY_TYPE_BLOCK_SIZE_EXPONENT(type) \
|
580 | 580 | (((type) >> 8) & 7)
|
|
0 commit comments