Fixes for building without hash. If all hash algorithms are disabled wc_HashAlg could report empty union. ZD 11585.

This commit is contained in:
David Garske
2021-02-22 14:37:04 -08:00
parent ac38e53fec
commit bf63b41465
2 changed files with 10 additions and 2 deletions

View File

@ -849,10 +849,12 @@ initDefaultName();
test_pass("SHAKE256 test passed!\n"); test_pass("SHAKE256 test passed!\n");
#endif #endif
#ifndef NO_HASH_WRAPPER
if ( (ret = hash_test()) != 0) if ( (ret = hash_test()) != 0)
return err_sys("Hash test failed!\n", ret); return err_sys("Hash test failed!\n", ret);
else else
test_pass("Hash test passed!\n"); test_pass("Hash test passed!\n");
#endif
#ifdef WOLFSSL_RIPEMD #ifdef WOLFSSL_RIPEMD
if ( (ret = ripemd_test()) != 0) if ( (ret = ripemd_test()) != 0)
@ -3384,7 +3386,7 @@ exit:
} }
#endif #endif
#ifndef NO_HASH_WRAPPER
WOLFSSL_TEST_SUBROUTINE int hash_test(void) WOLFSSL_TEST_SUBROUTINE int hash_test(void)
{ {
wc_HashAlg hash; wc_HashAlg hash;
@ -3689,6 +3691,7 @@ WOLFSSL_TEST_SUBROUTINE int hash_test(void)
return 0; return 0;
} }
#endif /* !NO_HASH_WRAPPER */
#if !defined(NO_HMAC) && !defined(NO_MD5) #if !defined(NO_HMAC) && !defined(NO_MD5)
WOLFSSL_TEST_SUBROUTINE int hmac_md5_test(void) WOLFSSL_TEST_SUBROUTINE int hmac_md5_test(void)

View File

@ -88,7 +88,7 @@ enum wc_HashFlags {
#endif #endif
}; };
#ifndef NO_HASH_WRAPPER
typedef union { typedef union {
#ifndef NO_MD5 #ifndef NO_MD5
wc_Md5 md5; wc_Md5 md5;
@ -112,6 +112,7 @@ typedef union {
wc_Sha3 sha3; wc_Sha3 sha3;
#endif #endif
} wc_HashAlg; } wc_HashAlg;
#endif /* !NO_HASH_WRAPPER */
/* Find largest possible digest size /* Find largest possible digest size
Note if this gets up to the size of 80 or over check smallstack build */ Note if this gets up to the size of 80 or over check smallstack build */
@ -151,6 +152,8 @@ WOLFSSL_API enum wc_HashType wc_OidGetHash(int oid);
WOLFSSL_API enum wc_HashType wc_HashTypeConvert(int hashType); WOLFSSL_API enum wc_HashType wc_HashTypeConvert(int hashType);
#ifndef NO_HASH_WRAPPER
WOLFSSL_API int wc_HashGetDigestSize(enum wc_HashType hash_type); WOLFSSL_API int wc_HashGetDigestSize(enum wc_HashType hash_type);
WOLFSSL_API int wc_HashGetBlockSize(enum wc_HashType hash_type); WOLFSSL_API int wc_HashGetBlockSize(enum wc_HashType hash_type);
WOLFSSL_API int wc_Hash(enum wc_HashType hash_type, WOLFSSL_API int wc_Hash(enum wc_HashType hash_type,
@ -215,6 +218,8 @@ WOLFSSL_API int wc_Shake256Hash(const byte*, word32, byte*, word32);
#endif #endif
#endif /* WOLFSSL_SHA3 */ #endif /* WOLFSSL_SHA3 */
#endif /* !NO_HASH_WRAPPER */
enum max_prf { enum max_prf {
#ifdef HAVE_FFDHE_8192 #ifdef HAVE_FFDHE_8192
MAX_PRF_HALF = 516, /* Maximum half secret len */ MAX_PRF_HALF = 516, /* Maximum half secret len */