Reduce code size in mbedtls_cipher_validate_values
Signed-off-by: Dave Rodgman <dave.rodgman@arm.com>
This commit is contained in:
parent
6d2c1b3748
commit
3e5cc175e0
1 changed files with 57 additions and 0 deletions
|
@ -42,6 +42,63 @@ static psa_status_t mbedtls_cipher_validate_values(
|
|||
psa_algorithm_t alg,
|
||||
psa_key_type_t key_type)
|
||||
{
|
||||
/* Reduce code size - hinting to the compiler about what it can assume allows the compiler to
|
||||
eliminate bits of the logic below. */
|
||||
#if !defined(PSA_WANT_KEY_TYPE_AES)
|
||||
MBEDTLS_ASSUME(key_type != PSA_KEY_TYPE_AES);
|
||||
#endif
|
||||
#if !defined(PSA_WANT_KEY_TYPE_ARIA)
|
||||
MBEDTLS_ASSUME(key_type != PSA_KEY_TYPE_ARIA);
|
||||
#endif
|
||||
#if !defined(PSA_WANT_KEY_TYPE_CAMELLIA)
|
||||
MBEDTLS_ASSUME(key_type != PSA_KEY_TYPE_CAMELLIA);
|
||||
#endif
|
||||
#if !defined(PSA_WANT_KEY_TYPE_CHACHA20)
|
||||
MBEDTLS_ASSUME(key_type != PSA_KEY_TYPE_CHACHA20);
|
||||
#endif
|
||||
#if !defined(PSA_WANT_KEY_TYPE_DES)
|
||||
MBEDTLS_ASSUME(key_type != PSA_KEY_TYPE_DES);
|
||||
#endif
|
||||
#if !defined(PSA_WANT_ALG_CCM)
|
||||
MBEDTLS_ASSUME(alg != PSA_ALG_AEAD_WITH_SHORTENED_TAG(PSA_ALG_CCM, 0));
|
||||
#endif
|
||||
#if !defined(PSA_WANT_ALG_GCM)
|
||||
MBEDTLS_ASSUME(alg != PSA_ALG_AEAD_WITH_SHORTENED_TAG(PSA_ALG_GCM, 0));
|
||||
#endif
|
||||
#if !defined(PSA_WANT_ALG_STREAM_CIPHER)
|
||||
MBEDTLS_ASSUME(alg != PSA_ALG_STREAM_CIPHER);
|
||||
#endif
|
||||
#if !defined(PSA_WANT_ALG_CHACHA20_POLY1305)
|
||||
MBEDTLS_ASSUME(alg != PSA_ALG_AEAD_WITH_SHORTENED_TAG(PSA_ALG_CHACHA20_POLY1305, 0));
|
||||
#endif
|
||||
#if !defined(PSA_WANT_ALG_CCM_STAR_NO_TAG)
|
||||
MBEDTLS_ASSUME(alg != PSA_ALG_CCM_STAR_NO_TAG);
|
||||
#endif
|
||||
#if !defined(PSA_WANT_ALG_CTR)
|
||||
MBEDTLS_ASSUME(alg != PSA_ALG_CTR);
|
||||
#endif
|
||||
#if !defined(PSA_WANT_ALG_CFB)
|
||||
MBEDTLS_ASSUME(alg != PSA_ALG_CFB);
|
||||
#endif
|
||||
#if !defined(PSA_WANT_ALG_OFB)
|
||||
MBEDTLS_ASSUME(alg != PSA_ALG_OFB);
|
||||
#endif
|
||||
#if !defined(PSA_WANT_ALG_XTS)
|
||||
MBEDTLS_ASSUME(alg != PSA_ALG_XTS);
|
||||
#endif
|
||||
#if !defined(PSA_WANT_ALG_ECB_NO_PADDING)
|
||||
MBEDTLS_ASSUME(alg != PSA_ALG_ECB_NO_PADDING);
|
||||
#endif
|
||||
#if !defined(PSA_WANT_ALG_CBC_NO_PADDING)
|
||||
MBEDTLS_ASSUME(alg != PSA_ALG_CBC_NO_PADDING);
|
||||
#endif
|
||||
#if !defined(PSA_WANT_ALG_CBC_PKCS7)
|
||||
MBEDTLS_ASSUME(alg != PSA_ALG_CBC_PKCS7);
|
||||
#endif
|
||||
#if !defined(PSA_WANT_ALG_CMAC)
|
||||
MBEDTLS_ASSUME(alg != PSA_ALG_CMAC);
|
||||
#endif
|
||||
|
||||
if (alg == PSA_ALG_STREAM_CIPHER ||
|
||||
alg == PSA_ALG_AEAD_WITH_SHORTENED_TAG(PSA_ALG_CHACHA20_POLY1305, 0)) {
|
||||
if (key_type == PSA_KEY_TYPE_CHACHA20) {
|
||||
|
|
Loading…
Reference in a new issue