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;
|
return FALSE;
|
||||||
}
|
}
|
||||||
encrypted.len -= this->icv_size;
|
encrypted.len -= this->icv_size;
|
||||||
if (plain)
|
if (!plain)
|
||||||
{
|
{
|
||||||
*plain = chunk_alloc(encrypted.len);
|
return crypt_data(this, iv, encrypted, encrypted) &&
|
||||||
return crypt_data(this, iv, encrypted, *plain) &&
|
verify_icv(this, encrypted, assoc, iv,
|
||||||
verify_icv(this, *plain, assoc, iv,
|
|
||||||
encrypted.ptr + encrypted.len);
|
encrypted.ptr + encrypted.len);
|
||||||
}
|
}
|
||||||
return crypt_data(this, iv, encrypted, encrypted) &&
|
*plain = chunk_alloc(encrypted.len);
|
||||||
verify_icv(this, encrypted, assoc, iv,
|
if (crypt_data(this, iv, encrypted, *plain) &&
|
||||||
encrypted.ptr + encrypted.len);
|
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,
|
METHOD(aead_t, get_block_size, size_t,
|
||||||
|
|||||||
Reference in New Issue
Block a user