From 9719a8450e4ff6f20d5b2548ffd3605da6c9abdf Mon Sep 17 00:00:00 2001 From: gabor-mezei-arm Date: Mon, 3 May 2021 16:26:20 +0200 Subject: [PATCH] Fix for algorithms other than hash-then-sign Signed-off-by: gabor-mezei-arm --- library/psa_crypto.c | 24 ++++++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-) diff --git a/library/psa_crypto.c b/library/psa_crypto.c index 7c95a6c94..aa1beb57c 100644 --- a/library/psa_crypto.c +++ b/library/psa_crypto.c @@ -3024,11 +3024,12 @@ psa_status_t psa_sign_message_internal( size_t *signature_length ) { psa_status_t status = PSA_ERROR_CORRUPTION_DETECTED; - size_t hash_length; - uint8_t hash[PSA_HASH_MAX_SIZE]; if ( PSA_ALG_IS_HASH_AND_SIGN( alg ) ) { + size_t hash_length; + uint8_t hash[PSA_HASH_MAX_SIZE]; + status = psa_driver_wrapper_hash_compute( PSA_ALG_SIGN_GET_HASH( alg ), input, input_length, @@ -3036,11 +3037,16 @@ psa_status_t psa_sign_message_internal( if( status != PSA_SUCCESS ) return status; + + return psa_driver_wrapper_sign_hash( + attributes, key_buffer, key_buffer_size, + alg, hash, hash_length, + signature, signature_size, signature_length ); } return psa_driver_wrapper_sign_hash( attributes, key_buffer, key_buffer_size, - alg, hash, hash_length, + alg, input, input_length, signature, signature_size, signature_length ); } @@ -3068,11 +3074,12 @@ psa_status_t psa_verify_message_internal( size_t signature_length ) { psa_status_t status = PSA_ERROR_CORRUPTION_DETECTED; - size_t hash_length; - uint8_t hash[PSA_HASH_MAX_SIZE]; if ( PSA_ALG_IS_HASH_AND_SIGN( alg ) ) { + size_t hash_length; + uint8_t hash[PSA_HASH_MAX_SIZE]; + status = psa_driver_wrapper_hash_compute( PSA_ALG_SIGN_GET_HASH( alg ), input, input_length, @@ -3080,11 +3087,16 @@ psa_status_t psa_verify_message_internal( if( status != PSA_SUCCESS ) return status; + + return psa_driver_wrapper_verify_hash( + attributes, key_buffer, key_buffer_size, + alg, hash, hash_length, + signature, signature_length ); } return psa_driver_wrapper_verify_hash( attributes, key_buffer, key_buffer_size, - alg, hash, hash_length, + alg, input, input_length, signature, signature_length ); }