fix(psa): increase psa-mbedtls heap size for rsa

The value assigned for the mbedtls heap size for large
rsa keys was too small when PSA_CRYPTO is set to 1,
leading to run-time failures if one was to attempt
to use a large RSA key with PSA_CRYPTO=1.

Change-Id: Id9b2648ae911879f483f1b88301f28694af0721d
Signed-off-by: Ryan Everett <ryan.everett@arm.com>
This commit is contained in:
Ryan Everett 2024-11-11 15:21:12 +00:00
parent e372c29153
commit 52d2934560
3 changed files with 20 additions and 7 deletions

View file

@ -132,18 +132,15 @@
#endif
/*
* Determine Mbed TLS heap size
* 13312 = 13*1024
* 11264 = 11*1024
* 7168 = 7*1024
* Determine Mbed TLS heap size.
*/
#if TF_MBEDTLS_USE_ECDSA
#define TF_MBEDTLS_HEAP_SIZE U(13312)
#define TF_MBEDTLS_HEAP_SIZE U(13 * 1024)
#elif TF_MBEDTLS_USE_RSA
#if TF_MBEDTLS_KEY_SIZE <= 2048
#define TF_MBEDTLS_HEAP_SIZE U(7168)
#define TF_MBEDTLS_HEAP_SIZE U(7 * 1024)
#else
#define TF_MBEDTLS_HEAP_SIZE U(11264)
#define TF_MBEDTLS_HEAP_SIZE U(11 * 1024)
#endif
#endif

View file

@ -26,4 +26,12 @@
*/
#define MBEDTLS_PSA_CRYPTO_EXTERNAL_RNG
/*
* Override heap size for PSA Crypto when RSA key size > 2048.
*/
#if TF_MBEDTLS_USE_RSA && TF_MBEDTLS_KEY_SIZE > 2048
#undef TF_MBEDTLS_HEAP_SIZE
#define TF_MBEDTLS_HEAP_SIZE U(12 * 1024)
#endif
#endif /* PSA_MBEDTLS_CONFIG_H */

View file

@ -26,4 +26,12 @@
*/
#define MBEDTLS_PSA_CRYPTO_EXTERNAL_RNG
/*
* Override heap size for PSA Crypto when RSA key size > 2048.
*/
#if TF_MBEDTLS_USE_RSA && TF_MBEDTLS_KEY_SIZE > 2048
#undef TF_MBEDTLS_HEAP_SIZE
#define TF_MBEDTLS_HEAP_SIZE U(12 * 1024)
#endif
#endif /* PLAT_ARM_PSA_MBEDTLS_CONFIG_H */