config_adjust_psa_from_legacy.h
config_psa.h
aes.h
aria.h
asn1.h
asn1write.h
base64.h
bignum.h
block_cipher.h
build_info.h
camellia.h
ccm.h
chacha20.h
chachapoly.h
cipher.h
cmac.h
config_adjust_psa_from_legacy.h
config_psa.h
ctr_drbg.h
debug.h
des.h
dhm.h
ecdh.h
ecdsa.h
ecjpake.h
ecp.h
entropy.h
error.h
gcm.h
hkdf.h
hmac_drbg.h
lms.h
md.h
md5.h
memory_buffer_alloc.h
net_sockets.h
nist_kw.h
oid.h
pem.h
pk.h
pkcs12.h
pkcs5.h
pkcs7.h
platform.h
platform_time.h
platform_util.h
poly1305.h
psa_util.h
ripemd160.h
rsa.h
sha1.h
sha256.h
sha3.h
sha512.h
ssl.h
ssl_cache.h
ssl_ciphersuites.h
ssl_cookie.h
ssl_ticket.h
threading.h
timing.h
version.h
x509.h
x509_crl.h
x509_crt.h
x509_csr.h
build_info.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_extra.h
crypto_platform.h
crypto_se_driver.h
crypto_sizes.h
crypto_struct.h
crypto_types.h
chachapoly_alt.h
MBEDTLS_PSA_BUILTIN_ALG_HMAC
1
PSA_WANT_ALG_HMAC
1
PSA_WANT_KEY_TYPE_HMAC
1

Adjust PSA configuration: construct PSA configuration from legacy.

This is an internal header. Do not include it directly.

When MBEDTLS_PSA_CRYPTO_CONFIG is disabled, we automatically enable cryptographic mechanisms through the PSA interface when the corresponding legacy mechanism is enabled. In many cases, this just enables the PSA wrapper code around the legacy implementation, but we also do this for some mechanisms where PSA has its own independent implementation so that high-level modules that can use either cryptographic API have the same feature set in both cases.

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

    #ifndefMBEDTLS_CONFIG_ADJUST_PSA_FROM_LEGACY_H
    #defineMBEDTLS_CONFIG_ADJUST_PSA_FROM_LEGACY_H

    #if!defined(MBEDTLS_CONFIG_FILES_READ)
    #error"Donotincludembedtls/config_adjust_*.hmanually!Thiscanleadtoproblems,"\
    "uptoandincludingruntimeerrorssuchasbufferoverflows."\
    "Ifyou'retryingtofixacomplaintfromcheck_config.h,justremove"\
    "itfromyourconfigurationfile:sinceMbedTLS3.0,itisincluded"\
    "automaticallyattherightpoint."
    #endif/**/

    /*
    *EnsurePSA_WANT_*definesaresetupproperlyifMBEDTLS_PSA_CRYPTO_CONFIG
    *isnotdefined
    */

    #ifdefined(MBEDTLS_CCM_C)
    #defineMBEDTLS_PSA_BUILTIN_ALG_CCM1
    #definePSA_WANT_ALG_CCM1
    #ifdefined(MBEDTLS_CIPHER_C)
    #defineMBEDTLS_PSA_BUILTIN_ALG_CCM_STAR_NO_TAG1
    #definePSA_WANT_ALG_CCM_STAR_NO_TAG1
    #endif/*MBEDTLS_CIPHER_C*/
    #endif/*MBEDTLS_CCM_C*/

    #ifdefined(MBEDTLS_CMAC_C)
    #defineMBEDTLS_PSA_BUILTIN_ALG_CMAC1
    #definePSA_WANT_ALG_CMAC1
    #endif/*MBEDTLS_CMAC_C*/

    #ifdefined(MBEDTLS_ECDH_C)
    #defineMBEDTLS_PSA_BUILTIN_ALG_ECDH1
    #definePSA_WANT_ALG_ECDH1
    #endif/*MBEDTLS_ECDH_C*/

    #ifdefined(MBEDTLS_ECDSA_C)
    #defineMBEDTLS_PSA_BUILTIN_ALG_ECDSA1
    #definePSA_WANT_ALG_ECDSA1
    #definePSA_WANT_ALG_ECDSA_ANY1

    //OnlyaddinDETERMINISTICsupportifECDSAisalsoenabled
    #ifdefined(MBEDTLS_ECDSA_DETERMINISTIC)
    #defineMBEDTLS_PSA_BUILTIN_ALG_DETERMINISTIC_ECDSA1
    #definePSA_WANT_ALG_DETERMINISTIC_ECDSA1
    #endif/*MBEDTLS_ECDSA_DETERMINISTIC*/

    #endif/*MBEDTLS_ECDSA_C*/

    #ifdefined(MBEDTLS_ECP_C)
    #definePSA_WANT_KEY_TYPE_ECC_KEY_PAIR_BASIC1
    #definePSA_WANT_KEY_TYPE_ECC_KEY_PAIR_IMPORT1
    #definePSA_WANT_KEY_TYPE_ECC_KEY_PAIR_EXPORT1
    #definePSA_WANT_KEY_TYPE_ECC_KEY_PAIR_GENERATE1
    /*Normallywewouldn'tenablethisbecauseit'snotimplementedinecp.c,
    *butsinceitusedtobeavailableanytimeECP_Cwasenabled,let'senable
    *itanywayforthesakeofbackwardscompatibility*/
    #definePSA_WANT_KEY_TYPE_ECC_KEY_PAIR_DERIVE1
    #defineMBEDTLS_PSA_BUILTIN_KEY_TYPE_ECC_KEY_PAIR_BASIC1
    #defineMBEDTLS_PSA_BUILTIN_KEY_TYPE_ECC_KEY_PAIR_IMPORT1
    #defineMBEDTLS_PSA_BUILTIN_KEY_TYPE_ECC_KEY_PAIR_EXPORT1
    #defineMBEDTLS_PSA_BUILTIN_KEY_TYPE_ECC_KEY_PAIR_GENERATE1
    /*SeecommentforPSA_WANT_KEY_TYPE_ECC_KEY_PAIR_DERIVEabove.*/
    #defineMBEDTLS_PSA_BUILTIN_KEY_TYPE_ECC_KEY_PAIR_DERIVE1
    #defineMBEDTLS_PSA_BUILTIN_KEY_TYPE_ECC_PUBLIC_KEY1
    #definePSA_WANT_KEY_TYPE_ECC_PUBLIC_KEY1
    #endif/*MBEDTLS_ECP_C*/

    #ifdefined(MBEDTLS_DHM_C)
    #definePSA_WANT_KEY_TYPE_DH_KEY_PAIR_BASIC1
    #definePSA_WANT_KEY_TYPE_DH_KEY_PAIR_IMPORT1
    #definePSA_WANT_KEY_TYPE_DH_KEY_PAIR_EXPORT1
    #definePSA_WANT_KEY_TYPE_DH_KEY_PAIR_GENERATE1
    #definePSA_WANT_KEY_TYPE_DH_PUBLIC_KEY1
    #definePSA_WANT_ALG_FFDH1
    #definePSA_WANT_DH_RFC7919_20481
    #definePSA_WANT_DH_RFC7919_30721
    #definePSA_WANT_DH_RFC7919_40961
    #definePSA_WANT_DH_RFC7919_61441
    #definePSA_WANT_DH_RFC7919_81921
    #defineMBEDTLS_PSA_BUILTIN_ALG_FFDH1
    #defineMBEDTLS_PSA_BUILTIN_KEY_TYPE_DH_KEY_PAIR_BASIC1
    #defineMBEDTLS_PSA_BUILTIN_KEY_TYPE_DH_KEY_PAIR_IMPORT1
    #defineMBEDTLS_PSA_BUILTIN_KEY_TYPE_DH_KEY_PAIR_EXPORT1
    #defineMBEDTLS_PSA_BUILTIN_KEY_TYPE_DH_KEY_PAIR_GENERATE1
    #defineMBEDTLS_PSA_BUILTIN_KEY_TYPE_DH_PUBLIC_KEY1
    #defineMBEDTLS_PSA_BUILTIN_DH_RFC7919_20481
    #defineMBEDTLS_PSA_BUILTIN_DH_RFC7919_30721
    #defineMBEDTLS_PSA_BUILTIN_DH_RFC7919_40961
    #defineMBEDTLS_PSA_BUILTIN_DH_RFC7919_61441
    #defineMBEDTLS_PSA_BUILTIN_DH_RFC7919_81921
    #endif/*MBEDTLS_DHM_C*/

    #ifdefined(MBEDTLS_GCM_C)
    #defineMBEDTLS_PSA_BUILTIN_ALG_GCM1
    #definePSA_WANT_ALG_GCM1
    #endif/*MBEDTLS_GCM_C*/

    /*EnablePSAHKDFalgorithmifmbedtlsHKDFissupported.
    *PSAHKDFEXTRACTandPSAHKDFEXPANDhaveminimalcostwhen
    *PSAHKDFisenabled,soenablebothalgorithmstogether
    *withPSAHKDF.*/
    #ifdefined(MBEDTLS_HKDF_C)
    #defineMBEDTLS_PSA_BUILTIN_ALG_HMAC1
    #definePSA_WANT_ALG_HMAC1
    #defineMBEDTLS_PSA_BUILTIN_ALG_HKDF1
    #definePSA_WANT_ALG_HKDF1
    #defineMBEDTLS_PSA_BUILTIN_ALG_HKDF_EXTRACT1
    #definePSA_WANT_ALG_HKDF_EXTRACT1
    #defineMBEDTLS_PSA_BUILTIN_ALG_HKDF_EXPAND1
    #definePSA_WANT_ALG_HKDF_EXPAND1
    #endif/*MBEDTLS_HKDF_C*/

    #defineMBEDTLS_PSA_BUILTIN_ALG_HMAC1
    #definePSA_WANT_ALG_HMAC1
    #definePSA_WANT_KEY_TYPE_HMAC1

    #ifdefined(MBEDTLS_MD_C)
    #defineMBEDTLS_PSA_BUILTIN_ALG_TLS12_PRF1
    #definePSA_WANT_ALG_TLS12_PRF1
    #defineMBEDTLS_PSA_BUILTIN_ALG_TLS12_PSK_TO_MS1
    #definePSA_WANT_ALG_TLS12_PSK_TO_MS1
    #endif/*MBEDTLS_MD_C*/

    #ifdefined(MBEDTLS_MD5_C)
    #defineMBEDTLS_PSA_BUILTIN_ALG_MD51
    #definePSA_WANT_ALG_MD51
    #endif

    #ifdefined(MBEDTLS_ECJPAKE_C)
    #defineMBEDTLS_PSA_BUILTIN_PAKE1
    #defineMBEDTLS_PSA_BUILTIN_ALG_JPAKE1
    #definePSA_WANT_ALG_JPAKE1
    #endif

    #ifdefined(MBEDTLS_RIPEMD160_C)
    #defineMBEDTLS_PSA_BUILTIN_ALG_RIPEMD1601
    #definePSA_WANT_ALG_RIPEMD1601
    #endif

    #ifdefined(MBEDTLS_RSA_C)
    #ifdefined(MBEDTLS_PKCS1_V15)
    #defineMBEDTLS_PSA_BUILTIN_ALG_RSA_PKCS1V15_CRYPT1
    #definePSA_WANT_ALG_RSA_PKCS1V15_CRYPT1
    #defineMBEDTLS_PSA_BUILTIN_ALG_RSA_PKCS1V15_SIGN1
    #definePSA_WANT_ALG_RSA_PKCS1V15_SIGN1
    #definePSA_WANT_ALG_RSA_PKCS1V15_SIGN_RAW1
    #endif/*MBEDTLS_PKCS1_V15*/
    #ifdefined(MBEDTLS_PKCS1_V21)
    #defineMBEDTLS_PSA_BUILTIN_ALG_RSA_OAEP1
    #definePSA_WANT_ALG_RSA_OAEP1
    #defineMBEDTLS_PSA_BUILTIN_ALG_RSA_PSS1
    #definePSA_WANT_ALG_RSA_PSS1
    #endif/*MBEDTLS_PKCS1_V21*/
    #ifdefined(MBEDTLS_GENPRIME)
    #defineMBEDTLS_PSA_BUILTIN_KEY_TYPE_RSA_KEY_PAIR_GENERATE1
    #definePSA_WANT_KEY_TYPE_RSA_KEY_PAIR_GENERATE1
    #endif/*MBEDTLS_GENPRIME*/
    #defineMBEDTLS_PSA_BUILTIN_KEY_TYPE_RSA_KEY_PAIR_BASIC1
    #defineMBEDTLS_PSA_BUILTIN_KEY_TYPE_RSA_KEY_PAIR_IMPORT1
    #defineMBEDTLS_PSA_BUILTIN_KEY_TYPE_RSA_KEY_PAIR_EXPORT1
    #definePSA_WANT_KEY_TYPE_RSA_KEY_PAIR_BASIC1
    #definePSA_WANT_KEY_TYPE_RSA_KEY_PAIR_IMPORT1
    #definePSA_WANT_KEY_TYPE_RSA_KEY_PAIR_EXPORT1
    #defineMBEDTLS_PSA_BUILTIN_KEY_TYPE_RSA_PUBLIC_KEY1
    #definePSA_WANT_KEY_TYPE_RSA_PUBLIC_KEY1
    #endif/*MBEDTLS_RSA_C*/

    #ifdefined(MBEDTLS_SHA1_C)
    #defineMBEDTLS_PSA_BUILTIN_ALG_SHA_11
    #definePSA_WANT_ALG_SHA_11
    #endif

    #ifdefined(MBEDTLS_SHA224_C)
    #defineMBEDTLS_PSA_BUILTIN_ALG_SHA_2241
    #definePSA_WANT_ALG_SHA_2241
    #endif

    #ifdefined(MBEDTLS_SHA256_C)
    #defineMBEDTLS_PSA_BUILTIN_ALG_SHA_2561
    #definePSA_WANT_ALG_SHA_2561
    #endif

    #ifdefined(MBEDTLS_SHA384_C)
    #defineMBEDTLS_PSA_BUILTIN_ALG_SHA_3841
    #definePSA_WANT_ALG_SHA_3841
    #endif

    #ifdefined(MBEDTLS_SHA512_C)
    #defineMBEDTLS_PSA_BUILTIN_ALG_SHA_5121
    #definePSA_WANT_ALG_SHA_5121
    #endif

    #ifdefined(MBEDTLS_SHA3_C)
    #defineMBEDTLS_PSA_BUILTIN_ALG_SHA3_2241
    #defineMBEDTLS_PSA_BUILTIN_ALG_SHA3_2561
    #defineMBEDTLS_PSA_BUILTIN_ALG_SHA3_3841
    #defineMBEDTLS_PSA_BUILTIN_ALG_SHA3_5121
    #definePSA_WANT_ALG_SHA3_2241
    #definePSA_WANT_ALG_SHA3_2561
    #definePSA_WANT_ALG_SHA3_3841
    #definePSA_WANT_ALG_SHA3_5121
    #endif

    #ifdefined(MBEDTLS_AES_C)
    #definePSA_WANT_KEY_TYPE_AES1
    #defineMBEDTLS_PSA_BUILTIN_KEY_TYPE_AES1
    #endif

    #ifdefined(MBEDTLS_ARIA_C)
    #definePSA_WANT_KEY_TYPE_ARIA1
    #defineMBEDTLS_PSA_BUILTIN_KEY_TYPE_ARIA1
    #endif

    #ifdefined(MBEDTLS_CAMELLIA_C)
    #definePSA_WANT_KEY_TYPE_CAMELLIA1
    #defineMBEDTLS_PSA_BUILTIN_KEY_TYPE_CAMELLIA1
    #endif

    #ifdefined(MBEDTLS_DES_C)
    #definePSA_WANT_KEY_TYPE_DES1
    #defineMBEDTLS_PSA_BUILTIN_KEY_TYPE_DES1
    #endif

    #ifdefined(MBEDTLS_PSA_BUILTIN_ALG_SHA_256)
    #defineMBEDTLS_PSA_BUILTIN_ALG_TLS12_ECJPAKE_TO_PMS1
    #definePSA_WANT_ALG_TLS12_ECJPAKE_TO_PMS1
    #endif

    #ifdefined(MBEDTLS_CHACHA20_C)
    #definePSA_WANT_KEY_TYPE_CHACHA201
    #defineMBEDTLS_PSA_BUILTIN_KEY_TYPE_CHACHA201
    /*ALG_STREAM_CIPHERrequiresCIPHER_CinordertobesupportedinPSA*/
    #ifdefined(MBEDTLS_CIPHER_C)
    #definePSA_WANT_ALG_STREAM_CIPHER1
    #defineMBEDTLS_PSA_BUILTIN_ALG_STREAM_CIPHER1
    #endif
    #ifdefined(MBEDTLS_CHACHAPOLY_C)
    #definePSA_WANT_ALG_CHACHA20_POLY13051
    #defineMBEDTLS_PSA_BUILTIN_ALG_CHACHA20_POLY13051
    #endif
    #endif

    #ifdefined(MBEDTLS_CIPHER_MODE_CBC)
    #defineMBEDTLS_PSA_BUILTIN_ALG_CBC_NO_PADDING1
    #definePSA_WANT_ALG_CBC_NO_PADDING1
    #ifdefined(MBEDTLS_CIPHER_PADDING_PKCS7)
    #defineMBEDTLS_PSA_BUILTIN_ALG_CBC_PKCS71
    #definePSA_WANT_ALG_CBC_PKCS71
    #endif
    #endif

    #if(defined(MBEDTLS_AES_C)||defined(MBEDTLS_DES_C)||\
    defined(MBEDTLS_ARIA_C)||defined(MBEDTLS_CAMELLIA_C))&&\
    defined(MBEDTLS_CIPHER_C)
    #defineMBEDTLS_PSA_BUILTIN_ALG_ECB_NO_PADDING1
    #definePSA_WANT_ALG_ECB_NO_PADDING1
    #endif

    #ifdefined(MBEDTLS_CIPHER_MODE_CFB)
    #defineMBEDTLS_PSA_BUILTIN_ALG_CFB1
    #definePSA_WANT_ALG_CFB1
    #endif

    #ifdefined(MBEDTLS_CIPHER_MODE_CTR)
    #defineMBEDTLS_PSA_BUILTIN_ALG_CTR1
    #definePSA_WANT_ALG_CTR1
    #endif

    #ifdefined(MBEDTLS_CIPHER_MODE_OFB)
    #defineMBEDTLS_PSA_BUILTIN_ALG_OFB1
    #definePSA_WANT_ALG_OFB1
    #endif

    #ifdefined(MBEDTLS_ECP_DP_BP256R1_ENABLED)
    #defineMBEDTLS_PSA_BUILTIN_ECC_BRAINPOOL_P_R1_2561
    #definePSA_WANT_ECC_BRAINPOOL_P_R1_2561
    #endif

    #ifdefined(MBEDTLS_ECP_DP_BP384R1_ENABLED)
    #defineMBEDTLS_PSA_BUILTIN_ECC_BRAINPOOL_P_R1_3841
    #definePSA_WANT_ECC_BRAINPOOL_P_R1_3841
    #endif

    #ifdefined(MBEDTLS_ECP_DP_BP512R1_ENABLED)
    #defineMBEDTLS_PSA_BUILTIN_ECC_BRAINPOOL_P_R1_5121
    #definePSA_WANT_ECC_BRAINPOOL_P_R1_5121
    #endif

    #ifdefined(MBEDTLS_ECP_DP_CURVE25519_ENABLED)
    #defineMBEDTLS_PSA_BUILTIN_ECC_MONTGOMERY_2551
    #definePSA_WANT_ECC_MONTGOMERY_2551
    #endif

    #ifdefined(MBEDTLS_ECP_DP_CURVE448_ENABLED)
    #defineMBEDTLS_PSA_BUILTIN_ECC_MONTGOMERY_4481
    #definePSA_WANT_ECC_MONTGOMERY_4481
    #endif

    #ifdefined(MBEDTLS_ECP_DP_SECP192R1_ENABLED)
    #defineMBEDTLS_PSA_BUILTIN_ECC_SECP_R1_1921
    #definePSA_WANT_ECC_SECP_R1_1921
    #endif

    #ifdefined(MBEDTLS_ECP_DP_SECP224R1_ENABLED)
    #defineMBEDTLS_PSA_BUILTIN_ECC_SECP_R1_2241
    #definePSA_WANT_ECC_SECP_R1_2241
    #endif

    #ifdefined(MBEDTLS_ECP_DP_SECP256R1_ENABLED)
    #defineMBEDTLS_PSA_BUILTIN_ECC_SECP_R1_2561
    #definePSA_WANT_ECC_SECP_R1_2561
    #endif

    #ifdefined(MBEDTLS_ECP_DP_SECP384R1_ENABLED)
    #defineMBEDTLS_PSA_BUILTIN_ECC_SECP_R1_3841
    #definePSA_WANT_ECC_SECP_R1_3841
    #endif

    #ifdefined(MBEDTLS_ECP_DP_SECP521R1_ENABLED)
    #defineMBEDTLS_PSA_BUILTIN_ECC_SECP_R1_5211
    #definePSA_WANT_ECC_SECP_R1_5211
    #endif

    #ifdefined(MBEDTLS_ECP_DP_SECP192K1_ENABLED)
    #defineMBEDTLS_PSA_BUILTIN_ECC_SECP_K1_1921
    #definePSA_WANT_ECC_SECP_K1_1921
    #endif

    /*SECP224K1isbuggyviathePSAAPI(https://github.com/Mbed-TLS/mbedtls/issues/3541)*/
    #if0&&defined(MBEDTLS_ECP_DP_SECP224K1_ENABLED)
    #defineMBEDTLS_PSA_BUILTIN_ECC_SECP_K1_2241
    #definePSA_WANT_ECC_SECP_K1_2241
    #endif

    #ifdefined(MBEDTLS_ECP_DP_SECP256K1_ENABLED)
    #defineMBEDTLS_PSA_BUILTIN_ECC_SECP_K1_2561
    #definePSA_WANT_ECC_SECP_K1_2561
    #endif

    #endif/*MBEDTLS_CONFIG_ADJUST_PSA_FROM_LEGACY_H*/