Additional init fixes for unit tests based on async valgrind report.
This commit is contained in:
parent
c06e672eb7
commit
84a396b7dc
27
tests/api.c
27
tests/api.c
@ -6558,9 +6558,9 @@ static int test_wc_AesGcmEncryptDecrypt (void)
|
||||
|
||||
printf(resultFmt, gcmD == 0 ? passed : failed);
|
||||
#endif /* HAVE_AES_DECRYPT */
|
||||
#endif
|
||||
|
||||
wc_AesFree(&aes);
|
||||
#endif
|
||||
|
||||
return ret;
|
||||
|
||||
@ -6613,6 +6613,10 @@ static int test_wc_GmacSetKey (void)
|
||||
|
||||
printf(testingFmt, "wc_GmacSetKey()");
|
||||
|
||||
ret = wc_AesInit(&gmac.aes, NULL, INVALID_DEVID);
|
||||
if (ret != 0)
|
||||
return ret;
|
||||
|
||||
ret = wc_GmacSetKey(&gmac, key16, sizeof(key16)/sizeof(byte));
|
||||
if (ret == 0) {
|
||||
ret = wc_GmacSetKey(&gmac, key24, sizeof(key24)/sizeof(byte));
|
||||
@ -6643,6 +6647,8 @@ static int test_wc_GmacSetKey (void)
|
||||
}
|
||||
}
|
||||
|
||||
wc_AesFree(&gmac.aes);
|
||||
|
||||
printf(resultFmt, ret == 0 ? passed : failed);
|
||||
|
||||
#endif
|
||||
@ -6732,6 +6738,10 @@ static int test_wc_GmacUpdate (void)
|
||||
|
||||
printf(testingFmt, "wc_GmacUpdate()");
|
||||
|
||||
ret = wc_AesInit(&gmac.aes, NULL, INVALID_DEVID);
|
||||
if (ret != 0)
|
||||
return ret;
|
||||
|
||||
ret = wc_GmacSetKey(&gmac, key16, sizeof(key16));
|
||||
if (ret == 0) {
|
||||
ret = wc_GmacUpdate(&gmac, iv, sizeof(iv), authIn, sizeof(authIn),
|
||||
@ -6782,6 +6792,8 @@ static int test_wc_GmacUpdate (void)
|
||||
}
|
||||
}
|
||||
|
||||
wc_AesFree(&gmac.aes);
|
||||
|
||||
printf(resultFmt, ret == 0 ? passed : failed);
|
||||
|
||||
#endif
|
||||
@ -8427,6 +8439,10 @@ static int test_wc_AesCcmSetKey (void)
|
||||
|
||||
printf(testingFmt, "wc_AesCcmSetKey()");
|
||||
|
||||
ret = wc_AesInit(&aes, NULL, INVALID_DEVID);
|
||||
if (ret != 0)
|
||||
return ret;
|
||||
|
||||
ret = wc_AesCcmSetKey(&aes, key16, sizeof(key16));
|
||||
if (ret == 0) {
|
||||
ret = wc_AesCcmSetKey(&aes, key24, sizeof(key24));
|
||||
@ -8451,6 +8467,8 @@ static int test_wc_AesCcmSetKey (void)
|
||||
}
|
||||
}
|
||||
|
||||
wc_AesFree(&aes);
|
||||
|
||||
printf(resultFmt, ret == 0 ? passed : failed);
|
||||
|
||||
#endif
|
||||
@ -8506,6 +8524,10 @@ static int test_wc_AesCcmEncryptDecrypt (void)
|
||||
byte plainOut[sizeof(cipherOut)];
|
||||
#endif
|
||||
|
||||
ret = wc_AesInit(&aes, NULL, INVALID_DEVID);
|
||||
if (ret != 0)
|
||||
return ret;
|
||||
|
||||
ret = wc_AesCcmSetKey(&aes, key16, sizeof(key16));
|
||||
if (ret == 0) {
|
||||
ccmE = wc_AesCcmEncrypt(&aes, cipherOut, plainT, sizeof(cipherOut),
|
||||
@ -8576,6 +8598,7 @@ static int test_wc_AesCcmEncryptDecrypt (void)
|
||||
|
||||
printf(resultFmt, ccmE == 0 ? passed : failed);
|
||||
if (ccmE != 0) {
|
||||
wc_AesFree(&aes);
|
||||
return ccmE;
|
||||
}
|
||||
#ifdef HAVE_AES_DECRYPT
|
||||
@ -8632,6 +8655,8 @@ static int test_wc_AesCcmEncryptDecrypt (void)
|
||||
}
|
||||
#endif
|
||||
|
||||
wc_AesFree(&aes);
|
||||
|
||||
#endif /* HAVE_AESCCM */
|
||||
|
||||
return ret;
|
||||
|
@ -176,9 +176,13 @@ int wc_Des3_CbcEncryptWithKey(byte* out, const byte* in, word32 sz,
|
||||
return MEMORY_E;
|
||||
#endif
|
||||
|
||||
ret = wc_Des3_SetKey(des3, key, iv, DES_ENCRYPTION);
|
||||
if (ret == 0)
|
||||
ret = wc_Des3_CbcEncrypt(des3, out, in, sz);
|
||||
ret = wc_Des3Init(des3, NULL, INVALID_DEVID);
|
||||
if (ret == 0) {
|
||||
ret = wc_Des3_SetKey(des3, key, iv, DES_ENCRYPTION);
|
||||
if (ret == 0)
|
||||
ret = wc_Des3_CbcEncrypt(des3, out, in, sz);
|
||||
wc_Des3Free(des3);
|
||||
}
|
||||
|
||||
#ifdef WOLFSSL_SMALL_STACK
|
||||
XFREE(des3, NULL, DYNAMIC_TYPE_TMP_BUFFER);
|
||||
@ -204,9 +208,13 @@ int wc_Des3_CbcDecryptWithKey(byte* out, const byte* in, word32 sz,
|
||||
return MEMORY_E;
|
||||
#endif
|
||||
|
||||
ret = wc_Des3_SetKey(des3, key, iv, DES_DECRYPTION);
|
||||
if (ret == 0)
|
||||
ret = wc_Des3_CbcDecrypt(des3, out, in, sz);
|
||||
ret = wc_Des3Init(des3, NULL, INVALID_DEVID);
|
||||
if (ret == 0) {
|
||||
ret = wc_Des3_SetKey(des3, key, iv, DES_DECRYPTION);
|
||||
if (ret == 0)
|
||||
ret = wc_Des3_CbcDecrypt(des3, out, in, sz);
|
||||
wc_Des3Free(des3);
|
||||
}
|
||||
|
||||
#ifdef WOLFSSL_SMALL_STACK
|
||||
XFREE(des3, NULL, DYNAMIC_TYPE_TMP_BUFFER);
|
||||
|
Loading…
Reference in New Issue
Block a user