From c3fe74f302625d23e8ee8d10b32c864ff1ef2df8 Mon Sep 17 00:00:00 2001 From: Gilles Peskine Date: Mon, 1 Dec 2025 14:14:05 +0100 Subject: [PATCH] Use short initializers in PAKE tests When initializing a PAKE operation structure, use an auxiliary function that doesn't initialize union members to all-bits-zero. Context: on most compilers, initializing a union to `{0}` initializes it to all bits zero; but on some compilers, the trailing part of members other than the first is left uninitialized. This way, we can run the tests on any platform and validate that the code would work correctly on platforms where union initialization is short, such as GCC 15. This commit extends 93dd99571b46f012a462c7a2494ccfe9ec0603a1 to `test_suite_psa_crypto_pake.function`. Signed-off-by: Gilles Peskine --- .../suites/test_suite_psa_crypto_pake.function | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/tests/suites/test_suite_psa_crypto_pake.function b/tests/suites/test_suite_psa_crypto_pake.function index 08c88a1d6e..2225959cfc 100644 --- a/tests/suites/test_suite_psa_crypto_pake.function +++ b/tests/suites/test_suite_psa_crypto_pake.function @@ -593,7 +593,7 @@ void ecjpake_setup(int alg_arg, int key_type_pw_arg, int key_usage_pw_arg, int expected_error_arg) { psa_pake_cipher_suite_t cipher_suite = psa_pake_cipher_suite_init(); - psa_pake_operation_t operation = psa_pake_operation_init(); + psa_pake_operation_t operation = psa_pake_operation_init_short(); psa_algorithm_t alg = alg_arg; psa_pake_primitive_t primitive = primitive_arg; psa_key_type_t key_type_pw = key_type_pw_arg; @@ -779,8 +779,8 @@ void ecjpake_rounds_inject(int alg_arg, int primitive_arg, int hash_arg, int inject_in_second_round) { psa_pake_cipher_suite_t cipher_suite = psa_pake_cipher_suite_init(); - psa_pake_operation_t server = psa_pake_operation_init(); - psa_pake_operation_t client = psa_pake_operation_init(); + psa_pake_operation_t server = psa_pake_operation_init_short(); + psa_pake_operation_t client = psa_pake_operation_init_short(); psa_algorithm_t alg = alg_arg; psa_algorithm_t hash_alg = hash_arg; mbedtls_svc_key_id_t key = MBEDTLS_SVC_KEY_ID_INIT; @@ -839,8 +839,8 @@ void ecjpake_rounds(int alg_arg, int primitive_arg, int hash_arg, int err_stage_arg) { psa_pake_cipher_suite_t cipher_suite = psa_pake_cipher_suite_init(); - psa_pake_operation_t server = psa_pake_operation_init(); - psa_pake_operation_t client = psa_pake_operation_init(); + psa_pake_operation_t server = psa_pake_operation_init_short(); + psa_pake_operation_t client = psa_pake_operation_init_short(); psa_algorithm_t alg = alg_arg; psa_algorithm_t hash_alg = hash_arg; psa_algorithm_t derive_alg = derive_alg_arg; @@ -980,7 +980,7 @@ void ecjpake_size_macros() void pake_input_getters_password() { psa_pake_cipher_suite_t cipher_suite = psa_pake_cipher_suite_init(); - psa_pake_operation_t operation = psa_pake_operation_init(); + psa_pake_operation_t operation = psa_pake_operation_init_short(); mbedtls_svc_key_id_t key = MBEDTLS_SVC_KEY_ID_INIT; psa_key_attributes_t attributes = PSA_KEY_ATTRIBUTES_INIT; const char *password = "password"; @@ -1045,7 +1045,7 @@ exit: void pake_input_getters_cipher_suite() { psa_pake_cipher_suite_t cipher_suite = psa_pake_cipher_suite_init(); - psa_pake_operation_t operation = psa_pake_operation_init(); + psa_pake_operation_t operation = psa_pake_operation_init_short(); psa_pake_cipher_suite_t cipher_suite_ret = psa_pake_cipher_suite_init(); psa_pake_primitive_t primitive = PSA_PAKE_PRIMITIVE( @@ -1079,7 +1079,7 @@ exit: void pake_input_getters_user() { psa_pake_cipher_suite_t cipher_suite = psa_pake_cipher_suite_init(); - psa_pake_operation_t operation = psa_pake_operation_init(); + psa_pake_operation_t operation = psa_pake_operation_init_short(); const char *users[] = { "client", "server", "other" }; uint8_t user_ret[20] = { 0 }; // max user length is 20 bytes size_t user_len_ret = 0; @@ -1142,7 +1142,7 @@ exit: void pake_input_getters_peer() { psa_pake_cipher_suite_t cipher_suite = psa_pake_cipher_suite_init(); - psa_pake_operation_t operation = psa_pake_operation_init(); + psa_pake_operation_t operation = psa_pake_operation_init_short(); const char *peers[] = { "client", "server", "other" }; uint8_t peer_ret[20] = { 0 }; // max peer length is 20 bytes size_t peer_len_ret = 0;