Skip to content

Commit

Permalink
Fixes for NO_AES_DECRYPT
Browse files Browse the repository at this point in the history
  • Loading branch information
dgarske committed Sep 24, 2024
1 parent 3f5b52e commit 7e9c677
Showing 1 changed file with 44 additions and 22 deletions.
66 changes: 44 additions & 22 deletions wolfcrypt/test/test.c
Original file line number Diff line number Diff line change
Expand Up @@ -9070,7 +9070,9 @@ static wc_test_ret_t EVP_test(const WOLFSSL_EVP_CIPHER* type, const byte* key,
#endif
#else
XMEMSET(enc, 0, sizeof(Aes));
#ifdef HAVE_AES_DECRYPT
XMEMSET(dec, 0, sizeof(Aes));
#endif
ret = wc_AesInit(enc, HEAP_HINT, INVALID_DEVID);
if (ret != 0)
ERROR_OUT(WC_TEST_RET_ENC_EC(ret), out);
Expand Down Expand Up @@ -9313,11 +9315,12 @@ static wc_test_ret_t EVP_test(const WOLFSSL_EVP_CIPHER* type, const byte* key,
ERROR_OUT(WC_TEST_RET_ENC_NC, out);
#endif /* HAVE_AES_DECRYPT */

out:

wc_AesFree(enc);
wc_AesFree(dec);
out:

wc_AesFree(enc);
#ifdef HAVE_AES_DECRYPT
wc_AesFree(dec);
#endif
#endif /* WOLFSSL_AES_256 */

return ret;
Expand Down Expand Up @@ -9459,7 +9462,9 @@ static wc_test_ret_t EVP_test(const WOLFSSL_EVP_CIPHER* type, const byte* key,
#endif
#else
XMEMSET(enc, 0, sizeof(Aes));
#ifdef HAVE_AES_DECRYPT
XMEMSET(dec, 0, sizeof(Aes));
#endif
ret = wc_AesInit(enc, HEAP_HINT, devId);
if (ret != 0)
ERROR_OUT(WC_TEST_RET_ENC_EC(ret), out);
Expand Down Expand Up @@ -9634,7 +9639,9 @@ static wc_test_ret_t EVP_test(const WOLFSSL_EVP_CIPHER* type, const byte* key,
out:

wc_AesFree(enc);
#ifdef HAVE_AES_DECRYPT
wc_AesFree(dec);
#endif

return ret;
}
Expand Down Expand Up @@ -9744,15 +9751,17 @@ static wc_test_ret_t EVP_test(const WOLFSSL_EVP_CIPHER* type, const byte* key,
#endif
#else
XMEMSET(enc, 0, sizeof(Aes));
#ifdef HAVE_AES_DECRYPT
XMEMSET(dec, 0, sizeof(Aes));
#endif
ret = wc_AesInit(enc, HEAP_HINT, devId);
if (ret != 0)
ERROR_OUT(WC_TEST_RET_ENC_EC(ret), out);
#ifdef HAVE_AES_DECRYPT
#ifdef HAVE_AES_DECRYPT
ret = wc_AesInit(dec, HEAP_HINT, devId);
if (ret != 0)
ERROR_OUT(WC_TEST_RET_ENC_EC(ret), out);
#endif
#endif
#endif /* WOLFSSL_SMALL_STACK && !WOLFSSL_NO_MALLOC */

#ifdef WOLFSSL_AES_128
Expand Down Expand Up @@ -9884,7 +9893,9 @@ static wc_test_ret_t EVP_test(const WOLFSSL_EVP_CIPHER* type, const byte* key,
out:

wc_AesFree(enc);
#ifdef HAVE_AES_DECRYPT
wc_AesFree(dec);
#endif

return ret;
}
Expand Down Expand Up @@ -9983,22 +9994,24 @@ static wc_test_ret_t EVP_test(const WOLFSSL_EVP_CIPHER* type, const byte* key,
enc = wc_AesNew(HEAP_HINT, devId);
if (enc == NULL)
ERROR_OUT(WC_TEST_RET_ENC_ERRNO, out);
#ifdef HAVE_AES_DECRYPT
#ifdef HAVE_AES_DECRYPT
dec = wc_AesNew(HEAP_HINT, devId);
if (dec == NULL)
ERROR_OUT(WC_TEST_RET_ENC_ERRNO, out);
#endif
#endif
#else
XMEMSET(enc, 0, sizeof(Aes));
#ifdef HAVE_AES_DECRYPT
XMEMSET(dec, 0, sizeof(Aes));
#endif
ret = wc_AesInit(enc, HEAP_HINT, devId);
if (ret != 0)
ERROR_OUT(WC_TEST_RET_ENC_EC(ret), out);
#ifdef HAVE_AES_DECRYPT
#ifdef HAVE_AES_DECRYPT
ret = wc_AesInit(dec, HEAP_HINT, devId);
if (ret != 0)
ERROR_OUT(WC_TEST_RET_ENC_EC(ret), out);
#endif
#endif
#endif /* WOLFSSL_SMALL_STACK && !WOLFSSL_NO_MALLOC */

#ifdef WOLFSSL_AES_128
Expand Down Expand Up @@ -10084,7 +10097,9 @@ static wc_test_ret_t EVP_test(const WOLFSSL_EVP_CIPHER* type, const byte* key,
out:

wc_AesFree(enc);
#ifdef HAVE_AES_DECRYPT
wc_AesFree(dec);
#endif

return ret;
}
Expand Down Expand Up @@ -12697,10 +12712,10 @@ static wc_test_ret_t aesecb_test(void)
#endif /* HAVE_AES_DECRYPT */
}

out:
out:

wc_AesFree(enc);
wc_AesFree(dec);
wc_AesFree(enc);
wc_AesFree(dec);

#endif /* WOLFSSL_AES_256 */

Expand Down Expand Up @@ -14062,22 +14077,24 @@ WOLFSSL_TEST_SUBROUTINE wc_test_ret_t aes192_test(void)
enc = wc_AesNew(HEAP_HINT, devId);
if (enc == NULL)
ERROR_OUT(WC_TEST_RET_ENC_ERRNO, out);
#ifdef HAVE_AES_DECRYPT
#ifdef HAVE_AES_DECRYPT
dec = wc_AesNew(HEAP_HINT, devId);
if (dec == NULL)
ERROR_OUT(WC_TEST_RET_ENC_ERRNO, out);
#endif
#endif
#else
XMEMSET(enc, 0, sizeof(Aes));
#ifdef HAVE_AES_DECRYPT
XMEMSET(dec, 0, sizeof(Aes));
#endif
ret = wc_AesInit(enc, HEAP_HINT, devId);
if (ret != 0)
ERROR_OUT(WC_TEST_RET_ENC_EC(ret), out);
#ifdef HAVE_AES_DECRYPT
#ifdef HAVE_AES_DECRYPT
ret = wc_AesInit(dec, HEAP_HINT, devId);
if (ret != 0)
ERROR_OUT(WC_TEST_RET_ENC_EC(ret), out);
#endif
#endif
#endif /* WOLFSSL_SMALL_STACK && !WOLFSSL_NO_MALLOC */

ret = wc_AesSetKey(enc, key, (int) sizeof(key), iv, AES_ENCRYPTION);
Expand Down Expand Up @@ -14116,7 +14133,9 @@ WOLFSSL_TEST_SUBROUTINE wc_test_ret_t aes192_test(void)
out:

wc_AesFree(enc);
#ifdef HAVE_AES_DECRYPT
wc_AesFree(dec);
#endif
#endif /* HAVE_AES_CBC */

return ret;
Expand Down Expand Up @@ -14180,22 +14199,24 @@ WOLFSSL_TEST_SUBROUTINE wc_test_ret_t aes256_test(void)
enc = wc_AesNew(HEAP_HINT, devId);
if (enc == NULL)
ERROR_OUT(WC_TEST_RET_ENC_ERRNO, out);
#ifdef HAVE_AES_DECRYPT
#ifdef HAVE_AES_DECRYPT
dec = wc_AesNew(HEAP_HINT, devId);
if (dec == NULL)
ERROR_OUT(WC_TEST_RET_ENC_ERRNO, out);
#endif
#endif
#else
XMEMSET(enc, 0, sizeof(Aes));
#ifdef HAVE_AES_DECRYPT
XMEMSET(dec, 0, sizeof(Aes));
#endif
ret = wc_AesInit(enc, HEAP_HINT, devId);
if (ret != 0)
ERROR_OUT(WC_TEST_RET_ENC_EC(ret), out);
#ifdef HAVE_AES_DECRYPT
#ifdef HAVE_AES_DECRYPT
ret = wc_AesInit(dec, HEAP_HINT, devId);
if (ret != 0)
ERROR_OUT(WC_TEST_RET_ENC_EC(ret), out);
#endif
#endif
#endif /* WOLFSSL_SMALL_STACK && !WOLFSSL_NO_MALLOC */

ret = wc_AesSetKey(enc, key, (word32)keySz, iv, AES_ENCRYPTION);
Expand Down Expand Up @@ -14311,8 +14332,9 @@ WOLFSSL_TEST_SUBROUTINE wc_test_ret_t aes256_test(void)
out:

wc_AesFree(enc);
#ifdef HAVE_AES_DECRYPT
wc_AesFree(dec);

#endif
#endif /* HAVE_AES_CBC */

return ret;
Expand Down

0 comments on commit 7e9c677

Please sign in to comment.