From 5c85ef0a564f6f9b52adc8e2f1ef0a49a31d1a08 Mon Sep 17 00:00:00 2001 From: Steven Cooreman Date: Thu, 29 Apr 2021 15:32:42 +0200 Subject: [PATCH] Remove unused items from MAC operation context structure Apparently it was at some point assumed that there would be support for MAC algorithms with IV, but that hasn't been implemented yet. Until that time, these context structure members are superfluous and can be removed. Signed-off-by: Steven Cooreman --- include/psa/crypto_builtin_composites.h | 5 +---- library/psa_crypto_mac.c | 9 --------- 2 files changed, 1 insertion(+), 13 deletions(-) diff --git a/include/psa/crypto_builtin_composites.h b/include/psa/crypto_builtin_composites.h index e1acf3955..3b0f82ad2 100644 --- a/include/psa/crypto_builtin_composites.h +++ b/include/psa/crypto_builtin_composites.h @@ -63,12 +63,9 @@ typedef struct { psa_algorithm_t alg; unsigned int key_set : 1; - unsigned int iv_required : 1; - unsigned int iv_set : 1; unsigned int has_input : 1; unsigned int is_sign : 1; uint8_t mac_size; - unsigned int id; union { unsigned dummy; /* Make the union non-empty even with no supported algorithms. */ @@ -81,7 +78,7 @@ typedef struct } ctx; } mbedtls_psa_mac_operation_t; -#define MBEDTLS_PSA_MAC_OPERATION_INIT {0, 0, 0, 0, 0, 0, 0, 0, {0}} +#define MBEDTLS_PSA_MAC_OPERATION_INIT {0, 0, 0, 0, 0, {0}} /* * BEYOND THIS POINT, TEST DRIVER DECLARATIONS ONLY. diff --git a/library/psa_crypto_mac.c b/library/psa_crypto_mac.c index 5ea2f1760..0189cded8 100644 --- a/library/psa_crypto_mac.c +++ b/library/psa_crypto_mac.c @@ -247,15 +247,12 @@ static psa_status_t mac_init( operation->alg = PSA_ALG_FULL_LENGTH_MAC( alg ); operation->key_set = 0; - operation->iv_set = 0; - operation->iv_required = 0; operation->has_input = 0; operation->is_sign = 0; #if defined(BUILTIN_ALG_CMAC) if( operation->alg == PSA_ALG_CMAC ) { - operation->iv_required = 0; mbedtls_cipher_init( &operation->ctx.cmac ); status = PSA_SUCCESS; } @@ -312,8 +309,6 @@ static psa_status_t mac_abort( mbedtls_psa_mac_operation_t *operation ) operation->alg = 0; operation->key_set = 0; - operation->iv_set = 0; - operation->iv_required = 0; operation->has_input = 0; operation->is_sign = 0; @@ -452,8 +447,6 @@ static psa_status_t mac_update( { if( ! operation->key_set ) return( PSA_ERROR_BAD_STATE ); - if( operation->iv_required && ! operation->iv_set ) - return( PSA_ERROR_BAD_STATE ); operation->has_input = 1; #if defined(BUILTIN_ALG_CMAC) @@ -486,8 +479,6 @@ static psa_status_t mac_finish_internal( mbedtls_psa_mac_operation_t *operation, { if( ! operation->key_set ) return( PSA_ERROR_BAD_STATE ); - if( operation->iv_required && ! operation->iv_set ) - return( PSA_ERROR_BAD_STATE ); if( mac_size < operation->mac_size ) return( PSA_ERROR_BUFFER_TOO_SMALL );