crypto_values.h
mbedtls/private_access.h
crypto.h
crypto_driver_common.h
mbedtls/private_access.h
crypto_values.h
debug.h
net_sockets.h
oid.h
pk.h
pkcs7.h
psa_util.h
ssl.h
ssl_cache.h
ssl_ciphersuites.h
ssl_cookie.h
ssl_ticket.h
x509.h
x509_crl.h
x509_crt.h
x509_csr.h
crypto.h
crypto_builtin_composites.h
crypto_builtin_key_derivation.h
crypto_builtin_primitives.h
crypto_driver_common.h
crypto_driver_contexts_composites.h
crypto_driver_contexts_key_derivation.h
crypto_driver_contexts_primitives.h
crypto_se_driver.h
crypto_struct.h
crypto_values.h
- PSA_SUCCESS
- PSA_ERROR_GENERIC_ERROR
- PSA_ERROR_NOT_SUPPORTED
- PSA_ERROR_NOT_PERMITTED
- PSA_ERROR_BUFFER_TOO_SMALL
- PSA_ERROR_ALREADY_EXISTS
- PSA_ERROR_DOES_NOT_EXIST
- PSA_ERROR_BAD_STATE
- PSA_ERROR_INVALID_ARGUMENT
- PSA_ERROR_INSUFFICIENT_MEMORY
- PSA_ERROR_INSUFFICIENT_STORAGE
- PSA_ERROR_COMMUNICATION_FAILURE
- PSA_ERROR_STORAGE_FAILURE
- PSA_ERROR_HARDWARE_FAILURE
- PSA_ERROR_CORRUPTION_DETECTED
- PSA_ERROR_INSUFFICIENT_ENTROPY
- PSA_ERROR_INVALID_SIGNATURE
- PSA_ERROR_INVALID_PADDING
- PSA_ERROR_INSUFFICIENT_DATA
- PSA_ERROR_SERVICE_FAILURE
- PSA_ERROR_INVALID_HANDLE
- PSA_ERROR_DATA_CORRUPT
- PSA_ERROR_DATA_INVALID
- PSA_OPERATION_INCOMPLETE
- PSA_KEY_TYPE_NONE
- PSA_KEY_TYPE_VENDOR_FLAG
- PSA_KEY_TYPE_CATEGORY_MASK
- PSA_KEY_TYPE_CATEGORY_RAW
- PSA_KEY_TYPE_CATEGORY_SYMMETRIC
- PSA_KEY_TYPE_CATEGORY_PUBLIC_KEY
- PSA_KEY_TYPE_CATEGORY_KEY_PAIR
- PSA_KEY_TYPE_CATEGORY_FLAG_PAIR
- PSA_KEY_TYPE_IS_VENDOR_DEFINED
- PSA_KEY_TYPE_IS_UNSTRUCTURED
- PSA_KEY_TYPE_IS_ASYMMETRIC
- PSA_KEY_TYPE_IS_PUBLIC_KEY
- PSA_KEY_TYPE_IS_KEY_PAIR
- PSA_KEY_TYPE_KEY_PAIR_OF_PUBLIC_KEY
- PSA_KEY_TYPE_PUBLIC_KEY_OF_KEY_PAIR
- PSA_KEY_TYPE_RAW_DATA
- PSA_KEY_TYPE_HMAC
- PSA_KEY_TYPE_DERIVE
- PSA_KEY_TYPE_PASSWORD
- PSA_KEY_TYPE_PASSWORD_HASH
- PSA_KEY_TYPE_PEPPER
- PSA_KEY_TYPE_AES
- PSA_KEY_TYPE_ARIA
- PSA_KEY_TYPE_DES
- PSA_KEY_TYPE_CAMELLIA
- PSA_KEY_TYPE_CHACHA20
- PSA_KEY_TYPE_RSA_PUBLIC_KEY
- PSA_KEY_TYPE_RSA_KEY_PAIR
- PSA_KEY_TYPE_IS_RSA
- PSA_KEY_TYPE_ECC_PUBLIC_KEY_BASE
- PSA_KEY_TYPE_ECC_KEY_PAIR_BASE
- PSA_KEY_TYPE_ECC_CURVE_MASK
- PSA_KEY_TYPE_ECC_KEY_PAIR
- PSA_KEY_TYPE_ECC_PUBLIC_KEY
- PSA_KEY_TYPE_IS_ECC
- PSA_KEY_TYPE_IS_ECC_KEY_PAIR
- PSA_KEY_TYPE_IS_ECC_PUBLIC_KEY
- PSA_KEY_TYPE_ECC_GET_FAMILY
- PSA_ECC_FAMILY_IS_WEIERSTRASS
- PSA_ECC_FAMILY_SECP_K1
- PSA_ECC_FAMILY_SECP_R1
- PSA_ECC_FAMILY_SECP_R2
- PSA_ECC_FAMILY_SECT_K1
- PSA_ECC_FAMILY_SECT_R1
- PSA_ECC_FAMILY_SECT_R2
- PSA_ECC_FAMILY_BRAINPOOL_P_R1
- PSA_ECC_FAMILY_MONTGOMERY
- PSA_ECC_FAMILY_TWISTED_EDWARDS
- PSA_KEY_TYPE_DH_PUBLIC_KEY_BASE
- PSA_KEY_TYPE_DH_KEY_PAIR_BASE
- PSA_KEY_TYPE_DH_GROUP_MASK
- PSA_KEY_TYPE_DH_KEY_PAIR
- PSA_KEY_TYPE_DH_PUBLIC_KEY
- PSA_KEY_TYPE_IS_DH
- PSA_KEY_TYPE_IS_DH_KEY_PAIR
- PSA_KEY_TYPE_IS_DH_PUBLIC_KEY
- PSA_KEY_TYPE_DH_GET_FAMILY
- PSA_DH_FAMILY_RFC7919
- PSA_GET_KEY_TYPE_BLOCK_SIZE_EXPONENT
- PSA_BLOCK_CIPHER_BLOCK_LENGTH
- PSA_ALG_VENDOR_FLAG
- PSA_ALG_CATEGORY_MASK
- PSA_ALG_CATEGORY_HASH
- PSA_ALG_CATEGORY_MAC
- PSA_ALG_CATEGORY_CIPHER
- PSA_ALG_CATEGORY_AEAD
- PSA_ALG_CATEGORY_SIGN
- PSA_ALG_CATEGORY_ASYMMETRIC_ENCRYPTION
- PSA_ALG_CATEGORY_KEY_DERIVATION
- PSA_ALG_CATEGORY_KEY_AGREEMENT
- PSA_ALG_IS_VENDOR_DEFINED
- PSA_ALG_IS_HASH
- PSA_ALG_IS_MAC
- PSA_ALG_IS_CIPHER
- PSA_ALG_IS_AEAD
- PSA_ALG_IS_SIGN
- PSA_ALG_IS_ASYMMETRIC_ENCRYPTION
- PSA_ALG_IS_KEY_AGREEMENT
- PSA_ALG_IS_KEY_DERIVATION
- PSA_ALG_IS_KEY_DERIVATION_STRETCHING
- PSA_ALG_NONE
- PSA_ALG_HASH_MASK
- PSA_ALG_MD5
- PSA_ALG_RIPEMD160
- PSA_ALG_SHA_1
- PSA_ALG_SHA_224
- PSA_ALG_SHA_256
- PSA_ALG_SHA_384
- PSA_ALG_SHA_512
- PSA_ALG_SHA_512_224
- PSA_ALG_SHA_512_256
- PSA_ALG_SHA3_224
- PSA_ALG_SHA3_256
- PSA_ALG_SHA3_384
- PSA_ALG_SHA3_512
- PSA_ALG_SHAKE256_512
- PSA_ALG_ANY_HASH
- PSA_ALG_MAC_SUBCATEGORY_MASK
- PSA_ALG_HMAC_BASE
- PSA_ALG_HMAC
- PSA_ALG_HMAC_GET_HASH
- PSA_ALG_IS_HMAC
- PSA_ALG_MAC_TRUNCATION_MASK
- PSA_MAC_TRUNCATION_OFFSET
- PSA_ALG_MAC_AT_LEAST_THIS_LENGTH_FLAG
- PSA_ALG_TRUNCATED_MAC
- PSA_ALG_FULL_LENGTH_MAC
- PSA_MAC_TRUNCATED_LENGTH
- PSA_ALG_AT_LEAST_THIS_LENGTH_MAC
- PSA_ALG_CIPHER_MAC_BASE
- PSA_ALG_CBC_MAC
- PSA_ALG_CMAC
- PSA_ALG_IS_BLOCK_CIPHER_MAC
- PSA_ALG_CIPHER_STREAM_FLAG
- PSA_ALG_CIPHER_FROM_BLOCK_FLAG
- PSA_ALG_IS_STREAM_CIPHER
- PSA_ALG_STREAM_CIPHER
- PSA_ALG_CTR
- PSA_ALG_CFB
- PSA_ALG_OFB
- PSA_ALG_XTS
- PSA_ALG_ECB_NO_PADDING
- PSA_ALG_CBC_NO_PADDING
- PSA_ALG_CBC_PKCS7
- PSA_ALG_AEAD_FROM_BLOCK_FLAG
- PSA_ALG_IS_AEAD_ON_BLOCK_CIPHER
- PSA_ALG_CCM
- PSA_ALG_CCM_STAR_NO_TAG
- PSA_ALG_GCM
- PSA_ALG_CHACHA20_POLY1305
- PSA_ALG_AEAD_TAG_LENGTH_MASK
- PSA_AEAD_TAG_LENGTH_OFFSET
- PSA_ALG_AEAD_AT_LEAST_THIS_LENGTH_FLAG
- PSA_ALG_AEAD_WITH_SHORTENED_TAG
- PSA_ALG_AEAD_GET_TAG_LENGTH
- PSA_ALG_AEAD_WITH_DEFAULT_LENGTH_TAG
- PSA_ALG_AEAD_WITH_DEFAULT_LENGTH_TAG_CASE
- PSA_ALG_AEAD_WITH_AT_LEAST_THIS_LENGTH_TAG
- PSA_ALG_RSA_PKCS1V15_SIGN_BASE
- PSA_ALG_RSA_PKCS1V15_SIGN
- PSA_ALG_RSA_PKCS1V15_SIGN_RAW
- PSA_ALG_IS_RSA_PKCS1V15_SIGN
- PSA_ALG_RSA_PSS_BASE
- PSA_ALG_RSA_PSS_ANY_SALT_BASE
- PSA_ALG_RSA_PSS
- PSA_ALG_RSA_PSS_ANY_SALT
- PSA_ALG_IS_RSA_PSS_STANDARD_SALT
- PSA_ALG_IS_RSA_PSS_ANY_SALT
- PSA_ALG_IS_RSA_PSS
- PSA_ALG_ECDSA_BASE
- PSA_ALG_ECDSA
- PSA_ALG_ECDSA_ANY
- PSA_ALG_DETERMINISTIC_ECDSA_BASE
- PSA_ALG_DETERMINISTIC_ECDSA
- PSA_ALG_ECDSA_DETERMINISTIC_FLAG
- PSA_ALG_IS_ECDSA
- PSA_ALG_ECDSA_IS_DETERMINISTIC
- PSA_ALG_IS_DETERMINISTIC_ECDSA
- PSA_ALG_IS_RANDOMIZED_ECDSA
- PSA_ALG_PURE_EDDSA
- PSA_ALG_HASH_EDDSA_BASE
- PSA_ALG_IS_HASH_EDDSA
- PSA_ALG_ED25519PH
- PSA_ALG_ED448PH
- PSA_ALG_IS_VENDOR_HASH_AND_SIGN
- PSA_ALG_IS_SIGN_HASH
- PSA_ALG_IS_SIGN_MESSAGE
- PSA_ALG_IS_HASH_AND_SIGN
- PSA_ALG_SIGN_GET_HASH
- PSA_ALG_RSA_PKCS1V15_CRYPT
- PSA_ALG_RSA_OAEP_BASE
- PSA_ALG_RSA_OAEP
- PSA_ALG_IS_RSA_OAEP
- PSA_ALG_RSA_OAEP_GET_HASH
- PSA_ALG_HKDF_BASE
- PSA_ALG_HKDF
- PSA_ALG_IS_HKDF
- PSA_ALG_HKDF_GET_HASH
- PSA_ALG_HKDF_EXTRACT_BASE
- PSA_ALG_HKDF_EXTRACT
- PSA_ALG_IS_HKDF_EXTRACT
- PSA_ALG_HKDF_EXPAND_BASE
- PSA_ALG_HKDF_EXPAND
- PSA_ALG_IS_HKDF_EXPAND
- PSA_ALG_IS_ANY_HKDF
- PSA_ALG_TLS12_PRF_BASE
- PSA_ALG_TLS12_PRF
- PSA_ALG_IS_TLS12_PRF
- PSA_ALG_TLS12_PRF_GET_HASH
- PSA_ALG_TLS12_PSK_TO_MS_BASE
- PSA_ALG_TLS12_PSK_TO_MS
- PSA_ALG_IS_TLS12_PSK_TO_MS
- PSA_ALG_TLS12_PSK_TO_MS_GET_HASH
- PSA_ALG_TLS12_ECJPAKE_TO_PMS
- PSA_ALG_KEY_DERIVATION_STRETCHING_FLAG
- PSA_ALG_PBKDF2_HMAC_BASE
- PSA_ALG_PBKDF2_HMAC
- PSA_ALG_IS_PBKDF2_HMAC
- PSA_ALG_PBKDF2_HMAC_GET_HASH
- PSA_ALG_PBKDF2_AES_CMAC_PRF_128
- PSA_ALG_IS_PBKDF2
- PSA_ALG_KEY_DERIVATION_MASK
- PSA_ALG_KEY_AGREEMENT_MASK
- PSA_ALG_KEY_AGREEMENT
- PSA_ALG_KEY_AGREEMENT_GET_KDF
- PSA_ALG_KEY_AGREEMENT_GET_BASE
- PSA_ALG_IS_RAW_KEY_AGREEMENT
- PSA_ALG_IS_KEY_DERIVATION_OR_AGREEMENT
- PSA_ALG_FFDH
- PSA_ALG_IS_FFDH
- PSA_ALG_ECDH
- PSA_ALG_IS_ECDH
- PSA_ALG_IS_WILDCARD
- PSA_ALG_GET_HASH
- PSA_KEY_LIFETIME_VOLATILE
- PSA_KEY_LIFETIME_PERSISTENT
- PSA_KEY_PERSISTENCE_VOLATILE
- PSA_KEY_PERSISTENCE_DEFAULT
- PSA_KEY_PERSISTENCE_READ_ONLY
- PSA_KEY_LIFETIME_GET_PERSISTENCE
- PSA_KEY_LIFETIME_GET_LOCATION
- PSA_KEY_LIFETIME_IS_VOLATILE
- PSA_KEY_LIFETIME_IS_READ_ONLY
- PSA_KEY_LIFETIME_FROM_PERSISTENCE_AND_LOCATION
- PSA_KEY_LOCATION_LOCAL_STORAGE
- PSA_KEY_LOCATION_VENDOR_FLAG
- PSA_KEY_ID_NULL
- PSA_KEY_ID_USER_MIN
- PSA_KEY_ID_USER_MAX
- PSA_KEY_ID_VENDOR_MIN
- PSA_KEY_ID_VENDOR_MAX
- MBEDTLS_SVC_KEY_ID_INIT
- MBEDTLS_SVC_KEY_ID_GET_KEY_ID
- MBEDTLS_SVC_KEY_ID_GET_OWNER_ID
- PSA_KEY_USAGE_EXPORT
- PSA_KEY_USAGE_COPY
- PSA_KEY_USAGE_ENCRYPT
- PSA_KEY_USAGE_DECRYPT
- PSA_KEY_USAGE_SIGN_MESSAGE
- PSA_KEY_USAGE_VERIFY_MESSAGE
- PSA_KEY_USAGE_SIGN_HASH
- PSA_KEY_USAGE_VERIFY_HASH
- PSA_KEY_USAGE_DERIVE
- PSA_KEY_USAGE_VERIFY_DERIVATION
- PSA_KEY_DERIVATION_INPUT_SECRET
- PSA_KEY_DERIVATION_INPUT_PASSWORD
- PSA_KEY_DERIVATION_INPUT_OTHER_SECRET
- PSA_KEY_DERIVATION_INPUT_LABEL
- PSA_KEY_DERIVATION_INPUT_SALT
- PSA_KEY_DERIVATION_INPUT_INFO
- PSA_KEY_DERIVATION_INPUT_SEED
- PSA_KEY_DERIVATION_INPUT_COST
- MBEDTLS_PSA_ALG_AEAD_EQUAL
- PSA_INTERRUPTIBLE_MAX_OPS_UNLIMITED
- mbedtls_svc_key_id_make
- mbedtls_svc_key_id_equal
- mbedtls_svc_key_id_is_null

PSA cryptography module: macros to build and analyze integer values.

This file may not be included directly. Applications must include psa/crypto.h. Drivers must include the appropriate driver header file.

This file contains portable definitions of macros to build and analyze values of integral types that encode properties of cryptographic keys, designations of cryptographic algorithms, and error codes returned by the library.

Note that many of the constants defined in this file are embedded in the persistent key store, as part of key metadata (including usage policies). As a consequence, they must not be changed (unless the storage format version changes).

This header file only defines preprocessor macros.

    /*
    *CopyrightTheMbedTLSContributors
    *SPDX-License-Identifier:Apache-2.0ORGPL-2.0-or-later
    */

    #ifndefPSA_CRYPTO_VALUES_H
    #definePSA_CRYPTO_VALUES_H
    #include"mbedtls/private_access.h"

    /*PSAerrorcodes*/

    /*ErrorcodesarestandardizedacrossPSAdomains(framework,crypto,storage,
    *etc.).Donotchangethevaluesinthissectionoreventheexpansions
    *ofeachmacro:itmustbepossibleto`#include`boththisheader
    *andsomeotherPSAcomponent'sheadersinthesameCsource,
    *whichwillleadtoduplicatedefinitionsofthe`PSA_SUCCESS`and
    *`PSA_ERROR_xxx`macros,whichisokifandonlyifthemacrosexpand
    *tothesamesequenceoftokens.
    *
    *Ifyoumustaddanew
    *value,checkwiththeArmPSAframeworkgrouptopickonethatother
    *domainsaren'talreadyusing.*/

    /*Telluncrustifynottotouchtheconstantdefinitions,otherwise
    *itmightchangethespacingtosomethingthatisnotPSA-compliant
    *(e.g.addingaspaceaftercasts).
    *
    **INDENT-OFF*
    */

    #definePSA_SUCCESS((psa_status_t)0)

    #definePSA_ERROR_GENERIC_ERROR((psa_status_t)-132)

    #definePSA_ERROR_NOT_SUPPORTED((psa_status_t)-134)

    #definePSA_ERROR_NOT_PERMITTED((psa_status_t)-133)

    #definePSA_ERROR_BUFFER_TOO_SMALL((psa_status_t)-138)

    #definePSA_ERROR_ALREADY_EXISTS((psa_status_t)-139)

    #definePSA_ERROR_DOES_NOT_EXIST((psa_status_t)-140)

    #definePSA_ERROR_BAD_STATE((psa_status_t)-137)

    #definePSA_ERROR_INVALID_ARGUMENT((psa_status_t)-135)

    #definePSA_ERROR_INSUFFICIENT_MEMORY((psa_status_t)-141)

    #definePSA_ERROR_INSUFFICIENT_STORAGE((psa_status_t)-142)

    #definePSA_ERROR_COMMUNICATION_FAILURE((psa_status_t)-145)

    #definePSA_ERROR_STORAGE_FAILURE((psa_status_t)-146)

    #definePSA_ERROR_HARDWARE_FAILURE((psa_status_t)-147)

    #definePSA_ERROR_CORRUPTION_DETECTED((psa_status_t)-151)

    #definePSA_ERROR_INSUFFICIENT_ENTROPY((psa_status_t)-148)

    #definePSA_ERROR_INVALID_SIGNATURE((psa_status_t)-149)

    #definePSA_ERROR_INVALID_PADDING((psa_status_t)-150)

    #definePSA_ERROR_INSUFFICIENT_DATA((psa_status_t)-143)

    #definePSA_ERROR_SERVICE_FAILURE((psa_status_t)-144)

    #definePSA_ERROR_INVALID_HANDLE((psa_status_t)-136)

    #definePSA_ERROR_DATA_CORRUPT((psa_status_t)-152)

    #definePSA_ERROR_DATA_INVALID((psa_status_t)-153)

    #definePSA_OPERATION_INCOMPLETE((psa_status_t)-248)

    /**INDENT-ON**/

    /*Notethatkeytypevalues,includingECCfamilyandDHgroupvalues,are
    *embeddedinthepersistentkeystore,aspartofkeymetadata.Asa
    *consequence,theymustnotbechanged(unlessthestorageformatversion
    *changes).
    */

    #definePSA_KEY_TYPE_NONE((psa_key_type_t)0x0000)

    #definePSA_KEY_TYPE_VENDOR_FLAG((psa_key_type_t)0x8000)

    #definePSA_KEY_TYPE_CATEGORY_MASK((psa_key_type_t)0x7000)
    #definePSA_KEY_TYPE_CATEGORY_RAW((psa_key_type_t)0x1000)
    #definePSA_KEY_TYPE_CATEGORY_SYMMETRIC((psa_key_type_t)0x2000)
    #definePSA_KEY_TYPE_CATEGORY_PUBLIC_KEY((psa_key_type_t)0x4000)
    #definePSA_KEY_TYPE_CATEGORY_KEY_PAIR((psa_key_type_t)0x7000)

    #definePSA_KEY_TYPE_CATEGORY_FLAG_PAIR((psa_key_type_t)0x3000)

    #definePSA_KEY_TYPE_IS_VENDOR_DEFINED(type)\
    (((type)&PSA_KEY_TYPE_VENDOR_FLAG)!=0)

    #definePSA_KEY_TYPE_IS_UNSTRUCTURED(type)\
    (((type)&PSA_KEY_TYPE_CATEGORY_MASK)==PSA_KEY_TYPE_CATEGORY_RAW||\
    ((type)&PSA_KEY_TYPE_CATEGORY_MASK)==PSA_KEY_TYPE_CATEGORY_SYMMETRIC)

    #definePSA_KEY_TYPE_IS_ASYMMETRIC(type)\
    (((type)&PSA_KEY_TYPE_CATEGORY_MASK\
    &~PSA_KEY_TYPE_CATEGORY_FLAG_PAIR)==\
    PSA_KEY_TYPE_CATEGORY_PUBLIC_KEY)
    #definePSA_KEY_TYPE_IS_PUBLIC_KEY(type)\
    (((type)&PSA_KEY_TYPE_CATEGORY_MASK)==PSA_KEY_TYPE_CATEGORY_PUBLIC_KEY)
    #definePSA_KEY_TYPE_IS_KEY_PAIR(type)\
    (((type)&PSA_KEY_TYPE_CATEGORY_MASK)==PSA_KEY_TYPE_CATEGORY_KEY_PAIR)
    #definePSA_KEY_TYPE_KEY_PAIR_OF_PUBLIC_KEY(type)\
    ((type)|PSA_KEY_TYPE_CATEGORY_FLAG_PAIR)
    #definePSA_KEY_TYPE_PUBLIC_KEY_OF_KEY_PAIR(type)\
    ((type)&~PSA_KEY_TYPE_CATEGORY_FLAG_PAIR)

    #definePSA_KEY_TYPE_RAW_DATA((psa_key_type_t)0x1001)

    #definePSA_KEY_TYPE_HMAC((psa_key_type_t)0x1100)

    #definePSA_KEY_TYPE_DERIVE((psa_key_type_t)0x1200)

    #definePSA_KEY_TYPE_PASSWORD((psa_key_type_t)0x1203)

    #definePSA_KEY_TYPE_PASSWORD_HASH((psa_key_type_t)0x1205)

    #definePSA_KEY_TYPE_PEPPER((psa_key_type_t)0x1206)

    #definePSA_KEY_TYPE_AES((psa_key_type_t)0x2400)

    #definePSA_KEY_TYPE_ARIA((psa_key_type_t)0x2406)

    #definePSA_KEY_TYPE_DES((psa_key_type_t)0x2301)

    #definePSA_KEY_TYPE_CAMELLIA((psa_key_type_t)0x2403)

    #definePSA_KEY_TYPE_CHACHA20((psa_key_type_t)0x2004)

    #definePSA_KEY_TYPE_RSA_PUBLIC_KEY((psa_key_type_t)0x4001)
    #definePSA_KEY_TYPE_RSA_KEY_PAIR((psa_key_type_t)0x7001)
    #definePSA_KEY_TYPE_IS_RSA(type)\
    (PSA_KEY_TYPE_PUBLIC_KEY_OF_KEY_PAIR(type)==PSA_KEY_TYPE_RSA_PUBLIC_KEY)

    #definePSA_KEY_TYPE_ECC_PUBLIC_KEY_BASE((psa_key_type_t)0x4100)
    #definePSA_KEY_TYPE_ECC_KEY_PAIR_BASE((psa_key_type_t)0x7100)
    #definePSA_KEY_TYPE_ECC_CURVE_MASK((psa_key_type_t)0x00ff)
    #definePSA_KEY_TYPE_ECC_KEY_PAIR(curve)\
    (PSA_KEY_TYPE_ECC_KEY_PAIR_BASE|(curve))
    #definePSA_KEY_TYPE_ECC_PUBLIC_KEY(curve)\
    (PSA_KEY_TYPE_ECC_PUBLIC_KEY_BASE|(curve))

    #definePSA_KEY_TYPE_IS_ECC(type)\
    ((PSA_KEY_TYPE_PUBLIC_KEY_OF_KEY_PAIR(type)&\
    ~PSA_KEY_TYPE_ECC_CURVE_MASK)==PSA_KEY_TYPE_ECC_PUBLIC_KEY_BASE)
    #definePSA_KEY_TYPE_IS_ECC_KEY_PAIR(type)\
    (((type)&~PSA_KEY_TYPE_ECC_CURVE_MASK)==\
    PSA_KEY_TYPE_ECC_KEY_PAIR_BASE)
    #definePSA_KEY_TYPE_IS_ECC_PUBLIC_KEY(type)\
    (((type)&~PSA_KEY_TYPE_ECC_CURVE_MASK)==\
    PSA_KEY_TYPE_ECC_PUBLIC_KEY_BASE)

    #definePSA_KEY_TYPE_ECC_GET_FAMILY(type)\
    ((psa_ecc_family_t)(PSA_KEY_TYPE_IS_ECC(type)?\
    ((type)&PSA_KEY_TYPE_ECC_CURVE_MASK):\
    0))

    #definePSA_ECC_FAMILY_IS_WEIERSTRASS(family)((family&0xc0)==0)

    #definePSA_ECC_FAMILY_SECP_K1((psa_ecc_family_t)0x17)

    #definePSA_ECC_FAMILY_SECP_R1((psa_ecc_family_t)0x12)
    /*SECP160R2(SEC2v1,obsolete,notsupportedinMbedTLS)*/
    #definePSA_ECC_FAMILY_SECP_R2((psa_ecc_family_t)0x1b)

    #definePSA_ECC_FAMILY_SECT_K1((psa_ecc_family_t)0x27)

    #definePSA_ECC_FAMILY_SECT_R1((psa_ecc_family_t)0x22)

    #definePSA_ECC_FAMILY_SECT_R2((psa_ecc_family_t)0x2b)

    #definePSA_ECC_FAMILY_BRAINPOOL_P_R1((psa_ecc_family_t)0x30)

    #definePSA_ECC_FAMILY_MONTGOMERY((psa_ecc_family_t)0x41)

    #definePSA_ECC_FAMILY_TWISTED_EDWARDS((psa_ecc_family_t)0x42)

    #definePSA_KEY_TYPE_DH_PUBLIC_KEY_BASE((psa_key_type_t)0x4200)
    #definePSA_KEY_TYPE_DH_KEY_PAIR_BASE((psa_key_type_t)0x7200)
    #definePSA_KEY_TYPE_DH_GROUP_MASK((psa_key_type_t)0x00ff)
    #definePSA_KEY_TYPE_DH_KEY_PAIR(group)\
    (PSA_KEY_TYPE_DH_KEY_PAIR_BASE|(group))
    #definePSA_KEY_TYPE_DH_PUBLIC_KEY(group)\
    (PSA_KEY_TYPE_DH_PUBLIC_KEY_BASE|(group))

    #definePSA_KEY_TYPE_IS_DH(type)\
    ((PSA_KEY_TYPE_PUBLIC_KEY_OF_KEY_PAIR(type)&\
    ~PSA_KEY_TYPE_DH_GROUP_MASK)==PSA_KEY_TYPE_DH_PUBLIC_KEY_BASE)
    #definePSA_KEY_TYPE_IS_DH_KEY_PAIR(type)\
    (((type)&~PSA_KEY_TYPE_DH_GROUP_MASK)==\
    PSA_KEY_TYPE_DH_KEY_PAIR_BASE)
    #definePSA_KEY_TYPE_IS_DH_PUBLIC_KEY(type)\
    (((type)&~PSA_KEY_TYPE_DH_GROUP_MASK)==\
    PSA_KEY_TYPE_DH_PUBLIC_KEY_BASE)

    #definePSA_KEY_TYPE_DH_GET_FAMILY(type)\
    ((psa_dh_family_t)(PSA_KEY_TYPE_IS_DH(type)?\
    ((type)&PSA_KEY_TYPE_DH_GROUP_MASK):\
    0))

    #definePSA_DH_FAMILY_RFC7919((psa_dh_family_t)0x03)

    #definePSA_GET_KEY_TYPE_BLOCK_SIZE_EXPONENT(type)\
    (((type)>>8)&7)
    #definePSA_BLOCK_CIPHER_BLOCK_LENGTH(type)\
    (((type)&PSA_KEY_TYPE_CATEGORY_MASK)==PSA_KEY_TYPE_CATEGORY_SYMMETRIC?\
    1u<<PSA_GET_KEY_TYPE_BLOCK_SIZE_EXPONENT(type):\
    0u)

    /*Notethatalgorithmvaluesareembeddedinthepersistentkeystore,
    *aspartofkeymetadata.Asaconsequence,theymustnotbechanged
    *(unlessthestorageformatversionchanges).
    */

    #definePSA_ALG_VENDOR_FLAG((psa_algorithm_t)0x80000000)

    #definePSA_ALG_CATEGORY_MASK((psa_algorithm_t)0x7f000000)
    #definePSA_ALG_CATEGORY_HASH((psa_algorithm_t)0x02000000)
    #definePSA_ALG_CATEGORY_MAC((psa_algorithm_t)0x03000000)
    #definePSA_ALG_CATEGORY_CIPHER((psa_algorithm_t)0x04000000)
    #definePSA_ALG_CATEGORY_AEAD((psa_algorithm_t)0x05000000)
    #definePSA_ALG_CATEGORY_SIGN((psa_algorithm_t)0x06000000)
    #definePSA_ALG_CATEGORY_ASYMMETRIC_ENCRYPTION((psa_algorithm_t)0x07000000)
    #definePSA_ALG_CATEGORY_KEY_DERIVATION((psa_algorithm_t)0x08000000)
    #definePSA_ALG_CATEGORY_KEY_AGREEMENT((psa_algorithm_t)0x09000000)

    #definePSA_ALG_IS_VENDOR_DEFINED(alg)\
    (((alg)&PSA_ALG_VENDOR_FLAG)!=0)

    #definePSA_ALG_IS_HASH(alg)\
    (((alg)&PSA_ALG_CATEGORY_MASK)==PSA_ALG_CATEGORY_HASH)

    #definePSA_ALG_IS_MAC(alg)\
    (((alg)&PSA_ALG_CATEGORY_MASK)==PSA_ALG_CATEGORY_MAC)

    #definePSA_ALG_IS_CIPHER(alg)\
    (((alg)&PSA_ALG_CATEGORY_MASK)==PSA_ALG_CATEGORY_CIPHER)

    #definePSA_ALG_IS_AEAD(alg)\
    (((alg)&PSA_ALG_CATEGORY_MASK)==PSA_ALG_CATEGORY_AEAD)

    #definePSA_ALG_IS_SIGN(alg)\
    (((alg)&PSA_ALG_CATEGORY_MASK)==PSA_ALG_CATEGORY_SIGN)

    #definePSA_ALG_IS_ASYMMETRIC_ENCRYPTION(alg)\
    (((alg)&PSA_ALG_CATEGORY_MASK)==PSA_ALG_CATEGORY_ASYMMETRIC_ENCRYPTION)

    #definePSA_ALG_IS_KEY_AGREEMENT(alg)\
    (((alg)&PSA_ALG_CATEGORY_MASK)==PSA_ALG_CATEGORY_KEY_AGREEMENT)

    #definePSA_ALG_IS_KEY_DERIVATION(alg)\
    (((alg)&PSA_ALG_CATEGORY_MASK)==PSA_ALG_CATEGORY_KEY_DERIVATION)

    #definePSA_ALG_IS_KEY_DERIVATION_STRETCHING(alg)\
    (PSA_ALG_IS_KEY_DERIVATION(alg)&&\
    (alg)&PSA_ALG_KEY_DERIVATION_STRETCHING_FLAG)

    /**INDENT-OFF*(https://github.com/ARM-software/psa-arch-tests/issues/337)*/
    #definePSA_ALG_NONE((psa_algorithm_t)0)
    /**INDENT-ON**/

    #definePSA_ALG_HASH_MASK((psa_algorithm_t)0x000000ff)
    #definePSA_ALG_MD5((psa_algorithm_t)0x02000003)
    #definePSA_ALG_RIPEMD160((psa_algorithm_t)0x02000004)
    #definePSA_ALG_SHA_1((psa_algorithm_t)0x02000005)
    #definePSA_ALG_SHA_224((psa_algorithm_t)0x02000008)
    #definePSA_ALG_SHA_256((psa_algorithm_t)0x02000009)
    #definePSA_ALG_SHA_384((psa_algorithm_t)0x0200000a)
    #definePSA_ALG_SHA_512((psa_algorithm_t)0x0200000b)
    #definePSA_ALG_SHA_512_224((psa_algorithm_t)0x0200000c)
    #definePSA_ALG_SHA_512_256((psa_algorithm_t)0x0200000d)
    #definePSA_ALG_SHA3_224((psa_algorithm_t)0x02000010)
    #definePSA_ALG_SHA3_256((psa_algorithm_t)0x02000011)
    #definePSA_ALG_SHA3_384((psa_algorithm_t)0x02000012)
    #definePSA_ALG_SHA3_512((psa_algorithm_t)0x02000013)
    #definePSA_ALG_SHAKE256_512((psa_algorithm_t)0x02000015)

    #definePSA_ALG_ANY_HASH((psa_algorithm_t)0x020000ff)

    #definePSA_ALG_MAC_SUBCATEGORY_MASK((psa_algorithm_t)0x00c00000)
    #definePSA_ALG_HMAC_BASE((psa_algorithm_t)0x03800000)
    #definePSA_ALG_HMAC(hash_alg)\
    (PSA_ALG_HMAC_BASE|((hash_alg)&PSA_ALG_HASH_MASK))

    #definePSA_ALG_HMAC_GET_HASH(hmac_alg)\
    (PSA_ALG_CATEGORY_HASH|((hmac_alg)&PSA_ALG_HASH_MASK))

    #definePSA_ALG_IS_HMAC(alg)\
    (((alg)&(PSA_ALG_CATEGORY_MASK|PSA_ALG_MAC_SUBCATEGORY_MASK))==\
    PSA_ALG_HMAC_BASE)

    /*IntheencodingofaMACalgorithm,thebitscorrespondingto
    *PSA_ALG_MAC_TRUNCATION_MASKencodethelengthtowhichtheMACis
    *truncated.Asanexception,thevalue0meanstheuntruncatedalgorithm,
    *whateveritslengthis.Thelengthisencodedin6bits,soitcan
    *reachupto63;thelargestMACis64bytessoitstrivialtruncation
    *tofulllengthiscorrectlyencodedas0andanynon-trivialtruncation
    *iscorrectlyencodedasavaluebetween1and63.*/
    #definePSA_ALG_MAC_TRUNCATION_MASK((psa_algorithm_t)0x003f0000)
    #definePSA_MAC_TRUNCATION_OFFSET16

    /*IntheencodingofaMACalgorithm,thebitcorrespondingto
    *#PSA_ALG_MAC_AT_LEAST_THIS_LENGTH_FLAGencodesthefactthatthealgorithm
    *isawildcardalgorithm.Akeywithsuchwildcardalgorithmaspermitted
    *algorithmpolicycanbeusedwithanyalgorithmcorrespondingtothe
    *samebaseclassandhavinga(potentiallytruncated)MAClengthgreateror
    *equalthantheoneencodedin#PSA_ALG_MAC_TRUNCATION_MASK.*/
    #definePSA_ALG_MAC_AT_LEAST_THIS_LENGTH_FLAG((psa_algorithm_t)0x00008000)

    #definePSA_ALG_TRUNCATED_MAC(mac_alg,mac_length)\
    (((mac_alg)&~(PSA_ALG_MAC_TRUNCATION_MASK|\
    PSA_ALG_MAC_AT_LEAST_THIS_LENGTH_FLAG))|\
    ((mac_length)<<PSA_MAC_TRUNCATION_OFFSET&PSA_ALG_MAC_TRUNCATION_MASK))

    #definePSA_ALG_FULL_LENGTH_MAC(mac_alg)\
    ((mac_alg)&~(PSA_ALG_MAC_TRUNCATION_MASK|\
    PSA_ALG_MAC_AT_LEAST_THIS_LENGTH_FLAG))

    #definePSA_MAC_TRUNCATED_LENGTH(mac_alg)\
    (((mac_alg)&PSA_ALG_MAC_TRUNCATION_MASK)>>PSA_MAC_TRUNCATION_OFFSET)

    #definePSA_ALG_AT_LEAST_THIS_LENGTH_MAC(mac_alg,min_mac_length)\
    (PSA_ALG_TRUNCATED_MAC(mac_alg,min_mac_length)|\
    PSA_ALG_MAC_AT_LEAST_THIS_LENGTH_FLAG)

    #definePSA_ALG_CIPHER_MAC_BASE((psa_algorithm_t)0x03c00000)
    #definePSA_ALG_CBC_MAC((psa_algorithm_t)0x03c00100)
    #definePSA_ALG_CMAC((psa_algorithm_t)0x03c00200)

    #definePSA_ALG_IS_BLOCK_CIPHER_MAC(alg)\
    (((alg)&(PSA_ALG_CATEGORY_MASK|PSA_ALG_MAC_SUBCATEGORY_MASK))==\
    PSA_ALG_CIPHER_MAC_BASE)

    #definePSA_ALG_CIPHER_STREAM_FLAG((psa_algorithm_t)0x00800000)
    #definePSA_ALG_CIPHER_FROM_BLOCK_FLAG((psa_algorithm_t)0x00400000)

    #definePSA_ALG_IS_STREAM_CIPHER(alg)\
    (((alg)&(PSA_ALG_CATEGORY_MASK|PSA_ALG_CIPHER_STREAM_FLAG))==\
    (PSA_ALG_CATEGORY_CIPHER|PSA_ALG_CIPHER_STREAM_FLAG))

    #definePSA_ALG_STREAM_CIPHER((psa_algorithm_t)0x04800100)

    #definePSA_ALG_CTR((psa_algorithm_t)0x04c01000)

    #definePSA_ALG_CFB((psa_algorithm_t)0x04c01100)

    #definePSA_ALG_OFB((psa_algorithm_t)0x04c01200)

    #definePSA_ALG_XTS((psa_algorithm_t)0x0440ff00)

    #definePSA_ALG_ECB_NO_PADDING((psa_algorithm_t)0x04404400)

    #definePSA_ALG_CBC_NO_PADDING((psa_algorithm_t)0x04404000)

    #definePSA_ALG_CBC_PKCS7((psa_algorithm_t)0x04404100)

    #definePSA_ALG_AEAD_FROM_BLOCK_FLAG((psa_algorithm_t)0x00400000)

    #definePSA_ALG_IS_AEAD_ON_BLOCK_CIPHER(alg)\
    (((alg)&(PSA_ALG_CATEGORY_MASK|PSA_ALG_AEAD_FROM_BLOCK_FLAG))==\
    (PSA_ALG_CATEGORY_AEAD|PSA_ALG_AEAD_FROM_BLOCK_FLAG))

    #definePSA_ALG_CCM((psa_algorithm_t)0x05500100)

    #definePSA_ALG_CCM_STAR_NO_TAG((psa_algorithm_t)0x04c01300)

    #definePSA_ALG_GCM((psa_algorithm_t)0x05500200)

    #definePSA_ALG_CHACHA20_POLY1305((psa_algorithm_t)0x05100500)

    /*IntheencodingofanAEADalgorithm,thebitscorrespondingto
    *PSA_ALG_AEAD_TAG_LENGTH_MASKencodethelengthoftheAEADtag.
    *Theconstantsfordefaultlengthsfollowthisencoding.
    */
    #definePSA_ALG_AEAD_TAG_LENGTH_MASK((psa_algorithm_t)0x003f0000)
    #definePSA_AEAD_TAG_LENGTH_OFFSET16

    /*IntheencodingofanAEADalgorithm,thebitcorrespondingto
    *#PSA_ALG_AEAD_AT_LEAST_THIS_LENGTH_FLAGencodesthefactthatthealgorithm
    *isawildcardalgorithm.Akeywithsuchwildcardalgorithmaspermitted
    *algorithmpolicycanbeusedwithanyalgorithmcorrespondingtothe
    *samebaseclassandhavingataglengthgreaterthanorequaltotheone
    *encodedin#PSA_ALG_AEAD_TAG_LENGTH_MASK.*/
    #definePSA_ALG_AEAD_AT_LEAST_THIS_LENGTH_FLAG((psa_algorithm_t)0x00008000)

    #definePSA_ALG_AEAD_WITH_SHORTENED_TAG(aead_alg,tag_length)\
    (((aead_alg)&~(PSA_ALG_AEAD_TAG_LENGTH_MASK|\
    PSA_ALG_AEAD_AT_LEAST_THIS_LENGTH_FLAG))|\
    ((tag_length)<<PSA_AEAD_TAG_LENGTH_OFFSET&\
    PSA_ALG_AEAD_TAG_LENGTH_MASK))

    #definePSA_ALG_AEAD_GET_TAG_LENGTH(aead_alg)\
    (((aead_alg)&PSA_ALG_AEAD_TAG_LENGTH_MASK)>>\
    PSA_AEAD_TAG_LENGTH_OFFSET)

    #definePSA_ALG_AEAD_WITH_DEFAULT_LENGTH_TAG(aead_alg)\
    (\
    PSA_ALG_AEAD_WITH_DEFAULT_LENGTH_TAG_CASE(aead_alg,PSA_ALG_CCM)\
    PSA_ALG_AEAD_WITH_DEFAULT_LENGTH_TAG_CASE(aead_alg,PSA_ALG_GCM)\
    PSA_ALG_AEAD_WITH_DEFAULT_LENGTH_TAG_CASE(aead_alg,PSA_ALG_CHACHA20_POLY1305)\
    0)
    #definePSA_ALG_AEAD_WITH_DEFAULT_LENGTH_TAG_CASE(aead_alg,ref)\
    PSA_ALG_AEAD_WITH_SHORTENED_TAG(aead_alg,0)==\
    PSA_ALG_AEAD_WITH_SHORTENED_TAG(ref,0)?\
    ref:

    #definePSA_ALG_AEAD_WITH_AT_LEAST_THIS_LENGTH_TAG(aead_alg,min_tag_length)\
    (PSA_ALG_AEAD_WITH_SHORTENED_TAG(aead_alg,min_tag_length)|\
    PSA_ALG_AEAD_AT_LEAST_THIS_LENGTH_FLAG)

    #definePSA_ALG_RSA_PKCS1V15_SIGN_BASE((psa_algorithm_t)0x06000200)
    #definePSA_ALG_RSA_PKCS1V15_SIGN(hash_alg)\
    (PSA_ALG_RSA_PKCS1V15_SIGN_BASE|((hash_alg)&PSA_ALG_HASH_MASK))
    #definePSA_ALG_RSA_PKCS1V15_SIGN_RAWPSA_ALG_RSA_PKCS1V15_SIGN_BASE
    #definePSA_ALG_IS_RSA_PKCS1V15_SIGN(alg)\
    (((alg)&~PSA_ALG_HASH_MASK)==PSA_ALG_RSA_PKCS1V15_SIGN_BASE)

    #definePSA_ALG_RSA_PSS_BASE((psa_algorithm_t)0x06000300)
    #definePSA_ALG_RSA_PSS_ANY_SALT_BASE((psa_algorithm_t)0x06001300)
    #definePSA_ALG_RSA_PSS(hash_alg)\
    (PSA_ALG_RSA_PSS_BASE|((hash_alg)&PSA_ALG_HASH_MASK))

    #definePSA_ALG_RSA_PSS_ANY_SALT(hash_alg)\
    (PSA_ALG_RSA_PSS_ANY_SALT_BASE|((hash_alg)&PSA_ALG_HASH_MASK))

    #definePSA_ALG_IS_RSA_PSS_STANDARD_SALT(alg)\
    (((alg)&~PSA_ALG_HASH_MASK)==PSA_ALG_RSA_PSS_BASE)

    #definePSA_ALG_IS_RSA_PSS_ANY_SALT(alg)\
    (((alg)&~PSA_ALG_HASH_MASK)==PSA_ALG_RSA_PSS_ANY_SALT_BASE)

    #definePSA_ALG_IS_RSA_PSS(alg)\
    (PSA_ALG_IS_RSA_PSS_STANDARD_SALT(alg)||\
    PSA_ALG_IS_RSA_PSS_ANY_SALT(alg))

    #definePSA_ALG_ECDSA_BASE((psa_algorithm_t)0x06000600)
    #definePSA_ALG_ECDSA(hash_alg)\
    (PSA_ALG_ECDSA_BASE|((hash_alg)&PSA_ALG_HASH_MASK))
    #definePSA_ALG_ECDSA_ANYPSA_ALG_ECDSA_BASE
    #definePSA_ALG_DETERMINISTIC_ECDSA_BASE((psa_algorithm_t)0x06000700)
    #definePSA_ALG_DETERMINISTIC_ECDSA(hash_alg)\
    (PSA_ALG_DETERMINISTIC_ECDSA_BASE|((hash_alg)&PSA_ALG_HASH_MASK))
    #definePSA_ALG_ECDSA_DETERMINISTIC_FLAG((psa_algorithm_t)0x00000100)
    #definePSA_ALG_IS_ECDSA(alg)\
    (((alg)&~PSA_ALG_HASH_MASK&~PSA_ALG_ECDSA_DETERMINISTIC_FLAG)==\
    PSA_ALG_ECDSA_BASE)
    #definePSA_ALG_ECDSA_IS_DETERMINISTIC(alg)\
    (((alg)&PSA_ALG_ECDSA_DETERMINISTIC_FLAG)!=0)
    #definePSA_ALG_IS_DETERMINISTIC_ECDSA(alg)\
    (PSA_ALG_IS_ECDSA(alg)&&PSA_ALG_ECDSA_IS_DETERMINISTIC(alg))
    #definePSA_ALG_IS_RANDOMIZED_ECDSA(alg)\
    (PSA_ALG_IS_ECDSA(alg)&&!PSA_ALG_ECDSA_IS_DETERMINISTIC(alg))

    #definePSA_ALG_PURE_EDDSA((psa_algorithm_t)0x06000800)

    #definePSA_ALG_HASH_EDDSA_BASE((psa_algorithm_t)0x06000900)
    #definePSA_ALG_IS_HASH_EDDSA(alg)\
    (((alg)&~PSA_ALG_HASH_MASK)==PSA_ALG_HASH_EDDSA_BASE)

    #definePSA_ALG_ED25519PH\
    (PSA_ALG_HASH_EDDSA_BASE|(PSA_ALG_SHA_512&PSA_ALG_HASH_MASK))

    #definePSA_ALG_ED448PH\
    (PSA_ALG_HASH_EDDSA_BASE|(PSA_ALG_SHAKE256_512&PSA_ALG_HASH_MASK))

    /*Defaultdefinition,tobeoverriddenifthelibraryisextendedwith
    *morehash-and-signalgorithmsthatwewanttokeepoutofthisheader
    *file.*/
    #definePSA_ALG_IS_VENDOR_HASH_AND_SIGN(alg)0

    #definePSA_ALG_IS_SIGN_HASH(alg)\
    (PSA_ALG_IS_RSA_PSS(alg)||PSA_ALG_IS_RSA_PKCS1V15_SIGN(alg)||\
    PSA_ALG_IS_ECDSA(alg)||PSA_ALG_IS_HASH_EDDSA(alg)||\
    PSA_ALG_IS_VENDOR_HASH_AND_SIGN(alg))

    #definePSA_ALG_IS_SIGN_MESSAGE(alg)\
    (PSA_ALG_IS_SIGN_HASH(alg)||(alg)==PSA_ALG_PURE_EDDSA)

    #definePSA_ALG_IS_HASH_AND_SIGN(alg)\
    (PSA_ALG_IS_SIGN_HASH(alg)&&\
    ((alg)&PSA_ALG_HASH_MASK)!=0)

    #definePSA_ALG_SIGN_GET_HASH(alg)\
    (PSA_ALG_IS_HASH_AND_SIGN(alg)?\
    ((alg)&PSA_ALG_HASH_MASK)|PSA_ALG_CATEGORY_HASH:\
    0)

    #definePSA_ALG_RSA_PKCS1V15_CRYPT((psa_algorithm_t)0x07000200)

    #definePSA_ALG_RSA_OAEP_BASE((psa_algorithm_t)0x07000300)
    #definePSA_ALG_RSA_OAEP(hash_alg)\
    (PSA_ALG_RSA_OAEP_BASE|((hash_alg)&PSA_ALG_HASH_MASK))
    #definePSA_ALG_IS_RSA_OAEP(alg)\
    (((alg)&~PSA_ALG_HASH_MASK)==PSA_ALG_RSA_OAEP_BASE)
    #definePSA_ALG_RSA_OAEP_GET_HASH(alg)\
    (PSA_ALG_IS_RSA_OAEP(alg)?\
    ((alg)&PSA_ALG_HASH_MASK)|PSA_ALG_CATEGORY_HASH:\
    0)

    #definePSA_ALG_HKDF_BASE((psa_algorithm_t)0x08000100)
    #definePSA_ALG_HKDF(hash_alg)\
    (PSA_ALG_HKDF_BASE|((hash_alg)&PSA_ALG_HASH_MASK))
    #definePSA_ALG_IS_HKDF(alg)\
    (((alg)&~PSA_ALG_HASH_MASK)==PSA_ALG_HKDF_BASE)
    #definePSA_ALG_HKDF_GET_HASH(hkdf_alg)\
    (PSA_ALG_CATEGORY_HASH|((hkdf_alg)&PSA_ALG_HASH_MASK))

    #definePSA_ALG_HKDF_EXTRACT_BASE((psa_algorithm_t)0x08000400)
    #definePSA_ALG_HKDF_EXTRACT(hash_alg)\
    (PSA_ALG_HKDF_EXTRACT_BASE|((hash_alg)&PSA_ALG_HASH_MASK))
    #definePSA_ALG_IS_HKDF_EXTRACT(alg)\
    (((alg)&~PSA_ALG_HASH_MASK)==PSA_ALG_HKDF_EXTRACT_BASE)

    #definePSA_ALG_HKDF_EXPAND_BASE((psa_algorithm_t)0x08000500)
    #definePSA_ALG_HKDF_EXPAND(hash_alg)\
    (PSA_ALG_HKDF_EXPAND_BASE|((hash_alg)&PSA_ALG_HASH_MASK))
    #definePSA_ALG_IS_HKDF_EXPAND(alg)\
    (((alg)&~PSA_ALG_HASH_MASK)==PSA_ALG_HKDF_EXPAND_BASE)

    #definePSA_ALG_IS_ANY_HKDF(alg)\
    (((alg)&~PSA_ALG_HASH_MASK)==PSA_ALG_HKDF_BASE||\
    ((alg)&~PSA_ALG_HASH_MASK)==PSA_ALG_HKDF_EXTRACT_BASE||\
    ((alg)&~PSA_ALG_HASH_MASK)==PSA_ALG_HKDF_EXPAND_BASE)

    #definePSA_ALG_TLS12_PRF_BASE((psa_algorithm_t)0x08000200)
    #definePSA_ALG_TLS12_PRF(hash_alg)\
    (PSA_ALG_TLS12_PRF_BASE|((hash_alg)&PSA_ALG_HASH_MASK))

    #definePSA_ALG_IS_TLS12_PRF(alg)\
    (((alg)&~PSA_ALG_HASH_MASK)==PSA_ALG_TLS12_PRF_BASE)
    #definePSA_ALG_TLS12_PRF_GET_HASH(hkdf_alg)\
    (PSA_ALG_CATEGORY_HASH|((hkdf_alg)&PSA_ALG_HASH_MASK))

    #definePSA_ALG_TLS12_PSK_TO_MS_BASE((psa_algorithm_t)0x08000300)
    #definePSA_ALG_TLS12_PSK_TO_MS(hash_alg)\
    (PSA_ALG_TLS12_PSK_TO_MS_BASE|((hash_alg)&PSA_ALG_HASH_MASK))

    #definePSA_ALG_IS_TLS12_PSK_TO_MS(alg)\
    (((alg)&~PSA_ALG_HASH_MASK)==PSA_ALG_TLS12_PSK_TO_MS_BASE)
    #definePSA_ALG_TLS12_PSK_TO_MS_GET_HASH(hkdf_alg)\
    (PSA_ALG_CATEGORY_HASH|((hkdf_alg)&PSA_ALG_HASH_MASK))

    /*TheTLS1.2ECJPAKE-to-PMSKDF.IttakesthesharedsecretK(anECpoint
    *incaseofECJ-PAKE)andcalculatesSHA256(K.X)thattherestofTLS1.2
    *willusetoderivethesessionsecret,asdefinedbystep2of
    *https://datatracker.ietf.org/doc/html/draft-cragie-tls-ecjpake-01#section-8.7.
    *UsesPSA_ALG_SHA_256.
    *Thisfunctiontakesasingleinput:
    *#PSA_KEY_DERIVATION_INPUT_SECRETisthesharedsecretKfromECJ-PAKE.
    *Theonlysupportedcurveissecp256r1(the256-bitcurvein
    *#PSA_ECC_FAMILY_SECP_R1),sotheinputmustbeexactly65bytes.
    *Theoutputhastobereadasasinglechunkof32bytes,definedas
    *PSA_TLS12_ECJPAKE_TO_PMS_DATA_SIZE.
    */
    #definePSA_ALG_TLS12_ECJPAKE_TO_PMS((psa_algorithm_t)0x08000609)

    /*Thisflagindicateswhetherthekeyderivationalgorithmissuitablefor
    *useonlow-entropysecretssuchaspassword-thesealgorithmsarealso
    *knownaskeystretchingorpasswordhashingschemes.Thesearealsothe
    *algorithmsthatacceptsinputsoftype#PSA_KEY_DERIVATION_INPUT_PASSWORD.
    *
    *Thosealgorithmscannotbecombinedwithakeyagreementalgorithm.
    */
    #definePSA_ALG_KEY_DERIVATION_STRETCHING_FLAG((psa_algorithm_t)0x00800000)

    #definePSA_ALG_PBKDF2_HMAC_BASE((psa_algorithm_t)0x08800100)
    #definePSA_ALG_PBKDF2_HMAC(hash_alg)\
    (PSA_ALG_PBKDF2_HMAC_BASE|((hash_alg)&PSA_ALG_HASH_MASK))

    #definePSA_ALG_IS_PBKDF2_HMAC(alg)\
    (((alg)&~PSA_ALG_HASH_MASK)==PSA_ALG_PBKDF2_HMAC_BASE)
    #definePSA_ALG_PBKDF2_HMAC_GET_HASH(pbkdf2_alg)\
    (PSA_ALG_CATEGORY_HASH|((pbkdf2_alg)&PSA_ALG_HASH_MASK))
    #definePSA_ALG_PBKDF2_AES_CMAC_PRF_128((psa_algorithm_t)0x08800200)

    #definePSA_ALG_IS_PBKDF2(kdf_alg)\
    (PSA_ALG_IS_PBKDF2_HMAC(kdf_alg)||\
    ((kdf_alg)==PSA_ALG_PBKDF2_AES_CMAC_PRF_128))

    #definePSA_ALG_KEY_DERIVATION_MASK((psa_algorithm_t)0xfe00ffff)
    #definePSA_ALG_KEY_AGREEMENT_MASK((psa_algorithm_t)0xffff0000)

    #definePSA_ALG_KEY_AGREEMENT(ka_alg,kdf_alg)\
    ((ka_alg)|(kdf_alg))

    #definePSA_ALG_KEY_AGREEMENT_GET_KDF(alg)\
    (((alg)&PSA_ALG_KEY_DERIVATION_MASK)|PSA_ALG_CATEGORY_KEY_DERIVATION)

    #definePSA_ALG_KEY_AGREEMENT_GET_BASE(alg)\
    (((alg)&PSA_ALG_KEY_AGREEMENT_MASK)|PSA_ALG_CATEGORY_KEY_AGREEMENT)

    #definePSA_ALG_IS_RAW_KEY_AGREEMENT(alg)\
    (PSA_ALG_IS_KEY_AGREEMENT(alg)&&\
    PSA_ALG_KEY_AGREEMENT_GET_KDF(alg)==PSA_ALG_CATEGORY_KEY_DERIVATION)

    #definePSA_ALG_IS_KEY_DERIVATION_OR_AGREEMENT(alg)\
    ((PSA_ALG_IS_KEY_DERIVATION(alg)||PSA_ALG_IS_KEY_AGREEMENT(alg)))

    #definePSA_ALG_FFDH((psa_algorithm_t)0x09010000)

    #definePSA_ALG_IS_FFDH(alg)\
    (PSA_ALG_KEY_AGREEMENT_GET_BASE(alg)==PSA_ALG_FFDH)

    #definePSA_ALG_ECDH((psa_algorithm_t)0x09020000)

    #definePSA_ALG_IS_ECDH(alg)\
    (PSA_ALG_KEY_AGREEMENT_GET_BASE(alg)==PSA_ALG_ECDH)

    #definePSA_ALG_IS_WILDCARD(alg)\
    (PSA_ALG_IS_HASH_AND_SIGN(alg)?\
    PSA_ALG_SIGN_GET_HASH(alg)==PSA_ALG_ANY_HASH:\
    PSA_ALG_IS_MAC(alg)?\
    (alg&PSA_ALG_MAC_AT_LEAST_THIS_LENGTH_FLAG)!=0:\
    PSA_ALG_IS_AEAD(alg)?\
    (alg&PSA_ALG_AEAD_AT_LEAST_THIS_LENGTH_FLAG)!=0:\
    (alg)==PSA_ALG_ANY_HASH)

    #definePSA_ALG_GET_HASH(alg)\
    (((alg)&0x000000ff)==0?((psa_algorithm_t)0):0x02000000|((alg)&0x000000ff))

    /*Notethatlocationandpersistencelevelvaluesareembeddedinthe
    *persistentkeystore,aspartofkeymetadata.Asaconsequence,they
    *mustnotbechanged(unlessthestorageformatversionchanges).
    */

    #definePSA_KEY_LIFETIME_VOLATILE((psa_key_lifetime_t)0x00000000)

    #definePSA_KEY_LIFETIME_PERSISTENT((psa_key_lifetime_t)0x00000001)

    #definePSA_KEY_PERSISTENCE_VOLATILE((psa_key_persistence_t)0x00)

    #definePSA_KEY_PERSISTENCE_DEFAULT((psa_key_persistence_t)0x01)

    #definePSA_KEY_PERSISTENCE_READ_ONLY((psa_key_persistence_t)0xff)

    #definePSA_KEY_LIFETIME_GET_PERSISTENCE(lifetime)\
    ((psa_key_persistence_t)((lifetime)&0x000000ff))

    #definePSA_KEY_LIFETIME_GET_LOCATION(lifetime)\
    ((psa_key_location_t)((lifetime)>>8))

    #definePSA_KEY_LIFETIME_IS_VOLATILE(lifetime)\
    (PSA_KEY_LIFETIME_GET_PERSISTENCE(lifetime)==\
    PSA_KEY_PERSISTENCE_VOLATILE)

    #definePSA_KEY_LIFETIME_IS_READ_ONLY(lifetime)\
    (PSA_KEY_LIFETIME_GET_PERSISTENCE(lifetime)==\
    PSA_KEY_PERSISTENCE_READ_ONLY)

    #definePSA_KEY_LIFETIME_FROM_PERSISTENCE_AND_LOCATION(persistence,location)\
    ((location)<<8|(persistence))

    #definePSA_KEY_LOCATION_LOCAL_STORAGE((psa_key_location_t)0x000000)

    #definePSA_KEY_LOCATION_VENDOR_FLAG((psa_key_location_t)0x800000)

    /*Notethatkeyidentifiervaluesareembeddedinthe
    *persistentkeystore,aspartofkeymetadata.Asaconsequence,they
    *mustnotbechanged(unlessthestorageformatversionchanges).
    */

    /**INDENT-OFF*(https://github.com/ARM-software/psa-arch-tests/issues/337)*/
    #definePSA_KEY_ID_NULL((psa_key_id_t)0)
    /**INDENT-ON**/
    #definePSA_KEY_ID_USER_MIN((psa_key_id_t)0x00000001)
    #definePSA_KEY_ID_USER_MAX((psa_key_id_t)0x3fffffff)
    #definePSA_KEY_ID_VENDOR_MIN((psa_key_id_t)0x40000000)
    #definePSA_KEY_ID_VENDOR_MAX((psa_key_id_t)0x7fffffff)

    #if!defined(MBEDTLS_PSA_CRYPTO_KEY_ID_ENCODES_OWNER)

    #defineMBEDTLS_SVC_KEY_ID_INIT((psa_key_id_t)0)
    #defineMBEDTLS_SVC_KEY_ID_GET_KEY_ID(id)(id)
    #defineMBEDTLS_SVC_KEY_ID_GET_OWNER_ID(id)(0)

    staticinlinembedtls_svc_key_id_tmbedtls_svc_key_id_make(
    unsignedintunused,psa_key_id_tkey_id)
    {
    (void)unused;

    returnkey_id;
    }

    staticinlineintmbedtls_svc_key_id_equal(mbedtls_svc_key_id_tid1,
    mbedtls_svc_key_id_tid2)
    {
    returnid1==id2;
    }

    staticinlineintmbedtls_svc_key_id_is_null(mbedtls_svc_key_id_tkey)
    {
    returnkey==0;
    }

    #else/*MBEDTLS_PSA_CRYPTO_KEY_ID_ENCODES_OWNER*/

    #defineMBEDTLS_SVC_KEY_ID_INIT((mbedtls_svc_key_id_t){0,0})
    #defineMBEDTLS_SVC_KEY_ID_GET_KEY_ID(id)((id).MBEDTLS_PRIVATE(key_id))
    #defineMBEDTLS_SVC_KEY_ID_GET_OWNER_ID(id)((id).MBEDTLS_PRIVATE(owner))

    staticinlinembedtls_svc_key_id_tmbedtls_svc_key_id_make(
    mbedtls_key_owner_id_towner_id,psa_key_id_tkey_id)
    {
    return(mbedtls_svc_key_id_t){.MBEDTLS_PRIVATE(key_id)=key_id,
    .MBEDTLS_PRIVATE(owner)=owner_id};
    }

    staticinlineintmbedtls_svc_key_id_equal(mbedtls_svc_key_id_tid1,
    mbedtls_svc_key_id_tid2)
    {
    return(id1.MBEDTLS_PRIVATE(key_id)==id2.MBEDTLS_PRIVATE(key_id))&&
    mbedtls_key_owner_id_equal(id1.MBEDTLS_PRIVATE(owner),id2.MBEDTLS_PRIVATE(owner));
    }

    staticinlineintmbedtls_svc_key_id_is_null(mbedtls_svc_key_id_tkey)
    {
    returnkey.MBEDTLS_PRIVATE(key_id)==0;
    }

    #endif/*!MBEDTLS_PSA_CRYPTO_KEY_ID_ENCODES_OWNER*/

    /*Notethatkeyusageflagsareembeddedinthe
    *persistentkeystore,aspartofkeymetadata.Asaconsequence,they
    *mustnotbechanged(unlessthestorageformatversionchanges).
    */

    #definePSA_KEY_USAGE_EXPORT((psa_key_usage_t)0x00000001)

    #definePSA_KEY_USAGE_COPY((psa_key_usage_t)0x00000002)

    #definePSA_KEY_USAGE_ENCRYPT((psa_key_usage_t)0x00000100)

    #definePSA_KEY_USAGE_DECRYPT((psa_key_usage_t)0x00000200)

    #definePSA_KEY_USAGE_SIGN_MESSAGE((psa_key_usage_t)0x00000400)

    #definePSA_KEY_USAGE_VERIFY_MESSAGE((psa_key_usage_t)0x00000800)

    #definePSA_KEY_USAGE_SIGN_HASH((psa_key_usage_t)0x00001000)

    #definePSA_KEY_USAGE_VERIFY_HASH((psa_key_usage_t)0x00002000)

    #definePSA_KEY_USAGE_DERIVE((psa_key_usage_t)0x00004000)

    #definePSA_KEY_USAGE_VERIFY_DERIVATION((psa_key_usage_t)0x00008000)

    /*Keyinputstepsarenotembeddedinthepersistentstorage,soyoucan
    *changethemifneeded:it'sonlyanABIchange.*/

    #definePSA_KEY_DERIVATION_INPUT_SECRET((psa_key_derivation_step_t)0x0101)

    #definePSA_KEY_DERIVATION_INPUT_PASSWORD((psa_key_derivation_step_t)0x0102)

    #definePSA_KEY_DERIVATION_INPUT_OTHER_SECRET\
    ((psa_key_derivation_step_t)0x0103)

    #definePSA_KEY_DERIVATION_INPUT_LABEL((psa_key_derivation_step_t)0x0201)

    #definePSA_KEY_DERIVATION_INPUT_SALT((psa_key_derivation_step_t)0x0202)

    #definePSA_KEY_DERIVATION_INPUT_INFO((psa_key_derivation_step_t)0x0203)

    #definePSA_KEY_DERIVATION_INPUT_SEED((psa_key_derivation_step_t)0x0204)

    #definePSA_KEY_DERIVATION_INPUT_COST((psa_key_derivation_step_t)0x0205)

    /*Helpermacros*/

    #defineMBEDTLS_PSA_ALG_AEAD_EQUAL(aead_alg_1,aead_alg_2)\
    (!(((aead_alg_1)^(aead_alg_2))&\
    ~(PSA_ALG_AEAD_TAG_LENGTH_MASK|PSA_ALG_AEAD_AT_LEAST_THIS_LENGTH_FLAG)))

    #definePSA_INTERRUPTIBLE_MAX_OPS_UNLIMITEDUINT32_MAX

    #endif/*PSA_CRYPTO_VALUES_H*/