plat_arm_psa_mbedtls_config.h 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637
  1. /*
  2. * Copyright (c) 2024, Arm Ltd. All rights reserved.
  3. *
  4. * SPDX-License-Identifier: BSD-3-Clause
  5. */
  6. #ifndef PLAT_ARM_PSA_MBEDTLS_CONFIG_H
  7. #define PLAT_ARM_PSA_MBEDTLS_CONFIG_H
  8. #include "plat_arm_mbedtls_config.h"
  9. #define MBEDTLS_PSA_CRYPTO_C
  10. #define MBEDTLS_PSA_ASSUME_EXCLUSIVE_BUFFERS
  11. /*
  12. * Using PSA crypto API requires an RNG right now. If we don't define the macro
  13. * below then we get build errors.
  14. *
  15. * This is a functionality gap in mbedTLS. The technical limitation is that
  16. * psa_crypto_init() is all-or-nothing, and fixing that would require separate
  17. * initialization of the keystore, the RNG, etc.
  18. *
  19. * By defining MBEDTLS_PSA_CRYPTO_EXTERNAL_RNG, we pretend using an external
  20. * RNG. As a result, the PSA crypto init code does nothing when it comes to
  21. * initializing the RNG, as we are supposed to take care of that ourselves.
  22. */
  23. #define MBEDTLS_PSA_CRYPTO_EXTERNAL_RNG
  24. /*
  25. * Override heap size for PSA Crypto when RSA key size > 2048.
  26. */
  27. #if TF_MBEDTLS_USE_RSA && TF_MBEDTLS_KEY_SIZE > 2048
  28. #undef TF_MBEDTLS_HEAP_SIZE
  29. #define TF_MBEDTLS_HEAP_SIZE U(12 * 1024)
  30. #endif
  31. #endif /* PLAT_ARM_PSA_MBEDTLS_CONFIG_H */