1
0
mirror of https://github.com/Mbed-TLS/mbedtls.git synced 2025-07-29 11:41:15 +03:00

Finish / Verify state checks

Ensure finish only called when encrypting and verify only called for
decrypting, and add tests to ensure this.

Signed-off-by: Paul Elliott <paul.elliott@arm.com>
This commit is contained in:
Paul Elliott
2021-06-22 19:15:20 +01:00
parent f88a565f18
commit 534d0b4484
2 changed files with 37 additions and 2 deletions

View File

@ -3780,7 +3780,7 @@ psa_status_t psa_aead_finish( psa_aead_operation_t *operation,
goto exit;
}
if( !operation->nonce_set )
if( !operation->nonce_set || operation->is_encrypt == 0 )
{
status = PSA_ERROR_BAD_STATE;
goto exit;
@ -3829,7 +3829,7 @@ psa_status_t psa_aead_verify( psa_aead_operation_t *operation,
goto exit;
}
if( !operation->nonce_set )
if( !operation->nonce_set || operation->is_encrypt == 1 )
{
status = PSA_ERROR_BAD_STATE;
goto exit;