mirror of
https://github.com/wolfSSL/wolfssl.git
synced 2026-07-06 21:50:52 +02:00
Fix sz==0 buffer underflow in devcrypto AES-CBC
This commit is contained in:
@@ -44,8 +44,11 @@ int wc_AesCbcEncrypt(Aes* aes, byte* out, const byte* in, word32 sz)
|
||||
return BAD_FUNC_ARG;
|
||||
}
|
||||
|
||||
/* encrypt only up to AES block size of date */
|
||||
/* encrypt only up to AES block size of data */
|
||||
sz = sz - (sz % WC_AES_BLOCK_SIZE);
|
||||
if (sz == 0) {
|
||||
return 0;
|
||||
}
|
||||
if (aes->ctx.cfd == -1) {
|
||||
ret = wc_DevCryptoCreate(&aes->ctx, CRYPTO_AES_CBC,
|
||||
(byte*)aes->devKey, aes->keylen);
|
||||
@@ -74,6 +77,9 @@ int wc_AesCbcDecrypt(Aes* aes, byte* out, const byte* in, word32 sz)
|
||||
if (aes == NULL || out == NULL || in == NULL || sz % WC_AES_BLOCK_SIZE != 0) {
|
||||
return BAD_FUNC_ARG;
|
||||
}
|
||||
if (sz == 0) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
XMEMCPY(aes->tmp, in + sz - WC_AES_BLOCK_SIZE, WC_AES_BLOCK_SIZE);
|
||||
if (aes->ctx.cfd == -1) {
|
||||
|
||||
Reference in New Issue
Block a user