config_adjust_psa_superset_legacy.h 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145
  1. /**
  2. * \file mbedtls/config_adjust_psa_superset_legacy.h
  3. * \brief Adjust PSA configuration: automatic enablement from legacy
  4. *
  5. * This is an internal header. Do not include it directly.
  6. *
  7. * To simplify some edge cases, we automatically enable certain cryptographic
  8. * mechanisms in the PSA API if they are enabled in the legacy API. The general
  9. * idea is that if legacy module M uses mechanism A internally, and A has
  10. * both a legacy and a PSA implementation, we enable A through PSA whenever
  11. * it's enabled through legacy. This facilitates the transition to PSA
  12. * implementations of A for users of M.
  13. */
  14. /*
  15. * Copyright The Mbed TLS Contributors
  16. * SPDX-License-Identifier: Apache-2.0 OR GPL-2.0-or-later
  17. */
  18. #ifndef MBEDTLS_CONFIG_ADJUST_PSA_SUPERSET_LEGACY_H
  19. #define MBEDTLS_CONFIG_ADJUST_PSA_SUPERSET_LEGACY_H
  20. #if !defined(MBEDTLS_CONFIG_FILES_READ)
  21. #error "Do not include mbedtls/config_adjust_*.h manually! This can lead to problems, " \
  22. "up to and including runtime errors such as buffer overflows. " \
  23. "If you're trying to fix a complaint from check_config.h, just remove " \
  24. "it from your configuration file: since Mbed TLS 3.0, it is included " \
  25. "automatically at the right point."
  26. #endif /* */
  27. /****************************************************************/
  28. /* Hashes that are built in are also enabled in PSA.
  29. * This simplifies dependency declarations especially
  30. * for modules that obey MBEDTLS_USE_PSA_CRYPTO. */
  31. /****************************************************************/
  32. #if defined(MBEDTLS_MD5_C)
  33. #define PSA_WANT_ALG_MD5 1
  34. #endif
  35. #if defined(MBEDTLS_RIPEMD160_C)
  36. #define PSA_WANT_ALG_RIPEMD160 1
  37. #endif
  38. #if defined(MBEDTLS_SHA1_C)
  39. #define PSA_WANT_ALG_SHA_1 1
  40. #endif
  41. #if defined(MBEDTLS_SHA224_C)
  42. #define PSA_WANT_ALG_SHA_224 1
  43. #endif
  44. #if defined(MBEDTLS_SHA256_C)
  45. #define PSA_WANT_ALG_SHA_256 1
  46. #endif
  47. #if defined(MBEDTLS_SHA384_C)
  48. #define PSA_WANT_ALG_SHA_384 1
  49. #endif
  50. #if defined(MBEDTLS_SHA512_C)
  51. #define PSA_WANT_ALG_SHA_512 1
  52. #endif
  53. #if defined(MBEDTLS_SHA3_C)
  54. #define PSA_WANT_ALG_SHA3_224 1
  55. #define PSA_WANT_ALG_SHA3_256 1
  56. #define PSA_WANT_ALG_SHA3_384 1
  57. #define PSA_WANT_ALG_SHA3_512 1
  58. #endif
  59. /* Ensure that the PSA's supported curves (PSA_WANT_ECC_xxx) are always a
  60. * superset of the builtin ones (MBEDTLS_ECP_DP_xxx). */
  61. #if defined(MBEDTLS_ECP_DP_BP256R1_ENABLED)
  62. #if !defined(PSA_WANT_ECC_BRAINPOOL_P_R1_256)
  63. #define PSA_WANT_ECC_BRAINPOOL_P_R1_256 1
  64. #endif /* PSA_WANT_ECC_BRAINPOOL_P_R1_256 */
  65. #endif /* MBEDTLS_ECP_DP_BP256R1_ENABLED */
  66. #if defined(MBEDTLS_ECP_DP_BP384R1_ENABLED)
  67. #if !defined(PSA_WANT_ECC_BRAINPOOL_P_R1_384)
  68. #define PSA_WANT_ECC_BRAINPOOL_P_R1_384 1
  69. #endif /* PSA_WANT_ECC_BRAINPOOL_P_R1_384 */
  70. #endif /*MBEDTLS_ECP_DP_BP384R1_ENABLED */
  71. #if defined(MBEDTLS_ECP_DP_BP512R1_ENABLED)
  72. #if !defined(PSA_WANT_ECC_BRAINPOOL_P_R1_512)
  73. #define PSA_WANT_ECC_BRAINPOOL_P_R1_512 1
  74. #endif /* PSA_WANT_ECC_BRAINPOOL_P_R1_512 */
  75. #endif /* MBEDTLS_ECP_DP_BP512R1_ENABLED */
  76. #if defined(MBEDTLS_ECP_DP_CURVE25519_ENABLED)
  77. #if !defined(PSA_WANT_ECC_MONTGOMERY_255)
  78. #define PSA_WANT_ECC_MONTGOMERY_255 1
  79. #endif /* PSA_WANT_ECC_MONTGOMERY_255 */
  80. #endif /* MBEDTLS_ECP_DP_CURVE25519_ENABLED */
  81. #if defined(MBEDTLS_ECP_DP_CURVE448_ENABLED)
  82. #if !defined(PSA_WANT_ECC_MONTGOMERY_448)
  83. #define PSA_WANT_ECC_MONTGOMERY_448 1
  84. #endif /* PSA_WANT_ECC_MONTGOMERY_448 */
  85. #endif /* MBEDTLS_ECP_DP_CURVE448_ENABLED */
  86. #if defined(MBEDTLS_ECP_DP_SECP192R1_ENABLED)
  87. #if !defined(PSA_WANT_ECC_SECP_R1_192)
  88. #define PSA_WANT_ECC_SECP_R1_192 1
  89. #endif /* PSA_WANT_ECC_SECP_R1_192 */
  90. #endif /* MBEDTLS_ECP_DP_SECP192R1_ENABLED */
  91. #if defined(MBEDTLS_ECP_DP_SECP224R1_ENABLED)
  92. #if !defined(PSA_WANT_ECC_SECP_R1_224)
  93. #define PSA_WANT_ECC_SECP_R1_224 1
  94. #endif /* PSA_WANT_ECC_SECP_R1_224 */
  95. #endif /* MBEDTLS_ECP_DP_SECP224R1_ENABLED */
  96. #if defined(MBEDTLS_ECP_DP_SECP256R1_ENABLED)
  97. #if !defined(PSA_WANT_ECC_SECP_R1_256)
  98. #define PSA_WANT_ECC_SECP_R1_256 1
  99. #endif /* PSA_WANT_ECC_SECP_R1_256 */
  100. #endif /* MBEDTLS_ECP_DP_SECP256R1_ENABLED */
  101. #if defined(MBEDTLS_ECP_DP_SECP384R1_ENABLED)
  102. #if !defined(PSA_WANT_ECC_SECP_R1_384)
  103. #define PSA_WANT_ECC_SECP_R1_384 1
  104. #endif /* PSA_WANT_ECC_SECP_R1_384 */
  105. #endif /* MBEDTLS_ECP_DP_SECP384R1_ENABLED */
  106. #if defined(MBEDTLS_ECP_DP_SECP521R1_ENABLED)
  107. #if !defined(PSA_WANT_ECC_SECP_R1_521)
  108. #define PSA_WANT_ECC_SECP_R1_521 1
  109. #endif /* PSA_WANT_ECC_SECP_R1_521 */
  110. #endif /* MBEDTLS_ECP_DP_SECP521R1_ENABLED */
  111. #if defined(MBEDTLS_ECP_DP_SECP192K1_ENABLED)
  112. #if !defined(PSA_WANT_ECC_SECP_K1_192)
  113. #define PSA_WANT_ECC_SECP_K1_192 1
  114. #endif /* PSA_WANT_ECC_SECP_K1_192 */
  115. #endif /* MBEDTLS_ECP_DP_SECP192K1_ENABLED */
  116. #if defined(MBEDTLS_ECP_DP_SECP256K1_ENABLED)
  117. #if !defined(PSA_WANT_ECC_SECP_K1_256)
  118. #define PSA_WANT_ECC_SECP_K1_256 1
  119. #endif /* PSA_WANT_ECC_SECP_K1_256 */
  120. #endif /* MBEDTLS_ECP_DP_SECP256K1_ENABLED */
  121. #endif /* MBEDTLS_CONFIG_ADJUST_PSA_SUPERSET_LEGACY_H */