Skip to content

Commit 28cd416

Browse files
Fix possible error code mangling in psa_mac_verify_finish
If psa_mac_finish_internal fails (which can only happen due to bad parameters or hardware problem), the error code was converted to PSA_ERROR_INVALID_SIGNATURE if the uninitialized stack variable actual_mac happened to contain the expected MAC. This is a minor bug but it may be possible to leverage it as part of a longer attack path in some scenarios. Reported externally. Found by static analysis.
1 parent 448d1cc commit 28cd416

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

library/psa_crypto.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3030,6 +3030,8 @@ psa_status_t psa_mac_verify_finish( psa_mac_operation_t *operation,
30303030

30313031
status = psa_mac_finish_internal( operation,
30323032
actual_mac, sizeof( actual_mac ) );
3033+
if( status != PSA_SUCCESS )
3034+
goto cleanup;
30333035

30343036
if( safer_memcmp( mac, actual_mac, mac_length ) != 0 )
30353037
status = PSA_ERROR_INVALID_SIGNATURE;

0 commit comments

Comments
 (0)