Skip to content

Commit fc7143a

Browse files
committed
Code review
1 parent 67700a1 commit fc7143a

1 file changed

Lines changed: 22 additions & 25 deletions

File tree

wolfcrypt/src/evp.c

Lines changed: 22 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -8110,6 +8110,26 @@ void wolfSSL_EVP_init(void)
81108110
}
81118111
#endif /* !NO_AES || !NO_DES3 */
81128112

8113+
static int IsCipherTypeAEAD(unsigned char cipherType)
8114+
{
8115+
switch (cipherType) {
8116+
case AES_128_GCM_TYPE:
8117+
case AES_192_GCM_TYPE:
8118+
case AES_256_GCM_TYPE:
8119+
case AES_128_CCM_TYPE:
8120+
case AES_192_CCM_TYPE:
8121+
case AES_256_CCM_TYPE:
8122+
case ARIA_128_GCM_TYPE:
8123+
case ARIA_192_GCM_TYPE:
8124+
case ARIA_256_GCM_TYPE:
8125+
case SM4_GCM_TYPE:
8126+
case SM4_CCM_TYPE:
8127+
return 1;
8128+
default:
8129+
return 0;
8130+
}
8131+
}
8132+
81138133
/* Return length on ok */
81148134
int wolfSSL_EVP_Cipher(WOLFSSL_EVP_CIPHER_CTX* ctx, byte* dst, byte* src,
81158135
word32 len)
@@ -8123,31 +8143,8 @@ void wolfSSL_EVP_init(void)
81238143
return WOLFSSL_FATAL_ERROR;
81248144
}
81258145

8126-
if (TRUE
8127-
#ifdef HAVE_AESGCM
8128-
&& ctx->cipherType != AES_128_GCM_TYPE &&
8129-
ctx->cipherType != AES_192_GCM_TYPE &&
8130-
ctx->cipherType != AES_256_GCM_TYPE
8131-
#endif
8132-
#ifdef HAVE_AESCCM
8133-
&& ctx->cipherType != AES_128_CCM_TYPE &&
8134-
ctx->cipherType != AES_192_CCM_TYPE &&
8135-
ctx->cipherType != AES_256_CCM_TYPE
8136-
#endif
8137-
#ifdef HAVE_ARIA
8138-
&& ctx->cipherType != ARIA_128_GCM_TYPE &&
8139-
ctx->cipherType != ARIA_192_GCM_TYPE &&
8140-
ctx->cipherType != ARIA_256_GCM_TYPE
8141-
#endif
8142-
#ifdef WOLFSSL_SM4_GCM
8143-
&& ctx->cipherType != SM4_GCM_TYPE
8144-
#endif
8145-
#ifdef WOLFSSL_SM4_CCM
8146-
&& ctx->cipherType != SM4_CCM_TYPE
8147-
#endif
8148-
) {
8149-
/* Not an AEAD cipher */
8150-
/* No-op for none AEAD ciphers */
8146+
if (!IsCipherTypeAEAD(ctx->cipherType)) {
8147+
/* No-op for non-AEAD ciphers */
81518148
if (src == NULL && dst == NULL && len == 0)
81528149
return 0;
81538150
if (src == NULL || dst == NULL) {

0 commit comments

Comments
 (0)