mirror of
https://github.com/wolfSSL/wolfssl.git
synced 2026-07-07 02:10:48 +02:00
fix for handling of error case with AES devcrypto
This commit is contained in:
@@ -253,13 +253,17 @@ int wc_AesCtrEncrypt(Aes* aes, byte* out, const byte* in, word32 sz)
|
||||
/* create key stream for later if needed */
|
||||
if (sz > 0) {
|
||||
Aes tmpAes;
|
||||
if ((ret = wc_AesSetKey(&tmpAes, (byte*)aes->devKey, aes->keylen,
|
||||
(byte*)aes->reg, AES_ENCRYPTION)) != 0)
|
||||
return ret;
|
||||
if ((ret = wc_AesEncryptDirect(&tmpAes, (byte*)aes->tmp,
|
||||
(const byte*)aes->reg)) != 0)
|
||||
return ret;
|
||||
ret = wc_AesSetKey(&tmpAes, (byte*)aes->devKey, aes->keylen,
|
||||
(byte*)aes->reg, AES_ENCRYPTION);
|
||||
if (ret == 0) {
|
||||
ret = wc_AesEncryptDirect(&tmpAes, (byte*)aes->tmp,
|
||||
(const byte*)aes->reg);
|
||||
}
|
||||
wc_AesFree(&tmpAes);
|
||||
ForceZero(&tmpAes, sizeof(tmpAes));
|
||||
if (ret != 0)
|
||||
return ret;
|
||||
|
||||
IncrementAesCounter((byte*)aes->reg);
|
||||
|
||||
aes->left = WC_AES_BLOCK_SIZE - (sz % WC_AES_BLOCK_SIZE);
|
||||
|
||||
Reference in New Issue
Block a user