1
0
mirror of https://github.com/Mbed-TLS/mbedtls.git synced 2025-07-29 11:41:15 +03:00

test: properly select MBEDTLS_PSA_STATIC_KEY_SLOT_BUFFER_SIZE value

This value should be:
- OK for all EC/FFDH key pairs/public keys;
- OK for all supported public RSA keys;
- OK for RSA key pairs up to 2048 bits;
- FAIL for RSA key pairs above 2048 bits.

Signed-off-by: Valerio Setti <valerio.setti@nordicsemi.no>
This commit is contained in:
Valerio Setti
2024-08-16 12:35:24 +02:00
parent 54dc535998
commit ba98d5b90e
5 changed files with 118 additions and 86 deletions

View File

@ -468,4 +468,26 @@ uint64_t mbedtls_test_parse_binary_string(data_t *bin_string);
#define MBEDTLS_TEST_PSA_INTERNAL_KEYS \
MBEDTLS_TEST_PSA_INTERNAL_KEYS_FOR_DRBG
/* Some helper macros to verify if MBEDTLS_PSA_STATIC_KEY_SLOT_BUFFER_SIZE is
* large enough to contain an RSA key pair of the given size. This is meant to be
* used in test cases where MBEDTLS_PSA_STATIC_KEY_SLOTS is enabled. */
#if defined(MBEDTLS_PSA_CRYPTO_C)
#if (MBEDTLS_PSA_STATIC_KEY_SLOT_BUFFER_SIZE >= PSA_KEY_EXPORT_RSA_KEY_PAIR_MAX_SIZE(4096))
#define STATIC_KEY_SLOTS_SUPPORT_RSA_4096
#endif
#if (MBEDTLS_PSA_STATIC_KEY_SLOT_BUFFER_SIZE >= PSA_KEY_EXPORT_RSA_KEY_PAIR_MAX_SIZE(2048))
#define STATIC_KEY_SLOTS_SUPPORT_RSA_2048
#endif
#if !defined(MBEDTLS_PSA_STATIC_KEY_SLOTS) || defined(STATIC_KEY_SLOTS_SUPPORT_RSA_4096)
#define MBEDTLS_TEST_ALLOW_RSA_4096
#endif
#else /* MBEDTLS_PSA_CRYPTO_C */
#define MBEDTLS_TEST_ALLOW_RSA_4096
#endif /* MBEDTLS_PSA_CRYPTO_C */
#endif /* PSA_CRYPTO_HELPERS_H */