Replace allocated hash buffer with array

Signed-off-by: Paul Elliott <paul.elliott@arm.com>
diff --git a/include/psa/crypto_builtin_composites.h b/include/psa/crypto_builtin_composites.h
index ba3d253..2ba9133 100644
--- a/include/psa/crypto_builtin_composites.h
+++ b/include/psa/crypto_builtin_composites.h
@@ -120,7 +120,7 @@
     size_t MBEDTLS_PRIVATE(coordinate_bytes);
     psa_algorithm_t MBEDTLS_PRIVATE(alg);
     mbedtls_md_type_t MBEDTLS_PRIVATE(md_alg);
-    uint8_t *MBEDTLS_PRIVATE(hash);
+    uint8_t MBEDTLS_PRIVATE(hash)[PSA_BITS_TO_BYTES(PSA_VENDOR_ECC_MAX_CURVE_BITS)];
     size_t MBEDTLS_PRIVATE(hash_length);
 
 #else
@@ -150,7 +150,7 @@
     mbedtls_ecdsa_context *MBEDTLS_PRIVATE(ctx);
     mbedtls_ecdsa_restart_ctx MBEDTLS_PRIVATE(restart_ctx);
 
-    uint8_t *MBEDTLS_PRIVATE(hash);
+    uint8_t MBEDTLS_PRIVATE(hash)[PSA_BITS_TO_BYTES(PSA_VENDOR_ECC_MAX_CURVE_BITS)];
     size_t MBEDTLS_PRIVATE(hash_length);
 
     mbedtls_mpi MBEDTLS_PRIVATE(r);
diff --git a/library/psa_crypto.c b/library/psa_crypto.c
index 97edc15..ab52918 100644
--- a/library/psa_crypto.c
+++ b/library/psa_crypto.c
@@ -3561,12 +3561,6 @@
     operation->md_alg = mbedtls_hash_info_md_from_psa(hash_alg);
     operation->alg = alg;
 
-    operation->hash = mbedtls_calloc(1, hash_length);
-
-    if (operation->hash == NULL) {
-        return PSA_ERROR_INSUFFICIENT_MEMORY;
-    }
-
     memcpy(operation->hash, hash, hash_length);
     operation->hash_length = hash_length;
 
@@ -3698,9 +3692,6 @@
         operation->ctx = NULL;
     }
 
-    mbedtls_free(operation->hash);
-    operation->hash = NULL;
-
     mbedtls_ecdsa_restart_free(&operation->restart_ctx);
 
     return PSA_SUCCESS;
@@ -3789,12 +3780,6 @@
 
     mbedtls_ecdsa_restart_init(&operation->restart_ctx);
 
-    operation->hash = mbedtls_calloc(1, hash_length);
-
-    if (operation->hash == NULL) {
-        return PSA_ERROR_INSUFFICIENT_MEMORY;
-    }
-
     memcpy(operation->hash, hash, hash_length);
     operation->hash_length = hash_length;
 
@@ -3858,9 +3843,6 @@
         operation->ctx = NULL;
     }
 
-    mbedtls_free(operation->hash);
-    operation->hash = NULL;
-
     mbedtls_ecdsa_restart_free(&operation->restart_ctx);
 
     mbedtls_mpi_free(&operation->r);