From 79617d99aefff403e0e82c84cdd4ae1419d1d6c6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Manuel=20P=C3=A9gouri=C3=A9-Gonnard?= Date: Wed, 5 Oct 2022 12:55:50 +0200 Subject: [PATCH] Fix namespacing issue MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This macro is specific to the Mbed TLS implementation and not part of the public API, so it shouldn't used the PSA_ namespace. Signed-off-by: Manuel Pégourié-Gonnard --- include/psa/crypto_extra.h | 4 ++-- library/psa_crypto_pake.c | 20 ++++++++++---------- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/include/psa/crypto_extra.h b/include/psa/crypto_extra.h index ef9d13886..4f65398e2 100644 --- a/include/psa/crypto_extra.h +++ b/include/psa/crypto_extra.h @@ -1909,7 +1909,7 @@ static inline void psa_pake_cs_set_hash( psa_pake_cipher_suite_t *cipher_suite, /* Note: the format for mbedtls_ecjpake_read/write function has an extra * length byte for each step, plus an extra 3 bytes for ECParameters in the * server's 2nd round. */ -#define PSA_PAKE_BUFFER_SIZE ( ( 3 + 1 + 65 + 1 + 65 + 1 + 32 ) * 2 ) +#define MBEDTLS_PSA_PAKE_BUFFER_SIZE ( ( 3 + 1 + 65 + 1 + 65 + 1 + 32 ) * 2 ) #endif struct psa_pake_operation_s @@ -1922,7 +1922,7 @@ struct psa_pake_operation_s unsigned int MBEDTLS_PRIVATE(output_step); mbedtls_svc_key_id_t MBEDTLS_PRIVATE(password); psa_pake_role_t MBEDTLS_PRIVATE(role); - uint8_t MBEDTLS_PRIVATE(buffer[PSA_PAKE_BUFFER_SIZE]); + uint8_t MBEDTLS_PRIVATE(buffer[MBEDTLS_PSA_PAKE_BUFFER_SIZE]); size_t MBEDTLS_PRIVATE(buffer_length); size_t MBEDTLS_PRIVATE(buffer_offset); #endif diff --git a/library/psa_crypto_pake.c b/library/psa_crypto_pake.c index df091bc2c..a8b02e396 100644 --- a/library/psa_crypto_pake.c +++ b/library/psa_crypto_pake.c @@ -230,7 +230,7 @@ psa_status_t psa_pake_setup( psa_pake_operation_t *operation, operation->input_step = PSA_PAKE_STEP_X1_X2; operation->output_step = PSA_PAKE_STEP_X1_X2; - mbedtls_platform_zeroize( operation->buffer, PSA_PAKE_BUFFER_SIZE ); + mbedtls_platform_zeroize( operation->buffer, MBEDTLS_PSA_PAKE_BUFFER_SIZE ); operation->buffer_length = 0; operation->buffer_offset = 0; @@ -491,7 +491,7 @@ psa_status_t psa_pake_output( psa_pake_operation_t *operation, { ret = mbedtls_ecjpake_write_round_one( &operation->ctx.ecjpake, operation->buffer, - PSA_PAKE_BUFFER_SIZE, + MBEDTLS_PSA_PAKE_BUFFER_SIZE, &operation->buffer_length, mbedtls_psa_get_random, MBEDTLS_PSA_RANDOM_STATE ); @@ -508,7 +508,7 @@ psa_status_t psa_pake_output( psa_pake_operation_t *operation, { ret = mbedtls_ecjpake_write_round_two( &operation->ctx.ecjpake, operation->buffer, - PSA_PAKE_BUFFER_SIZE, + MBEDTLS_PSA_PAKE_BUFFER_SIZE, &operation->buffer_length, mbedtls_psa_get_random, MBEDTLS_PSA_RANDOM_STATE ); @@ -566,7 +566,7 @@ psa_status_t psa_pake_output( psa_pake_operation_t *operation, ( operation->state == PSA_PAKE_OUTPUT_X2S && operation->sequence == PSA_PAKE_X1_STEP_ZK_PROOF ) ) { - mbedtls_platform_zeroize( operation->buffer, PSA_PAKE_BUFFER_SIZE ); + mbedtls_platform_zeroize( operation->buffer, MBEDTLS_PSA_PAKE_BUFFER_SIZE ); operation->buffer_length = 0; operation->buffer_offset = 0; @@ -660,7 +660,7 @@ psa_status_t psa_pake_input( psa_pake_operation_t *operation, operation->sequence = PSA_PAKE_X1_STEP_KEY_SHARE; } - buffer_remain = PSA_PAKE_BUFFER_SIZE - operation->buffer_length; + buffer_remain = MBEDTLS_PSA_PAKE_BUFFER_SIZE - operation->buffer_length; if( input_length == 0 || input_length > buffer_remain ) @@ -735,7 +735,7 @@ psa_status_t psa_pake_input( psa_pake_operation_t *operation, operation->buffer, operation->buffer_length ); - mbedtls_platform_zeroize( operation->buffer, PSA_PAKE_BUFFER_SIZE ); + mbedtls_platform_zeroize( operation->buffer, MBEDTLS_PSA_PAKE_BUFFER_SIZE ); operation->buffer_length = 0; if( ret != 0 ) @@ -751,7 +751,7 @@ psa_status_t psa_pake_input( psa_pake_operation_t *operation, operation->buffer, operation->buffer_length ); - mbedtls_platform_zeroize( operation->buffer, PSA_PAKE_BUFFER_SIZE ); + mbedtls_platform_zeroize( operation->buffer, MBEDTLS_PSA_PAKE_BUFFER_SIZE ); operation->buffer_length = 0; if( ret != 0 ) @@ -797,7 +797,7 @@ psa_status_t psa_pake_get_implicit_key(psa_pake_operation_t *operation, { ret = mbedtls_ecjpake_write_shared_key( &operation->ctx.ecjpake, operation->buffer, - PSA_PAKE_BUFFER_SIZE, + MBEDTLS_PSA_PAKE_BUFFER_SIZE, &operation->buffer_length, mbedtls_psa_get_random, MBEDTLS_PSA_RANDOM_STATE ); @@ -812,7 +812,7 @@ psa_status_t psa_pake_get_implicit_key(psa_pake_operation_t *operation, operation->buffer, operation->buffer_length ); - mbedtls_platform_zeroize( operation->buffer, PSA_PAKE_BUFFER_SIZE ); + mbedtls_platform_zeroize( operation->buffer, MBEDTLS_PSA_PAKE_BUFFER_SIZE ); psa_pake_abort( operation ); @@ -837,7 +837,7 @@ psa_status_t psa_pake_abort(psa_pake_operation_t * operation) operation->output_step = PSA_PAKE_STEP_INVALID; operation->password = MBEDTLS_SVC_KEY_ID_INIT; operation->role = PSA_PAKE_ROLE_NONE; - mbedtls_platform_zeroize( operation->buffer, PSA_PAKE_BUFFER_SIZE ); + mbedtls_platform_zeroize( operation->buffer, MBEDTLS_PSA_PAKE_BUFFER_SIZE ); operation->buffer_length = 0; operation->buffer_offset = 0; mbedtls_ecjpake_free( &operation->ctx.ecjpake );