mirror of
https://github.com/Mbed-TLS/mbedtls.git
synced 2026-07-30 16:26:33 +08:00
Fix -Wundef warnings for PSA macros in pk_internal.h
MBEDTLS_PSA_MAX_EC_PUBKEY_LENGTH and MBEDTLS_PSA_MAX_EC_KEY_PAIR_LENGTH are only defined when MBEDTLS_PSA_CRYPTO_CLIENT is enabled (via psa_util_internal.h). However, the PK_EXPORT_KEYS_ON_THE_STACK block used them unconditionally, triggering -Wundef warnings when compiling with a minimal config that does not enable PSA. Guard the PSA-specific size macros with #if defined(MBEDTLS_PSA_CRYPTO_CLIENT), falling back to 0 when PSA is disabled. The subsequent MBEDTLS_ECP_MAX_BYTES comparison will set the proper value. Signed-off-by: Lin Huang <lhuang04@meta.com>
This commit is contained in:
parent
9576d65f0f
commit
b772dbf8c2
@ -61,13 +61,17 @@
|
||||
#endif
|
||||
|
||||
#if defined(PK_EXPORT_KEYS_ON_THE_STACK)
|
||||
/* We know for ECC, pubkey are longer than privkeys, but double check.
|
||||
* Also, take the maximum size of legacy and PSA, as PSA might be disabled. */
|
||||
/* Take the maximum size of legacy ECP and PSA EC sizes.
|
||||
* PSA might be disabled, so guard the PSA-specific macros. */
|
||||
#if defined(MBEDTLS_PSA_CRYPTO_CLIENT)
|
||||
#define PK_EXPORT_KEY_STACK_BUFFER_SIZE MBEDTLS_PSA_MAX_EC_PUBKEY_LENGTH
|
||||
#if PK_EXPORT_KEY_STACK_BUFFER_SIZE < MBEDTLS_PSA_MAX_EC_KEY_PAIR_LENGTH
|
||||
#undef PK_EXPORT_KEY_STACK_BUFFER_SIZE
|
||||
#define PK_EXPORT_KEY_STACK_BUFFER_SIZE MBEDTLS_PSA_MAX_EC_KEY_PAIR_LENGTH
|
||||
#endif
|
||||
#else
|
||||
#define PK_EXPORT_KEY_STACK_BUFFER_SIZE 0
|
||||
#endif /* MBEDTLS_PSA_CRYPTO_CLIENT */
|
||||
#if PK_EXPORT_KEY_STACK_BUFFER_SIZE < MBEDTLS_ECP_MAX_BYTES
|
||||
#undef PK_EXPORT_KEY_STACK_BUFFER_SIZE
|
||||
#define PK_EXPORT_KEY_STACK_BUFFER_SIZE MBEDTLS_ECP_MAX_BYTES
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user