ccm: Fix memory leak on failed ICV verification if not using in-place decryption
Fixes: 80a93a1335 ("Implemented a ccm plugin providing CCM mode based on CBC crypters")
This commit is contained in:
@@ -283,16 +283,21 @@ METHOD(aead_t, decrypt, bool,
|
||||
return FALSE;
|
||||
}
|
||||
encrypted.len -= this->icv_size;
|
||||
if (plain)
|
||||
if (!plain)
|
||||
{
|
||||
*plain = chunk_alloc(encrypted.len);
|
||||
return crypt_data(this, iv, encrypted, *plain) &&
|
||||
verify_icv(this, *plain, assoc, iv,
|
||||
return crypt_data(this, iv, encrypted, encrypted) &&
|
||||
verify_icv(this, encrypted, assoc, iv,
|
||||
encrypted.ptr + encrypted.len);
|
||||
}
|
||||
return crypt_data(this, iv, encrypted, encrypted) &&
|
||||
verify_icv(this, encrypted, assoc, iv,
|
||||
encrypted.ptr + encrypted.len);
|
||||
*plain = chunk_alloc(encrypted.len);
|
||||
if (crypt_data(this, iv, encrypted, *plain) &&
|
||||
verify_icv(this, *plain, assoc, iv,
|
||||
encrypted.ptr + encrypted.len))
|
||||
{
|
||||
return TRUE;
|
||||
}
|
||||
chunk_free(plain);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
METHOD(aead_t, get_block_size, size_t,
|
||||
|
||||
Reference in New Issue
Block a user