|
282 | 282 | *
|
283 | 283 | * Zero is not the encoding of any key type.
|
284 | 284 | */
|
285 |
| -#define PSA_KEY_TYPE_NONE ((psa_key_type_t)0x00000000) |
| 285 | +#define PSA_KEY_TYPE_NONE ((psa_key_type_t)0x0000) |
286 | 286 |
|
287 | 287 | /** Vendor-defined key type flag.
|
288 | 288 | *
|
|
291 | 291 | * must use an encoding with the #PSA_KEY_TYPE_VENDOR_FLAG bit set and should
|
292 | 292 | * respect the bitwise structure used by standard encodings whenever practical.
|
293 | 293 | */
|
294 |
| -#define PSA_KEY_TYPE_VENDOR_FLAG ((psa_key_type_t)0x80000000) |
| 294 | +#define PSA_KEY_TYPE_VENDOR_FLAG ((psa_key_type_t)0x8000) |
295 | 295 |
|
296 |
| -#define PSA_KEY_TYPE_CATEGORY_MASK ((psa_key_type_t)0x70000000) |
297 |
| -#define PSA_KEY_TYPE_CATEGORY_SYMMETRIC ((psa_key_type_t)0x40000000) |
298 |
| -#define PSA_KEY_TYPE_CATEGORY_RAW ((psa_key_type_t)0x50000000) |
299 |
| -#define PSA_KEY_TYPE_CATEGORY_PUBLIC_KEY ((psa_key_type_t)0x60000000) |
300 |
| -#define PSA_KEY_TYPE_CATEGORY_KEY_PAIR ((psa_key_type_t)0x70000000) |
| 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) |
| 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)0x10000000) |
| 302 | +#define PSA_KEY_TYPE_CATEGORY_FLAG_PAIR ((psa_key_type_t)0x1000) |
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)0x10000000) == \ |
| 316 | + (((type) & PSA_KEY_TYPE_CATEGORY_MASK & ~(psa_key_type_t)0x1000) == \ |
317 | 317 | PSA_KEY_TYPE_CATEGORY_SYMMETRIC)
|
318 | 318 |
|
319 | 319 | /** Whether a key type is asymmetric: either a key pair or a public key. */
|
|
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)0x50010000) |
| 360 | +#define PSA_KEY_TYPE_RAW_DATA ((psa_key_type_t)0x5001) |
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)0x51000000) |
| 370 | +#define PSA_KEY_TYPE_HMAC ((psa_key_type_t)0x5100) |
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)0x52000000) |
| 377 | +#define PSA_KEY_TYPE_DERIVE ((psa_key_type_t)0x5200) |
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)0x44020000) |
| 384 | +#define PSA_KEY_TYPE_AES ((psa_key_type_t)0x4402) |
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)0x43020000) |
| 395 | +#define PSA_KEY_TYPE_DES ((psa_key_type_t)0x4302) |
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)0x44040000) |
| 399 | +#define PSA_KEY_TYPE_CAMELLIA ((psa_key_type_t)0x4404) |
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)0x40020000) |
| 405 | +#define PSA_KEY_TYPE_ARC4 ((psa_key_type_t)0x4002) |
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)0x40040000) |
| 414 | +#define PSA_KEY_TYPE_CHACHA20 ((psa_key_type_t)0x4004) |
415 | 415 |
|
416 | 416 | /** RSA public key. */
|
417 |
| -#define PSA_KEY_TYPE_RSA_PUBLIC_KEY ((psa_key_type_t)0x60020000) |
| 417 | +#define PSA_KEY_TYPE_RSA_PUBLIC_KEY ((psa_key_type_t)0x6002) |
418 | 418 | /** RSA key pair (private and public key). */
|
419 |
| -#define PSA_KEY_TYPE_RSA_KEY_PAIR ((psa_key_type_t)0x70020000) |
| 419 | +#define PSA_KEY_TYPE_RSA_KEY_PAIR ((psa_key_type_t)0x7002) |
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)0x61000000) |
425 |
| -#define PSA_KEY_TYPE_ECC_KEY_PAIR_BASE ((psa_key_type_t)0x71000000) |
426 |
| -#define PSA_KEY_TYPE_ECC_CURVE_MASK ((psa_key_type_t)0x00ffffff) |
| 424 | +#define PSA_KEY_TYPE_ECC_PUBLIC_KEY_BASE ((psa_key_type_t)0x6100) |
| 425 | +#define PSA_KEY_TYPE_ECC_KEY_PAIR_BASE ((psa_key_type_t)0x7100) |
| 426 | +#define PSA_KEY_TYPE_ECC_CURVE_MASK ((psa_key_type_t)0x00ff) |
427 | 427 | /** Elliptic curve key pair.
|
428 | 428 | *
|
429 | 429 | * \param curve A value of type ::psa_ecc_curve_t that identifies the
|
|
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) 0x160000) |
| 469 | +#define PSA_ECC_CURVE_SECP_K1 ((psa_ecc_curve_t) 0x16) |
470 | 470 |
|
471 | 471 | /** SEC random curves over prime fields.
|
472 | 472 | *
|
|
476 | 476 | * _SEC 2: Recommended Elliptic Curve Domain Parameters_.
|
477 | 477 | * https://www.secg.org/sec2-v2.pdf
|
478 | 478 | */
|
479 |
| -#define PSA_ECC_CURVE_SECP_R1 ((psa_ecc_curve_t) 0x120000) |
| 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) 0x1a0000) |
| 481 | +#define PSA_ECC_CURVE_SECP_R2 ((psa_ecc_curve_t) 0x1a) |
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) 0x260000) |
| 491 | +#define PSA_ECC_CURVE_SECT_K1 ((psa_ecc_curve_t) 0x26) |
492 | 492 |
|
493 | 493 | /** SEC random curves over binary fields.
|
494 | 494 | *
|
|
498 | 498 | * _SEC 2: Recommended Elliptic Curve Domain Parameters_.
|
499 | 499 | * https://www.secg.org/sec2-v2.pdf
|
500 | 500 | */
|
501 |
| -#define PSA_ECC_CURVE_SECT_R1 ((psa_ecc_curve_t) 0x220000) |
| 501 | +#define PSA_ECC_CURVE_SECT_R1 ((psa_ecc_curve_t) 0x22) |
502 | 502 |
|
503 | 503 | /** SEC additional random curves over binary fields.
|
504 | 504 | *
|
|
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) 0x2a0000) |
| 511 | +#define PSA_ECC_CURVE_SECT_R2 ((psa_ecc_curve_t) 0x2a) |
512 | 512 |
|
513 | 513 | /** Brainpool P random curves.
|
514 | 514 | *
|
|
517 | 517 | * brainpoolP320r1, brainpoolP384r1, brainpoolP512r1.
|
518 | 518 | * It is defined in RFC 5639.
|
519 | 519 | */
|
520 |
| -#define PSA_ECC_CURVE_BRAINPOOL_P_R1 ((psa_ecc_curve_t) 0x300000) |
| 520 | +#define PSA_ECC_CURVE_BRAINPOOL_P_R1 ((psa_ecc_curve_t) 0x30) |
521 | 521 |
|
522 | 522 | /** Curve25519 and Curve448.
|
523 | 523 | *
|
|
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) 0x400000) |
| 532 | +#define PSA_ECC_CURVE_XED ((psa_ecc_curve_t) 0x40) |
533 | 533 |
|
534 |
| -#define PSA_KEY_TYPE_DH_PUBLIC_KEY_BASE ((psa_key_type_t)0x62000000) |
535 |
| -#define PSA_KEY_TYPE_DH_KEY_PAIR_BASE ((psa_key_type_t)0x72000000) |
536 |
| -#define PSA_KEY_TYPE_DH_GROUP_MASK ((psa_key_type_t)0x00ffffff) |
| 534 | +#define PSA_KEY_TYPE_DH_PUBLIC_KEY_BASE ((psa_key_type_t)0x6200) |
| 535 | +#define PSA_KEY_TYPE_DH_KEY_PAIR_BASE ((psa_key_type_t)0x7200) |
| 536 | +#define PSA_KEY_TYPE_DH_GROUP_MASK ((psa_key_type_t)0x00ff) |
537 | 537 | /** Diffie-Hellman key pair.
|
538 | 538 | *
|
539 | 539 | * \param group A value of type ::psa_dh_group_t that identifies the
|
|
577 | 577 | #define PSA_DH_GROUP_RFC7919 ((psa_dh_group_t) 0x02)
|
578 | 578 |
|
579 | 579 | #define PSA_GET_KEY_TYPE_BLOCK_SIZE_EXPONENT(type) \
|
580 |
| - (((type) >> 24) & 7) |
| 580 | + (((type) >> 8) & 7) |
581 | 581 | /** The block size of a block cipher.
|
582 | 582 | *
|
583 | 583 | * \param type A cipher key type (value of type #psa_key_type_t).
|
|
0 commit comments