Update LMS PSA error conversion
Signed-off-by: Raef Coles <raef.coles@arm.com>
diff --git a/library/lms.c b/library/lms.c
index 93aaca1..ec6ec0c 100644
--- a/library/lms.c
+++ b/library/lms.c
@@ -110,47 +110,40 @@
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;
op = psa_hash_operation_init( );
status = psa_hash_setup( &op, PSA_ALG_SHA_256 );
- ret = mbedtls_lms_error_from_psa( status );
- if( ret != 0 )
+ if( status != PSA_SUCCESS )
goto exit;
status = psa_hash_update( &op, params->I_key_identifier,
MBEDTLS_LMOTS_I_KEY_ID_LEN );
- ret = mbedtls_lms_error_from_psa( status );
- if( ret != 0 )
+ if( status != PSA_SUCCESS )
goto exit;
mbedtls_lms_unsigned_int_to_network_bytes( r_node_idx, 4, r_node_idx_bytes );
status = psa_hash_update( &op, r_node_idx_bytes, 4 );
- ret = mbedtls_lms_error_from_psa( status );
- if( ret != 0 )
+ if( status != PSA_SUCCESS )
goto exit;
status = psa_hash_update( &op, D_LEAF_CONSTANT_BYTES, D_CONST_LEN );
- ret = mbedtls_lms_error_from_psa( status );
- if( ret != 0 )
+ if( status != PSA_SUCCESS )
goto exit;
status = psa_hash_update( &op, pub_key,
MBEDTLS_LMOTS_N_HASH_LEN(params->otstype) );
- ret = mbedtls_lms_error_from_psa( status );
- if( ret != 0 )
+ if( status != PSA_SUCCESS )
goto exit;
status = psa_hash_finish( &op, out, MBEDTLS_LMS_M_NODE_BYTES(params->type),
&output_hash_len );
- ret = mbedtls_lms_error_from_psa( status );
- if( ret != 0 )
+ if( status != PSA_SUCCESS )
goto exit;
exit:
psa_hash_abort( &op );
- return( ret );
+ return ( mbedtls_lms_error_from_psa( status ) );
}
/* Calculate the value of an internal node of the merkle tree (which is a hash
@@ -185,53 +178,45 @@
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;
op = psa_hash_operation_init( );
status = psa_hash_setup( &op, PSA_ALG_SHA_256 );
- ret = mbedtls_lms_error_from_psa( status );
- if( ret != 0 )
+ if( status != PSA_SUCCESS )
goto exit;
status = psa_hash_update( &op, params->I_key_identifier,
MBEDTLS_LMOTS_I_KEY_ID_LEN );
- ret = mbedtls_lms_error_from_psa( status );
- if( ret != 0 )
+ if( status != PSA_SUCCESS )
goto exit;
mbedtls_lms_unsigned_int_to_network_bytes( r_node_idx, 4, r_node_idx_bytes );
status = psa_hash_update( &op, r_node_idx_bytes, 4 );
- ret = mbedtls_lms_error_from_psa( status );
- if( ret != 0 )
+ if( status != PSA_SUCCESS )
goto exit;
status = psa_hash_update( &op, D_INTR_CONSTANT_BYTES, D_CONST_LEN );
- ret = mbedtls_lms_error_from_psa( status );
- if( ret != 0 )
+ if( status != PSA_SUCCESS )
goto exit;
status = psa_hash_update( &op, left_node,
MBEDTLS_LMS_M_NODE_BYTES(params->type) );
- ret = mbedtls_lms_error_from_psa( status );
- if( ret != 0 )
+ if( status != PSA_SUCCESS )
goto exit;
status = psa_hash_update( &op, right_node,
MBEDTLS_LMS_M_NODE_BYTES(params->type) );
- ret = mbedtls_lms_error_from_psa( status );
- if( ret != 0 )
+ if( status != PSA_SUCCESS )
goto exit;
- ret = psa_hash_finish( &op, out, MBEDTLS_LMS_M_NODE_BYTES(params->type),
+ status = psa_hash_finish( &op, out, MBEDTLS_LMS_M_NODE_BYTES(params->type),
&output_hash_len );
- ret = mbedtls_lms_error_from_psa( status );
- if( ret != 0 )
+ if( status != PSA_SUCCESS )
goto exit;
exit:
psa_hash_abort( &op );
- return ret;
+ return( mbedtls_lms_error_from_psa( status ) );
}
void mbedtls_lms_init_public( mbedtls_lms_public_t *ctx )