From 4201533196cd4703a980f33d98606bdbc66412fe Mon Sep 17 00:00:00 2001 From: David Horstmann Date: Wed, 13 Mar 2024 15:42:31 +0000 Subject: [PATCH 1/5] Invert and rename config option Replace MBEDTLS_PSA_COPY_CALLER_BUFFERS with inverse: !MBEDTLS_PSA_ASSUME_EXCLUSIVE_BUFFERS. This ensures that buffer protection is enabled by default without any change to the Mbed TLS config file. Signed-off-by: David Horstmann --- include/mbedtls/config.h | 18 +++++++++++------- library/psa_crypto.c | 34 +++++++++++++++++----------------- tests/scripts/all.sh | 8 ++++---- tests/src/helpers.c | 4 ++-- 4 files changed, 34 insertions(+), 30 deletions(-) diff --git a/include/mbedtls/config.h b/include/mbedtls/config.h index d48df66e5..4842fd494 100644 --- a/include/mbedtls/config.h +++ b/include/mbedtls/config.h @@ -1571,20 +1571,24 @@ //#define MBEDTLS_PSA_INJECT_ENTROPY /** - * \def MBEDTLS_PSA_COPY_CALLER_BUFFERS + * \def MBEDTLS_PSA_ASSUME_EXCLUSIVE_BUFFERS * - * Make local copies of buffers supplied by the callers of PSA functions. + * Assume all buffers passed to PSA functions are owned exclusively by the + * PSA function and are not stored in shared memory. * - * This should be enabled whenever caller-supplied buffers are owned by - * an untrusted party, for example where arguments to PSA calls are passed + * This option may be enabled if all buffers passed to any PSA function reside + * in memory that is accessible only to the PSA function during its execution. + * + * This option MUST be disabled whenever buffer arguments are in memory shared + * with an untrusted party, for example where arguments to PSA calls are passed * across a trust boundary. * - * \note Enabling this option increases memory usage and code size. + * \note Enabling this option reduces memory usage and code size. * - * \note Disabling this option causes overlap of input and output buffers + * \note Enabling this option causes overlap of input and output buffers * not to be supported by PSA functions. */ -#define MBEDTLS_PSA_COPY_CALLER_BUFFERS +//#define MBEDTLS_PSA_ASSUME_EXCLUSIVE_BUFFERS /** * \def MBEDTLS_RSA_NO_CRT diff --git a/library/psa_crypto.c b/library/psa_crypto.c index 8e981f61f..e85e5792e 100644 --- a/library/psa_crypto.c +++ b/library/psa_crypto.c @@ -106,7 +106,7 @@ mbedtls_psa_drbg_context_t *const mbedtls_psa_random_state = if (global_data.initialized == 0) \ return PSA_ERROR_BAD_STATE; -#if defined(MBEDTLS_PSA_COPY_CALLER_BUFFERS) +#if !defined(MBEDTLS_PSA_ASSUME_EXCLUSIVE_BUFFERS) /* Declare a local copy of an input buffer and a variable that will be used * to store a pointer to the start of the buffer. @@ -202,7 +202,7 @@ mbedtls_psa_drbg_context_t *const mbedtls_psa_random_state = status = local_output_status; \ } \ } while (0) -#else /* MBEDTLS_PSA_COPY_CALLER_BUFFERS */ +#else /* !MBEDTLS_PSA_ASSUME_EXCLUSIVE_BUFFERS */ #define LOCAL_INPUT_DECLARE(input, input_copy_name) \ const uint8_t *input_copy_name = NULL; #define LOCAL_INPUT_ALLOC(input, length, input_copy) \ @@ -215,7 +215,7 @@ mbedtls_psa_drbg_context_t *const mbedtls_psa_random_state = output_copy = output; #define LOCAL_OUTPUT_FREE(output, output_copy) \ output_copy = NULL; -#endif /* MBEDTLS_PSA_COPY_CALLER_BUFFERS */ +#endif /* !MBEDTLS_PSA_ASSUME_EXCLUSIVE_BUFFERS */ psa_status_t mbedtls_to_psa_error(int ret) { @@ -1506,7 +1506,7 @@ psa_status_t psa_export_key(mbedtls_svc_key_id_t key, slot->key.data, slot->key.bytes, data, data_size, data_length); -#if defined(MBEDTLS_PSA_COPY_CALLER_BUFFERS) +#if !defined(MBEDTLS_PSA_ASSUME_EXCLUSIVE_BUFFERS) exit: #endif unlock_status = psa_unlock_key_slot(slot); @@ -2362,7 +2362,7 @@ psa_status_t psa_hash_finish(psa_hash_operation_t *operation, LOCAL_OUTPUT_ALLOC(hash_external, hash_size, hash); status = psa_hash_finish_internal(operation, hash, hash_size, hash_length); -#if defined(MBEDTLS_PSA_COPY_CALLER_BUFFERS) +#if !defined(MBEDTLS_PSA_ASSUME_EXCLUSIVE_BUFFERS) exit: #endif LOCAL_OUTPUT_FREE(hash_external, hash); @@ -2425,7 +2425,7 @@ psa_status_t psa_hash_compute(psa_algorithm_t alg, status = psa_driver_wrapper_hash_compute(alg, input, input_length, hash, hash_size, hash_length); -#if defined(MBEDTLS_PSA_COPY_CALLER_BUFFERS) +#if !defined(MBEDTLS_PSA_ASSUME_EXCLUSIVE_BUFFERS) exit: #endif LOCAL_INPUT_FREE(input_external, input); @@ -2667,7 +2667,7 @@ psa_status_t psa_mac_update(psa_mac_operation_t *operation, psa_mac_abort(operation); } -#if defined(MBEDTLS_PSA_COPY_CALLER_BUFFERS) +#if !defined(MBEDTLS_PSA_ASSUME_EXCLUSIVE_BUFFERS) exit: #endif LOCAL_INPUT_FREE(input_external, input); @@ -2852,7 +2852,7 @@ psa_status_t psa_mac_compute(mbedtls_svc_key_id_t key, input, input_length, mac, mac_size, mac_length, 1); -#if defined(MBEDTLS_PSA_COPY_CALLER_BUFFERS) +#if !defined(MBEDTLS_PSA_ASSUME_EXCLUSIVE_BUFFERS) exit: #endif LOCAL_INPUT_FREE(input_external, input); @@ -3110,7 +3110,7 @@ psa_status_t psa_sign_message(mbedtls_svc_key_id_t key, status = psa_sign_internal(key, 1, alg, input, input_length, signature, signature_size, signature_length); -#if defined(MBEDTLS_PSA_COPY_CALLER_BUFFERS) +#if !defined(MBEDTLS_PSA_ASSUME_EXCLUSIVE_BUFFERS) exit: #endif LOCAL_INPUT_FREE(input_external, input); @@ -3168,7 +3168,7 @@ psa_status_t psa_verify_message(mbedtls_svc_key_id_t key, status = psa_verify_internal(key, 1, alg, input, input_length, signature, signature_length); -#if defined(MBEDTLS_PSA_COPY_CALLER_BUFFERS) +#if !defined(MBEDTLS_PSA_ASSUME_EXCLUSIVE_BUFFERS) exit: #endif LOCAL_INPUT_FREE(input_external, input); @@ -3242,7 +3242,7 @@ psa_status_t psa_sign_hash(mbedtls_svc_key_id_t key, status = psa_sign_internal(key, 0, alg, hash, hash_length, signature, signature_size, signature_length); -#if defined(MBEDTLS_PSA_COPY_CALLER_BUFFERS) +#if !defined(MBEDTLS_PSA_ASSUME_EXCLUSIVE_BUFFERS) exit: #endif LOCAL_INPUT_FREE(hash_external, hash); @@ -3314,7 +3314,7 @@ psa_status_t psa_verify_hash(mbedtls_svc_key_id_t key, status = psa_verify_internal(key, 0, alg, hash, hash_length, signature, signature_length); -#if defined(MBEDTLS_PSA_COPY_CALLER_BUFFERS) +#if !defined(MBEDTLS_PSA_ASSUME_EXCLUSIVE_BUFFERS) exit: #endif LOCAL_INPUT_FREE(hash_external, hash); @@ -4106,7 +4106,7 @@ psa_status_t psa_aead_encrypt(mbedtls_svc_key_id_t key, } /* Exit label is only used for buffer copying, prevent unused warnings. */ -#if defined(MBEDTLS_PSA_COPY_CALLER_BUFFERS) +#if !defined(MBEDTLS_PSA_ASSUME_EXCLUSIVE_BUFFERS) exit: #endif LOCAL_INPUT_FREE(nonce_external, nonce); @@ -4174,7 +4174,7 @@ psa_status_t psa_aead_decrypt(mbedtls_svc_key_id_t key, } /* Exit label is only used for buffer copying, prevent unused warnings. */ -#if defined(MBEDTLS_PSA_COPY_CALLER_BUFFERS) +#if !defined(MBEDTLS_PSA_ASSUME_EXCLUSIVE_BUFFERS) exit: #endif LOCAL_INPUT_FREE(nonce_external, nonce); @@ -5232,7 +5232,7 @@ psa_status_t psa_key_derivation_input_bytes( status = psa_key_derivation_input_internal(operation, step, PSA_KEY_TYPE_NONE, data, data_length); -#if defined(MBEDTLS_PSA_COPY_CALLER_BUFFERS) +#if !defined(MBEDTLS_PSA_ASSUME_EXCLUSIVE_BUFFERS) exit: #endif LOCAL_INPUT_FREE(data_external, data); @@ -5450,7 +5450,7 @@ psa_status_t psa_key_derivation_key_agreement(psa_key_derivation_operation_t *op slot, peer_key, peer_key_length); -#if defined(MBEDTLS_PSA_COPY_CALLER_BUFFERS) +#if !defined(MBEDTLS_PSA_ASSUME_EXCLUSIVE_BUFFERS) exit: #endif if (status != PSA_SUCCESS) { @@ -5622,7 +5622,7 @@ psa_status_t psa_generate_random(uint8_t *output_external, status = psa_generate_random_internal(output, output_size); -#if defined(MBEDTLS_PSA_COPY_CALLER_BUFFERS) +#if !defined(MBEDTLS_PSA_ASSUME_EXCLUSIVE_BUFFERS) exit: #endif LOCAL_OUTPUT_FREE(output_external, output); diff --git a/tests/scripts/all.sh b/tests/scripts/all.sh index 345cfd67e..6b4b4e4a3 100755 --- a/tests/scripts/all.sh +++ b/tests/scripts/all.sh @@ -947,14 +947,14 @@ component_test_psa_crypto_key_id_encodes_owner () { make test } -component_test_no_psa_copy_caller_buffers () { - msg "build: full config - MBEDTLS_PSA_COPY_CALLER_BUFFERS, cmake, gcc, ASan" +component_test_psa_assume_exclusive_buffers () { + msg "build: full config + MBEDTLS_PSA_ASSUME_EXCLUSIVE_BUFFERS, cmake, gcc, ASan" scripts/config.py full - scripts/config.py unset MBEDTLS_PSA_COPY_CALLER_BUFFERS + scripts/config.py set MBEDTLS_PSA_ASSUME_EXCLUSIVE_BUFFERS CC=gcc cmake -D CMAKE_BUILD_TYPE:String=Asan . make - msg "test: full config - MBEDTLS_PSA_COPY_CALLER_BUFFERS, cmake, gcc, ASan" + msg "test: full config + MBEDTLS_PSA_ASSUME_EXCLUSIVE_BUFFERS, cmake, gcc, ASan" make test } diff --git a/tests/src/helpers.c b/tests/src/helpers.c index fd7b548d1..a1e1d459c 100644 --- a/tests/src/helpers.c +++ b/tests/src/helpers.c @@ -51,7 +51,7 @@ int mbedtls_test_platform_setup(void) int ret = 0; #if defined(MBEDTLS_TEST_HOOKS) && defined(MBEDTLS_PSA_CRYPTO_C) \ - && defined(MBEDTLS_PSA_COPY_CALLER_BUFFERS) \ + && !defined(MBEDTLS_PSA_ASSUME_EXCLUSIVE_BUFFERS) \ && defined(MBEDTLS_TEST_MEMORY_CAN_POISON) mbedtls_poison_test_hooks_setup(); #endif @@ -77,7 +77,7 @@ int mbedtls_test_platform_setup(void) void mbedtls_test_platform_teardown(void) { #if defined(MBEDTLS_TEST_HOOKS) && defined(MBEDTLS_PSA_CRYPTO_C) \ - && defined(MBEDTLS_PSA_COPY_CALLER_BUFFERS) \ + && !defined(MBEDTLS_PSA_ASSUME_EXCLUSIVE_BUFFERS) \ && defined(MBEDTLS_TEST_MEMORY_CAN_POISON) mbedtls_poison_test_hooks_teardown(); #endif From 43c128db3ecb56d0e9b34b81107241e56704dee4 Mon Sep 17 00:00:00 2001 From: David Horstmann Date: Wed, 13 Mar 2024 15:57:46 +0000 Subject: [PATCH 2/5] Update wrapper generation script and regenerate Update the guards generated by the wrapper generation script to use !MBEDTLS_PSA_ASSUME_EXCLUSIVE_BUFFERS and regenerate the PSA test wrappers. Signed-off-by: David Horstmann --- tests/scripts/generate_psa_wrappers.py | 4 +- tests/src/psa_test_wrappers.c | 256 ++++++++++++------------- 2 files changed, 130 insertions(+), 130 deletions(-) diff --git a/tests/scripts/generate_psa_wrappers.py b/tests/scripts/generate_psa_wrappers.py index 1ab71d31e..755a5842a 100755 --- a/tests/scripts/generate_psa_wrappers.py +++ b/tests/scripts/generate_psa_wrappers.py @@ -140,10 +140,10 @@ class PSAWrapperGenerator(c_wrapper_generator.Base): """ if not buffer_parameters: return - out.write('#if defined(MBEDTLS_PSA_COPY_CALLER_BUFFERS)\n') + out.write('#if !defined(MBEDTLS_PSA_ASSUME_EXCLUSIVE_BUFFERS)\n') for param in buffer_parameters: self._write_poison_buffer_parameter(out, param, poison) - out.write('#endif /* defined(MBEDTLS_PSA_COPY_CALLER_BUFFERS) */\n') + out.write('#endif /* !defined(MBEDTLS_PSA_ASSUME_EXCLUSIVE_BUFFERS) */\n') @staticmethod def _parameter_should_be_copied(function_name: str, diff --git a/tests/src/psa_test_wrappers.c b/tests/src/psa_test_wrappers.c index 3aa802039..e70ffb34a 100644 --- a/tests/src/psa_test_wrappers.c +++ b/tests/src/psa_test_wrappers.c @@ -66,19 +66,19 @@ psa_status_t mbedtls_test_wrap_psa_aead_decrypt( size_t arg9_plaintext_size, size_t *arg10_plaintext_length) { -#if defined(MBEDTLS_PSA_COPY_CALLER_BUFFERS) +#if !defined(MBEDTLS_PSA_ASSUME_EXCLUSIVE_BUFFERS) MBEDTLS_TEST_MEMORY_POISON(arg2_nonce, arg3_nonce_length); MBEDTLS_TEST_MEMORY_POISON(arg4_additional_data, arg5_additional_data_length); MBEDTLS_TEST_MEMORY_POISON(arg6_ciphertext, arg7_ciphertext_length); MBEDTLS_TEST_MEMORY_POISON(arg8_plaintext, arg9_plaintext_size); -#endif /* defined(MBEDTLS_PSA_COPY_CALLER_BUFFERS) */ +#endif /* !defined(MBEDTLS_PSA_ASSUME_EXCLUSIVE_BUFFERS) */ psa_status_t status = (psa_aead_decrypt)(arg0_key, arg1_alg, arg2_nonce, arg3_nonce_length, arg4_additional_data, arg5_additional_data_length, arg6_ciphertext, arg7_ciphertext_length, arg8_plaintext, arg9_plaintext_size, arg10_plaintext_length); -#if defined(MBEDTLS_PSA_COPY_CALLER_BUFFERS) +#if !defined(MBEDTLS_PSA_ASSUME_EXCLUSIVE_BUFFERS) MBEDTLS_TEST_MEMORY_UNPOISON(arg2_nonce, arg3_nonce_length); MBEDTLS_TEST_MEMORY_UNPOISON(arg4_additional_data, arg5_additional_data_length); MBEDTLS_TEST_MEMORY_UNPOISON(arg6_ciphertext, arg7_ciphertext_length); MBEDTLS_TEST_MEMORY_UNPOISON(arg8_plaintext, arg9_plaintext_size); -#endif /* defined(MBEDTLS_PSA_COPY_CALLER_BUFFERS) */ +#endif /* !defined(MBEDTLS_PSA_ASSUME_EXCLUSIVE_BUFFERS) */ return status; } @@ -96,19 +96,19 @@ psa_status_t mbedtls_test_wrap_psa_aead_encrypt( size_t arg9_ciphertext_size, size_t *arg10_ciphertext_length) { -#if defined(MBEDTLS_PSA_COPY_CALLER_BUFFERS) +#if !defined(MBEDTLS_PSA_ASSUME_EXCLUSIVE_BUFFERS) MBEDTLS_TEST_MEMORY_POISON(arg2_nonce, arg3_nonce_length); MBEDTLS_TEST_MEMORY_POISON(arg4_additional_data, arg5_additional_data_length); MBEDTLS_TEST_MEMORY_POISON(arg6_plaintext, arg7_plaintext_length); MBEDTLS_TEST_MEMORY_POISON(arg8_ciphertext, arg9_ciphertext_size); -#endif /* defined(MBEDTLS_PSA_COPY_CALLER_BUFFERS) */ +#endif /* !defined(MBEDTLS_PSA_ASSUME_EXCLUSIVE_BUFFERS) */ psa_status_t status = (psa_aead_encrypt)(arg0_key, arg1_alg, arg2_nonce, arg3_nonce_length, arg4_additional_data, arg5_additional_data_length, arg6_plaintext, arg7_plaintext_length, arg8_ciphertext, arg9_ciphertext_size, arg10_ciphertext_length); -#if defined(MBEDTLS_PSA_COPY_CALLER_BUFFERS) +#if !defined(MBEDTLS_PSA_ASSUME_EXCLUSIVE_BUFFERS) MBEDTLS_TEST_MEMORY_UNPOISON(arg2_nonce, arg3_nonce_length); MBEDTLS_TEST_MEMORY_UNPOISON(arg4_additional_data, arg5_additional_data_length); MBEDTLS_TEST_MEMORY_UNPOISON(arg6_plaintext, arg7_plaintext_length); MBEDTLS_TEST_MEMORY_UNPOISON(arg8_ciphertext, arg9_ciphertext_size); -#endif /* defined(MBEDTLS_PSA_COPY_CALLER_BUFFERS) */ +#endif /* !defined(MBEDTLS_PSA_ASSUME_EXCLUSIVE_BUFFERS) */ return status; } @@ -124,17 +124,17 @@ psa_status_t mbedtls_test_wrap_psa_asymmetric_decrypt( size_t arg7_output_size, size_t *arg8_output_length) { -#if defined(MBEDTLS_PSA_COPY_CALLER_BUFFERS) +#if !defined(MBEDTLS_PSA_ASSUME_EXCLUSIVE_BUFFERS) MBEDTLS_TEST_MEMORY_POISON(arg2_input, arg3_input_length); MBEDTLS_TEST_MEMORY_POISON(arg4_salt, arg5_salt_length); MBEDTLS_TEST_MEMORY_POISON(arg6_output, arg7_output_size); -#endif /* defined(MBEDTLS_PSA_COPY_CALLER_BUFFERS) */ +#endif /* !defined(MBEDTLS_PSA_ASSUME_EXCLUSIVE_BUFFERS) */ psa_status_t status = (psa_asymmetric_decrypt)(arg0_key, arg1_alg, arg2_input, arg3_input_length, arg4_salt, arg5_salt_length, arg6_output, arg7_output_size, arg8_output_length); -#if defined(MBEDTLS_PSA_COPY_CALLER_BUFFERS) +#if !defined(MBEDTLS_PSA_ASSUME_EXCLUSIVE_BUFFERS) MBEDTLS_TEST_MEMORY_UNPOISON(arg2_input, arg3_input_length); MBEDTLS_TEST_MEMORY_UNPOISON(arg4_salt, arg5_salt_length); MBEDTLS_TEST_MEMORY_UNPOISON(arg6_output, arg7_output_size); -#endif /* defined(MBEDTLS_PSA_COPY_CALLER_BUFFERS) */ +#endif /* !defined(MBEDTLS_PSA_ASSUME_EXCLUSIVE_BUFFERS) */ return status; } @@ -150,17 +150,17 @@ psa_status_t mbedtls_test_wrap_psa_asymmetric_encrypt( size_t arg7_output_size, size_t *arg8_output_length) { -#if defined(MBEDTLS_PSA_COPY_CALLER_BUFFERS) +#if !defined(MBEDTLS_PSA_ASSUME_EXCLUSIVE_BUFFERS) MBEDTLS_TEST_MEMORY_POISON(arg2_input, arg3_input_length); MBEDTLS_TEST_MEMORY_POISON(arg4_salt, arg5_salt_length); MBEDTLS_TEST_MEMORY_POISON(arg6_output, arg7_output_size); -#endif /* defined(MBEDTLS_PSA_COPY_CALLER_BUFFERS) */ +#endif /* !defined(MBEDTLS_PSA_ASSUME_EXCLUSIVE_BUFFERS) */ psa_status_t status = (psa_asymmetric_encrypt)(arg0_key, arg1_alg, arg2_input, arg3_input_length, arg4_salt, arg5_salt_length, arg6_output, arg7_output_size, arg8_output_length); -#if defined(MBEDTLS_PSA_COPY_CALLER_BUFFERS) +#if !defined(MBEDTLS_PSA_ASSUME_EXCLUSIVE_BUFFERS) MBEDTLS_TEST_MEMORY_UNPOISON(arg2_input, arg3_input_length); MBEDTLS_TEST_MEMORY_UNPOISON(arg4_salt, arg5_salt_length); MBEDTLS_TEST_MEMORY_UNPOISON(arg6_output, arg7_output_size); -#endif /* defined(MBEDTLS_PSA_COPY_CALLER_BUFFERS) */ +#endif /* !defined(MBEDTLS_PSA_ASSUME_EXCLUSIVE_BUFFERS) */ return status; } @@ -182,15 +182,15 @@ psa_status_t mbedtls_test_wrap_psa_cipher_decrypt( size_t arg5_output_size, size_t *arg6_output_length) { -#if defined(MBEDTLS_PSA_COPY_CALLER_BUFFERS) +#if !defined(MBEDTLS_PSA_ASSUME_EXCLUSIVE_BUFFERS) MBEDTLS_TEST_MEMORY_POISON(arg2_input, arg3_input_length); MBEDTLS_TEST_MEMORY_POISON(arg4_output, arg5_output_size); -#endif /* defined(MBEDTLS_PSA_COPY_CALLER_BUFFERS) */ +#endif /* !defined(MBEDTLS_PSA_ASSUME_EXCLUSIVE_BUFFERS) */ psa_status_t status = (psa_cipher_decrypt)(arg0_key, arg1_alg, arg2_input, arg3_input_length, arg4_output, arg5_output_size, arg6_output_length); -#if defined(MBEDTLS_PSA_COPY_CALLER_BUFFERS) +#if !defined(MBEDTLS_PSA_ASSUME_EXCLUSIVE_BUFFERS) MBEDTLS_TEST_MEMORY_UNPOISON(arg2_input, arg3_input_length); MBEDTLS_TEST_MEMORY_UNPOISON(arg4_output, arg5_output_size); -#endif /* defined(MBEDTLS_PSA_COPY_CALLER_BUFFERS) */ +#endif /* !defined(MBEDTLS_PSA_ASSUME_EXCLUSIVE_BUFFERS) */ return status; } @@ -214,15 +214,15 @@ psa_status_t mbedtls_test_wrap_psa_cipher_encrypt( size_t arg5_output_size, size_t *arg6_output_length) { -#if defined(MBEDTLS_PSA_COPY_CALLER_BUFFERS) +#if !defined(MBEDTLS_PSA_ASSUME_EXCLUSIVE_BUFFERS) MBEDTLS_TEST_MEMORY_POISON(arg2_input, arg3_input_length); MBEDTLS_TEST_MEMORY_POISON(arg4_output, arg5_output_size); -#endif /* defined(MBEDTLS_PSA_COPY_CALLER_BUFFERS) */ +#endif /* !defined(MBEDTLS_PSA_ASSUME_EXCLUSIVE_BUFFERS) */ psa_status_t status = (psa_cipher_encrypt)(arg0_key, arg1_alg, arg2_input, arg3_input_length, arg4_output, arg5_output_size, arg6_output_length); -#if defined(MBEDTLS_PSA_COPY_CALLER_BUFFERS) +#if !defined(MBEDTLS_PSA_ASSUME_EXCLUSIVE_BUFFERS) MBEDTLS_TEST_MEMORY_UNPOISON(arg2_input, arg3_input_length); MBEDTLS_TEST_MEMORY_UNPOISON(arg4_output, arg5_output_size); -#endif /* defined(MBEDTLS_PSA_COPY_CALLER_BUFFERS) */ +#endif /* !defined(MBEDTLS_PSA_ASSUME_EXCLUSIVE_BUFFERS) */ return status; } @@ -243,13 +243,13 @@ psa_status_t mbedtls_test_wrap_psa_cipher_finish( size_t arg2_output_size, size_t *arg3_output_length) { -#if defined(MBEDTLS_PSA_COPY_CALLER_BUFFERS) +#if !defined(MBEDTLS_PSA_ASSUME_EXCLUSIVE_BUFFERS) MBEDTLS_TEST_MEMORY_POISON(arg1_output, arg2_output_size); -#endif /* defined(MBEDTLS_PSA_COPY_CALLER_BUFFERS) */ +#endif /* !defined(MBEDTLS_PSA_ASSUME_EXCLUSIVE_BUFFERS) */ psa_status_t status = (psa_cipher_finish)(arg0_operation, arg1_output, arg2_output_size, arg3_output_length); -#if defined(MBEDTLS_PSA_COPY_CALLER_BUFFERS) +#if !defined(MBEDTLS_PSA_ASSUME_EXCLUSIVE_BUFFERS) MBEDTLS_TEST_MEMORY_UNPOISON(arg1_output, arg2_output_size); -#endif /* defined(MBEDTLS_PSA_COPY_CALLER_BUFFERS) */ +#endif /* !defined(MBEDTLS_PSA_ASSUME_EXCLUSIVE_BUFFERS) */ return status; } @@ -260,13 +260,13 @@ psa_status_t mbedtls_test_wrap_psa_cipher_generate_iv( size_t arg2_iv_size, size_t *arg3_iv_length) { -#if defined(MBEDTLS_PSA_COPY_CALLER_BUFFERS) +#if !defined(MBEDTLS_PSA_ASSUME_EXCLUSIVE_BUFFERS) MBEDTLS_TEST_MEMORY_POISON(arg1_iv, arg2_iv_size); -#endif /* defined(MBEDTLS_PSA_COPY_CALLER_BUFFERS) */ +#endif /* !defined(MBEDTLS_PSA_ASSUME_EXCLUSIVE_BUFFERS) */ psa_status_t status = (psa_cipher_generate_iv)(arg0_operation, arg1_iv, arg2_iv_size, arg3_iv_length); -#if defined(MBEDTLS_PSA_COPY_CALLER_BUFFERS) +#if !defined(MBEDTLS_PSA_ASSUME_EXCLUSIVE_BUFFERS) MBEDTLS_TEST_MEMORY_UNPOISON(arg1_iv, arg2_iv_size); -#endif /* defined(MBEDTLS_PSA_COPY_CALLER_BUFFERS) */ +#endif /* !defined(MBEDTLS_PSA_ASSUME_EXCLUSIVE_BUFFERS) */ return status; } @@ -276,13 +276,13 @@ psa_status_t mbedtls_test_wrap_psa_cipher_set_iv( const uint8_t *arg1_iv, size_t arg2_iv_length) { -#if defined(MBEDTLS_PSA_COPY_CALLER_BUFFERS) +#if !defined(MBEDTLS_PSA_ASSUME_EXCLUSIVE_BUFFERS) MBEDTLS_TEST_MEMORY_POISON(arg1_iv, arg2_iv_length); -#endif /* defined(MBEDTLS_PSA_COPY_CALLER_BUFFERS) */ +#endif /* !defined(MBEDTLS_PSA_ASSUME_EXCLUSIVE_BUFFERS) */ psa_status_t status = (psa_cipher_set_iv)(arg0_operation, arg1_iv, arg2_iv_length); -#if defined(MBEDTLS_PSA_COPY_CALLER_BUFFERS) +#if !defined(MBEDTLS_PSA_ASSUME_EXCLUSIVE_BUFFERS) MBEDTLS_TEST_MEMORY_UNPOISON(arg1_iv, arg2_iv_length); -#endif /* defined(MBEDTLS_PSA_COPY_CALLER_BUFFERS) */ +#endif /* !defined(MBEDTLS_PSA_ASSUME_EXCLUSIVE_BUFFERS) */ return status; } @@ -295,15 +295,15 @@ psa_status_t mbedtls_test_wrap_psa_cipher_update( size_t arg4_output_size, size_t *arg5_output_length) { -#if defined(MBEDTLS_PSA_COPY_CALLER_BUFFERS) +#if !defined(MBEDTLS_PSA_ASSUME_EXCLUSIVE_BUFFERS) MBEDTLS_TEST_MEMORY_POISON(arg1_input, arg2_input_length); MBEDTLS_TEST_MEMORY_POISON(arg3_output, arg4_output_size); -#endif /* defined(MBEDTLS_PSA_COPY_CALLER_BUFFERS) */ +#endif /* !defined(MBEDTLS_PSA_ASSUME_EXCLUSIVE_BUFFERS) */ psa_status_t status = (psa_cipher_update)(arg0_operation, arg1_input, arg2_input_length, arg3_output, arg4_output_size, arg5_output_length); -#if defined(MBEDTLS_PSA_COPY_CALLER_BUFFERS) +#if !defined(MBEDTLS_PSA_ASSUME_EXCLUSIVE_BUFFERS) MBEDTLS_TEST_MEMORY_UNPOISON(arg1_input, arg2_input_length); MBEDTLS_TEST_MEMORY_UNPOISON(arg3_output, arg4_output_size); -#endif /* defined(MBEDTLS_PSA_COPY_CALLER_BUFFERS) */ +#endif /* !defined(MBEDTLS_PSA_ASSUME_EXCLUSIVE_BUFFERS) */ return status; } @@ -339,13 +339,13 @@ psa_status_t mbedtls_test_wrap_psa_export_key( size_t arg2_data_size, size_t *arg3_data_length) { -#if defined(MBEDTLS_PSA_COPY_CALLER_BUFFERS) +#if !defined(MBEDTLS_PSA_ASSUME_EXCLUSIVE_BUFFERS) MBEDTLS_TEST_MEMORY_POISON(arg1_data, arg2_data_size); -#endif /* defined(MBEDTLS_PSA_COPY_CALLER_BUFFERS) */ +#endif /* !defined(MBEDTLS_PSA_ASSUME_EXCLUSIVE_BUFFERS) */ psa_status_t status = (psa_export_key)(arg0_key, arg1_data, arg2_data_size, arg3_data_length); -#if defined(MBEDTLS_PSA_COPY_CALLER_BUFFERS) +#if !defined(MBEDTLS_PSA_ASSUME_EXCLUSIVE_BUFFERS) MBEDTLS_TEST_MEMORY_UNPOISON(arg1_data, arg2_data_size); -#endif /* defined(MBEDTLS_PSA_COPY_CALLER_BUFFERS) */ +#endif /* !defined(MBEDTLS_PSA_ASSUME_EXCLUSIVE_BUFFERS) */ return status; } @@ -356,13 +356,13 @@ psa_status_t mbedtls_test_wrap_psa_export_public_key( size_t arg2_data_size, size_t *arg3_data_length) { -#if defined(MBEDTLS_PSA_COPY_CALLER_BUFFERS) +#if !defined(MBEDTLS_PSA_ASSUME_EXCLUSIVE_BUFFERS) MBEDTLS_TEST_MEMORY_POISON(arg1_data, arg2_data_size); -#endif /* defined(MBEDTLS_PSA_COPY_CALLER_BUFFERS) */ +#endif /* !defined(MBEDTLS_PSA_ASSUME_EXCLUSIVE_BUFFERS) */ psa_status_t status = (psa_export_public_key)(arg0_key, arg1_data, arg2_data_size, arg3_data_length); -#if defined(MBEDTLS_PSA_COPY_CALLER_BUFFERS) +#if !defined(MBEDTLS_PSA_ASSUME_EXCLUSIVE_BUFFERS) MBEDTLS_TEST_MEMORY_UNPOISON(arg1_data, arg2_data_size); -#endif /* defined(MBEDTLS_PSA_COPY_CALLER_BUFFERS) */ +#endif /* !defined(MBEDTLS_PSA_ASSUME_EXCLUSIVE_BUFFERS) */ return status; } @@ -380,13 +380,13 @@ psa_status_t mbedtls_test_wrap_psa_generate_random( uint8_t *arg0_output, size_t arg1_output_size) { -#if defined(MBEDTLS_PSA_COPY_CALLER_BUFFERS) +#if !defined(MBEDTLS_PSA_ASSUME_EXCLUSIVE_BUFFERS) MBEDTLS_TEST_MEMORY_POISON(arg0_output, arg1_output_size); -#endif /* defined(MBEDTLS_PSA_COPY_CALLER_BUFFERS) */ +#endif /* !defined(MBEDTLS_PSA_ASSUME_EXCLUSIVE_BUFFERS) */ psa_status_t status = (psa_generate_random)(arg0_output, arg1_output_size); -#if defined(MBEDTLS_PSA_COPY_CALLER_BUFFERS) +#if !defined(MBEDTLS_PSA_ASSUME_EXCLUSIVE_BUFFERS) MBEDTLS_TEST_MEMORY_UNPOISON(arg0_output, arg1_output_size); -#endif /* defined(MBEDTLS_PSA_COPY_CALLER_BUFFERS) */ +#endif /* !defined(MBEDTLS_PSA_ASSUME_EXCLUSIVE_BUFFERS) */ return status; } @@ -424,15 +424,15 @@ psa_status_t mbedtls_test_wrap_psa_hash_compare( const uint8_t *arg3_hash, size_t arg4_hash_length) { -#if defined(MBEDTLS_PSA_COPY_CALLER_BUFFERS) +#if !defined(MBEDTLS_PSA_ASSUME_EXCLUSIVE_BUFFERS) MBEDTLS_TEST_MEMORY_POISON(arg1_input, arg2_input_length); MBEDTLS_TEST_MEMORY_POISON(arg3_hash, arg4_hash_length); -#endif /* defined(MBEDTLS_PSA_COPY_CALLER_BUFFERS) */ +#endif /* !defined(MBEDTLS_PSA_ASSUME_EXCLUSIVE_BUFFERS) */ psa_status_t status = (psa_hash_compare)(arg0_alg, arg1_input, arg2_input_length, arg3_hash, arg4_hash_length); -#if defined(MBEDTLS_PSA_COPY_CALLER_BUFFERS) +#if !defined(MBEDTLS_PSA_ASSUME_EXCLUSIVE_BUFFERS) MBEDTLS_TEST_MEMORY_UNPOISON(arg1_input, arg2_input_length); MBEDTLS_TEST_MEMORY_UNPOISON(arg3_hash, arg4_hash_length); -#endif /* defined(MBEDTLS_PSA_COPY_CALLER_BUFFERS) */ +#endif /* !defined(MBEDTLS_PSA_ASSUME_EXCLUSIVE_BUFFERS) */ return status; } @@ -445,15 +445,15 @@ psa_status_t mbedtls_test_wrap_psa_hash_compute( size_t arg4_hash_size, size_t *arg5_hash_length) { -#if defined(MBEDTLS_PSA_COPY_CALLER_BUFFERS) +#if !defined(MBEDTLS_PSA_ASSUME_EXCLUSIVE_BUFFERS) MBEDTLS_TEST_MEMORY_POISON(arg1_input, arg2_input_length); MBEDTLS_TEST_MEMORY_POISON(arg3_hash, arg4_hash_size); -#endif /* defined(MBEDTLS_PSA_COPY_CALLER_BUFFERS) */ +#endif /* !defined(MBEDTLS_PSA_ASSUME_EXCLUSIVE_BUFFERS) */ psa_status_t status = (psa_hash_compute)(arg0_alg, arg1_input, arg2_input_length, arg3_hash, arg4_hash_size, arg5_hash_length); -#if defined(MBEDTLS_PSA_COPY_CALLER_BUFFERS) +#if !defined(MBEDTLS_PSA_ASSUME_EXCLUSIVE_BUFFERS) MBEDTLS_TEST_MEMORY_UNPOISON(arg1_input, arg2_input_length); MBEDTLS_TEST_MEMORY_UNPOISON(arg3_hash, arg4_hash_size); -#endif /* defined(MBEDTLS_PSA_COPY_CALLER_BUFFERS) */ +#endif /* !defined(MBEDTLS_PSA_ASSUME_EXCLUSIVE_BUFFERS) */ return status; } @@ -464,13 +464,13 @@ psa_status_t mbedtls_test_wrap_psa_hash_finish( size_t arg2_hash_size, size_t *arg3_hash_length) { -#if defined(MBEDTLS_PSA_COPY_CALLER_BUFFERS) +#if !defined(MBEDTLS_PSA_ASSUME_EXCLUSIVE_BUFFERS) MBEDTLS_TEST_MEMORY_POISON(arg1_hash, arg2_hash_size); -#endif /* defined(MBEDTLS_PSA_COPY_CALLER_BUFFERS) */ +#endif /* !defined(MBEDTLS_PSA_ASSUME_EXCLUSIVE_BUFFERS) */ psa_status_t status = (psa_hash_finish)(arg0_operation, arg1_hash, arg2_hash_size, arg3_hash_length); -#if defined(MBEDTLS_PSA_COPY_CALLER_BUFFERS) +#if !defined(MBEDTLS_PSA_ASSUME_EXCLUSIVE_BUFFERS) MBEDTLS_TEST_MEMORY_UNPOISON(arg1_hash, arg2_hash_size); -#endif /* defined(MBEDTLS_PSA_COPY_CALLER_BUFFERS) */ +#endif /* !defined(MBEDTLS_PSA_ASSUME_EXCLUSIVE_BUFFERS) */ return status; } @@ -489,13 +489,13 @@ psa_status_t mbedtls_test_wrap_psa_hash_update( const uint8_t *arg1_input, size_t arg2_input_length) { -#if defined(MBEDTLS_PSA_COPY_CALLER_BUFFERS) +#if !defined(MBEDTLS_PSA_ASSUME_EXCLUSIVE_BUFFERS) MBEDTLS_TEST_MEMORY_POISON(arg1_input, arg2_input_length); -#endif /* defined(MBEDTLS_PSA_COPY_CALLER_BUFFERS) */ +#endif /* !defined(MBEDTLS_PSA_ASSUME_EXCLUSIVE_BUFFERS) */ psa_status_t status = (psa_hash_update)(arg0_operation, arg1_input, arg2_input_length); -#if defined(MBEDTLS_PSA_COPY_CALLER_BUFFERS) +#if !defined(MBEDTLS_PSA_ASSUME_EXCLUSIVE_BUFFERS) MBEDTLS_TEST_MEMORY_UNPOISON(arg1_input, arg2_input_length); -#endif /* defined(MBEDTLS_PSA_COPY_CALLER_BUFFERS) */ +#endif /* !defined(MBEDTLS_PSA_ASSUME_EXCLUSIVE_BUFFERS) */ return status; } @@ -505,13 +505,13 @@ psa_status_t mbedtls_test_wrap_psa_hash_verify( const uint8_t *arg1_hash, size_t arg2_hash_length) { -#if defined(MBEDTLS_PSA_COPY_CALLER_BUFFERS) +#if !defined(MBEDTLS_PSA_ASSUME_EXCLUSIVE_BUFFERS) MBEDTLS_TEST_MEMORY_POISON(arg1_hash, arg2_hash_length); -#endif /* defined(MBEDTLS_PSA_COPY_CALLER_BUFFERS) */ +#endif /* !defined(MBEDTLS_PSA_ASSUME_EXCLUSIVE_BUFFERS) */ psa_status_t status = (psa_hash_verify)(arg0_operation, arg1_hash, arg2_hash_length); -#if defined(MBEDTLS_PSA_COPY_CALLER_BUFFERS) +#if !defined(MBEDTLS_PSA_ASSUME_EXCLUSIVE_BUFFERS) MBEDTLS_TEST_MEMORY_UNPOISON(arg1_hash, arg2_hash_length); -#endif /* defined(MBEDTLS_PSA_COPY_CALLER_BUFFERS) */ +#endif /* !defined(MBEDTLS_PSA_ASSUME_EXCLUSIVE_BUFFERS) */ return status; } @@ -522,13 +522,13 @@ psa_status_t mbedtls_test_wrap_psa_import_key( size_t arg2_data_length, mbedtls_svc_key_id_t *arg3_key) { -#if defined(MBEDTLS_PSA_COPY_CALLER_BUFFERS) +#if !defined(MBEDTLS_PSA_ASSUME_EXCLUSIVE_BUFFERS) MBEDTLS_TEST_MEMORY_POISON(arg1_data, arg2_data_length); -#endif /* defined(MBEDTLS_PSA_COPY_CALLER_BUFFERS) */ +#endif /* !defined(MBEDTLS_PSA_ASSUME_EXCLUSIVE_BUFFERS) */ psa_status_t status = (psa_import_key)(arg0_attributes, arg1_data, arg2_data_length, arg3_key); -#if defined(MBEDTLS_PSA_COPY_CALLER_BUFFERS) +#if !defined(MBEDTLS_PSA_ASSUME_EXCLUSIVE_BUFFERS) MBEDTLS_TEST_MEMORY_UNPOISON(arg1_data, arg2_data_length); -#endif /* defined(MBEDTLS_PSA_COPY_CALLER_BUFFERS) */ +#endif /* !defined(MBEDTLS_PSA_ASSUME_EXCLUSIVE_BUFFERS) */ return status; } @@ -556,13 +556,13 @@ psa_status_t mbedtls_test_wrap_psa_key_derivation_input_bytes( const uint8_t *arg2_data, size_t arg3_data_length) { -#if defined(MBEDTLS_PSA_COPY_CALLER_BUFFERS) +#if !defined(MBEDTLS_PSA_ASSUME_EXCLUSIVE_BUFFERS) MBEDTLS_TEST_MEMORY_POISON(arg2_data, arg3_data_length); -#endif /* defined(MBEDTLS_PSA_COPY_CALLER_BUFFERS) */ +#endif /* !defined(MBEDTLS_PSA_ASSUME_EXCLUSIVE_BUFFERS) */ psa_status_t status = (psa_key_derivation_input_bytes)(arg0_operation, arg1_step, arg2_data, arg3_data_length); -#if defined(MBEDTLS_PSA_COPY_CALLER_BUFFERS) +#if !defined(MBEDTLS_PSA_ASSUME_EXCLUSIVE_BUFFERS) MBEDTLS_TEST_MEMORY_UNPOISON(arg2_data, arg3_data_length); -#endif /* defined(MBEDTLS_PSA_COPY_CALLER_BUFFERS) */ +#endif /* !defined(MBEDTLS_PSA_ASSUME_EXCLUSIVE_BUFFERS) */ return status; } @@ -584,13 +584,13 @@ psa_status_t mbedtls_test_wrap_psa_key_derivation_key_agreement( const uint8_t *arg3_peer_key, size_t arg4_peer_key_length) { -#if defined(MBEDTLS_PSA_COPY_CALLER_BUFFERS) +#if !defined(MBEDTLS_PSA_ASSUME_EXCLUSIVE_BUFFERS) MBEDTLS_TEST_MEMORY_POISON(arg3_peer_key, arg4_peer_key_length); -#endif /* defined(MBEDTLS_PSA_COPY_CALLER_BUFFERS) */ +#endif /* !defined(MBEDTLS_PSA_ASSUME_EXCLUSIVE_BUFFERS) */ psa_status_t status = (psa_key_derivation_key_agreement)(arg0_operation, arg1_step, arg2_private_key, arg3_peer_key, arg4_peer_key_length); -#if defined(MBEDTLS_PSA_COPY_CALLER_BUFFERS) +#if !defined(MBEDTLS_PSA_ASSUME_EXCLUSIVE_BUFFERS) MBEDTLS_TEST_MEMORY_UNPOISON(arg3_peer_key, arg4_peer_key_length); -#endif /* defined(MBEDTLS_PSA_COPY_CALLER_BUFFERS) */ +#endif /* !defined(MBEDTLS_PSA_ASSUME_EXCLUSIVE_BUFFERS) */ return status; } @@ -600,13 +600,13 @@ psa_status_t mbedtls_test_wrap_psa_key_derivation_output_bytes( uint8_t *arg1_output, size_t arg2_output_length) { -#if defined(MBEDTLS_PSA_COPY_CALLER_BUFFERS) +#if !defined(MBEDTLS_PSA_ASSUME_EXCLUSIVE_BUFFERS) MBEDTLS_TEST_MEMORY_POISON(arg1_output, arg2_output_length); -#endif /* defined(MBEDTLS_PSA_COPY_CALLER_BUFFERS) */ +#endif /* !defined(MBEDTLS_PSA_ASSUME_EXCLUSIVE_BUFFERS) */ psa_status_t status = (psa_key_derivation_output_bytes)(arg0_operation, arg1_output, arg2_output_length); -#if defined(MBEDTLS_PSA_COPY_CALLER_BUFFERS) +#if !defined(MBEDTLS_PSA_ASSUME_EXCLUSIVE_BUFFERS) MBEDTLS_TEST_MEMORY_UNPOISON(arg1_output, arg2_output_length); -#endif /* defined(MBEDTLS_PSA_COPY_CALLER_BUFFERS) */ +#endif /* !defined(MBEDTLS_PSA_ASSUME_EXCLUSIVE_BUFFERS) */ return status; } @@ -656,15 +656,15 @@ psa_status_t mbedtls_test_wrap_psa_mac_compute( size_t arg5_mac_size, size_t *arg6_mac_length) { -#if defined(MBEDTLS_PSA_COPY_CALLER_BUFFERS) +#if !defined(MBEDTLS_PSA_ASSUME_EXCLUSIVE_BUFFERS) MBEDTLS_TEST_MEMORY_POISON(arg2_input, arg3_input_length); MBEDTLS_TEST_MEMORY_POISON(arg4_mac, arg5_mac_size); -#endif /* defined(MBEDTLS_PSA_COPY_CALLER_BUFFERS) */ +#endif /* !defined(MBEDTLS_PSA_ASSUME_EXCLUSIVE_BUFFERS) */ psa_status_t status = (psa_mac_compute)(arg0_key, arg1_alg, arg2_input, arg3_input_length, arg4_mac, arg5_mac_size, arg6_mac_length); -#if defined(MBEDTLS_PSA_COPY_CALLER_BUFFERS) +#if !defined(MBEDTLS_PSA_ASSUME_EXCLUSIVE_BUFFERS) MBEDTLS_TEST_MEMORY_UNPOISON(arg2_input, arg3_input_length); MBEDTLS_TEST_MEMORY_UNPOISON(arg4_mac, arg5_mac_size); -#endif /* defined(MBEDTLS_PSA_COPY_CALLER_BUFFERS) */ +#endif /* !defined(MBEDTLS_PSA_ASSUME_EXCLUSIVE_BUFFERS) */ return status; } @@ -675,13 +675,13 @@ psa_status_t mbedtls_test_wrap_psa_mac_sign_finish( size_t arg2_mac_size, size_t *arg3_mac_length) { -#if defined(MBEDTLS_PSA_COPY_CALLER_BUFFERS) +#if !defined(MBEDTLS_PSA_ASSUME_EXCLUSIVE_BUFFERS) MBEDTLS_TEST_MEMORY_POISON(arg1_mac, arg2_mac_size); -#endif /* defined(MBEDTLS_PSA_COPY_CALLER_BUFFERS) */ +#endif /* !defined(MBEDTLS_PSA_ASSUME_EXCLUSIVE_BUFFERS) */ psa_status_t status = (psa_mac_sign_finish)(arg0_operation, arg1_mac, arg2_mac_size, arg3_mac_length); -#if defined(MBEDTLS_PSA_COPY_CALLER_BUFFERS) +#if !defined(MBEDTLS_PSA_ASSUME_EXCLUSIVE_BUFFERS) MBEDTLS_TEST_MEMORY_UNPOISON(arg1_mac, arg2_mac_size); -#endif /* defined(MBEDTLS_PSA_COPY_CALLER_BUFFERS) */ +#endif /* !defined(MBEDTLS_PSA_ASSUME_EXCLUSIVE_BUFFERS) */ return status; } @@ -701,13 +701,13 @@ psa_status_t mbedtls_test_wrap_psa_mac_update( const uint8_t *arg1_input, size_t arg2_input_length) { -#if defined(MBEDTLS_PSA_COPY_CALLER_BUFFERS) +#if !defined(MBEDTLS_PSA_ASSUME_EXCLUSIVE_BUFFERS) MBEDTLS_TEST_MEMORY_POISON(arg1_input, arg2_input_length); -#endif /* defined(MBEDTLS_PSA_COPY_CALLER_BUFFERS) */ +#endif /* !defined(MBEDTLS_PSA_ASSUME_EXCLUSIVE_BUFFERS) */ psa_status_t status = (psa_mac_update)(arg0_operation, arg1_input, arg2_input_length); -#if defined(MBEDTLS_PSA_COPY_CALLER_BUFFERS) +#if !defined(MBEDTLS_PSA_ASSUME_EXCLUSIVE_BUFFERS) MBEDTLS_TEST_MEMORY_UNPOISON(arg1_input, arg2_input_length); -#endif /* defined(MBEDTLS_PSA_COPY_CALLER_BUFFERS) */ +#endif /* !defined(MBEDTLS_PSA_ASSUME_EXCLUSIVE_BUFFERS) */ return status; } @@ -720,15 +720,15 @@ psa_status_t mbedtls_test_wrap_psa_mac_verify( const uint8_t *arg4_mac, size_t arg5_mac_length) { -#if defined(MBEDTLS_PSA_COPY_CALLER_BUFFERS) +#if !defined(MBEDTLS_PSA_ASSUME_EXCLUSIVE_BUFFERS) MBEDTLS_TEST_MEMORY_POISON(arg2_input, arg3_input_length); MBEDTLS_TEST_MEMORY_POISON(arg4_mac, arg5_mac_length); -#endif /* defined(MBEDTLS_PSA_COPY_CALLER_BUFFERS) */ +#endif /* !defined(MBEDTLS_PSA_ASSUME_EXCLUSIVE_BUFFERS) */ psa_status_t status = (psa_mac_verify)(arg0_key, arg1_alg, arg2_input, arg3_input_length, arg4_mac, arg5_mac_length); -#if defined(MBEDTLS_PSA_COPY_CALLER_BUFFERS) +#if !defined(MBEDTLS_PSA_ASSUME_EXCLUSIVE_BUFFERS) MBEDTLS_TEST_MEMORY_UNPOISON(arg2_input, arg3_input_length); MBEDTLS_TEST_MEMORY_UNPOISON(arg4_mac, arg5_mac_length); -#endif /* defined(MBEDTLS_PSA_COPY_CALLER_BUFFERS) */ +#endif /* !defined(MBEDTLS_PSA_ASSUME_EXCLUSIVE_BUFFERS) */ return status; } @@ -738,13 +738,13 @@ psa_status_t mbedtls_test_wrap_psa_mac_verify_finish( const uint8_t *arg1_mac, size_t arg2_mac_length) { -#if defined(MBEDTLS_PSA_COPY_CALLER_BUFFERS) +#if !defined(MBEDTLS_PSA_ASSUME_EXCLUSIVE_BUFFERS) MBEDTLS_TEST_MEMORY_POISON(arg1_mac, arg2_mac_length); -#endif /* defined(MBEDTLS_PSA_COPY_CALLER_BUFFERS) */ +#endif /* !defined(MBEDTLS_PSA_ASSUME_EXCLUSIVE_BUFFERS) */ psa_status_t status = (psa_mac_verify_finish)(arg0_operation, arg1_mac, arg2_mac_length); -#if defined(MBEDTLS_PSA_COPY_CALLER_BUFFERS) +#if !defined(MBEDTLS_PSA_ASSUME_EXCLUSIVE_BUFFERS) MBEDTLS_TEST_MEMORY_UNPOISON(arg1_mac, arg2_mac_length); -#endif /* defined(MBEDTLS_PSA_COPY_CALLER_BUFFERS) */ +#endif /* !defined(MBEDTLS_PSA_ASSUME_EXCLUSIVE_BUFFERS) */ return status; } @@ -776,15 +776,15 @@ psa_status_t mbedtls_test_wrap_psa_raw_key_agreement( size_t arg5_output_size, size_t *arg6_output_length) { -#if defined(MBEDTLS_PSA_COPY_CALLER_BUFFERS) +#if !defined(MBEDTLS_PSA_ASSUME_EXCLUSIVE_BUFFERS) MBEDTLS_TEST_MEMORY_POISON(arg2_peer_key, arg3_peer_key_length); MBEDTLS_TEST_MEMORY_POISON(arg4_output, arg5_output_size); -#endif /* defined(MBEDTLS_PSA_COPY_CALLER_BUFFERS) */ +#endif /* !defined(MBEDTLS_PSA_ASSUME_EXCLUSIVE_BUFFERS) */ psa_status_t status = (psa_raw_key_agreement)(arg0_alg, arg1_private_key, arg2_peer_key, arg3_peer_key_length, arg4_output, arg5_output_size, arg6_output_length); -#if defined(MBEDTLS_PSA_COPY_CALLER_BUFFERS) +#if !defined(MBEDTLS_PSA_ASSUME_EXCLUSIVE_BUFFERS) MBEDTLS_TEST_MEMORY_UNPOISON(arg2_peer_key, arg3_peer_key_length); MBEDTLS_TEST_MEMORY_UNPOISON(arg4_output, arg5_output_size); -#endif /* defined(MBEDTLS_PSA_COPY_CALLER_BUFFERS) */ +#endif /* !defined(MBEDTLS_PSA_ASSUME_EXCLUSIVE_BUFFERS) */ return status; } @@ -798,15 +798,15 @@ psa_status_t mbedtls_test_wrap_psa_sign_hash( size_t arg5_signature_size, size_t *arg6_signature_length) { -#if defined(MBEDTLS_PSA_COPY_CALLER_BUFFERS) +#if !defined(MBEDTLS_PSA_ASSUME_EXCLUSIVE_BUFFERS) MBEDTLS_TEST_MEMORY_POISON(arg2_hash, arg3_hash_length); MBEDTLS_TEST_MEMORY_POISON(arg4_signature, arg5_signature_size); -#endif /* defined(MBEDTLS_PSA_COPY_CALLER_BUFFERS) */ +#endif /* !defined(MBEDTLS_PSA_ASSUME_EXCLUSIVE_BUFFERS) */ psa_status_t status = (psa_sign_hash)(arg0_key, arg1_alg, arg2_hash, arg3_hash_length, arg4_signature, arg5_signature_size, arg6_signature_length); -#if defined(MBEDTLS_PSA_COPY_CALLER_BUFFERS) +#if !defined(MBEDTLS_PSA_ASSUME_EXCLUSIVE_BUFFERS) MBEDTLS_TEST_MEMORY_UNPOISON(arg2_hash, arg3_hash_length); MBEDTLS_TEST_MEMORY_UNPOISON(arg4_signature, arg5_signature_size); -#endif /* defined(MBEDTLS_PSA_COPY_CALLER_BUFFERS) */ +#endif /* !defined(MBEDTLS_PSA_ASSUME_EXCLUSIVE_BUFFERS) */ return status; } @@ -820,15 +820,15 @@ psa_status_t mbedtls_test_wrap_psa_sign_message( size_t arg5_signature_size, size_t *arg6_signature_length) { -#if defined(MBEDTLS_PSA_COPY_CALLER_BUFFERS) +#if !defined(MBEDTLS_PSA_ASSUME_EXCLUSIVE_BUFFERS) MBEDTLS_TEST_MEMORY_POISON(arg2_input, arg3_input_length); MBEDTLS_TEST_MEMORY_POISON(arg4_signature, arg5_signature_size); -#endif /* defined(MBEDTLS_PSA_COPY_CALLER_BUFFERS) */ +#endif /* !defined(MBEDTLS_PSA_ASSUME_EXCLUSIVE_BUFFERS) */ psa_status_t status = (psa_sign_message)(arg0_key, arg1_alg, arg2_input, arg3_input_length, arg4_signature, arg5_signature_size, arg6_signature_length); -#if defined(MBEDTLS_PSA_COPY_CALLER_BUFFERS) +#if !defined(MBEDTLS_PSA_ASSUME_EXCLUSIVE_BUFFERS) MBEDTLS_TEST_MEMORY_UNPOISON(arg2_input, arg3_input_length); MBEDTLS_TEST_MEMORY_UNPOISON(arg4_signature, arg5_signature_size); -#endif /* defined(MBEDTLS_PSA_COPY_CALLER_BUFFERS) */ +#endif /* !defined(MBEDTLS_PSA_ASSUME_EXCLUSIVE_BUFFERS) */ return status; } @@ -841,15 +841,15 @@ psa_status_t mbedtls_test_wrap_psa_verify_hash( const uint8_t *arg4_signature, size_t arg5_signature_length) { -#if defined(MBEDTLS_PSA_COPY_CALLER_BUFFERS) +#if !defined(MBEDTLS_PSA_ASSUME_EXCLUSIVE_BUFFERS) MBEDTLS_TEST_MEMORY_POISON(arg2_hash, arg3_hash_length); MBEDTLS_TEST_MEMORY_POISON(arg4_signature, arg5_signature_length); -#endif /* defined(MBEDTLS_PSA_COPY_CALLER_BUFFERS) */ +#endif /* !defined(MBEDTLS_PSA_ASSUME_EXCLUSIVE_BUFFERS) */ psa_status_t status = (psa_verify_hash)(arg0_key, arg1_alg, arg2_hash, arg3_hash_length, arg4_signature, arg5_signature_length); -#if defined(MBEDTLS_PSA_COPY_CALLER_BUFFERS) +#if !defined(MBEDTLS_PSA_ASSUME_EXCLUSIVE_BUFFERS) MBEDTLS_TEST_MEMORY_UNPOISON(arg2_hash, arg3_hash_length); MBEDTLS_TEST_MEMORY_UNPOISON(arg4_signature, arg5_signature_length); -#endif /* defined(MBEDTLS_PSA_COPY_CALLER_BUFFERS) */ +#endif /* !defined(MBEDTLS_PSA_ASSUME_EXCLUSIVE_BUFFERS) */ return status; } @@ -862,15 +862,15 @@ psa_status_t mbedtls_test_wrap_psa_verify_message( const uint8_t *arg4_signature, size_t arg5_signature_length) { -#if defined(MBEDTLS_PSA_COPY_CALLER_BUFFERS) +#if !defined(MBEDTLS_PSA_ASSUME_EXCLUSIVE_BUFFERS) MBEDTLS_TEST_MEMORY_POISON(arg2_input, arg3_input_length); MBEDTLS_TEST_MEMORY_POISON(arg4_signature, arg5_signature_length); -#endif /* defined(MBEDTLS_PSA_COPY_CALLER_BUFFERS) */ +#endif /* !defined(MBEDTLS_PSA_ASSUME_EXCLUSIVE_BUFFERS) */ psa_status_t status = (psa_verify_message)(arg0_key, arg1_alg, arg2_input, arg3_input_length, arg4_signature, arg5_signature_length); -#if defined(MBEDTLS_PSA_COPY_CALLER_BUFFERS) +#if !defined(MBEDTLS_PSA_ASSUME_EXCLUSIVE_BUFFERS) MBEDTLS_TEST_MEMORY_UNPOISON(arg2_input, arg3_input_length); MBEDTLS_TEST_MEMORY_UNPOISON(arg4_signature, arg5_signature_length); -#endif /* defined(MBEDTLS_PSA_COPY_CALLER_BUFFERS) */ +#endif /* !defined(MBEDTLS_PSA_ASSUME_EXCLUSIVE_BUFFERS) */ return status; } From c34fa81ea975f96996c37a867b4adf60977dfd43 Mon Sep 17 00:00:00 2001 From: David Horstmann Date: Thu, 14 Mar 2024 09:24:38 +0000 Subject: [PATCH 3/5] Remove MBEDTLS_PSA_ASSUME_EXCLUSIVE_BUFFERS from full This option removes a feature (buffer protection) so should not be in the full config. Signed-off-by: David Horstmann --- scripts/config.py | 1 + 1 file changed, 1 insertion(+) diff --git a/scripts/config.py b/scripts/config.py index 604f8a847..c7563e4c9 100755 --- a/scripts/config.py +++ b/scripts/config.py @@ -200,6 +200,7 @@ EXCLUDE_FROM_FULL = frozenset([ 'MBEDTLS_TEST_NULL_ENTROPY', # removes a feature 'MBEDTLS_X509_ALLOW_UNSUPPORTED_CRITICAL_EXTENSION', # influences the use of X.509 in TLS 'MBEDTLS_ZLIB_SUPPORT', # build dependency (libz) + 'MBEDTLS_PSA_ASSUME_EXCLUSIVE_BUFFERS', # removes a feature ]) def is_seamless_alt(name): From 5bada225ebb45f1cbe2dd32fc4fcba68bd6849c8 Mon Sep 17 00:00:00 2001 From: David Horstmann Date: Thu, 14 Mar 2024 11:20:47 +0000 Subject: [PATCH 4/5] Update generated files with inverted option Achieved by running: tests/scripts/check-generated-files.sh -u Signed-off-by: David Horstmann --- library/version_features.c | 6 +++--- programs/test/query_config.c | 14 +++++++------- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/library/version_features.c b/library/version_features.c index 170e7fae8..6f663b12a 100644 --- a/library/version_features.c +++ b/library/version_features.c @@ -456,9 +456,9 @@ static const char * const features[] = { #if defined(MBEDTLS_PSA_INJECT_ENTROPY) "MBEDTLS_PSA_INJECT_ENTROPY", #endif /* MBEDTLS_PSA_INJECT_ENTROPY */ -#if defined(MBEDTLS_PSA_COPY_CALLER_BUFFERS) - "MBEDTLS_PSA_COPY_CALLER_BUFFERS", -#endif /* MBEDTLS_PSA_COPY_CALLER_BUFFERS */ +#if defined(MBEDTLS_PSA_ASSUME_EXCLUSIVE_BUFFERS) + "MBEDTLS_PSA_ASSUME_EXCLUSIVE_BUFFERS", +#endif /* MBEDTLS_PSA_ASSUME_EXCLUSIVE_BUFFERS */ #if defined(MBEDTLS_RSA_NO_CRT) "MBEDTLS_RSA_NO_CRT", #endif /* MBEDTLS_RSA_NO_CRT */ diff --git a/programs/test/query_config.c b/programs/test/query_config.c index cd798f7c7..5d9886bcd 100644 --- a/programs/test/query_config.c +++ b/programs/test/query_config.c @@ -1296,13 +1296,13 @@ int query_config(const char *config) } #endif /* MBEDTLS_PSA_INJECT_ENTROPY */ -#if defined(MBEDTLS_PSA_COPY_CALLER_BUFFERS) - if( strcmp( "MBEDTLS_PSA_COPY_CALLER_BUFFERS", config ) == 0 ) +#if defined(MBEDTLS_PSA_ASSUME_EXCLUSIVE_BUFFERS) + if( strcmp( "MBEDTLS_PSA_ASSUME_EXCLUSIVE_BUFFERS", config ) == 0 ) { - MACRO_EXPANSION_TO_STR( MBEDTLS_PSA_COPY_CALLER_BUFFERS ); + MACRO_EXPANSION_TO_STR( MBEDTLS_PSA_ASSUME_EXCLUSIVE_BUFFERS ); return( 0 ); } -#endif /* MBEDTLS_PSA_COPY_CALLER_BUFFERS */ +#endif /* MBEDTLS_PSA_ASSUME_EXCLUSIVE_BUFFERS */ #if defined(MBEDTLS_RSA_NO_CRT) if( strcmp( "MBEDTLS_RSA_NO_CRT", config ) == 0 ) @@ -3466,9 +3466,9 @@ void list_config(void) OUTPUT_MACRO_NAME_VALUE(MBEDTLS_PSA_INJECT_ENTROPY); #endif /* MBEDTLS_PSA_INJECT_ENTROPY */ -#if defined(MBEDTLS_PSA_COPY_CALLER_BUFFERS) - OUTPUT_MACRO_NAME_VALUE(MBEDTLS_PSA_COPY_CALLER_BUFFERS); -#endif /* MBEDTLS_PSA_COPY_CALLER_BUFFERS */ +#if defined(MBEDTLS_PSA_ASSUME_EXCLUSIVE_BUFFERS) + OUTPUT_MACRO_NAME_VALUE(MBEDTLS_PSA_ASSUME_EXCLUSIVE_BUFFERS); +#endif /* MBEDTLS_PSA_ASSUME_EXCLUSIVE_BUFFERS */ #if defined(MBEDTLS_RSA_NO_CRT) OUTPUT_MACRO_NAME_VALUE(MBEDTLS_RSA_NO_CRT); From a7cb1d0fc950a985b8e6a35714aeca45bd710fc9 Mon Sep 17 00:00:00 2001 From: David Horstmann Date: Thu, 14 Mar 2024 14:52:45 +0000 Subject: [PATCH 5/5] Preserve alphabetical sorting of config options In the list that is excluded from the full config. Signed-off-by: David Horstmann --- scripts/config.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/config.py b/scripts/config.py index c7563e4c9..22bdb5e6d 100755 --- a/scripts/config.py +++ b/scripts/config.py @@ -185,6 +185,7 @@ EXCLUDE_FROM_FULL = frozenset([ 'MBEDTLS_NO_UDBL_DIVISION', # influences anything that uses bignum 'MBEDTLS_PKCS11_C', # build dependency (libpkcs11-helper) 'MBEDTLS_PLATFORM_NO_STD_FUNCTIONS', # removes a feature + 'MBEDTLS_PSA_ASSUME_EXCLUSIVE_BUFFERS', # removes a feature 'MBEDTLS_PSA_CRYPTO_CONFIG', # toggles old/new style PSA config 'MBEDTLS_PSA_CRYPTO_EXTERNAL_RNG', # behavior change + build dependency 'MBEDTLS_PSA_CRYPTO_KEY_ID_ENCODES_OWNER', # incompatible with USE_PSA_CRYPTO @@ -200,7 +201,6 @@ EXCLUDE_FROM_FULL = frozenset([ 'MBEDTLS_TEST_NULL_ENTROPY', # removes a feature 'MBEDTLS_X509_ALLOW_UNSUPPORTED_CRITICAL_EXTENSION', # influences the use of X.509 in TLS 'MBEDTLS_ZLIB_SUPPORT', # build dependency (libz) - 'MBEDTLS_PSA_ASSUME_EXCLUSIVE_BUFFERS', # removes a feature ]) def is_seamless_alt(name):