From 81892f45940160ef3a1d05544b3818bc11ce2556 Mon Sep 17 00:00:00 2001 From: David Garske Date: Wed, 17 Jun 2020 11:16:33 -0700 Subject: [PATCH] Fix for use of `WC_MAX_SYM_KEY_SIZE` in macro. Fixes build case with `--enable-nullcipher --disable-aes`. --- wolfssl/wolfcrypt/wc_encrypt.h | 25 +++++++++++++++++-------- 1 file changed, 17 insertions(+), 8 deletions(-) diff --git a/wolfssl/wolfcrypt/wc_encrypt.h b/wolfssl/wolfcrypt/wc_encrypt.h index 6d26e2cba..a5c33807d 100644 --- a/wolfssl/wolfcrypt/wc_encrypt.h +++ b/wolfssl/wolfcrypt/wc_encrypt.h @@ -28,24 +28,33 @@ #define WOLF_CRYPT_ENCRYPT_H #include -#include -#include -#include -#include +#ifndef NO_AES + #include +#endif +#ifdef HAVE_CHACHA + #include +#endif +#ifndef NO_DES3 + #include +#endif +#ifndef NO_RC4 + #include +#endif #ifdef __cplusplus extern "C" { #endif -/* determine max cipher key size */ +/* determine max cipher key size - cannot use enum values here, must be define, + * since WC_MAX_SYM_KEY_SIZE is used in if macro logic. */ #ifndef NO_AES #define WC_MAX_SYM_KEY_SIZE (AES_MAX_KEY_SIZE/8) #elif defined(HAVE_CHACHA) - #define WC_MAX_SYM_KEY_SIZE CHACHA_MAX_KEY_SZ + #define WC_MAX_SYM_KEY_SIZE 32 /* CHACHA_MAX_KEY_SZ */ #elif !defined(NO_DES3) - #define WC_MAX_SYM_KEY_SIZE DES3_KEY_SIZE + #define WC_MAX_SYM_KEY_SIZE 24 /* DES3_KEY_SIZE */ #elif !defined(NO_RC4) - #define WC_MAX_SYM_KEY_SIZE RC4_KEY_SIZE + #define WC_MAX_SYM_KEY_SIZE 16 /* RC4_KEY_SIZE */ #else #define WC_MAX_SYM_KEY_SIZE 32 #endif