diff --git a/include/psa/crypto_builtin_composites.h b/include/psa/crypto_builtin_composites.h index ba3d253022..2ba9133983 100644 --- a/include/psa/crypto_builtin_composites.h +++ b/include/psa/crypto_builtin_composites.h @@ -120,7 +120,7 @@ typedef struct { 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 @@ typedef struct { 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 97edc15a44..ab52918cd9 100644 --- a/library/psa_crypto.c +++ b/library/psa_crypto.c @@ -3561,12 +3561,6 @@ psa_status_t mbedtls_psa_sign_hash_start( 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 @@ psa_status_t mbedtls_psa_sign_hash_abort( operation->ctx = NULL; } - mbedtls_free(operation->hash); - operation->hash = NULL; - mbedtls_ecdsa_restart_free(&operation->restart_ctx); return PSA_SUCCESS; @@ -3789,12 +3780,6 @@ psa_status_t mbedtls_psa_verify_hash_start( 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 @@ psa_status_t mbedtls_psa_verify_hash_abort( operation->ctx = NULL; } - mbedtls_free(operation->hash); - operation->hash = NULL; - mbedtls_ecdsa_restart_free(&operation->restart_ctx); mbedtls_mpi_free(&operation->r);