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:
Tobias Brunner
2026-07-22 18:20:12 +02:00
parent 40aa0a12c4
commit 85c02dc16c
+12 -7
View File
@@ -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,