Update LMS local variable allocation
To use a default failure value, and to avoid a call to
psa_hash_operation_init()
Signed-off-by: Raef Coles <raef.coles@arm.com>
diff --git a/library/lmots.c b/library/lmots.c
index 055db8f..504da2e 100644
--- a/library/lmots.c
+++ b/library/lmots.c
@@ -152,13 +152,12 @@
const unsigned char *C_random_value,
unsigned char *out )
{
- psa_hash_operation_t op;
- psa_status_t status;
+ psa_hash_operation_t op = PSA_HASH_OPERATION_INIT;
+ psa_status_t status = PSA_ERROR_CORRUPTION_DETECTED;
size_t output_hash_len;
unsigned short checksum;
int ret = MBEDTLS_ERR_ERROR_CORRUPTION_DETECTED;
- op = psa_hash_operation_init( );
status = psa_hash_setup( &op, PSA_ALG_SHA_256 );
ret = mbedtls_lms_error_from_psa( status );
if( ret != 0 )
@@ -250,14 +249,12 @@
unsigned char j_hash_idx_bytes[J_HASH_IDX_LEN];
unsigned int j_hash_idx_min;
unsigned int j_hash_idx_max;
- psa_hash_operation_t op;
- psa_status_t status;
+ psa_hash_operation_t op = PSA_HASH_OPERATION_INIT;
+ psa_status_t status = PSA_ERROR_CORRUPTION_DETECTED;
size_t output_hash_len;
unsigned char tmp_hash[MBEDTLS_LMOTS_N_HASH_LEN_MAX];
int ret = MBEDTLS_ERR_ERROR_CORRUPTION_DETECTED;
- op = psa_hash_operation_init( );
-
for ( i_digit_idx = 0;
i_digit_idx < MBEDTLS_LMOTS_P_SIG_DIGIT_COUNT(params->type);
i_digit_idx++ )
@@ -361,12 +358,11 @@
const unsigned char *y_hashed_digits,
unsigned char *pub_key )
{
- psa_hash_operation_t op;
- psa_status_t status;
+ psa_hash_operation_t op = PSA_HASH_OPERATION_INIT;
+ psa_status_t status = PSA_ERROR_CORRUPTION_DETECTED;
size_t output_hash_len;
int ret = MBEDTLS_ERR_ERROR_CORRUPTION_DETECTED;
- op = psa_hash_operation_init( );
status = psa_hash_setup( &op, PSA_ALG_SHA_256 );
ret = mbedtls_lms_error_from_psa( status );
if( ret != 0 )
@@ -587,8 +583,8 @@
const unsigned char *seed,
size_t seed_size )
{
- psa_hash_operation_t op;
- psa_status_t status;
+ psa_hash_operation_t op = PSA_HASH_OPERATION_INIT;
+ psa_status_t status = PSA_ERROR_CORRUPTION_DETECTED;
size_t output_hash_len;
unsigned int i_digit_idx;
unsigned char i_digit_idx_bytes[2];
@@ -605,8 +601,6 @@
return( MBEDTLS_ERR_LMS_BAD_INPUT_DATA );
}
- op = psa_hash_operation_init( );
-
ctx->params.type = type;
memcpy( ctx->params.I_key_identifier,
diff --git a/library/lms.c b/library/lms.c
index 50e6434..93aaca1 100644
--- a/library/lms.c
+++ b/library/lms.c
@@ -107,7 +107,7 @@
unsigned char *out )
{
psa_hash_operation_t op;
- psa_status_t status;
+ psa_status_t status = PSA_ERROR_CORRUPTION_DETECTED;
size_t output_hash_len;
unsigned char r_node_idx_bytes[4];
int ret = MBEDTLS_ERR_ERROR_CORRUPTION_DETECTED;
@@ -182,7 +182,7 @@
unsigned char *out )
{
psa_hash_operation_t op;
- psa_status_t status;
+ psa_status_t status = PSA_ERROR_CORRUPTION_DETECTED;
size_t output_hash_len;
unsigned char r_node_idx_bytes[4];
int ret = MBEDTLS_ERR_ERROR_CORRUPTION_DETECTED;