Ensure tag lengths match in verification

Signed-off-by: Paul Elliott <paul.elliott@arm.com>
This commit is contained in:
Paul Elliott 2021-05-21 18:03:15 +01:00
parent f47b0957ab
commit 3a16e014f2

View File

@ -733,8 +733,8 @@ psa_status_t mbedtls_psa_aead_verify(
{
*plaintext_length = finish_output_size;
if( do_tag_check &&
mbedtls_psa_safer_memcmp(tag, check_tag, tag_length) != 0 )
if( do_tag_check && ( tag_length != operation->tag_length ||
mbedtls_psa_safer_memcmp(tag, check_tag, tag_length) != 0 ) )
status = PSA_ERROR_INVALID_SIGNATURE;
}