From 9dd2440c95707ae66e707f8144a80a384e89c5c2 Mon Sep 17 00:00:00 2001 From: Przemek Stekiel Date: Thu, 26 Jan 2023 15:06:09 +0100 Subject: [PATCH] Change pake input: key_lifetime -> key attributes In the future key attributes will be available for opaque driver via psa_crypto_driver_pake_get_password_key(). Signed-off-by: Przemek Stekiel Signed-off-by: Przemek Stekiel --- include/psa/crypto_extra.h | 2 +- library/psa_crypto.c | 2 +- .../psa_crypto_driver_wrappers.c.jinja | 2 +- tests/scripts/all.sh | 12 ++++++++++-- 4 files changed, 13 insertions(+), 5 deletions(-) diff --git a/include/psa/crypto_extra.h b/include/psa/crypto_extra.h index 32e956925..2d6b6abd1 100644 --- a/include/psa/crypto_extra.h +++ b/include/psa/crypto_extra.h @@ -1970,7 +1970,7 @@ struct psa_crypto_driver_pake_inputs_s { uint8_t *MBEDTLS_PRIVATE(password); size_t MBEDTLS_PRIVATE(password_len); psa_pake_role_t MBEDTLS_PRIVATE(role); - psa_key_lifetime_t MBEDTLS_PRIVATE(key_lifetime); + psa_key_attributes_t MBEDTLS_PRIVATE(attributes); psa_pake_cipher_suite_t MBEDTLS_PRIVATE(cipher_suite); }; diff --git a/library/psa_crypto.c b/library/psa_crypto.c index 5e567ad12..b4fad33d3 100644 --- a/library/psa_crypto.c +++ b/library/psa_crypto.c @@ -7306,7 +7306,7 @@ psa_status_t psa_pake_set_password_key( memcpy(operation->data.inputs.password, slot->key.data, slot->key.bytes); operation->data.inputs.password_len = slot->key.bytes; - operation->data.inputs.key_lifetime = attributes.core.lifetime; + operation->data.inputs.attributes = attributes; error: unlock_status = psa_unlock_key_slot(slot); return (status == PSA_SUCCESS) ? unlock_status : status; diff --git a/scripts/data_files/driver_templates/psa_crypto_driver_wrappers.c.jinja b/scripts/data_files/driver_templates/psa_crypto_driver_wrappers.c.jinja index d7dabed63..d52ed5993 100644 --- a/scripts/data_files/driver_templates/psa_crypto_driver_wrappers.c.jinja +++ b/scripts/data_files/driver_templates/psa_crypto_driver_wrappers.c.jinja @@ -2816,7 +2816,7 @@ psa_status_t psa_driver_wrapper_pake_setup( psa_status_t status = PSA_ERROR_CORRUPTION_DETECTED; psa_key_location_t location = - PSA_KEY_LIFETIME_GET_LOCATION( inputs->key_lifetime ); + PSA_KEY_LIFETIME_GET_LOCATION( inputs->attributes.core.lifetime ); switch( location ) { diff --git a/tests/scripts/all.sh b/tests/scripts/all.sh index 98060d720..7964319e6 100755 --- a/tests/scripts/all.sh +++ b/tests/scripts/all.sh @@ -2506,15 +2506,19 @@ component_test_psa_crypto_config_accel_pake () { loc_accel_list="ALG_JPAKE" loc_accel_flags=$( echo "$loc_accel_list" | sed 's/[^ ]* */-DLIBTESTDRIVER1_MBEDTLS_PSA_ACCEL_&/g' ) - make -C tests libtestdriver1.a CFLAGS="$ASAN_CFLAGS $loc_accel_flags" LDFLAGS="$ASAN_CFLAGS" + make -C tests libtestdriver1.a CFLAGS="$ASAN_CFLAGS $loc_accel_flags" LDFLAGS="$ASAN_CFLAGS" DEBUG=1 scripts/config.py set MBEDTLS_PSA_CRYPTO_DRIVERS scripts/config.py set MBEDTLS_PSA_CRYPTO_CONFIG scripts/config.py unset MBEDTLS_ECJPAKE_C + # Dynamic secure element support is a deprecated feature and needs to be disabled here. + # This is done to have the same form of psa_key_attributes_s for libdriver and library. + scripts/config.py unset MBEDTLS_PSA_CRYPTO_SE_C + loc_accel_flags="$loc_accel_flags $( echo "$loc_accel_list" | sed 's/[^ ]* */-DMBEDTLS_PSA_ACCEL_&/g' )" - make CFLAGS="$ASAN_CFLAGS -Werror -I../tests/include -I../tests -I../../tests -DPSA_CRYPTO_DRIVER_TEST -DMBEDTLS_TEST_LIBTESTDRIVER1 $loc_accel_flags" LDFLAGS="-ltestdriver1 $ASAN_CFLAGS" + make CFLAGS="$ASAN_CFLAGS -Werror -I../tests/include -I../tests -I../../tests -DPSA_CRYPTO_DRIVER_TEST -DMBEDTLS_TEST_LIBTESTDRIVER1 $loc_accel_flags" LDFLAGS="-ltestdriver1 $ASAN_CFLAGS" DEBUG=1 msg "test: ssl-opt.sh, MBEDTLS_PSA_CRYPTO_CONFIG with accelerated PAKE" tests/ssl-opt.sh -f "ECJPAKE" @@ -2547,6 +2551,10 @@ component_test_psa_crypto_config_accel_pake_no_fallback () { scripts/config.py -f include/psa/crypto_config.h unset PSA_WANT_ALG_JPAKE scripts/config.py unset MBEDTLS_KEY_EXCHANGE_ECJPAKE_ENABLED + # Dynamic secure element support is a deprecated feature and needs to be disabled here. + # This is done to have the same form of psa_key_attributes_s for libdriver and library. + scripts/config.py unset MBEDTLS_PSA_CRYPTO_SE_C + loc_accel_flags="$loc_accel_flags $( echo "$loc_accel_list" | sed 's/[^ ]* */-DMBEDTLS_PSA_ACCEL_&/g' )" make CFLAGS="$ASAN_CFLAGS -Werror -I../tests/include -I../tests -I../../tests -DPSA_CRYPTO_DRIVER_TEST -DMBEDTLS_TEST_LIBTESTDRIVER1 $loc_accel_flags" LDFLAGS="-ltestdriver1 $ASAN_CFLAGS"