Dispatch sign/verify funtions through the driver interface

Signed-off-by: gabor-mezei-arm <gabor.mezei@arm.com>
diff --git a/library/psa_crypto.c b/library/psa_crypto.c
index 4cb6ff3..00558e1 100644
--- a/library/psa_crypto.c
+++ b/library/psa_crypto.c
@@ -2917,20 +2917,9 @@
 
     if( operation == PSA_SIGN_MESSAGE )
     {
-        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,
-                                                  hash, sizeof( hash ),
-                                                  &hash_length );
-
-        if( status != PSA_SUCCESS )
-            goto exit;
-
-        status = psa_driver_wrapper_sign_hash(
+        status = psa_driver_wrapper_sign_message(
             &attributes, slot->key.data, slot->key.bytes,
-            alg, hash, hash_length,
+            alg, input, input_length,
             signature, signature_size, signature_length );
     }
     else if( operation == PSA_SIGN_HASH )
@@ -3006,20 +2995,9 @@
 
     if( operation == PSA_VERIFY_MESSAGE )
     {
-        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,
-                                                  hash, sizeof( hash ),
-                                                  &hash_length );
-
-        if( status != PSA_SUCCESS )
-            goto exit;
-
-        status = psa_driver_wrapper_verify_hash(
+        status = psa_driver_wrapper_verify_message(
             &attributes, slot->key.data, slot->key.bytes,
-            alg, hash, hash_length,
+            alg, input, input_length,
             signature, signature_length );
     }
     else if( operation == PSA_VERIFY_HASH )
@@ -3030,13 +3008,41 @@
             signature, signature_length );
     }
 
-exit:
     unlock_status = psa_unlock_key_slot( slot );
 
     return( ( status == PSA_SUCCESS ) ? unlock_status : status );
 
 }
 
+psa_status_t psa_sign_message_internal(
+    const psa_key_attributes_t *attributes,
+    const uint8_t *key_buffer,
+    size_t key_buffer_size,
+    psa_algorithm_t alg,
+    const uint8_t *input,
+    size_t input_length,
+    uint8_t *signature,
+    size_t signature_size,
+    size_t *signature_length )
+{
+    psa_status_t status = PSA_ERROR_CORRUPTION_DETECTED;
+    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,
+                                              hash, sizeof( hash ),
+                                              &hash_length );
+
+    if( status != PSA_SUCCESS )
+        return status;
+
+    return psa_sign_hash_internal(
+                attributes, key_buffer, key_buffer_size,
+                alg, hash, hash_length,
+                signature, signature_size, signature_length );
+}
+
 psa_status_t psa_sign_message( mbedtls_svc_key_id_t key,
                                psa_algorithm_t alg,
                                const uint8_t * input,
@@ -3050,6 +3056,34 @@
         signature, signature_size, signature_length );
 }
 
+psa_status_t psa_verify_message_internal(
+    const psa_key_attributes_t *attributes,
+    const uint8_t *key_buffer,
+    size_t key_buffer_size,
+    psa_algorithm_t alg,
+    const uint8_t *input,
+    size_t input_length,
+    const uint8_t *signature,
+    size_t signature_length )
+{
+    psa_status_t status = PSA_ERROR_CORRUPTION_DETECTED;
+    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,
+                                              hash, sizeof( hash ),
+                                              &hash_length );
+
+    if( status != PSA_SUCCESS )
+        return status;
+
+    return psa_verify_hash_internal(
+                attributes, key_buffer, key_buffer_size,
+                alg, hash, hash_length,
+                signature, signature_length );
+}
+
 psa_status_t psa_verify_message( mbedtls_svc_key_id_t key,
                                  psa_algorithm_t alg,
                                  const uint8_t * input,