Merge changes from topic "mb/cov-fix" into integration

* changes:
  fix(tbbr): guard defines under MBEDTLS_CONFIG_FILE
  refactor(tbbr): enforce compile-time error for invalid algorithm selection
This commit is contained in:
Lauren Wehrmeister 2023-10-27 22:05:35 +02:00 committed by TrustedFirmware Code Review
commit ed2d256a68

View file

@ -32,7 +32,12 @@
* buffers must be big enough to hold either. As RSA keys are bigger than ECDSA * buffers must be big enough to hold either. As RSA keys are bigger than ECDSA
* ones for all key sizes we support, they impose the minimum size of these * ones for all key sizes we support, they impose the minimum size of these
* buffers. * buffers.
*
* If the platform employs its own mbedTLS configuration, it is the platform's
* responsibility to define TF_MBEDTLS_USE_RSA or TF_MBEDTLS_USE_ECDSA to
* establish the appropriate PK_DER_LEN size.
*/ */
#ifdef MBEDTLS_CONFIG_FILE
#if TF_MBEDTLS_USE_RSA #if TF_MBEDTLS_USE_RSA
#if TF_MBEDTLS_KEY_SIZE == 1024 #if TF_MBEDTLS_KEY_SIZE == 1024
#define PK_DER_LEN 162 #define PK_DER_LEN 162
@ -45,7 +50,7 @@
#else #else
#error "Invalid value for TF_MBEDTLS_KEY_SIZE" #error "Invalid value for TF_MBEDTLS_KEY_SIZE"
#endif #endif
#else /* Only using ECDSA keys. */ #elif TF_MBEDTLS_USE_ECDSA
#if TF_MBEDTLS_KEY_SIZE == 384 #if TF_MBEDTLS_KEY_SIZE == 384
#define PK_DER_LEN 120 #define PK_DER_LEN 120
#elif TF_MBEDTLS_KEY_SIZE == 256 #elif TF_MBEDTLS_KEY_SIZE == 256
@ -53,7 +58,9 @@
#else #else
#error "Invalid value for TF_MBEDTLS_KEY_SIZE" #error "Invalid value for TF_MBEDTLS_KEY_SIZE"
#endif #endif
#endif #else
#error "Invalid value of algorithm"
#endif /* TF_MBEDTLS_USE_RSA */
#if TF_MBEDTLS_HASH_ALG_ID == TF_MBEDTLS_SHA256 #if TF_MBEDTLS_HASH_ALG_ID == TF_MBEDTLS_SHA256
#define HASH_DER_LEN 51 #define HASH_DER_LEN 51
@ -64,5 +71,6 @@
#else #else
#error "Invalid value for TF_MBEDTLS_HASH_ALG_ID" #error "Invalid value for TF_MBEDTLS_HASH_ALG_ID"
#endif #endif
#endif /* MBEDTLS_CONFIG_FILE */
#endif /* COT_DEF_H */ #endif /* COT_DEF_H */