mirror of
https://github.com/wolfSSL/wolfssl.git
synced 2025-07-31 19:24:42 +02:00
Added missing AES/DES3/HMAC init functions for helping with valgrind reports on unitialized use for async markers.
This commit is contained in:
148
tests/api.c
148
tests/api.c
@@ -4209,6 +4209,10 @@ static int test_wc_Md5HmacSetKey (void)
|
||||
|
||||
printf(testingFmt, "wc_HmacSetKey() with MD5");
|
||||
|
||||
ret = wc_HmacInit(&hmac, NULL, INVALID_DEVID);
|
||||
if (ret != 0)
|
||||
return ret;
|
||||
|
||||
for (itr = 0; itr < times; itr++) {
|
||||
ret = wc_HmacSetKey(&hmac, MD5, (byte*)keys[itr],
|
||||
(word32)XSTRLEN(keys[itr]));
|
||||
@@ -4254,6 +4258,8 @@ static int test_wc_Md5HmacSetKey (void)
|
||||
#endif
|
||||
}
|
||||
|
||||
wc_HmacFree(&hmac);
|
||||
|
||||
printf(resultFmt, flag == 0 ? passed : failed);
|
||||
|
||||
#endif
|
||||
@@ -4288,6 +4294,10 @@ static int test_wc_ShaHmacSetKey (void)
|
||||
|
||||
printf(testingFmt, "wc_HmacSetKey() with SHA");
|
||||
|
||||
ret = wc_HmacInit(&hmac, NULL, INVALID_DEVID);
|
||||
if (ret != 0)
|
||||
return ret;
|
||||
|
||||
for (itr = 0; itr < times; itr++) {
|
||||
ret = wc_HmacSetKey(&hmac, SHA, (byte*)keys[itr],
|
||||
(word32)XSTRLEN(keys[itr]));
|
||||
@@ -4333,6 +4343,8 @@ static int test_wc_ShaHmacSetKey (void)
|
||||
#endif
|
||||
}
|
||||
|
||||
wc_HmacFree(&hmac);
|
||||
|
||||
printf(resultFmt, flag == 0 ? passed : failed);
|
||||
|
||||
#endif
|
||||
@@ -4366,6 +4378,10 @@ static int test_wc_Sha224HmacSetKey (void)
|
||||
|
||||
printf(testingFmt, "wc_HmacSetKey() with SHA 224");
|
||||
|
||||
ret = wc_HmacInit(&hmac, NULL, INVALID_DEVID);
|
||||
if (ret != 0)
|
||||
return ret;
|
||||
|
||||
for (itr = 0; itr < times; itr++) {
|
||||
ret = wc_HmacSetKey(&hmac, SHA224, (byte*)keys[itr],
|
||||
(word32)XSTRLEN(keys[itr]));
|
||||
@@ -4411,6 +4427,8 @@ static int test_wc_Sha224HmacSetKey (void)
|
||||
#endif
|
||||
}
|
||||
|
||||
wc_HmacFree(&hmac);
|
||||
|
||||
printf(resultFmt, flag == 0 ? passed : failed);
|
||||
|
||||
#endif
|
||||
@@ -4444,6 +4462,10 @@ static int test_wc_Sha256HmacSetKey (void)
|
||||
|
||||
printf(testingFmt, "wc_HmacSetKey() with SHA256");
|
||||
|
||||
ret = wc_HmacInit(&hmac, NULL, INVALID_DEVID);
|
||||
if (ret != 0)
|
||||
return ret;
|
||||
|
||||
for (itr = 0; itr < times; itr++) {
|
||||
ret = wc_HmacSetKey(&hmac, SHA256, (byte*)keys[itr],
|
||||
(word32)XSTRLEN(keys[itr]));
|
||||
@@ -4489,6 +4511,8 @@ static int test_wc_Sha256HmacSetKey (void)
|
||||
#endif
|
||||
}
|
||||
|
||||
wc_HmacFree(&hmac);
|
||||
|
||||
printf(resultFmt, flag == 0 ? passed : failed);
|
||||
|
||||
#endif
|
||||
@@ -4522,6 +4546,10 @@ static int test_wc_Sha384HmacSetKey (void)
|
||||
|
||||
printf(testingFmt, "wc_HmacSetKey() with SHA384");
|
||||
|
||||
ret = wc_HmacInit(&hmac, NULL, INVALID_DEVID);
|
||||
if (ret != 0)
|
||||
return ret;
|
||||
|
||||
for (itr = 0; itr < times; itr++) {
|
||||
ret = wc_HmacSetKey(&hmac, SHA384, (byte*)keys[itr],
|
||||
(word32)XSTRLEN(keys[itr]));
|
||||
@@ -4567,6 +4595,8 @@ static int test_wc_Sha384HmacSetKey (void)
|
||||
#endif
|
||||
}
|
||||
|
||||
wc_HmacFree(&hmac);
|
||||
|
||||
printf(resultFmt, flag == 0 ? passed : failed);
|
||||
|
||||
#endif
|
||||
@@ -4601,6 +4631,10 @@ static int test_wc_Md5HmacUpdate (void)
|
||||
|
||||
printf(testingFmt, "wc_HmacUpdate() with MD5");
|
||||
|
||||
ret = wc_HmacInit(&hmac, NULL, INVALID_DEVID);
|
||||
if (ret != 0)
|
||||
return ret;
|
||||
|
||||
ret = wc_HmacSetKey(&hmac, MD5, (byte*)keys, (word32)XSTRLEN(keys));
|
||||
if (ret != 0) {
|
||||
flag = ret;
|
||||
@@ -4642,6 +4676,8 @@ static int test_wc_Md5HmacUpdate (void)
|
||||
}
|
||||
}
|
||||
|
||||
wc_HmacFree(&hmac);
|
||||
|
||||
printf(resultFmt, flag == 0 ? passed : failed);
|
||||
|
||||
#endif
|
||||
@@ -4675,6 +4711,10 @@ static int test_wc_ShaHmacUpdate (void)
|
||||
|
||||
printf(testingFmt, "wc_HmacUpdate() with SHA");
|
||||
|
||||
ret = wc_HmacInit(&hmac, NULL, INVALID_DEVID);
|
||||
if (ret != 0)
|
||||
return ret;
|
||||
|
||||
ret = wc_HmacSetKey(&hmac, SHA, (byte*)keys, (word32)XSTRLEN(keys));
|
||||
if (ret != 0) {
|
||||
flag = ret;
|
||||
@@ -4716,6 +4756,8 @@ static int test_wc_ShaHmacUpdate (void)
|
||||
}
|
||||
}
|
||||
|
||||
wc_HmacFree(&hmac);
|
||||
|
||||
printf(resultFmt, flag == 0 ? passed : failed);
|
||||
|
||||
#endif
|
||||
@@ -4749,6 +4791,10 @@ static int test_wc_Sha224HmacUpdate (void)
|
||||
|
||||
printf(testingFmt, "wc_HmacUpdate() with SHA224");
|
||||
|
||||
ret = wc_HmacInit(&hmac, NULL, INVALID_DEVID);
|
||||
if (ret != 0)
|
||||
return ret;
|
||||
|
||||
ret = wc_HmacSetKey(&hmac, SHA224, (byte*)keys, (word32)XSTRLEN(keys));
|
||||
if (ret != 0) {
|
||||
flag = ret;
|
||||
@@ -4790,6 +4836,8 @@ static int test_wc_Sha224HmacUpdate (void)
|
||||
}
|
||||
}
|
||||
|
||||
wc_HmacFree(&hmac);
|
||||
|
||||
printf(resultFmt, flag == 0 ? passed : failed);
|
||||
|
||||
#endif
|
||||
@@ -4823,6 +4871,10 @@ static int test_wc_Sha256HmacUpdate (void)
|
||||
|
||||
printf(testingFmt, "wc_HmacUpdate() with SHA256");
|
||||
|
||||
ret = wc_HmacInit(&hmac, NULL, INVALID_DEVID);
|
||||
if (ret != 0)
|
||||
return ret;
|
||||
|
||||
ret = wc_HmacSetKey(&hmac, SHA256, (byte*)keys, (word32)XSTRLEN(keys));
|
||||
if (ret != 0) {
|
||||
flag = ret;
|
||||
@@ -4864,6 +4916,8 @@ static int test_wc_Sha256HmacUpdate (void)
|
||||
}
|
||||
}
|
||||
|
||||
wc_HmacFree(&hmac);
|
||||
|
||||
printf(resultFmt, flag == 0 ? passed : failed);
|
||||
|
||||
#endif
|
||||
@@ -4897,6 +4951,10 @@ static int test_wc_Sha384HmacUpdate (void)
|
||||
|
||||
printf(testingFmt, "wc_HmacUpdate() with SHA384");
|
||||
|
||||
ret = wc_HmacInit(&hmac, NULL, INVALID_DEVID);
|
||||
if (ret != 0)
|
||||
return ret;
|
||||
|
||||
ret = wc_HmacSetKey(&hmac, SHA384, (byte*)keys, (word32)XSTRLEN(keys));
|
||||
if (ret != 0) {
|
||||
flag = ret;
|
||||
@@ -4938,6 +4996,8 @@ static int test_wc_Sha384HmacUpdate (void)
|
||||
}
|
||||
}
|
||||
|
||||
wc_HmacFree(&hmac);
|
||||
|
||||
printf(resultFmt, flag == 0 ? passed : failed);
|
||||
|
||||
#endif
|
||||
@@ -4971,14 +5031,12 @@ static int test_wc_Md5HmacFinal (void)
|
||||
|
||||
ret = wc_HmacInit(&hmac, NULL, INVALID_DEVID);
|
||||
if (ret != 0)
|
||||
flag = ret;
|
||||
return ret;
|
||||
|
||||
if (!flag) {
|
||||
ret = wc_HmacSetKey(&hmac, MD5, (byte*)key, (word32)XSTRLEN(key));
|
||||
if (ret != 0) {
|
||||
flag = ret;
|
||||
}
|
||||
}
|
||||
|
||||
if (!flag) {
|
||||
ret = wc_HmacUpdate(&hmac, (byte*)a.input, (word32)a.inLen);
|
||||
@@ -5053,14 +5111,12 @@ static int test_wc_ShaHmacFinal (void)
|
||||
|
||||
ret = wc_HmacInit(&hmac, NULL, INVALID_DEVID);
|
||||
if (ret != 0)
|
||||
flag = ret;
|
||||
return ret;
|
||||
|
||||
if (!flag) {
|
||||
ret = wc_HmacSetKey(&hmac, SHA, (byte*)key, (word32)XSTRLEN(key));
|
||||
if (ret != 0) {
|
||||
flag = ret;
|
||||
}
|
||||
}
|
||||
|
||||
if (!flag) {
|
||||
ret = wc_HmacUpdate(&hmac, (byte*)a.input, (word32)a.inLen);
|
||||
@@ -5136,14 +5192,12 @@ static int test_wc_Sha224HmacFinal (void)
|
||||
|
||||
ret = wc_HmacInit(&hmac, NULL, INVALID_DEVID);
|
||||
if (ret != 0)
|
||||
flag = ret;
|
||||
return ret;
|
||||
|
||||
if (!flag) {
|
||||
ret = wc_HmacSetKey(&hmac, SHA224, (byte*)key, (word32)XSTRLEN(key));
|
||||
if (ret != 0) {
|
||||
flag = ret;
|
||||
}
|
||||
}
|
||||
|
||||
if (!flag) {
|
||||
ret = wc_HmacUpdate(&hmac, (byte*)a.input, (word32)a.inLen);
|
||||
@@ -5218,14 +5272,12 @@ static int test_wc_Sha256HmacFinal (void)
|
||||
|
||||
ret = wc_HmacInit(&hmac, NULL, INVALID_DEVID);
|
||||
if (ret != 0)
|
||||
flag = ret;
|
||||
return ret;
|
||||
|
||||
if (!flag) {
|
||||
ret = wc_HmacSetKey(&hmac, SHA256, (byte*)key, (word32)XSTRLEN(key));
|
||||
if (ret != 0) {
|
||||
flag = ret;
|
||||
}
|
||||
}
|
||||
|
||||
if (!flag) {
|
||||
ret = wc_HmacUpdate(&hmac, (byte*)a.input, (word32)a.inLen);
|
||||
@@ -5301,14 +5353,12 @@ static int test_wc_Sha384HmacFinal (void)
|
||||
|
||||
ret = wc_HmacInit(&hmac, NULL, INVALID_DEVID);
|
||||
if (ret != 0)
|
||||
flag = ret;
|
||||
return ret;
|
||||
|
||||
if (!flag) {
|
||||
ret = wc_HmacSetKey(&hmac, SHA384, (byte*)key, (word32)XSTRLEN(key));
|
||||
if (ret != 0) {
|
||||
flag = ret;
|
||||
}
|
||||
}
|
||||
|
||||
if (!flag) {
|
||||
ret = wc_HmacUpdate(&hmac, (byte*)a.input, (word32)a.inLen);
|
||||
@@ -5380,6 +5430,10 @@ static int test_wc_Des3_SetIV (void)
|
||||
|
||||
printf(testingFmt, "wc_Des3_SetIV()");
|
||||
|
||||
ret = wc_Des3Init(&des, NULL, INVALID_DEVID);
|
||||
if (ret != 0)
|
||||
return ret;
|
||||
|
||||
/* DES_ENCRYPTION or DES_DECRYPTION */
|
||||
ret = wc_Des3_SetKey(&des, key, iv, DES_ENCRYPTION);
|
||||
|
||||
@@ -5401,6 +5455,8 @@ static int test_wc_Des3_SetIV (void)
|
||||
}
|
||||
#endif
|
||||
|
||||
wc_Des3Free(&des);
|
||||
|
||||
printf(resultFmt, ret == 0 ? passed : failed);
|
||||
|
||||
#endif
|
||||
@@ -5432,6 +5488,10 @@ static int test_wc_Des3_SetKey (void)
|
||||
|
||||
printf(testingFmt, "wc_Des3_SetKey()");
|
||||
|
||||
ret = wc_Des3Init(&des, NULL, INVALID_DEVID);
|
||||
if (ret != 0)
|
||||
return ret;
|
||||
|
||||
/* DES_ENCRYPTION or DES_DECRYPTION */
|
||||
ret = wc_Des3_SetKey(&des, key, iv, DES_ENCRYPTION);
|
||||
if (ret == 0) {
|
||||
@@ -5455,6 +5515,8 @@ static int test_wc_Des3_SetKey (void)
|
||||
}
|
||||
} /* END if ret != 0 */
|
||||
|
||||
wc_Des3Free(&des);
|
||||
|
||||
printf(resultFmt, ret == 0 ? passed : failed);
|
||||
|
||||
#endif
|
||||
@@ -5495,6 +5557,10 @@ static int test_wc_Des3_CbcEncryptDecrypt (void)
|
||||
|
||||
printf(testingFmt, "wc_Des3_CbcEncrypt()");
|
||||
|
||||
ret = wc_Des3Init(&des, NULL, INVALID_DEVID);
|
||||
if (ret != 0)
|
||||
return ret;
|
||||
|
||||
ret = wc_Des3_SetKey(&des, key, iv, DES_ENCRYPTION);
|
||||
|
||||
if (ret == 0) {
|
||||
@@ -5545,6 +5611,8 @@ static int test_wc_Des3_CbcEncryptDecrypt (void)
|
||||
}
|
||||
}
|
||||
|
||||
wc_Des3Free(&des);
|
||||
|
||||
printf(resultFmt, ret == 0 ? passed : failed);
|
||||
|
||||
#endif
|
||||
@@ -5935,6 +6003,10 @@ static int test_wc_AesSetIV (void)
|
||||
|
||||
printf(testingFmt, "wc_AesSetIV()");
|
||||
|
||||
ret = wc_AesInit(&aes, NULL, INVALID_DEVID);
|
||||
if (ret != 0)
|
||||
return ret;
|
||||
|
||||
ret = wc_AesSetKey(&aes, key16, (word32) sizeof(key16) / sizeof(byte),
|
||||
iv1, AES_ENCRYPTION);
|
||||
if(ret == 0) {
|
||||
@@ -5951,6 +6023,8 @@ static int test_wc_AesSetIV (void)
|
||||
}
|
||||
}
|
||||
|
||||
wc_AesFree(&aes);
|
||||
|
||||
printf(resultFmt, ret == 0 ? passed : failed);
|
||||
|
||||
#endif
|
||||
@@ -5994,10 +6068,11 @@ static int test_wc_AesSetKey (void)
|
||||
printf(testingFmt, "wc_AesSetKey()");
|
||||
|
||||
ret = wc_AesInit(&aes, NULL, INVALID_DEVID);
|
||||
if (ret == 0) {
|
||||
if (ret != 0)
|
||||
return ret;
|
||||
|
||||
ret = wc_AesSetKey(&aes, key16, (word32) sizeof(key16) / sizeof(byte),
|
||||
iv, AES_ENCRYPTION);
|
||||
}
|
||||
if (ret == 0) {
|
||||
ret = wc_AesSetKey (&aes, key24, (word32) sizeof(key24) / sizeof(byte),
|
||||
iv, AES_ENCRYPTION);
|
||||
@@ -6022,6 +6097,8 @@ static int test_wc_AesSetKey (void)
|
||||
}
|
||||
}
|
||||
|
||||
wc_AesFree(&aes);
|
||||
|
||||
printf(resultFmt, ret == 0 ? passed : failed);
|
||||
|
||||
#endif
|
||||
@@ -6066,9 +6143,10 @@ static int test_wc_AesCbcEncryptDecrypt (void)
|
||||
XMEMSET(dec2, 0, sizeof(vector));
|
||||
|
||||
ret = wc_AesInit(&aes, NULL, INVALID_DEVID);
|
||||
if (ret == 0) {
|
||||
if (ret != 0)
|
||||
return ret;
|
||||
|
||||
ret = wc_AesSetKey(&aes, key32, AES_BLOCK_SIZE * 2, iv, AES_ENCRYPTION);
|
||||
}
|
||||
if (ret == 0) {
|
||||
ret = wc_AesCbcEncrypt(&aes, enc, vector, sizeof(vector));
|
||||
if (ret == 0) {
|
||||
@@ -6114,6 +6192,7 @@ static int test_wc_AesCbcEncryptDecrypt (void)
|
||||
}
|
||||
printf(resultFmt, cbcE == 0 ? passed : failed);
|
||||
if (cbcE != 0) {
|
||||
wc_AesFree(&aes);
|
||||
return cbcE;
|
||||
}
|
||||
|
||||
@@ -6137,6 +6216,7 @@ static int test_wc_AesCbcEncryptDecrypt (void)
|
||||
}
|
||||
printf(resultFmt, cbcD == 0 ? passed : failed);
|
||||
if (cbcD != 0) {
|
||||
wc_AesFree(&aes);
|
||||
return cbcD;
|
||||
}
|
||||
|
||||
@@ -6162,7 +6242,11 @@ static int test_wc_AesCbcEncryptDecrypt (void)
|
||||
cbcDWK = SSL_FATAL_ERROR;
|
||||
}
|
||||
}
|
||||
|
||||
wc_AesFree(&aes);
|
||||
|
||||
printf(resultFmt, cbcDWK == 0 ? passed : failed);
|
||||
|
||||
if (cbcDWK != 0) {
|
||||
return cbcDWK;
|
||||
}
|
||||
@@ -6202,13 +6286,16 @@ static int test_wc_AesCtrEncryptDecrypt (void)
|
||||
printf(testingFmt, "wc_AesCtrEncrypt()");
|
||||
|
||||
ret = wc_AesInit(&aesEnc, NULL, INVALID_DEVID);
|
||||
if (ret == 0) {
|
||||
if (ret != 0)
|
||||
return ret;
|
||||
ret = wc_AesInit(&aesDec, NULL, INVALID_DEVID);
|
||||
if (ret != 0) {
|
||||
wc_AesFree(&aesEnc);
|
||||
return ret;
|
||||
}
|
||||
if (ret == 0) {
|
||||
|
||||
ret = wc_AesSetKey(&aesEnc, key32, AES_BLOCK_SIZE * 2,
|
||||
iv, AES_ENCRYPTION);
|
||||
}
|
||||
if (ret == 0) {
|
||||
ret = wc_AesCtrEncrypt(&aesEnc, enc, vector,
|
||||
sizeof(vector)/sizeof(byte));
|
||||
@@ -6241,6 +6328,9 @@ static int test_wc_AesCtrEncryptDecrypt (void)
|
||||
}
|
||||
}
|
||||
|
||||
wc_AesFree(&aesEnc);
|
||||
wc_AesFree(&aesDec);
|
||||
|
||||
printf(resultFmt, ret == 0 ? passed : failed);
|
||||
|
||||
#endif
|
||||
@@ -6296,6 +6386,10 @@ static int test_wc_AesGcmSetKey (void)
|
||||
|
||||
printf(testingFmt, "wc_AesGcmSetKey()");
|
||||
|
||||
ret = wc_AesInit(&aes, NULL, INVALID_DEVID);
|
||||
if (ret != 0)
|
||||
return ret;
|
||||
|
||||
ret = wc_AesGcmSetKey(&aes, key16, sizeof(key16)/sizeof(byte));
|
||||
if (ret == 0) {
|
||||
ret = wc_AesGcmSetKey(&aes, key24, sizeof(key24)/sizeof(byte));
|
||||
@@ -6320,6 +6414,8 @@ static int test_wc_AesGcmSetKey (void)
|
||||
}
|
||||
}
|
||||
|
||||
wc_AesFree(&aes);
|
||||
|
||||
printf(resultFmt, ret == 0 ? passed : failed);
|
||||
|
||||
#endif
|
||||
@@ -6367,6 +6463,10 @@ static int test_wc_AesGcmEncryptDecrypt (void)
|
||||
XMEMSET(dec, 0, sizeof(vector));
|
||||
XMEMSET(resultT, 0, AES_BLOCK_SIZE);
|
||||
|
||||
ret = wc_AesInit(&aes, NULL, INVALID_DEVID);
|
||||
if (ret != 0)
|
||||
return ret;
|
||||
|
||||
ret = wc_AesGcmSetKey(&aes, key32, sizeof(key32)/sizeof(byte));
|
||||
if (ret == 0) {
|
||||
gcmE = wc_AesGcmEncrypt(&aes, enc, vector, sizeof(vector),
|
||||
@@ -6413,6 +6513,7 @@ static int test_wc_AesGcmEncryptDecrypt (void)
|
||||
|
||||
printf(resultFmt, gcmE == 0 ? passed : failed);
|
||||
if (gcmE != 0) {
|
||||
wc_AesFree(&aes);
|
||||
return gcmE;
|
||||
}
|
||||
|
||||
@@ -6458,6 +6559,9 @@ static int test_wc_AesGcmEncryptDecrypt (void)
|
||||
printf(resultFmt, gcmD == 0 ? passed : failed);
|
||||
#endif /* HAVE_AES_DECRYPT */
|
||||
#endif
|
||||
|
||||
wc_AesFree(&aes);
|
||||
|
||||
return ret;
|
||||
|
||||
} /* END test_wc_AesGcmEncryptDecrypt */
|
||||
|
@@ -841,11 +841,15 @@ int wolfSSL_GetHmacMaxSize(void)
|
||||
saltSz = hashSz;
|
||||
}
|
||||
|
||||
ret = wc_HmacInit(&myHmac, NULL, INVALID_DEVID);
|
||||
if (ret == 0) {
|
||||
ret = wc_HmacSetKey(&myHmac, type, localSalt, saltSz);
|
||||
if (ret == 0)
|
||||
ret = wc_HmacUpdate(&myHmac, inKey, inKeySz);
|
||||
if (ret == 0)
|
||||
ret = wc_HmacFinal(&myHmac, out);
|
||||
wc_HmacFree(&myHmac);
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
@@ -871,6 +875,10 @@ int wolfSSL_GetHmacMaxSize(void)
|
||||
word32 hashSz = wc_HmacSizeByType(type);
|
||||
byte n = 0x1;
|
||||
|
||||
ret = wc_HmacInit(&myHmac, NULL, INVALID_DEVID);
|
||||
if (ret != 0)
|
||||
return ret;
|
||||
|
||||
while (outIdx < outSz) {
|
||||
int tmpSz = (n == 1) ? 0 : hashSz;
|
||||
word32 left = outSz - outIdx;
|
||||
@@ -898,6 +906,8 @@ int wolfSSL_GetHmacMaxSize(void)
|
||||
n++;
|
||||
}
|
||||
|
||||
wc_HmacFree(&myHmac);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
@@ -53,10 +53,15 @@ int wc_AesCbcDecryptWithKey(byte* out, const byte* in, word32 inSz,
|
||||
return MEMORY_E;
|
||||
#endif
|
||||
|
||||
ret = wc_AesInit(aes, NULL, INVALID_DEVID);
|
||||
if (ret == 0) {
|
||||
ret = wc_AesSetKey(aes, key, keySz, iv, AES_DECRYPTION);
|
||||
if (ret == 0)
|
||||
ret = wc_AesCbcDecrypt(aes, out, in, inSz);
|
||||
|
||||
wc_AesFree(aes);
|
||||
}
|
||||
|
||||
#ifdef WOLFSSL_SMALL_STACK
|
||||
XFREE(aes, NULL, DYNAMIC_TYPE_TMP_BUFFER);
|
||||
#endif
|
||||
@@ -81,10 +86,15 @@ int wc_AesCbcEncryptWithKey(byte* out, const byte* in, word32 inSz,
|
||||
return MEMORY_E;
|
||||
#endif
|
||||
|
||||
ret = wc_AesInit(aes, NULL, INVALID_DEVID);
|
||||
if (ret == 0) {
|
||||
ret = wc_AesSetKey(aes, key, keySz, iv, AES_ENCRYPTION);
|
||||
if (ret == 0)
|
||||
ret = wc_AesCbcEncrypt(aes, out, in, inSz);
|
||||
|
||||
wc_AesFree(aes);
|
||||
}
|
||||
|
||||
#ifdef WOLFSSL_SMALL_STACK
|
||||
XFREE(aes, NULL, DYNAMIC_TYPE_TMP_BUFFER);
|
||||
#endif
|
||||
|
Reference in New Issue
Block a user