1
0
mirror of https://github.com/Mbed-TLS/mbedtls.git synced 2025-08-08 17:42:09 +03:00

Merge remote-tracking branch 'restricted/development-restricted' into update-development-r

Conflicts:
	programs/Makefile
	tests/scripts/check-generated-files.sh
This commit is contained in:
Dave Rodgman
2024-01-26 12:42:51 +00:00
31 changed files with 4331 additions and 28 deletions

View File

@@ -254,6 +254,8 @@ function(add_test_suite suite_name)
target_include_directories(test_suite_${data_name}
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/../library)
# Request C11, which is needed for memory poisoning tests
set_target_properties(test_suite_${data_name} PROPERTIES C_STANDARD 11)
if(${data_name} MATCHES ${SKIP_TEST_SUITES_REGEX})
message(STATUS "The test suite ${data_name} will not be executed.")

107
tests/include/test/memory.h Normal file
View File

@@ -0,0 +1,107 @@
/**
* \file memory.h
*
* \brief Helper macros and functions related to testing memory management.
*/
/*
* Copyright The Mbed TLS Contributors
* SPDX-License-Identifier: Apache-2.0 OR GPL-2.0-or-later
*/
#ifndef TEST_MEMORY_H
#define TEST_MEMORY_H
#include "mbedtls/build_info.h"
#include "mbedtls/platform.h"
#include "test/helpers.h"
/** \def MBEDTLS_TEST_MEMORY_CAN_POISON
*
* This macro is defined if the tests are compiled with a method to mark
* memory as poisoned, which can be used to enforce some memory access
* policies.
*
* Support for the C11 thread_local keyword is also required.
*
* Currently, only Asan (Address Sanitizer) is supported.
*/
#if defined(MBEDTLS_TEST_HAVE_ASAN) && \
(__STDC_VERSION__ >= 201112L)
# define MBEDTLS_TEST_MEMORY_CAN_POISON
#endif
/** \def MBEDTLS_TEST_MEMORY_POISON(buf, size)
*
* Poison a memory area so that any attempt to read or write from it will
* cause a runtime failure.
*
* Depending on the implementation, this may poison a few bytes beyond the
* indicated region, but will never poison a separate object on the heap
* or a separate object with more than the alignment of a long long.
*
* The behavior is undefined if any part of the memory area is invalid.
*
* This is a no-op in builds without a poisoning method.
* See #MBEDTLS_TEST_MEMORY_CAN_POISON.
*
* \param buf Pointer to the beginning of the memory area to poison.
* \param size Size of the memory area in bytes.
*/
/** \def MBEDTLS_TEST_MEMORY_UNPOISON(buf, size)
*
* Undo the effect of #MBEDTLS_TEST_MEMORY_POISON.
*
* The behavior is undefined if any part of the memory area is invalid,
* or if the memory area contains a mixture of poisoned and unpoisoned parts.
*
* This is a no-op in builds without a poisoning method.
* See #MBEDTLS_TEST_MEMORY_CAN_POISON.
*
* \param buf Pointer to the beginning of the memory area to unpoison.
* \param size Size of the memory area in bytes.
*/
#if defined(MBEDTLS_TEST_MEMORY_CAN_POISON)
/** Thread-local variable used to enable memory poisoning. This is set and
* unset in the test wrappers so that calls to PSA functions from the library
* do not poison memory.
*/
extern _Thread_local unsigned int mbedtls_test_memory_poisoning_count;
/** Poison a memory area so that any attempt to read or write from it will
* cause a runtime failure.
*
* The behavior is undefined if any part of the memory area is invalid.
*/
void mbedtls_test_memory_poison(const unsigned char *ptr, size_t size);
#define MBEDTLS_TEST_MEMORY_POISON(ptr, size) \
do { \
mbedtls_test_memory_poisoning_count++; \
mbedtls_test_memory_poison(ptr, size); \
} while (0)
/** Undo the effect of mbedtls_test_memory_poison().
*
* This is a no-op if the given area is entirely valid, unpoisoned memory.
*
* The behavior is undefined if any part of the memory area is invalid,
* or if the memory area contains a mixture of poisoned and unpoisoned parts.
*/
void mbedtls_test_memory_unpoison(const unsigned char *ptr, size_t size);
#define MBEDTLS_TEST_MEMORY_UNPOISON(ptr, size) \
do { \
mbedtls_test_memory_unpoison(ptr, size); \
if (mbedtls_test_memory_poisoning_count != 0) { \
mbedtls_test_memory_poisoning_count--; \
} \
} while (0)
#else /* MBEDTLS_TEST_MEMORY_CAN_POISON */
#define MBEDTLS_TEST_MEMORY_POISON(ptr, size) ((void) (ptr), (void) (size))
#define MBEDTLS_TEST_MEMORY_UNPOISON(ptr, size) ((void) (ptr), (void) (size))
#endif /* MBEDTLS_TEST_MEMORY_CAN_POISON */
#endif /* TEST_MEMORY_H */

View File

@@ -16,6 +16,12 @@
#include <psa/crypto.h>
#endif
#include "test/psa_test_wrappers.h"
#if defined(MBEDTLS_TEST_HOOKS) && defined(MBEDTLS_PSA_CRYPTO_C) \
&& defined(MBEDTLS_PSA_COPY_CALLER_BUFFERS)
#include "test/psa_memory_poisoning_wrappers.h"
#endif
#if defined(MBEDTLS_PSA_CRYPTO_C)
/** Initialize the PSA Crypto subsystem. */

View File

@@ -0,0 +1,40 @@
/** Support for memory poisoning wrappers for PSA functions.
*
* The wrappers poison the input and output buffers of each function
* before calling it, to ensure that it does not access the buffers
* except by calling the approved buffer-copying functions.
*
* This header declares support functions. The wrappers themselves are
* decalred in the automatically generated file `test/psa_test_wrappers.h`.
*/
/*
* Copyright The Mbed TLS Contributors
* SPDX-License-Identifier: Apache-2.0 OR GPL-2.0-or-later
*/
#ifndef PSA_MEMORY_POISONING_WRAPPERS_H
#define PSA_MEMORY_POISONING_WRAPPERS_H
#include "psa/crypto.h"
#include "test/memory.h"
#if defined(MBEDTLS_TEST_HOOKS) && defined(MBEDTLS_TEST_MEMORY_CAN_POISON)
/**
* \brief Setup the memory poisoning test hooks used by
* psa_crypto_copy_input() and psa_crypto_copy_output() for
* memory poisoning.
*/
void mbedtls_poison_test_hooks_setup(void);
/**
* \brief Teardown the memory poisoning test hooks used by
* psa_crypto_copy_input() and psa_crypto_copy_output() for
* memory poisoning.
*/
void mbedtls_poison_test_hooks_teardown(void);
#endif /* MBEDTLS_TEST_HOOKS && MBEDTLS_TEST_MEMORY_CAN_POISON */
#endif /* PSA_MEMORY_POISONING_WRAPPERS_H */

View File

@@ -0,0 +1,722 @@
/* Automatically generated by generate_psa_wrappers.py, do not edit! */
/* Copyright The Mbed TLS Contributors
* SPDX-License-Identifier: Apache-2.0 OR GPL-2.0-or-later
*/
#ifndef TEST_PSA_TEST_WRAPPERS_H
#define TEST_PSA_TEST_WRAPPERS_H
#ifdef __cplusplus
extern "C" {
#endif
#include <mbedtls/build_info.h>
#if defined(MBEDTLS_PSA_CRYPTO_C) && defined(MBEDTLS_TEST_HOOKS) && \
!defined(RECORD_PSA_STATUS_COVERAGE_LOG)
#include <psa/crypto.h>
#include <test/memory.h>
#include <test/psa_crypto_helpers.h>
#include <test/psa_test_wrappers.h>
#if defined(MBEDTLS_PSA_INJECT_ENTROPY)
psa_status_t mbedtls_test_wrap_mbedtls_psa_inject_entropy(
const uint8_t *arg0_seed,
size_t arg1_seed_size);
#define mbedtls_psa_inject_entropy(arg0_seed, arg1_seed_size) \
mbedtls_test_wrap_mbedtls_psa_inject_entropy(arg0_seed, arg1_seed_size)
#endif /* defined(MBEDTLS_PSA_INJECT_ENTROPY) */
#if defined(MBEDTLS_PSA_CRYPTO_BUILTIN_KEYS)
psa_status_t mbedtls_test_wrap_mbedtls_psa_platform_get_builtin_key(
mbedtls_svc_key_id_t arg0_key_id,
psa_key_lifetime_t *arg1_lifetime,
psa_drv_slot_number_t *arg2_slot_number);
#define mbedtls_psa_platform_get_builtin_key(arg0_key_id, arg1_lifetime, arg2_slot_number) \
mbedtls_test_wrap_mbedtls_psa_platform_get_builtin_key(arg0_key_id, arg1_lifetime, arg2_slot_number)
#endif /* defined(MBEDTLS_PSA_CRYPTO_BUILTIN_KEYS) */
#if defined(MBEDTLS_PSA_CRYPTO_SE_C)
psa_status_t mbedtls_test_wrap_mbedtls_psa_register_se_key(
const psa_key_attributes_t *arg0_attributes);
#define mbedtls_psa_register_se_key(arg0_attributes) \
mbedtls_test_wrap_mbedtls_psa_register_se_key(arg0_attributes)
#endif /* defined(MBEDTLS_PSA_CRYPTO_SE_C) */
psa_status_t mbedtls_test_wrap_psa_aead_abort(
psa_aead_operation_t *arg0_operation);
#define psa_aead_abort(arg0_operation) \
mbedtls_test_wrap_psa_aead_abort(arg0_operation)
psa_status_t mbedtls_test_wrap_psa_aead_decrypt(
mbedtls_svc_key_id_t arg0_key,
psa_algorithm_t arg1_alg,
const uint8_t *arg2_nonce,
size_t arg3_nonce_length,
const uint8_t *arg4_additional_data,
size_t arg5_additional_data_length,
const uint8_t *arg6_ciphertext,
size_t arg7_ciphertext_length,
uint8_t *arg8_plaintext,
size_t arg9_plaintext_size,
size_t *arg10_plaintext_length);
#define 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) \
mbedtls_test_wrap_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)
psa_status_t mbedtls_test_wrap_psa_aead_decrypt_setup(
psa_aead_operation_t *arg0_operation,
mbedtls_svc_key_id_t arg1_key,
psa_algorithm_t arg2_alg);
#define psa_aead_decrypt_setup(arg0_operation, arg1_key, arg2_alg) \
mbedtls_test_wrap_psa_aead_decrypt_setup(arg0_operation, arg1_key, arg2_alg)
psa_status_t mbedtls_test_wrap_psa_aead_encrypt(
mbedtls_svc_key_id_t arg0_key,
psa_algorithm_t arg1_alg,
const uint8_t *arg2_nonce,
size_t arg3_nonce_length,
const uint8_t *arg4_additional_data,
size_t arg5_additional_data_length,
const uint8_t *arg6_plaintext,
size_t arg7_plaintext_length,
uint8_t *arg8_ciphertext,
size_t arg9_ciphertext_size,
size_t *arg10_ciphertext_length);
#define 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) \
mbedtls_test_wrap_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)
psa_status_t mbedtls_test_wrap_psa_aead_encrypt_setup(
psa_aead_operation_t *arg0_operation,
mbedtls_svc_key_id_t arg1_key,
psa_algorithm_t arg2_alg);
#define psa_aead_encrypt_setup(arg0_operation, arg1_key, arg2_alg) \
mbedtls_test_wrap_psa_aead_encrypt_setup(arg0_operation, arg1_key, arg2_alg)
psa_status_t mbedtls_test_wrap_psa_aead_finish(
psa_aead_operation_t *arg0_operation,
uint8_t *arg1_ciphertext,
size_t arg2_ciphertext_size,
size_t *arg3_ciphertext_length,
uint8_t *arg4_tag,
size_t arg5_tag_size,
size_t *arg6_tag_length);
#define psa_aead_finish(arg0_operation, arg1_ciphertext, arg2_ciphertext_size, arg3_ciphertext_length, arg4_tag, arg5_tag_size, arg6_tag_length) \
mbedtls_test_wrap_psa_aead_finish(arg0_operation, arg1_ciphertext, arg2_ciphertext_size, arg3_ciphertext_length, arg4_tag, arg5_tag_size, arg6_tag_length)
psa_status_t mbedtls_test_wrap_psa_aead_generate_nonce(
psa_aead_operation_t *arg0_operation,
uint8_t *arg1_nonce,
size_t arg2_nonce_size,
size_t *arg3_nonce_length);
#define psa_aead_generate_nonce(arg0_operation, arg1_nonce, arg2_nonce_size, arg3_nonce_length) \
mbedtls_test_wrap_psa_aead_generate_nonce(arg0_operation, arg1_nonce, arg2_nonce_size, arg3_nonce_length)
psa_status_t mbedtls_test_wrap_psa_aead_set_lengths(
psa_aead_operation_t *arg0_operation,
size_t arg1_ad_length,
size_t arg2_plaintext_length);
#define psa_aead_set_lengths(arg0_operation, arg1_ad_length, arg2_plaintext_length) \
mbedtls_test_wrap_psa_aead_set_lengths(arg0_operation, arg1_ad_length, arg2_plaintext_length)
psa_status_t mbedtls_test_wrap_psa_aead_set_nonce(
psa_aead_operation_t *arg0_operation,
const uint8_t *arg1_nonce,
size_t arg2_nonce_length);
#define psa_aead_set_nonce(arg0_operation, arg1_nonce, arg2_nonce_length) \
mbedtls_test_wrap_psa_aead_set_nonce(arg0_operation, arg1_nonce, arg2_nonce_length)
psa_status_t mbedtls_test_wrap_psa_aead_update(
psa_aead_operation_t *arg0_operation,
const uint8_t *arg1_input,
size_t arg2_input_length,
uint8_t *arg3_output,
size_t arg4_output_size,
size_t *arg5_output_length);
#define psa_aead_update(arg0_operation, arg1_input, arg2_input_length, arg3_output, arg4_output_size, arg5_output_length) \
mbedtls_test_wrap_psa_aead_update(arg0_operation, arg1_input, arg2_input_length, arg3_output, arg4_output_size, arg5_output_length)
psa_status_t mbedtls_test_wrap_psa_aead_update_ad(
psa_aead_operation_t *arg0_operation,
const uint8_t *arg1_input,
size_t arg2_input_length);
#define psa_aead_update_ad(arg0_operation, arg1_input, arg2_input_length) \
mbedtls_test_wrap_psa_aead_update_ad(arg0_operation, arg1_input, arg2_input_length)
psa_status_t mbedtls_test_wrap_psa_aead_verify(
psa_aead_operation_t *arg0_operation,
uint8_t *arg1_plaintext,
size_t arg2_plaintext_size,
size_t *arg3_plaintext_length,
const uint8_t *arg4_tag,
size_t arg5_tag_length);
#define psa_aead_verify(arg0_operation, arg1_plaintext, arg2_plaintext_size, arg3_plaintext_length, arg4_tag, arg5_tag_length) \
mbedtls_test_wrap_psa_aead_verify(arg0_operation, arg1_plaintext, arg2_plaintext_size, arg3_plaintext_length, arg4_tag, arg5_tag_length)
psa_status_t mbedtls_test_wrap_psa_asymmetric_decrypt(
mbedtls_svc_key_id_t arg0_key,
psa_algorithm_t arg1_alg,
const uint8_t *arg2_input,
size_t arg3_input_length,
const uint8_t *arg4_salt,
size_t arg5_salt_length,
uint8_t *arg6_output,
size_t arg7_output_size,
size_t *arg8_output_length);
#define 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) \
mbedtls_test_wrap_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)
psa_status_t mbedtls_test_wrap_psa_asymmetric_encrypt(
mbedtls_svc_key_id_t arg0_key,
psa_algorithm_t arg1_alg,
const uint8_t *arg2_input,
size_t arg3_input_length,
const uint8_t *arg4_salt,
size_t arg5_salt_length,
uint8_t *arg6_output,
size_t arg7_output_size,
size_t *arg8_output_length);
#define 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) \
mbedtls_test_wrap_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)
psa_status_t mbedtls_test_wrap_psa_cipher_abort(
psa_cipher_operation_t *arg0_operation);
#define psa_cipher_abort(arg0_operation) \
mbedtls_test_wrap_psa_cipher_abort(arg0_operation)
psa_status_t mbedtls_test_wrap_psa_cipher_decrypt(
mbedtls_svc_key_id_t arg0_key,
psa_algorithm_t arg1_alg,
const uint8_t *arg2_input,
size_t arg3_input_length,
uint8_t *arg4_output,
size_t arg5_output_size,
size_t *arg6_output_length);
#define psa_cipher_decrypt(arg0_key, arg1_alg, arg2_input, arg3_input_length, arg4_output, arg5_output_size, arg6_output_length) \
mbedtls_test_wrap_psa_cipher_decrypt(arg0_key, arg1_alg, arg2_input, arg3_input_length, arg4_output, arg5_output_size, arg6_output_length)
psa_status_t mbedtls_test_wrap_psa_cipher_decrypt_setup(
psa_cipher_operation_t *arg0_operation,
mbedtls_svc_key_id_t arg1_key,
psa_algorithm_t arg2_alg);
#define psa_cipher_decrypt_setup(arg0_operation, arg1_key, arg2_alg) \
mbedtls_test_wrap_psa_cipher_decrypt_setup(arg0_operation, arg1_key, arg2_alg)
psa_status_t mbedtls_test_wrap_psa_cipher_encrypt(
mbedtls_svc_key_id_t arg0_key,
psa_algorithm_t arg1_alg,
const uint8_t *arg2_input,
size_t arg3_input_length,
uint8_t *arg4_output,
size_t arg5_output_size,
size_t *arg6_output_length);
#define psa_cipher_encrypt(arg0_key, arg1_alg, arg2_input, arg3_input_length, arg4_output, arg5_output_size, arg6_output_length) \
mbedtls_test_wrap_psa_cipher_encrypt(arg0_key, arg1_alg, arg2_input, arg3_input_length, arg4_output, arg5_output_size, arg6_output_length)
psa_status_t mbedtls_test_wrap_psa_cipher_encrypt_setup(
psa_cipher_operation_t *arg0_operation,
mbedtls_svc_key_id_t arg1_key,
psa_algorithm_t arg2_alg);
#define psa_cipher_encrypt_setup(arg0_operation, arg1_key, arg2_alg) \
mbedtls_test_wrap_psa_cipher_encrypt_setup(arg0_operation, arg1_key, arg2_alg)
psa_status_t mbedtls_test_wrap_psa_cipher_finish(
psa_cipher_operation_t *arg0_operation,
uint8_t *arg1_output,
size_t arg2_output_size,
size_t *arg3_output_length);
#define psa_cipher_finish(arg0_operation, arg1_output, arg2_output_size, arg3_output_length) \
mbedtls_test_wrap_psa_cipher_finish(arg0_operation, arg1_output, arg2_output_size, arg3_output_length)
psa_status_t mbedtls_test_wrap_psa_cipher_generate_iv(
psa_cipher_operation_t *arg0_operation,
uint8_t *arg1_iv,
size_t arg2_iv_size,
size_t *arg3_iv_length);
#define psa_cipher_generate_iv(arg0_operation, arg1_iv, arg2_iv_size, arg3_iv_length) \
mbedtls_test_wrap_psa_cipher_generate_iv(arg0_operation, arg1_iv, arg2_iv_size, arg3_iv_length)
psa_status_t mbedtls_test_wrap_psa_cipher_set_iv(
psa_cipher_operation_t *arg0_operation,
const uint8_t *arg1_iv,
size_t arg2_iv_length);
#define psa_cipher_set_iv(arg0_operation, arg1_iv, arg2_iv_length) \
mbedtls_test_wrap_psa_cipher_set_iv(arg0_operation, arg1_iv, arg2_iv_length)
psa_status_t mbedtls_test_wrap_psa_cipher_update(
psa_cipher_operation_t *arg0_operation,
const uint8_t *arg1_input,
size_t arg2_input_length,
uint8_t *arg3_output,
size_t arg4_output_size,
size_t *arg5_output_length);
#define psa_cipher_update(arg0_operation, arg1_input, arg2_input_length, arg3_output, arg4_output_size, arg5_output_length) \
mbedtls_test_wrap_psa_cipher_update(arg0_operation, arg1_input, arg2_input_length, arg3_output, arg4_output_size, arg5_output_length)
psa_status_t mbedtls_test_wrap_psa_copy_key(
mbedtls_svc_key_id_t arg0_source_key,
const psa_key_attributes_t *arg1_attributes,
mbedtls_svc_key_id_t *arg2_target_key);
#define psa_copy_key(arg0_source_key, arg1_attributes, arg2_target_key) \
mbedtls_test_wrap_psa_copy_key(arg0_source_key, arg1_attributes, arg2_target_key)
psa_status_t mbedtls_test_wrap_psa_crypto_driver_pake_get_cipher_suite(
const psa_crypto_driver_pake_inputs_t *arg0_inputs,
psa_pake_cipher_suite_t *arg1_cipher_suite);
#define psa_crypto_driver_pake_get_cipher_suite(arg0_inputs, arg1_cipher_suite) \
mbedtls_test_wrap_psa_crypto_driver_pake_get_cipher_suite(arg0_inputs, arg1_cipher_suite)
psa_status_t mbedtls_test_wrap_psa_crypto_driver_pake_get_password(
const psa_crypto_driver_pake_inputs_t *arg0_inputs,
uint8_t *arg1_buffer,
size_t arg2_buffer_size,
size_t *arg3_buffer_length);
#define psa_crypto_driver_pake_get_password(arg0_inputs, arg1_buffer, arg2_buffer_size, arg3_buffer_length) \
mbedtls_test_wrap_psa_crypto_driver_pake_get_password(arg0_inputs, arg1_buffer, arg2_buffer_size, arg3_buffer_length)
psa_status_t mbedtls_test_wrap_psa_crypto_driver_pake_get_password_len(
const psa_crypto_driver_pake_inputs_t *arg0_inputs,
size_t *arg1_password_len);
#define psa_crypto_driver_pake_get_password_len(arg0_inputs, arg1_password_len) \
mbedtls_test_wrap_psa_crypto_driver_pake_get_password_len(arg0_inputs, arg1_password_len)
psa_status_t mbedtls_test_wrap_psa_crypto_driver_pake_get_peer(
const psa_crypto_driver_pake_inputs_t *arg0_inputs,
uint8_t *arg1_peer_id,
size_t arg2_peer_id_size,
size_t *arg3_peer_id_length);
#define psa_crypto_driver_pake_get_peer(arg0_inputs, arg1_peer_id, arg2_peer_id_size, arg3_peer_id_length) \
mbedtls_test_wrap_psa_crypto_driver_pake_get_peer(arg0_inputs, arg1_peer_id, arg2_peer_id_size, arg3_peer_id_length)
psa_status_t mbedtls_test_wrap_psa_crypto_driver_pake_get_peer_len(
const psa_crypto_driver_pake_inputs_t *arg0_inputs,
size_t *arg1_peer_len);
#define psa_crypto_driver_pake_get_peer_len(arg0_inputs, arg1_peer_len) \
mbedtls_test_wrap_psa_crypto_driver_pake_get_peer_len(arg0_inputs, arg1_peer_len)
psa_status_t mbedtls_test_wrap_psa_crypto_driver_pake_get_user(
const psa_crypto_driver_pake_inputs_t *arg0_inputs,
uint8_t *arg1_user_id,
size_t arg2_user_id_size,
size_t *arg3_user_id_len);
#define psa_crypto_driver_pake_get_user(arg0_inputs, arg1_user_id, arg2_user_id_size, arg3_user_id_len) \
mbedtls_test_wrap_psa_crypto_driver_pake_get_user(arg0_inputs, arg1_user_id, arg2_user_id_size, arg3_user_id_len)
psa_status_t mbedtls_test_wrap_psa_crypto_driver_pake_get_user_len(
const psa_crypto_driver_pake_inputs_t *arg0_inputs,
size_t *arg1_user_len);
#define psa_crypto_driver_pake_get_user_len(arg0_inputs, arg1_user_len) \
mbedtls_test_wrap_psa_crypto_driver_pake_get_user_len(arg0_inputs, arg1_user_len)
psa_status_t mbedtls_test_wrap_psa_crypto_init(void);
#define psa_crypto_init() \
mbedtls_test_wrap_psa_crypto_init()
psa_status_t mbedtls_test_wrap_psa_destroy_key(
mbedtls_svc_key_id_t arg0_key);
#define psa_destroy_key(arg0_key) \
mbedtls_test_wrap_psa_destroy_key(arg0_key)
psa_status_t mbedtls_test_wrap_psa_export_key(
mbedtls_svc_key_id_t arg0_key,
uint8_t *arg1_data,
size_t arg2_data_size,
size_t *arg3_data_length);
#define psa_export_key(arg0_key, arg1_data, arg2_data_size, arg3_data_length) \
mbedtls_test_wrap_psa_export_key(arg0_key, arg1_data, arg2_data_size, arg3_data_length)
psa_status_t mbedtls_test_wrap_psa_export_public_key(
mbedtls_svc_key_id_t arg0_key,
uint8_t *arg1_data,
size_t arg2_data_size,
size_t *arg3_data_length);
#define psa_export_public_key(arg0_key, arg1_data, arg2_data_size, arg3_data_length) \
mbedtls_test_wrap_psa_export_public_key(arg0_key, arg1_data, arg2_data_size, arg3_data_length)
psa_status_t mbedtls_test_wrap_psa_generate_key(
const psa_key_attributes_t *arg0_attributes,
mbedtls_svc_key_id_t *arg1_key);
#define psa_generate_key(arg0_attributes, arg1_key) \
mbedtls_test_wrap_psa_generate_key(arg0_attributes, arg1_key)
psa_status_t mbedtls_test_wrap_psa_generate_random(
uint8_t *arg0_output,
size_t arg1_output_size);
#define psa_generate_random(arg0_output, arg1_output_size) \
mbedtls_test_wrap_psa_generate_random(arg0_output, arg1_output_size)
psa_status_t mbedtls_test_wrap_psa_get_key_attributes(
mbedtls_svc_key_id_t arg0_key,
psa_key_attributes_t *arg1_attributes);
#define psa_get_key_attributes(arg0_key, arg1_attributes) \
mbedtls_test_wrap_psa_get_key_attributes(arg0_key, arg1_attributes)
psa_status_t mbedtls_test_wrap_psa_hash_abort(
psa_hash_operation_t *arg0_operation);
#define psa_hash_abort(arg0_operation) \
mbedtls_test_wrap_psa_hash_abort(arg0_operation)
psa_status_t mbedtls_test_wrap_psa_hash_clone(
const psa_hash_operation_t *arg0_source_operation,
psa_hash_operation_t *arg1_target_operation);
#define psa_hash_clone(arg0_source_operation, arg1_target_operation) \
mbedtls_test_wrap_psa_hash_clone(arg0_source_operation, arg1_target_operation)
psa_status_t mbedtls_test_wrap_psa_hash_compare(
psa_algorithm_t arg0_alg,
const uint8_t *arg1_input,
size_t arg2_input_length,
const uint8_t *arg3_hash,
size_t arg4_hash_length);
#define psa_hash_compare(arg0_alg, arg1_input, arg2_input_length, arg3_hash, arg4_hash_length) \
mbedtls_test_wrap_psa_hash_compare(arg0_alg, arg1_input, arg2_input_length, arg3_hash, arg4_hash_length)
psa_status_t mbedtls_test_wrap_psa_hash_compute(
psa_algorithm_t arg0_alg,
const uint8_t *arg1_input,
size_t arg2_input_length,
uint8_t *arg3_hash,
size_t arg4_hash_size,
size_t *arg5_hash_length);
#define psa_hash_compute(arg0_alg, arg1_input, arg2_input_length, arg3_hash, arg4_hash_size, arg5_hash_length) \
mbedtls_test_wrap_psa_hash_compute(arg0_alg, arg1_input, arg2_input_length, arg3_hash, arg4_hash_size, arg5_hash_length)
psa_status_t mbedtls_test_wrap_psa_hash_finish(
psa_hash_operation_t *arg0_operation,
uint8_t *arg1_hash,
size_t arg2_hash_size,
size_t *arg3_hash_length);
#define psa_hash_finish(arg0_operation, arg1_hash, arg2_hash_size, arg3_hash_length) \
mbedtls_test_wrap_psa_hash_finish(arg0_operation, arg1_hash, arg2_hash_size, arg3_hash_length)
psa_status_t mbedtls_test_wrap_psa_hash_setup(
psa_hash_operation_t *arg0_operation,
psa_algorithm_t arg1_alg);
#define psa_hash_setup(arg0_operation, arg1_alg) \
mbedtls_test_wrap_psa_hash_setup(arg0_operation, arg1_alg)
psa_status_t mbedtls_test_wrap_psa_hash_update(
psa_hash_operation_t *arg0_operation,
const uint8_t *arg1_input,
size_t arg2_input_length);
#define psa_hash_update(arg0_operation, arg1_input, arg2_input_length) \
mbedtls_test_wrap_psa_hash_update(arg0_operation, arg1_input, arg2_input_length)
psa_status_t mbedtls_test_wrap_psa_hash_verify(
psa_hash_operation_t *arg0_operation,
const uint8_t *arg1_hash,
size_t arg2_hash_length);
#define psa_hash_verify(arg0_operation, arg1_hash, arg2_hash_length) \
mbedtls_test_wrap_psa_hash_verify(arg0_operation, arg1_hash, arg2_hash_length)
psa_status_t mbedtls_test_wrap_psa_import_key(
const psa_key_attributes_t *arg0_attributes,
const uint8_t *arg1_data,
size_t arg2_data_length,
mbedtls_svc_key_id_t *arg3_key);
#define psa_import_key(arg0_attributes, arg1_data, arg2_data_length, arg3_key) \
mbedtls_test_wrap_psa_import_key(arg0_attributes, arg1_data, arg2_data_length, arg3_key)
psa_status_t mbedtls_test_wrap_psa_key_derivation_abort(
psa_key_derivation_operation_t *arg0_operation);
#define psa_key_derivation_abort(arg0_operation) \
mbedtls_test_wrap_psa_key_derivation_abort(arg0_operation)
psa_status_t mbedtls_test_wrap_psa_key_derivation_get_capacity(
const psa_key_derivation_operation_t *arg0_operation,
size_t *arg1_capacity);
#define psa_key_derivation_get_capacity(arg0_operation, arg1_capacity) \
mbedtls_test_wrap_psa_key_derivation_get_capacity(arg0_operation, arg1_capacity)
psa_status_t mbedtls_test_wrap_psa_key_derivation_input_bytes(
psa_key_derivation_operation_t *arg0_operation,
psa_key_derivation_step_t arg1_step,
const uint8_t *arg2_data,
size_t arg3_data_length);
#define psa_key_derivation_input_bytes(arg0_operation, arg1_step, arg2_data, arg3_data_length) \
mbedtls_test_wrap_psa_key_derivation_input_bytes(arg0_operation, arg1_step, arg2_data, arg3_data_length)
psa_status_t mbedtls_test_wrap_psa_key_derivation_input_integer(
psa_key_derivation_operation_t *arg0_operation,
psa_key_derivation_step_t arg1_step,
uint64_t arg2_value);
#define psa_key_derivation_input_integer(arg0_operation, arg1_step, arg2_value) \
mbedtls_test_wrap_psa_key_derivation_input_integer(arg0_operation, arg1_step, arg2_value)
psa_status_t mbedtls_test_wrap_psa_key_derivation_input_key(
psa_key_derivation_operation_t *arg0_operation,
psa_key_derivation_step_t arg1_step,
mbedtls_svc_key_id_t arg2_key);
#define psa_key_derivation_input_key(arg0_operation, arg1_step, arg2_key) \
mbedtls_test_wrap_psa_key_derivation_input_key(arg0_operation, arg1_step, arg2_key)
psa_status_t mbedtls_test_wrap_psa_key_derivation_key_agreement(
psa_key_derivation_operation_t *arg0_operation,
psa_key_derivation_step_t arg1_step,
mbedtls_svc_key_id_t arg2_private_key,
const uint8_t *arg3_peer_key,
size_t arg4_peer_key_length);
#define psa_key_derivation_key_agreement(arg0_operation, arg1_step, arg2_private_key, arg3_peer_key, arg4_peer_key_length) \
mbedtls_test_wrap_psa_key_derivation_key_agreement(arg0_operation, arg1_step, arg2_private_key, arg3_peer_key, arg4_peer_key_length)
psa_status_t mbedtls_test_wrap_psa_key_derivation_output_bytes(
psa_key_derivation_operation_t *arg0_operation,
uint8_t *arg1_output,
size_t arg2_output_length);
#define psa_key_derivation_output_bytes(arg0_operation, arg1_output, arg2_output_length) \
mbedtls_test_wrap_psa_key_derivation_output_bytes(arg0_operation, arg1_output, arg2_output_length)
psa_status_t mbedtls_test_wrap_psa_key_derivation_output_key(
const psa_key_attributes_t *arg0_attributes,
psa_key_derivation_operation_t *arg1_operation,
mbedtls_svc_key_id_t *arg2_key);
#define psa_key_derivation_output_key(arg0_attributes, arg1_operation, arg2_key) \
mbedtls_test_wrap_psa_key_derivation_output_key(arg0_attributes, arg1_operation, arg2_key)
psa_status_t mbedtls_test_wrap_psa_key_derivation_set_capacity(
psa_key_derivation_operation_t *arg0_operation,
size_t arg1_capacity);
#define psa_key_derivation_set_capacity(arg0_operation, arg1_capacity) \
mbedtls_test_wrap_psa_key_derivation_set_capacity(arg0_operation, arg1_capacity)
psa_status_t mbedtls_test_wrap_psa_key_derivation_setup(
psa_key_derivation_operation_t *arg0_operation,
psa_algorithm_t arg1_alg);
#define psa_key_derivation_setup(arg0_operation, arg1_alg) \
mbedtls_test_wrap_psa_key_derivation_setup(arg0_operation, arg1_alg)
psa_status_t mbedtls_test_wrap_psa_mac_abort(
psa_mac_operation_t *arg0_operation);
#define psa_mac_abort(arg0_operation) \
mbedtls_test_wrap_psa_mac_abort(arg0_operation)
psa_status_t mbedtls_test_wrap_psa_mac_compute(
mbedtls_svc_key_id_t arg0_key,
psa_algorithm_t arg1_alg,
const uint8_t *arg2_input,
size_t arg3_input_length,
uint8_t *arg4_mac,
size_t arg5_mac_size,
size_t *arg6_mac_length);
#define psa_mac_compute(arg0_key, arg1_alg, arg2_input, arg3_input_length, arg4_mac, arg5_mac_size, arg6_mac_length) \
mbedtls_test_wrap_psa_mac_compute(arg0_key, arg1_alg, arg2_input, arg3_input_length, arg4_mac, arg5_mac_size, arg6_mac_length)
psa_status_t mbedtls_test_wrap_psa_mac_sign_finish(
psa_mac_operation_t *arg0_operation,
uint8_t *arg1_mac,
size_t arg2_mac_size,
size_t *arg3_mac_length);
#define psa_mac_sign_finish(arg0_operation, arg1_mac, arg2_mac_size, arg3_mac_length) \
mbedtls_test_wrap_psa_mac_sign_finish(arg0_operation, arg1_mac, arg2_mac_size, arg3_mac_length)
psa_status_t mbedtls_test_wrap_psa_mac_sign_setup(
psa_mac_operation_t *arg0_operation,
mbedtls_svc_key_id_t arg1_key,
psa_algorithm_t arg2_alg);
#define psa_mac_sign_setup(arg0_operation, arg1_key, arg2_alg) \
mbedtls_test_wrap_psa_mac_sign_setup(arg0_operation, arg1_key, arg2_alg)
psa_status_t mbedtls_test_wrap_psa_mac_update(
psa_mac_operation_t *arg0_operation,
const uint8_t *arg1_input,
size_t arg2_input_length);
#define psa_mac_update(arg0_operation, arg1_input, arg2_input_length) \
mbedtls_test_wrap_psa_mac_update(arg0_operation, arg1_input, arg2_input_length)
psa_status_t mbedtls_test_wrap_psa_mac_verify(
mbedtls_svc_key_id_t arg0_key,
psa_algorithm_t arg1_alg,
const uint8_t *arg2_input,
size_t arg3_input_length,
const uint8_t *arg4_mac,
size_t arg5_mac_length);
#define psa_mac_verify(arg0_key, arg1_alg, arg2_input, arg3_input_length, arg4_mac, arg5_mac_length) \
mbedtls_test_wrap_psa_mac_verify(arg0_key, arg1_alg, arg2_input, arg3_input_length, arg4_mac, arg5_mac_length)
psa_status_t mbedtls_test_wrap_psa_mac_verify_finish(
psa_mac_operation_t *arg0_operation,
const uint8_t *arg1_mac,
size_t arg2_mac_length);
#define psa_mac_verify_finish(arg0_operation, arg1_mac, arg2_mac_length) \
mbedtls_test_wrap_psa_mac_verify_finish(arg0_operation, arg1_mac, arg2_mac_length)
psa_status_t mbedtls_test_wrap_psa_mac_verify_setup(
psa_mac_operation_t *arg0_operation,
mbedtls_svc_key_id_t arg1_key,
psa_algorithm_t arg2_alg);
#define psa_mac_verify_setup(arg0_operation, arg1_key, arg2_alg) \
mbedtls_test_wrap_psa_mac_verify_setup(arg0_operation, arg1_key, arg2_alg)
psa_status_t mbedtls_test_wrap_psa_pake_abort(
psa_pake_operation_t *arg0_operation);
#define psa_pake_abort(arg0_operation) \
mbedtls_test_wrap_psa_pake_abort(arg0_operation)
psa_status_t mbedtls_test_wrap_psa_pake_get_implicit_key(
psa_pake_operation_t *arg0_operation,
psa_key_derivation_operation_t *arg1_output);
#define psa_pake_get_implicit_key(arg0_operation, arg1_output) \
mbedtls_test_wrap_psa_pake_get_implicit_key(arg0_operation, arg1_output)
psa_status_t mbedtls_test_wrap_psa_pake_input(
psa_pake_operation_t *arg0_operation,
psa_pake_step_t arg1_step,
const uint8_t *arg2_input,
size_t arg3_input_length);
#define psa_pake_input(arg0_operation, arg1_step, arg2_input, arg3_input_length) \
mbedtls_test_wrap_psa_pake_input(arg0_operation, arg1_step, arg2_input, arg3_input_length)
psa_status_t mbedtls_test_wrap_psa_pake_output(
psa_pake_operation_t *arg0_operation,
psa_pake_step_t arg1_step,
uint8_t *arg2_output,
size_t arg3_output_size,
size_t *arg4_output_length);
#define psa_pake_output(arg0_operation, arg1_step, arg2_output, arg3_output_size, arg4_output_length) \
mbedtls_test_wrap_psa_pake_output(arg0_operation, arg1_step, arg2_output, arg3_output_size, arg4_output_length)
psa_status_t mbedtls_test_wrap_psa_pake_set_password_key(
psa_pake_operation_t *arg0_operation,
mbedtls_svc_key_id_t arg1_password);
#define psa_pake_set_password_key(arg0_operation, arg1_password) \
mbedtls_test_wrap_psa_pake_set_password_key(arg0_operation, arg1_password)
psa_status_t mbedtls_test_wrap_psa_pake_set_peer(
psa_pake_operation_t *arg0_operation,
const uint8_t *arg1_peer_id,
size_t arg2_peer_id_len);
#define psa_pake_set_peer(arg0_operation, arg1_peer_id, arg2_peer_id_len) \
mbedtls_test_wrap_psa_pake_set_peer(arg0_operation, arg1_peer_id, arg2_peer_id_len)
psa_status_t mbedtls_test_wrap_psa_pake_set_role(
psa_pake_operation_t *arg0_operation,
psa_pake_role_t arg1_role);
#define psa_pake_set_role(arg0_operation, arg1_role) \
mbedtls_test_wrap_psa_pake_set_role(arg0_operation, arg1_role)
psa_status_t mbedtls_test_wrap_psa_pake_set_user(
psa_pake_operation_t *arg0_operation,
const uint8_t *arg1_user_id,
size_t arg2_user_id_len);
#define psa_pake_set_user(arg0_operation, arg1_user_id, arg2_user_id_len) \
mbedtls_test_wrap_psa_pake_set_user(arg0_operation, arg1_user_id, arg2_user_id_len)
psa_status_t mbedtls_test_wrap_psa_pake_setup(
psa_pake_operation_t *arg0_operation,
const psa_pake_cipher_suite_t *arg1_cipher_suite);
#define psa_pake_setup(arg0_operation, arg1_cipher_suite) \
mbedtls_test_wrap_psa_pake_setup(arg0_operation, arg1_cipher_suite)
psa_status_t mbedtls_test_wrap_psa_purge_key(
mbedtls_svc_key_id_t arg0_key);
#define psa_purge_key(arg0_key) \
mbedtls_test_wrap_psa_purge_key(arg0_key)
psa_status_t mbedtls_test_wrap_psa_raw_key_agreement(
psa_algorithm_t arg0_alg,
mbedtls_svc_key_id_t arg1_private_key,
const uint8_t *arg2_peer_key,
size_t arg3_peer_key_length,
uint8_t *arg4_output,
size_t arg5_output_size,
size_t *arg6_output_length);
#define psa_raw_key_agreement(arg0_alg, arg1_private_key, arg2_peer_key, arg3_peer_key_length, arg4_output, arg5_output_size, arg6_output_length) \
mbedtls_test_wrap_psa_raw_key_agreement(arg0_alg, arg1_private_key, arg2_peer_key, arg3_peer_key_length, arg4_output, arg5_output_size, arg6_output_length)
psa_status_t mbedtls_test_wrap_psa_sign_hash(
mbedtls_svc_key_id_t arg0_key,
psa_algorithm_t arg1_alg,
const uint8_t *arg2_hash,
size_t arg3_hash_length,
uint8_t *arg4_signature,
size_t arg5_signature_size,
size_t *arg6_signature_length);
#define psa_sign_hash(arg0_key, arg1_alg, arg2_hash, arg3_hash_length, arg4_signature, arg5_signature_size, arg6_signature_length) \
mbedtls_test_wrap_psa_sign_hash(arg0_key, arg1_alg, arg2_hash, arg3_hash_length, arg4_signature, arg5_signature_size, arg6_signature_length)
psa_status_t mbedtls_test_wrap_psa_sign_hash_abort(
psa_sign_hash_interruptible_operation_t *arg0_operation);
#define psa_sign_hash_abort(arg0_operation) \
mbedtls_test_wrap_psa_sign_hash_abort(arg0_operation)
psa_status_t mbedtls_test_wrap_psa_sign_hash_complete(
psa_sign_hash_interruptible_operation_t *arg0_operation,
uint8_t *arg1_signature,
size_t arg2_signature_size,
size_t *arg3_signature_length);
#define psa_sign_hash_complete(arg0_operation, arg1_signature, arg2_signature_size, arg3_signature_length) \
mbedtls_test_wrap_psa_sign_hash_complete(arg0_operation, arg1_signature, arg2_signature_size, arg3_signature_length)
psa_status_t mbedtls_test_wrap_psa_sign_hash_start(
psa_sign_hash_interruptible_operation_t *arg0_operation,
mbedtls_svc_key_id_t arg1_key,
psa_algorithm_t arg2_alg,
const uint8_t *arg3_hash,
size_t arg4_hash_length);
#define psa_sign_hash_start(arg0_operation, arg1_key, arg2_alg, arg3_hash, arg4_hash_length) \
mbedtls_test_wrap_psa_sign_hash_start(arg0_operation, arg1_key, arg2_alg, arg3_hash, arg4_hash_length)
psa_status_t mbedtls_test_wrap_psa_sign_message(
mbedtls_svc_key_id_t arg0_key,
psa_algorithm_t arg1_alg,
const uint8_t *arg2_input,
size_t arg3_input_length,
uint8_t *arg4_signature,
size_t arg5_signature_size,
size_t *arg6_signature_length);
#define psa_sign_message(arg0_key, arg1_alg, arg2_input, arg3_input_length, arg4_signature, arg5_signature_size, arg6_signature_length) \
mbedtls_test_wrap_psa_sign_message(arg0_key, arg1_alg, arg2_input, arg3_input_length, arg4_signature, arg5_signature_size, arg6_signature_length)
psa_status_t mbedtls_test_wrap_psa_verify_hash(
mbedtls_svc_key_id_t arg0_key,
psa_algorithm_t arg1_alg,
const uint8_t *arg2_hash,
size_t arg3_hash_length,
const uint8_t *arg4_signature,
size_t arg5_signature_length);
#define psa_verify_hash(arg0_key, arg1_alg, arg2_hash, arg3_hash_length, arg4_signature, arg5_signature_length) \
mbedtls_test_wrap_psa_verify_hash(arg0_key, arg1_alg, arg2_hash, arg3_hash_length, arg4_signature, arg5_signature_length)
psa_status_t mbedtls_test_wrap_psa_verify_hash_abort(
psa_verify_hash_interruptible_operation_t *arg0_operation);
#define psa_verify_hash_abort(arg0_operation) \
mbedtls_test_wrap_psa_verify_hash_abort(arg0_operation)
psa_status_t mbedtls_test_wrap_psa_verify_hash_complete(
psa_verify_hash_interruptible_operation_t *arg0_operation);
#define psa_verify_hash_complete(arg0_operation) \
mbedtls_test_wrap_psa_verify_hash_complete(arg0_operation)
psa_status_t mbedtls_test_wrap_psa_verify_hash_start(
psa_verify_hash_interruptible_operation_t *arg0_operation,
mbedtls_svc_key_id_t arg1_key,
psa_algorithm_t arg2_alg,
const uint8_t *arg3_hash,
size_t arg4_hash_length,
const uint8_t *arg5_signature,
size_t arg6_signature_length);
#define psa_verify_hash_start(arg0_operation, arg1_key, arg2_alg, arg3_hash, arg4_hash_length, arg5_signature, arg6_signature_length) \
mbedtls_test_wrap_psa_verify_hash_start(arg0_operation, arg1_key, arg2_alg, arg3_hash, arg4_hash_length, arg5_signature, arg6_signature_length)
psa_status_t mbedtls_test_wrap_psa_verify_message(
mbedtls_svc_key_id_t arg0_key,
psa_algorithm_t arg1_alg,
const uint8_t *arg2_input,
size_t arg3_input_length,
const uint8_t *arg4_signature,
size_t arg5_signature_length);
#define psa_verify_message(arg0_key, arg1_alg, arg2_input, arg3_input_length, arg4_signature, arg5_signature_length) \
mbedtls_test_wrap_psa_verify_message(arg0_key, arg1_alg, arg2_input, arg3_input_length, arg4_signature, arg5_signature_length)
#endif /* defined(MBEDTLS_PSA_CRYPTO_C) && defined(MBEDTLS_TEST_HOOKS) && \
!defined(RECORD_PSA_STATUS_COVERAGE_LOG) */
#ifdef __cplusplus
}
#endif
#endif /* TEST_PSA_TEST_WRAPPERS_H */
/* End of automatically generated file. */

View File

@@ -1050,7 +1050,7 @@ component_check_test_dependencies () {
grep 'depends_on' \
tests/suites/test_suite_psa*.data tests/suites/test_suite_psa*.function |
grep -Eo '!?MBEDTLS_[^: ]*' |
grep -v MBEDTLS_PSA_ |
grep -v -e MBEDTLS_PSA_ -e MBEDTLS_TEST_ |
sort -u > $found
# Expected ones with justification - keep in sorted order by ASCII table!
@@ -1129,7 +1129,7 @@ component_test_default_cmake_gcc_asan () {
programs/test/selftest
msg "test: metatests (GCC, ASan build)"
tests/scripts/run-metatests.sh any asan
tests/scripts/run-metatests.sh any asan poison
msg "test: ssl-opt.sh (ASan build)" # ~ 1 min
tests/ssl-opt.sh
@@ -1220,6 +1220,17 @@ 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"
scripts/config.py full
scripts/config.py unset MBEDTLS_PSA_COPY_CALLER_BUFFERS
CC=gcc cmake -D CMAKE_BUILD_TYPE:String=Asan .
make
msg "test: full config - MBEDTLS_PSA_COPY_CALLER_BUFFERS, cmake, gcc, ASan"
make test
}
# check_renamed_symbols HEADER LIB
# Check that if HEADER contains '#define MACRO ...' then MACRO is not a symbol
# name is LIB.
@@ -1930,7 +1941,7 @@ component_test_everest () {
make test
msg "test: metatests (clang, ASan)"
tests/scripts/run-metatests.sh any asan
tests/scripts/run-metatests.sh any asan poison
msg "test: Everest ECDH context - ECDH-related part of ssl-opt.sh (ASan build)" # ~ 5s
tests/ssl-opt.sh -f ECDH

View File

@@ -144,3 +144,8 @@ if in_mbedtls_repo; then
# the step that creates or updates these files.
check scripts/generate_visualc_files.pl visualc/VS2013
fi
# Generated files that are present in the repository even in the development
# branch. (This is intended to be temporary, until the generator scripts are
# fully reviewed and the build scripts support a generated header file.)
check tests/scripts/generate_psa_wrappers.py tests/include/test/psa_test_wrappers.h tests/src/psa_test_wrappers.c

View File

@@ -0,0 +1,253 @@
#!/usr/bin/env python3
"""Generate wrapper functions for PSA function calls.
"""
# Copyright The Mbed TLS Contributors
# SPDX-License-Identifier: Apache-2.0 OR GPL-2.0-or-later
### WARNING: the code in this file has not been extensively reviewed yet.
### We do not think it is harmful, but it may be below our normal standards
### for robustness and maintainability.
import argparse
import itertools
import os
from typing import Iterator, List, Optional, Tuple
import scripts_path #pylint: disable=unused-import
from mbedtls_dev import build_tree
from mbedtls_dev import c_parsing_helper
from mbedtls_dev import c_wrapper_generator
from mbedtls_dev import typing_util
class BufferParameter:
"""Description of an input or output buffer parameter sequence to a PSA function."""
#pylint: disable=too-few-public-methods
def __init__(self, i: int, is_output: bool,
buffer_name: str, size_name: str) -> None:
"""Initialize the parameter information.
i is the index of the function argument that is the pointer to the buffer.
The size is argument i+1. For a variable-size output, the actual length
goes in argument i+2.
buffer_name and size_names are the names of arguments i and i+1.
This class does not yet help with the output length.
"""
self.index = i
self.buffer_name = buffer_name
self.size_name = size_name
self.is_output = is_output
class PSAWrapperGenerator(c_wrapper_generator.Base):
"""Generate a C source file containing wrapper functions for PSA Crypto API calls."""
_CPP_GUARDS = ('defined(MBEDTLS_PSA_CRYPTO_C) && ' +
'defined(MBEDTLS_TEST_HOOKS) && \\\n ' +
'!defined(RECORD_PSA_STATUS_COVERAGE_LOG)')
_WRAPPER_NAME_PREFIX = 'mbedtls_test_wrap_'
_WRAPPER_NAME_SUFFIX = ''
def gather_data(self) -> None:
root_dir = build_tree.guess_mbedtls_root()
for header_name in ['crypto.h', 'crypto_extra.h']:
header_path = os.path.join(root_dir, 'include', 'psa', header_name)
c_parsing_helper.read_function_declarations(self.functions, header_path)
_SKIP_FUNCTIONS = frozenset([
'mbedtls_psa_external_get_random', # not a library function
'psa_get_key_domain_parameters', # client-side function
'psa_get_key_slot_number', # client-side function
'psa_key_derivation_verify_bytes', # not implemented yet
'psa_key_derivation_verify_key', # not implemented yet
'psa_set_key_domain_parameters', # client-side function
])
def _skip_function(self, function: c_wrapper_generator.FunctionInfo) -> bool:
if function.return_type != 'psa_status_t':
return True
if function.name in self._SKIP_FUNCTIONS:
return True
return False
# PAKE stuff: not implemented yet
_PAKE_STUFF = frozenset([
'psa_crypto_driver_pake_inputs_t *',
'psa_pake_cipher_suite_t *',
])
def _return_variable_name(self,
function: c_wrapper_generator.FunctionInfo) -> str:
"""The name of the variable that will contain the return value."""
if function.return_type == 'psa_status_t':
return 'status'
return super()._return_variable_name(function)
_FUNCTION_GUARDS = c_wrapper_generator.Base._FUNCTION_GUARDS.copy() \
#pylint: disable=protected-access
_FUNCTION_GUARDS.update({
'mbedtls_psa_register_se_key': 'defined(MBEDTLS_PSA_CRYPTO_SE_C)',
'mbedtls_psa_inject_entropy': 'defined(MBEDTLS_PSA_INJECT_ENTROPY)',
'mbedtls_psa_external_get_random': 'defined(MBEDTLS_PSA_CRYPTO_EXTERNAL_RNG)',
'mbedtls_psa_platform_get_builtin_key': 'defined(MBEDTLS_PSA_CRYPTO_BUILTIN_KEYS)',
})
@staticmethod
def _detect_buffer_parameters(arguments: List[c_parsing_helper.ArgumentInfo],
argument_names: List[str]) -> Iterator[BufferParameter]:
"""Detect function arguments that are buffers (pointer, size [,length])."""
types = ['' if arg.suffix else arg.type for arg in arguments]
# pairs = list of (type_of_arg_N, type_of_arg_N+1)
# where each type_of_arg_X is the empty string if the type is an array
# or there is no argument X.
pairs = enumerate(itertools.zip_longest(types, types[1:], fillvalue=''))
for i, t01 in pairs:
if (t01[0] == 'const uint8_t *' or t01[0] == 'uint8_t *') and \
t01[1] == 'size_t':
yield BufferParameter(i, not t01[0].startswith('const '),
argument_names[i], argument_names[i+1])
@staticmethod
def _write_poison_buffer_parameter(out: typing_util.Writable,
param: BufferParameter,
poison: bool) -> None:
"""Write poisoning or unpoisoning code for a buffer parameter.
Write poisoning code if poison is true, unpoisoning code otherwise.
"""
out.write(' MBEDTLS_TEST_MEMORY_{}({}, {});\n'.format(
'POISON' if poison else 'UNPOISON',
param.buffer_name, param.size_name
))
def _write_poison_buffer_parameters(self, out: typing_util.Writable,
buffer_parameters: List[BufferParameter],
poison: bool) -> None:
"""Write poisoning or unpoisoning code for the buffer parameters.
Write poisoning code if poison is true, unpoisoning code otherwise.
"""
if not buffer_parameters:
return
out.write('#if defined(MBEDTLS_PSA_COPY_CALLER_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')
@staticmethod
def _parameter_should_be_copied(function_name: str,
_buffer_name: Optional[str]) -> bool:
"""Whether the specified buffer argument to a PSA function should be copied.
"""
# Proof-of-concept: just instrument one function for now
if function_name == 'psa_cipher_encrypt':
return True
return False
def _write_function_call(self, out: typing_util.Writable,
function: c_wrapper_generator.FunctionInfo,
argument_names: List[str]) -> None:
buffer_parameters = list(
param
for param in self._detect_buffer_parameters(function.arguments,
argument_names)
if self._parameter_should_be_copied(function.name,
function.arguments[param.index].name))
self._write_poison_buffer_parameters(out, buffer_parameters, True)
super()._write_function_call(out, function, argument_names)
self._write_poison_buffer_parameters(out, buffer_parameters, False)
def _write_prologue(self, out: typing_util.Writable, header: bool) -> None:
super()._write_prologue(out, header)
out.write("""
#if {}
#include <psa/crypto.h>
#include <test/memory.h>
#include <test/psa_crypto_helpers.h>
#include <test/psa_test_wrappers.h>
"""
.format(self._CPP_GUARDS))
def _write_epilogue(self, out: typing_util.Writable, header: bool) -> None:
out.write("""
#endif /* {} */
"""
.format(self._CPP_GUARDS))
super()._write_epilogue(out, header)
class PSALoggingWrapperGenerator(PSAWrapperGenerator, c_wrapper_generator.Logging):
"""Generate a C source file containing wrapper functions that log PSA Crypto API calls."""
def __init__(self, stream: str) -> None:
super().__init__()
self.set_stream(stream)
_PRINTF_TYPE_CAST = c_wrapper_generator.Logging._PRINTF_TYPE_CAST.copy()
_PRINTF_TYPE_CAST.update({
'mbedtls_svc_key_id_t': 'unsigned',
'psa_algorithm_t': 'unsigned',
'psa_drv_slot_number_t': 'unsigned long long',
'psa_key_derivation_step_t': 'int',
'psa_key_id_t': 'unsigned',
'psa_key_slot_number_t': 'unsigned long long',
'psa_key_lifetime_t': 'unsigned',
'psa_key_type_t': 'unsigned',
'psa_key_usage_flags_t': 'unsigned',
'psa_pake_role_t': 'int',
'psa_pake_step_t': 'int',
'psa_status_t': 'int',
})
def _printf_parameters(self, typ: str, var: str) -> Tuple[str, List[str]]:
if typ.startswith('const '):
typ = typ[6:]
if typ == 'uint8_t *':
# Skip buffers
return '', []
if typ.endswith('operation_t *'):
return '', []
if typ in self._PAKE_STUFF:
return '', []
if typ == 'psa_key_attributes_t *':
return (var + '={id=%u, lifetime=0x%08x, type=0x%08x, bits=%u, alg=%08x, usage=%08x}',
['(unsigned) psa_get_key_{}({})'.format(field, var)
for field in ['id', 'lifetime', 'type', 'bits', 'algorithm', 'usage_flags']])
return super()._printf_parameters(typ, var)
DEFAULT_C_OUTPUT_FILE_NAME = 'tests/src/psa_test_wrappers.c'
DEFAULT_H_OUTPUT_FILE_NAME = 'tests/include/test/psa_test_wrappers.h'
def main() -> None:
parser = argparse.ArgumentParser(description=globals()['__doc__'])
parser.add_argument('--log',
help='Stream to log to (default: no logging code)')
parser.add_argument('--output-c',
metavar='FILENAME',
default=DEFAULT_C_OUTPUT_FILE_NAME,
help=('Output .c file path (default: {}; skip .c output if empty)'
.format(DEFAULT_C_OUTPUT_FILE_NAME)))
parser.add_argument('--output-h',
metavar='FILENAME',
default=DEFAULT_H_OUTPUT_FILE_NAME,
help=('Output .h file path (default: {}; skip .h output if empty)'
.format(DEFAULT_H_OUTPUT_FILE_NAME)))
options = parser.parse_args()
if options.log:
generator = PSALoggingWrapperGenerator(options.log) #type: PSAWrapperGenerator
else:
generator = PSAWrapperGenerator()
generator.gather_data()
if options.output_h:
generator.write_h_file(options.output_h)
if options.output_c:
generator.write_c_file(options.output_c)
if __name__ == '__main__':
main()

View File

@@ -13,6 +13,10 @@
#include <test/psa_crypto_helpers.h>
#endif
#if defined(MBEDTLS_TEST_HOOKS) && defined(MBEDTLS_PSA_CRYPTO_C)
#include <test/psa_memory_poisoning_wrappers.h>
#endif
/*----------------------------------------------------------------------------*/
/* Static global variables */
@@ -29,6 +33,12 @@ 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_TEST_MEMORY_CAN_POISON)
mbedtls_poison_test_hooks_setup();
#endif
#if defined(MBEDTLS_PSA_INJECT_ENTROPY)
/* Make sure that injected entropy is present. Otherwise
* psa_crypto_init() will fail. This is not necessary for test suites
@@ -49,6 +59,12 @@ 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_TEST_MEMORY_CAN_POISON)
mbedtls_poison_test_hooks_teardown();
#endif
#if defined(MBEDTLS_PLATFORM_C)
mbedtls_platform_teardown(&platform_ctx);
#endif /* MBEDTLS_PLATFORM_C */

View File

@@ -0,0 +1,31 @@
/** Helper functions for memory poisoning in tests.
*/
/*
* Copyright The Mbed TLS Contributors
* SPDX-License-Identifier: Apache-2.0 OR GPL-2.0-or-later
*/
#include "test/memory.h"
#include "psa_crypto_invasive.h"
#if defined(MBEDTLS_TEST_HOOKS) && defined(MBEDTLS_PSA_CRYPTO_C) \
&& defined(MBEDTLS_TEST_MEMORY_CAN_POISON)
void mbedtls_poison_test_hooks_setup(void)
{
psa_input_pre_copy_hook = mbedtls_test_memory_unpoison;
psa_input_post_copy_hook = mbedtls_test_memory_poison;
psa_output_pre_copy_hook = mbedtls_test_memory_unpoison;
psa_output_post_copy_hook = mbedtls_test_memory_poison;
}
void mbedtls_poison_test_hooks_teardown(void)
{
psa_input_pre_copy_hook = NULL;
psa_input_post_copy_hook = NULL;
psa_output_pre_copy_hook = NULL;
psa_output_post_copy_hook = NULL;
}
#endif /* MBEDTLS_TEST_HOOKS && MBEDTLS_PSA_CRYPTO_C &&
MBEDTLS_TEST_MEMORY_CAN_POISON */

View File

@@ -0,0 +1,984 @@
/* Automatically generated by generate_psa_wrappers.py, do not edit! */
/* Copyright The Mbed TLS Contributors
* SPDX-License-Identifier: Apache-2.0 OR GPL-2.0-or-later
*/
#include <mbedtls/build_info.h>
#if defined(MBEDTLS_PSA_CRYPTO_C) && defined(MBEDTLS_TEST_HOOKS) && \
!defined(RECORD_PSA_STATUS_COVERAGE_LOG)
#include <psa/crypto.h>
#include <test/memory.h>
#include <test/psa_crypto_helpers.h>
#include <test/psa_test_wrappers.h>
/* Wrapper for mbedtls_psa_inject_entropy */
#if defined(MBEDTLS_PSA_INJECT_ENTROPY)
psa_status_t mbedtls_test_wrap_mbedtls_psa_inject_entropy(
const uint8_t *arg0_seed,
size_t arg1_seed_size)
{
psa_status_t status = (mbedtls_psa_inject_entropy)(arg0_seed, arg1_seed_size);
return status;
}
#endif /* defined(MBEDTLS_PSA_INJECT_ENTROPY) */
/* Wrapper for mbedtls_psa_platform_get_builtin_key */
#if defined(MBEDTLS_PSA_CRYPTO_BUILTIN_KEYS)
psa_status_t mbedtls_test_wrap_mbedtls_psa_platform_get_builtin_key(
mbedtls_svc_key_id_t arg0_key_id,
psa_key_lifetime_t *arg1_lifetime,
psa_drv_slot_number_t *arg2_slot_number)
{
psa_status_t status = (mbedtls_psa_platform_get_builtin_key)(arg0_key_id, arg1_lifetime, arg2_slot_number);
return status;
}
#endif /* defined(MBEDTLS_PSA_CRYPTO_BUILTIN_KEYS) */
/* Wrapper for mbedtls_psa_register_se_key */
#if defined(MBEDTLS_PSA_CRYPTO_SE_C)
psa_status_t mbedtls_test_wrap_mbedtls_psa_register_se_key(
const psa_key_attributes_t *arg0_attributes)
{
psa_status_t status = (mbedtls_psa_register_se_key)(arg0_attributes);
return status;
}
#endif /* defined(MBEDTLS_PSA_CRYPTO_SE_C) */
/* Wrapper for psa_aead_abort */
psa_status_t mbedtls_test_wrap_psa_aead_abort(
psa_aead_operation_t *arg0_operation)
{
psa_status_t status = (psa_aead_abort)(arg0_operation);
return status;
}
/* Wrapper for psa_aead_decrypt */
psa_status_t mbedtls_test_wrap_psa_aead_decrypt(
mbedtls_svc_key_id_t arg0_key,
psa_algorithm_t arg1_alg,
const uint8_t *arg2_nonce,
size_t arg3_nonce_length,
const uint8_t *arg4_additional_data,
size_t arg5_additional_data_length,
const uint8_t *arg6_ciphertext,
size_t arg7_ciphertext_length,
uint8_t *arg8_plaintext,
size_t arg9_plaintext_size,
size_t *arg10_plaintext_length)
{
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);
return status;
}
/* Wrapper for psa_aead_decrypt_setup */
psa_status_t mbedtls_test_wrap_psa_aead_decrypt_setup(
psa_aead_operation_t *arg0_operation,
mbedtls_svc_key_id_t arg1_key,
psa_algorithm_t arg2_alg)
{
psa_status_t status = (psa_aead_decrypt_setup)(arg0_operation, arg1_key, arg2_alg);
return status;
}
/* Wrapper for psa_aead_encrypt */
psa_status_t mbedtls_test_wrap_psa_aead_encrypt(
mbedtls_svc_key_id_t arg0_key,
psa_algorithm_t arg1_alg,
const uint8_t *arg2_nonce,
size_t arg3_nonce_length,
const uint8_t *arg4_additional_data,
size_t arg5_additional_data_length,
const uint8_t *arg6_plaintext,
size_t arg7_plaintext_length,
uint8_t *arg8_ciphertext,
size_t arg9_ciphertext_size,
size_t *arg10_ciphertext_length)
{
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);
return status;
}
/* Wrapper for psa_aead_encrypt_setup */
psa_status_t mbedtls_test_wrap_psa_aead_encrypt_setup(
psa_aead_operation_t *arg0_operation,
mbedtls_svc_key_id_t arg1_key,
psa_algorithm_t arg2_alg)
{
psa_status_t status = (psa_aead_encrypt_setup)(arg0_operation, arg1_key, arg2_alg);
return status;
}
/* Wrapper for psa_aead_finish */
psa_status_t mbedtls_test_wrap_psa_aead_finish(
psa_aead_operation_t *arg0_operation,
uint8_t *arg1_ciphertext,
size_t arg2_ciphertext_size,
size_t *arg3_ciphertext_length,
uint8_t *arg4_tag,
size_t arg5_tag_size,
size_t *arg6_tag_length)
{
psa_status_t status = (psa_aead_finish)(arg0_operation, arg1_ciphertext, arg2_ciphertext_size, arg3_ciphertext_length, arg4_tag, arg5_tag_size, arg6_tag_length);
return status;
}
/* Wrapper for psa_aead_generate_nonce */
psa_status_t mbedtls_test_wrap_psa_aead_generate_nonce(
psa_aead_operation_t *arg0_operation,
uint8_t *arg1_nonce,
size_t arg2_nonce_size,
size_t *arg3_nonce_length)
{
psa_status_t status = (psa_aead_generate_nonce)(arg0_operation, arg1_nonce, arg2_nonce_size, arg3_nonce_length);
return status;
}
/* Wrapper for psa_aead_set_lengths */
psa_status_t mbedtls_test_wrap_psa_aead_set_lengths(
psa_aead_operation_t *arg0_operation,
size_t arg1_ad_length,
size_t arg2_plaintext_length)
{
psa_status_t status = (psa_aead_set_lengths)(arg0_operation, arg1_ad_length, arg2_plaintext_length);
return status;
}
/* Wrapper for psa_aead_set_nonce */
psa_status_t mbedtls_test_wrap_psa_aead_set_nonce(
psa_aead_operation_t *arg0_operation,
const uint8_t *arg1_nonce,
size_t arg2_nonce_length)
{
psa_status_t status = (psa_aead_set_nonce)(arg0_operation, arg1_nonce, arg2_nonce_length);
return status;
}
/* Wrapper for psa_aead_update */
psa_status_t mbedtls_test_wrap_psa_aead_update(
psa_aead_operation_t *arg0_operation,
const uint8_t *arg1_input,
size_t arg2_input_length,
uint8_t *arg3_output,
size_t arg4_output_size,
size_t *arg5_output_length)
{
psa_status_t status = (psa_aead_update)(arg0_operation, arg1_input, arg2_input_length, arg3_output, arg4_output_size, arg5_output_length);
return status;
}
/* Wrapper for psa_aead_update_ad */
psa_status_t mbedtls_test_wrap_psa_aead_update_ad(
psa_aead_operation_t *arg0_operation,
const uint8_t *arg1_input,
size_t arg2_input_length)
{
psa_status_t status = (psa_aead_update_ad)(arg0_operation, arg1_input, arg2_input_length);
return status;
}
/* Wrapper for psa_aead_verify */
psa_status_t mbedtls_test_wrap_psa_aead_verify(
psa_aead_operation_t *arg0_operation,
uint8_t *arg1_plaintext,
size_t arg2_plaintext_size,
size_t *arg3_plaintext_length,
const uint8_t *arg4_tag,
size_t arg5_tag_length)
{
psa_status_t status = (psa_aead_verify)(arg0_operation, arg1_plaintext, arg2_plaintext_size, arg3_plaintext_length, arg4_tag, arg5_tag_length);
return status;
}
/* Wrapper for psa_asymmetric_decrypt */
psa_status_t mbedtls_test_wrap_psa_asymmetric_decrypt(
mbedtls_svc_key_id_t arg0_key,
psa_algorithm_t arg1_alg,
const uint8_t *arg2_input,
size_t arg3_input_length,
const uint8_t *arg4_salt,
size_t arg5_salt_length,
uint8_t *arg6_output,
size_t arg7_output_size,
size_t *arg8_output_length)
{
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);
return status;
}
/* Wrapper for psa_asymmetric_encrypt */
psa_status_t mbedtls_test_wrap_psa_asymmetric_encrypt(
mbedtls_svc_key_id_t arg0_key,
psa_algorithm_t arg1_alg,
const uint8_t *arg2_input,
size_t arg3_input_length,
const uint8_t *arg4_salt,
size_t arg5_salt_length,
uint8_t *arg6_output,
size_t arg7_output_size,
size_t *arg8_output_length)
{
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);
return status;
}
/* Wrapper for psa_cipher_abort */
psa_status_t mbedtls_test_wrap_psa_cipher_abort(
psa_cipher_operation_t *arg0_operation)
{
psa_status_t status = (psa_cipher_abort)(arg0_operation);
return status;
}
/* Wrapper for psa_cipher_decrypt */
psa_status_t mbedtls_test_wrap_psa_cipher_decrypt(
mbedtls_svc_key_id_t arg0_key,
psa_algorithm_t arg1_alg,
const uint8_t *arg2_input,
size_t arg3_input_length,
uint8_t *arg4_output,
size_t arg5_output_size,
size_t *arg6_output_length)
{
psa_status_t status = (psa_cipher_decrypt)(arg0_key, arg1_alg, arg2_input, arg3_input_length, arg4_output, arg5_output_size, arg6_output_length);
return status;
}
/* Wrapper for psa_cipher_decrypt_setup */
psa_status_t mbedtls_test_wrap_psa_cipher_decrypt_setup(
psa_cipher_operation_t *arg0_operation,
mbedtls_svc_key_id_t arg1_key,
psa_algorithm_t arg2_alg)
{
psa_status_t status = (psa_cipher_decrypt_setup)(arg0_operation, arg1_key, arg2_alg);
return status;
}
/* Wrapper for psa_cipher_encrypt */
psa_status_t mbedtls_test_wrap_psa_cipher_encrypt(
mbedtls_svc_key_id_t arg0_key,
psa_algorithm_t arg1_alg,
const uint8_t *arg2_input,
size_t arg3_input_length,
uint8_t *arg4_output,
size_t arg5_output_size,
size_t *arg6_output_length)
{
#if defined(MBEDTLS_PSA_COPY_CALLER_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) */
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)
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) */
return status;
}
/* Wrapper for psa_cipher_encrypt_setup */
psa_status_t mbedtls_test_wrap_psa_cipher_encrypt_setup(
psa_cipher_operation_t *arg0_operation,
mbedtls_svc_key_id_t arg1_key,
psa_algorithm_t arg2_alg)
{
psa_status_t status = (psa_cipher_encrypt_setup)(arg0_operation, arg1_key, arg2_alg);
return status;
}
/* Wrapper for psa_cipher_finish */
psa_status_t mbedtls_test_wrap_psa_cipher_finish(
psa_cipher_operation_t *arg0_operation,
uint8_t *arg1_output,
size_t arg2_output_size,
size_t *arg3_output_length)
{
psa_status_t status = (psa_cipher_finish)(arg0_operation, arg1_output, arg2_output_size, arg3_output_length);
return status;
}
/* Wrapper for psa_cipher_generate_iv */
psa_status_t mbedtls_test_wrap_psa_cipher_generate_iv(
psa_cipher_operation_t *arg0_operation,
uint8_t *arg1_iv,
size_t arg2_iv_size,
size_t *arg3_iv_length)
{
psa_status_t status = (psa_cipher_generate_iv)(arg0_operation, arg1_iv, arg2_iv_size, arg3_iv_length);
return status;
}
/* Wrapper for psa_cipher_set_iv */
psa_status_t mbedtls_test_wrap_psa_cipher_set_iv(
psa_cipher_operation_t *arg0_operation,
const uint8_t *arg1_iv,
size_t arg2_iv_length)
{
psa_status_t status = (psa_cipher_set_iv)(arg0_operation, arg1_iv, arg2_iv_length);
return status;
}
/* Wrapper for psa_cipher_update */
psa_status_t mbedtls_test_wrap_psa_cipher_update(
psa_cipher_operation_t *arg0_operation,
const uint8_t *arg1_input,
size_t arg2_input_length,
uint8_t *arg3_output,
size_t arg4_output_size,
size_t *arg5_output_length)
{
psa_status_t status = (psa_cipher_update)(arg0_operation, arg1_input, arg2_input_length, arg3_output, arg4_output_size, arg5_output_length);
return status;
}
/* Wrapper for psa_copy_key */
psa_status_t mbedtls_test_wrap_psa_copy_key(
mbedtls_svc_key_id_t arg0_source_key,
const psa_key_attributes_t *arg1_attributes,
mbedtls_svc_key_id_t *arg2_target_key)
{
psa_status_t status = (psa_copy_key)(arg0_source_key, arg1_attributes, arg2_target_key);
return status;
}
/* Wrapper for psa_crypto_driver_pake_get_cipher_suite */
psa_status_t mbedtls_test_wrap_psa_crypto_driver_pake_get_cipher_suite(
const psa_crypto_driver_pake_inputs_t *arg0_inputs,
psa_pake_cipher_suite_t *arg1_cipher_suite)
{
psa_status_t status = (psa_crypto_driver_pake_get_cipher_suite)(arg0_inputs, arg1_cipher_suite);
return status;
}
/* Wrapper for psa_crypto_driver_pake_get_password */
psa_status_t mbedtls_test_wrap_psa_crypto_driver_pake_get_password(
const psa_crypto_driver_pake_inputs_t *arg0_inputs,
uint8_t *arg1_buffer,
size_t arg2_buffer_size,
size_t *arg3_buffer_length)
{
psa_status_t status = (psa_crypto_driver_pake_get_password)(arg0_inputs, arg1_buffer, arg2_buffer_size, arg3_buffer_length);
return status;
}
/* Wrapper for psa_crypto_driver_pake_get_password_len */
psa_status_t mbedtls_test_wrap_psa_crypto_driver_pake_get_password_len(
const psa_crypto_driver_pake_inputs_t *arg0_inputs,
size_t *arg1_password_len)
{
psa_status_t status = (psa_crypto_driver_pake_get_password_len)(arg0_inputs, arg1_password_len);
return status;
}
/* Wrapper for psa_crypto_driver_pake_get_peer */
psa_status_t mbedtls_test_wrap_psa_crypto_driver_pake_get_peer(
const psa_crypto_driver_pake_inputs_t *arg0_inputs,
uint8_t *arg1_peer_id,
size_t arg2_peer_id_size,
size_t *arg3_peer_id_length)
{
psa_status_t status = (psa_crypto_driver_pake_get_peer)(arg0_inputs, arg1_peer_id, arg2_peer_id_size, arg3_peer_id_length);
return status;
}
/* Wrapper for psa_crypto_driver_pake_get_peer_len */
psa_status_t mbedtls_test_wrap_psa_crypto_driver_pake_get_peer_len(
const psa_crypto_driver_pake_inputs_t *arg0_inputs,
size_t *arg1_peer_len)
{
psa_status_t status = (psa_crypto_driver_pake_get_peer_len)(arg0_inputs, arg1_peer_len);
return status;
}
/* Wrapper for psa_crypto_driver_pake_get_user */
psa_status_t mbedtls_test_wrap_psa_crypto_driver_pake_get_user(
const psa_crypto_driver_pake_inputs_t *arg0_inputs,
uint8_t *arg1_user_id,
size_t arg2_user_id_size,
size_t *arg3_user_id_len)
{
psa_status_t status = (psa_crypto_driver_pake_get_user)(arg0_inputs, arg1_user_id, arg2_user_id_size, arg3_user_id_len);
return status;
}
/* Wrapper for psa_crypto_driver_pake_get_user_len */
psa_status_t mbedtls_test_wrap_psa_crypto_driver_pake_get_user_len(
const psa_crypto_driver_pake_inputs_t *arg0_inputs,
size_t *arg1_user_len)
{
psa_status_t status = (psa_crypto_driver_pake_get_user_len)(arg0_inputs, arg1_user_len);
return status;
}
/* Wrapper for psa_crypto_init */
psa_status_t mbedtls_test_wrap_psa_crypto_init(void)
{
psa_status_t status = (psa_crypto_init)();
return status;
}
/* Wrapper for psa_destroy_key */
psa_status_t mbedtls_test_wrap_psa_destroy_key(
mbedtls_svc_key_id_t arg0_key)
{
psa_status_t status = (psa_destroy_key)(arg0_key);
return status;
}
/* Wrapper for psa_export_key */
psa_status_t mbedtls_test_wrap_psa_export_key(
mbedtls_svc_key_id_t arg0_key,
uint8_t *arg1_data,
size_t arg2_data_size,
size_t *arg3_data_length)
{
psa_status_t status = (psa_export_key)(arg0_key, arg1_data, arg2_data_size, arg3_data_length);
return status;
}
/* Wrapper for psa_export_public_key */
psa_status_t mbedtls_test_wrap_psa_export_public_key(
mbedtls_svc_key_id_t arg0_key,
uint8_t *arg1_data,
size_t arg2_data_size,
size_t *arg3_data_length)
{
psa_status_t status = (psa_export_public_key)(arg0_key, arg1_data, arg2_data_size, arg3_data_length);
return status;
}
/* Wrapper for psa_generate_key */
psa_status_t mbedtls_test_wrap_psa_generate_key(
const psa_key_attributes_t *arg0_attributes,
mbedtls_svc_key_id_t *arg1_key)
{
psa_status_t status = (psa_generate_key)(arg0_attributes, arg1_key);
return status;
}
/* Wrapper for psa_generate_random */
psa_status_t mbedtls_test_wrap_psa_generate_random(
uint8_t *arg0_output,
size_t arg1_output_size)
{
psa_status_t status = (psa_generate_random)(arg0_output, arg1_output_size);
return status;
}
/* Wrapper for psa_get_key_attributes */
psa_status_t mbedtls_test_wrap_psa_get_key_attributes(
mbedtls_svc_key_id_t arg0_key,
psa_key_attributes_t *arg1_attributes)
{
psa_status_t status = (psa_get_key_attributes)(arg0_key, arg1_attributes);
return status;
}
/* Wrapper for psa_hash_abort */
psa_status_t mbedtls_test_wrap_psa_hash_abort(
psa_hash_operation_t *arg0_operation)
{
psa_status_t status = (psa_hash_abort)(arg0_operation);
return status;
}
/* Wrapper for psa_hash_clone */
psa_status_t mbedtls_test_wrap_psa_hash_clone(
const psa_hash_operation_t *arg0_source_operation,
psa_hash_operation_t *arg1_target_operation)
{
psa_status_t status = (psa_hash_clone)(arg0_source_operation, arg1_target_operation);
return status;
}
/* Wrapper for psa_hash_compare */
psa_status_t mbedtls_test_wrap_psa_hash_compare(
psa_algorithm_t arg0_alg,
const uint8_t *arg1_input,
size_t arg2_input_length,
const uint8_t *arg3_hash,
size_t arg4_hash_length)
{
psa_status_t status = (psa_hash_compare)(arg0_alg, arg1_input, arg2_input_length, arg3_hash, arg4_hash_length);
return status;
}
/* Wrapper for psa_hash_compute */
psa_status_t mbedtls_test_wrap_psa_hash_compute(
psa_algorithm_t arg0_alg,
const uint8_t *arg1_input,
size_t arg2_input_length,
uint8_t *arg3_hash,
size_t arg4_hash_size,
size_t *arg5_hash_length)
{
psa_status_t status = (psa_hash_compute)(arg0_alg, arg1_input, arg2_input_length, arg3_hash, arg4_hash_size, arg5_hash_length);
return status;
}
/* Wrapper for psa_hash_finish */
psa_status_t mbedtls_test_wrap_psa_hash_finish(
psa_hash_operation_t *arg0_operation,
uint8_t *arg1_hash,
size_t arg2_hash_size,
size_t *arg3_hash_length)
{
psa_status_t status = (psa_hash_finish)(arg0_operation, arg1_hash, arg2_hash_size, arg3_hash_length);
return status;
}
/* Wrapper for psa_hash_setup */
psa_status_t mbedtls_test_wrap_psa_hash_setup(
psa_hash_operation_t *arg0_operation,
psa_algorithm_t arg1_alg)
{
psa_status_t status = (psa_hash_setup)(arg0_operation, arg1_alg);
return status;
}
/* Wrapper for psa_hash_update */
psa_status_t mbedtls_test_wrap_psa_hash_update(
psa_hash_operation_t *arg0_operation,
const uint8_t *arg1_input,
size_t arg2_input_length)
{
psa_status_t status = (psa_hash_update)(arg0_operation, arg1_input, arg2_input_length);
return status;
}
/* Wrapper for psa_hash_verify */
psa_status_t mbedtls_test_wrap_psa_hash_verify(
psa_hash_operation_t *arg0_operation,
const uint8_t *arg1_hash,
size_t arg2_hash_length)
{
psa_status_t status = (psa_hash_verify)(arg0_operation, arg1_hash, arg2_hash_length);
return status;
}
/* Wrapper for psa_import_key */
psa_status_t mbedtls_test_wrap_psa_import_key(
const psa_key_attributes_t *arg0_attributes,
const uint8_t *arg1_data,
size_t arg2_data_length,
mbedtls_svc_key_id_t *arg3_key)
{
psa_status_t status = (psa_import_key)(arg0_attributes, arg1_data, arg2_data_length, arg3_key);
return status;
}
/* Wrapper for psa_key_derivation_abort */
psa_status_t mbedtls_test_wrap_psa_key_derivation_abort(
psa_key_derivation_operation_t *arg0_operation)
{
psa_status_t status = (psa_key_derivation_abort)(arg0_operation);
return status;
}
/* Wrapper for psa_key_derivation_get_capacity */
psa_status_t mbedtls_test_wrap_psa_key_derivation_get_capacity(
const psa_key_derivation_operation_t *arg0_operation,
size_t *arg1_capacity)
{
psa_status_t status = (psa_key_derivation_get_capacity)(arg0_operation, arg1_capacity);
return status;
}
/* Wrapper for psa_key_derivation_input_bytes */
psa_status_t mbedtls_test_wrap_psa_key_derivation_input_bytes(
psa_key_derivation_operation_t *arg0_operation,
psa_key_derivation_step_t arg1_step,
const uint8_t *arg2_data,
size_t arg3_data_length)
{
psa_status_t status = (psa_key_derivation_input_bytes)(arg0_operation, arg1_step, arg2_data, arg3_data_length);
return status;
}
/* Wrapper for psa_key_derivation_input_integer */
psa_status_t mbedtls_test_wrap_psa_key_derivation_input_integer(
psa_key_derivation_operation_t *arg0_operation,
psa_key_derivation_step_t arg1_step,
uint64_t arg2_value)
{
psa_status_t status = (psa_key_derivation_input_integer)(arg0_operation, arg1_step, arg2_value);
return status;
}
/* Wrapper for psa_key_derivation_input_key */
psa_status_t mbedtls_test_wrap_psa_key_derivation_input_key(
psa_key_derivation_operation_t *arg0_operation,
psa_key_derivation_step_t arg1_step,
mbedtls_svc_key_id_t arg2_key)
{
psa_status_t status = (psa_key_derivation_input_key)(arg0_operation, arg1_step, arg2_key);
return status;
}
/* Wrapper for psa_key_derivation_key_agreement */
psa_status_t mbedtls_test_wrap_psa_key_derivation_key_agreement(
psa_key_derivation_operation_t *arg0_operation,
psa_key_derivation_step_t arg1_step,
mbedtls_svc_key_id_t arg2_private_key,
const uint8_t *arg3_peer_key,
size_t arg4_peer_key_length)
{
psa_status_t status = (psa_key_derivation_key_agreement)(arg0_operation, arg1_step, arg2_private_key, arg3_peer_key, arg4_peer_key_length);
return status;
}
/* Wrapper for psa_key_derivation_output_bytes */
psa_status_t mbedtls_test_wrap_psa_key_derivation_output_bytes(
psa_key_derivation_operation_t *arg0_operation,
uint8_t *arg1_output,
size_t arg2_output_length)
{
psa_status_t status = (psa_key_derivation_output_bytes)(arg0_operation, arg1_output, arg2_output_length);
return status;
}
/* Wrapper for psa_key_derivation_output_key */
psa_status_t mbedtls_test_wrap_psa_key_derivation_output_key(
const psa_key_attributes_t *arg0_attributes,
psa_key_derivation_operation_t *arg1_operation,
mbedtls_svc_key_id_t *arg2_key)
{
psa_status_t status = (psa_key_derivation_output_key)(arg0_attributes, arg1_operation, arg2_key);
return status;
}
/* Wrapper for psa_key_derivation_set_capacity */
psa_status_t mbedtls_test_wrap_psa_key_derivation_set_capacity(
psa_key_derivation_operation_t *arg0_operation,
size_t arg1_capacity)
{
psa_status_t status = (psa_key_derivation_set_capacity)(arg0_operation, arg1_capacity);
return status;
}
/* Wrapper for psa_key_derivation_setup */
psa_status_t mbedtls_test_wrap_psa_key_derivation_setup(
psa_key_derivation_operation_t *arg0_operation,
psa_algorithm_t arg1_alg)
{
psa_status_t status = (psa_key_derivation_setup)(arg0_operation, arg1_alg);
return status;
}
/* Wrapper for psa_mac_abort */
psa_status_t mbedtls_test_wrap_psa_mac_abort(
psa_mac_operation_t *arg0_operation)
{
psa_status_t status = (psa_mac_abort)(arg0_operation);
return status;
}
/* Wrapper for psa_mac_compute */
psa_status_t mbedtls_test_wrap_psa_mac_compute(
mbedtls_svc_key_id_t arg0_key,
psa_algorithm_t arg1_alg,
const uint8_t *arg2_input,
size_t arg3_input_length,
uint8_t *arg4_mac,
size_t arg5_mac_size,
size_t *arg6_mac_length)
{
psa_status_t status = (psa_mac_compute)(arg0_key, arg1_alg, arg2_input, arg3_input_length, arg4_mac, arg5_mac_size, arg6_mac_length);
return status;
}
/* Wrapper for psa_mac_sign_finish */
psa_status_t mbedtls_test_wrap_psa_mac_sign_finish(
psa_mac_operation_t *arg0_operation,
uint8_t *arg1_mac,
size_t arg2_mac_size,
size_t *arg3_mac_length)
{
psa_status_t status = (psa_mac_sign_finish)(arg0_operation, arg1_mac, arg2_mac_size, arg3_mac_length);
return status;
}
/* Wrapper for psa_mac_sign_setup */
psa_status_t mbedtls_test_wrap_psa_mac_sign_setup(
psa_mac_operation_t *arg0_operation,
mbedtls_svc_key_id_t arg1_key,
psa_algorithm_t arg2_alg)
{
psa_status_t status = (psa_mac_sign_setup)(arg0_operation, arg1_key, arg2_alg);
return status;
}
/* Wrapper for psa_mac_update */
psa_status_t mbedtls_test_wrap_psa_mac_update(
psa_mac_operation_t *arg0_operation,
const uint8_t *arg1_input,
size_t arg2_input_length)
{
psa_status_t status = (psa_mac_update)(arg0_operation, arg1_input, arg2_input_length);
return status;
}
/* Wrapper for psa_mac_verify */
psa_status_t mbedtls_test_wrap_psa_mac_verify(
mbedtls_svc_key_id_t arg0_key,
psa_algorithm_t arg1_alg,
const uint8_t *arg2_input,
size_t arg3_input_length,
const uint8_t *arg4_mac,
size_t arg5_mac_length)
{
psa_status_t status = (psa_mac_verify)(arg0_key, arg1_alg, arg2_input, arg3_input_length, arg4_mac, arg5_mac_length);
return status;
}
/* Wrapper for psa_mac_verify_finish */
psa_status_t mbedtls_test_wrap_psa_mac_verify_finish(
psa_mac_operation_t *arg0_operation,
const uint8_t *arg1_mac,
size_t arg2_mac_length)
{
psa_status_t status = (psa_mac_verify_finish)(arg0_operation, arg1_mac, arg2_mac_length);
return status;
}
/* Wrapper for psa_mac_verify_setup */
psa_status_t mbedtls_test_wrap_psa_mac_verify_setup(
psa_mac_operation_t *arg0_operation,
mbedtls_svc_key_id_t arg1_key,
psa_algorithm_t arg2_alg)
{
psa_status_t status = (psa_mac_verify_setup)(arg0_operation, arg1_key, arg2_alg);
return status;
}
/* Wrapper for psa_pake_abort */
psa_status_t mbedtls_test_wrap_psa_pake_abort(
psa_pake_operation_t *arg0_operation)
{
psa_status_t status = (psa_pake_abort)(arg0_operation);
return status;
}
/* Wrapper for psa_pake_get_implicit_key */
psa_status_t mbedtls_test_wrap_psa_pake_get_implicit_key(
psa_pake_operation_t *arg0_operation,
psa_key_derivation_operation_t *arg1_output)
{
psa_status_t status = (psa_pake_get_implicit_key)(arg0_operation, arg1_output);
return status;
}
/* Wrapper for psa_pake_input */
psa_status_t mbedtls_test_wrap_psa_pake_input(
psa_pake_operation_t *arg0_operation,
psa_pake_step_t arg1_step,
const uint8_t *arg2_input,
size_t arg3_input_length)
{
psa_status_t status = (psa_pake_input)(arg0_operation, arg1_step, arg2_input, arg3_input_length);
return status;
}
/* Wrapper for psa_pake_output */
psa_status_t mbedtls_test_wrap_psa_pake_output(
psa_pake_operation_t *arg0_operation,
psa_pake_step_t arg1_step,
uint8_t *arg2_output,
size_t arg3_output_size,
size_t *arg4_output_length)
{
psa_status_t status = (psa_pake_output)(arg0_operation, arg1_step, arg2_output, arg3_output_size, arg4_output_length);
return status;
}
/* Wrapper for psa_pake_set_password_key */
psa_status_t mbedtls_test_wrap_psa_pake_set_password_key(
psa_pake_operation_t *arg0_operation,
mbedtls_svc_key_id_t arg1_password)
{
psa_status_t status = (psa_pake_set_password_key)(arg0_operation, arg1_password);
return status;
}
/* Wrapper for psa_pake_set_peer */
psa_status_t mbedtls_test_wrap_psa_pake_set_peer(
psa_pake_operation_t *arg0_operation,
const uint8_t *arg1_peer_id,
size_t arg2_peer_id_len)
{
psa_status_t status = (psa_pake_set_peer)(arg0_operation, arg1_peer_id, arg2_peer_id_len);
return status;
}
/* Wrapper for psa_pake_set_role */
psa_status_t mbedtls_test_wrap_psa_pake_set_role(
psa_pake_operation_t *arg0_operation,
psa_pake_role_t arg1_role)
{
psa_status_t status = (psa_pake_set_role)(arg0_operation, arg1_role);
return status;
}
/* Wrapper for psa_pake_set_user */
psa_status_t mbedtls_test_wrap_psa_pake_set_user(
psa_pake_operation_t *arg0_operation,
const uint8_t *arg1_user_id,
size_t arg2_user_id_len)
{
psa_status_t status = (psa_pake_set_user)(arg0_operation, arg1_user_id, arg2_user_id_len);
return status;
}
/* Wrapper for psa_pake_setup */
psa_status_t mbedtls_test_wrap_psa_pake_setup(
psa_pake_operation_t *arg0_operation,
const psa_pake_cipher_suite_t *arg1_cipher_suite)
{
psa_status_t status = (psa_pake_setup)(arg0_operation, arg1_cipher_suite);
return status;
}
/* Wrapper for psa_purge_key */
psa_status_t mbedtls_test_wrap_psa_purge_key(
mbedtls_svc_key_id_t arg0_key)
{
psa_status_t status = (psa_purge_key)(arg0_key);
return status;
}
/* Wrapper for psa_raw_key_agreement */
psa_status_t mbedtls_test_wrap_psa_raw_key_agreement(
psa_algorithm_t arg0_alg,
mbedtls_svc_key_id_t arg1_private_key,
const uint8_t *arg2_peer_key,
size_t arg3_peer_key_length,
uint8_t *arg4_output,
size_t arg5_output_size,
size_t *arg6_output_length)
{
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);
return status;
}
/* Wrapper for psa_sign_hash */
psa_status_t mbedtls_test_wrap_psa_sign_hash(
mbedtls_svc_key_id_t arg0_key,
psa_algorithm_t arg1_alg,
const uint8_t *arg2_hash,
size_t arg3_hash_length,
uint8_t *arg4_signature,
size_t arg5_signature_size,
size_t *arg6_signature_length)
{
psa_status_t status = (psa_sign_hash)(arg0_key, arg1_alg, arg2_hash, arg3_hash_length, arg4_signature, arg5_signature_size, arg6_signature_length);
return status;
}
/* Wrapper for psa_sign_hash_abort */
psa_status_t mbedtls_test_wrap_psa_sign_hash_abort(
psa_sign_hash_interruptible_operation_t *arg0_operation)
{
psa_status_t status = (psa_sign_hash_abort)(arg0_operation);
return status;
}
/* Wrapper for psa_sign_hash_complete */
psa_status_t mbedtls_test_wrap_psa_sign_hash_complete(
psa_sign_hash_interruptible_operation_t *arg0_operation,
uint8_t *arg1_signature,
size_t arg2_signature_size,
size_t *arg3_signature_length)
{
psa_status_t status = (psa_sign_hash_complete)(arg0_operation, arg1_signature, arg2_signature_size, arg3_signature_length);
return status;
}
/* Wrapper for psa_sign_hash_start */
psa_status_t mbedtls_test_wrap_psa_sign_hash_start(
psa_sign_hash_interruptible_operation_t *arg0_operation,
mbedtls_svc_key_id_t arg1_key,
psa_algorithm_t arg2_alg,
const uint8_t *arg3_hash,
size_t arg4_hash_length)
{
psa_status_t status = (psa_sign_hash_start)(arg0_operation, arg1_key, arg2_alg, arg3_hash, arg4_hash_length);
return status;
}
/* Wrapper for psa_sign_message */
psa_status_t mbedtls_test_wrap_psa_sign_message(
mbedtls_svc_key_id_t arg0_key,
psa_algorithm_t arg1_alg,
const uint8_t *arg2_input,
size_t arg3_input_length,
uint8_t *arg4_signature,
size_t arg5_signature_size,
size_t *arg6_signature_length)
{
psa_status_t status = (psa_sign_message)(arg0_key, arg1_alg, arg2_input, arg3_input_length, arg4_signature, arg5_signature_size, arg6_signature_length);
return status;
}
/* Wrapper for psa_verify_hash */
psa_status_t mbedtls_test_wrap_psa_verify_hash(
mbedtls_svc_key_id_t arg0_key,
psa_algorithm_t arg1_alg,
const uint8_t *arg2_hash,
size_t arg3_hash_length,
const uint8_t *arg4_signature,
size_t arg5_signature_length)
{
psa_status_t status = (psa_verify_hash)(arg0_key, arg1_alg, arg2_hash, arg3_hash_length, arg4_signature, arg5_signature_length);
return status;
}
/* Wrapper for psa_verify_hash_abort */
psa_status_t mbedtls_test_wrap_psa_verify_hash_abort(
psa_verify_hash_interruptible_operation_t *arg0_operation)
{
psa_status_t status = (psa_verify_hash_abort)(arg0_operation);
return status;
}
/* Wrapper for psa_verify_hash_complete */
psa_status_t mbedtls_test_wrap_psa_verify_hash_complete(
psa_verify_hash_interruptible_operation_t *arg0_operation)
{
psa_status_t status = (psa_verify_hash_complete)(arg0_operation);
return status;
}
/* Wrapper for psa_verify_hash_start */
psa_status_t mbedtls_test_wrap_psa_verify_hash_start(
psa_verify_hash_interruptible_operation_t *arg0_operation,
mbedtls_svc_key_id_t arg1_key,
psa_algorithm_t arg2_alg,
const uint8_t *arg3_hash,
size_t arg4_hash_length,
const uint8_t *arg5_signature,
size_t arg6_signature_length)
{
psa_status_t status = (psa_verify_hash_start)(arg0_operation, arg1_key, arg2_alg, arg3_hash, arg4_hash_length, arg5_signature, arg6_signature_length);
return status;
}
/* Wrapper for psa_verify_message */
psa_status_t mbedtls_test_wrap_psa_verify_message(
mbedtls_svc_key_id_t arg0_key,
psa_algorithm_t arg1_alg,
const uint8_t *arg2_input,
size_t arg3_input_length,
const uint8_t *arg4_signature,
size_t arg5_signature_length)
{
psa_status_t status = (psa_verify_message)(arg0_key, arg1_alg, arg2_input, arg3_input_length, arg4_signature, arg5_signature_length);
return status;
}
#endif /* defined(MBEDTLS_PSA_CRYPTO_C) && defined(MBEDTLS_TEST_HOOKS) && \
!defined(RECORD_PSA_STATUS_COVERAGE_LOG) */
/* End of automatically generated file. */

60
tests/src/test_memory.c Normal file
View File

@@ -0,0 +1,60 @@
/**
* \file memory.c
*
* \brief Helper functions related to testing memory management.
*/
/*
* Copyright The Mbed TLS Contributors
* SPDX-License-Identifier: Apache-2.0 OR GPL-2.0-or-later
*/
#include <test/helpers.h>
#include <test/macros.h>
#include <test/memory.h>
#if defined(MBEDTLS_TEST_MEMORY_CAN_POISON)
#include <sanitizer/asan_interface.h>
#include <stdint.h>
#endif
#if defined(MBEDTLS_TEST_MEMORY_CAN_POISON)
_Thread_local unsigned int mbedtls_test_memory_poisoning_count = 0;
static void align_for_asan(const unsigned char **p_ptr, size_t *p_size)
{
uintptr_t start = (uintptr_t) *p_ptr;
uintptr_t end = start + (uintptr_t) *p_size;
/* ASan can only poison regions with 8-byte alignment, and only poisons a
* region if it's fully within the requested range. We want to poison the
* whole requested region and don't mind a few extra bytes. Therefore,
* align start down to an 8-byte boundary, and end up to an 8-byte
* boundary. */
start = start & ~(uintptr_t) 7;
end = (end + 7) & ~(uintptr_t) 7;
*p_ptr = (const unsigned char *) start;
*p_size = end - start;
}
void mbedtls_test_memory_poison(const unsigned char *ptr, size_t size)
{
if (mbedtls_test_memory_poisoning_count == 0) {
return;
}
if (size == 0) {
return;
}
align_for_asan(&ptr, &size);
__asan_poison_memory_region(ptr, size);
}
void mbedtls_test_memory_unpoison(const unsigned char *ptr, size_t size)
{
if (size == 0) {
return;
}
align_for_asan(&ptr, &size);
__asan_unpoison_memory_region(ptr, size);
}
#endif /* Memory poisoning */

View File

@@ -15,7 +15,6 @@
#include "psa/crypto.h"
#include "psa_crypto_slot_management.h"
/* For psa_can_do_hash() */
#include "psa_crypto_core.h"
#include "test/asn1_helpers.h"

View File

@@ -1495,14 +1495,7 @@ void cipher_entry_points(int alg_arg, int key_type_arg,
output, output_buffer_size, &function_output_length);
TEST_EQUAL(mbedtls_test_driver_cipher_hooks.hits_encrypt, 1);
TEST_EQUAL(status, PSA_ERROR_GENERIC_ERROR);
/*
* Check that the output buffer is still in the same state.
* This will fail if the output buffer is used by the core to pass the IV
* it generated to the driver (and is not restored).
*/
for (size_t i = 0; i < output_buffer_size; i++) {
TEST_EQUAL(output[i], 0xa5);
}
mbedtls_test_driver_cipher_hooks.hits = 0;
/* Test setup call, encrypt */

View File

@@ -0,0 +1,62 @@
PSA input buffer copy: straightforward copy
copy_input:20:20:PSA_SUCCESS
PSA input buffer copy: copy buffer larger than required
copy_input:10:20:PSA_SUCCESS
PSA input buffer copy: copy buffer too small
copy_input:20:10:PSA_ERROR_CORRUPTION_DETECTED
PSA input buffer copy: zero-length source buffer
copy_input:0:10:PSA_SUCCESS
PSA input buffer copy: zero-length both buffers
copy_input:0:0:PSA_SUCCESS
PSA output buffer copy: straightforward copy
copy_output:20:20:PSA_SUCCESS
PSA output buffer copy: output buffer larger than required
copy_output:10:20:PSA_SUCCESS
PSA output buffer copy: output buffer too small
copy_output:20:10:PSA_ERROR_BUFFER_TOO_SMALL
PSA output buffer copy: zero-length source buffer
copy_output:0:10:PSA_SUCCESS
PSA output buffer copy: zero-length both buffers
copy_output:0:0:PSA_SUCCESS
PSA crypto local input alloc
local_input_alloc:200:PSA_SUCCESS
PSA crypto local input alloc, NULL buffer
local_input_alloc:0:PSA_SUCCESS
PSA crypto local input free
local_input_free:200
PSA crypto local input free, NULL buffer
local_input_free:0
PSA crypto local input round-trip
local_input_round_trip
PSA crypto local output alloc
local_output_alloc:200:PSA_SUCCESS
PSA crypto local output alloc, NULL buffer
local_output_alloc:0:PSA_SUCCESS
PSA crypto local output free
local_output_free:200:0:PSA_SUCCESS
PSA crypto local output free, NULL buffer
local_output_free:0:0:PSA_SUCCESS
PSA crypto local output free, NULL original buffer
local_output_free:200:1:PSA_ERROR_CORRUPTION_DETECTED
PSA crypto local output round-trip
local_output_round_trip

View File

@@ -0,0 +1,258 @@
/* BEGIN_HEADER */
#include <stdint.h>
#include "common.h"
#include "psa/crypto.h"
#include "psa_crypto_core.h"
#include "psa_crypto_invasive.h"
#include "test/psa_crypto_helpers.h"
#include "test/memory.h"
/* Helper to fill a buffer with a data pattern. The pattern is not
* important, it just allows a basic check that the correct thing has
* been written, in a way that will detect an error in offset. */
static void fill_buffer_pattern(uint8_t *buffer, size_t len)
{
for (size_t i = 0; i < len; i++) {
buffer[i] = (uint8_t) (i % 256);
}
}
/* END_HEADER */
/* BEGIN_DEPENDENCIES
* depends_on:MBEDTLS_PSA_CRYPTO_C:MBEDTLS_TEST_HOOKS
* END_DEPENDENCIES
*/
/* BEGIN_CASE */
void copy_input(int src_len, int dst_len, psa_status_t exp_status)
{
uint8_t *src_buffer = NULL;
uint8_t *dst_buffer = NULL;
psa_status_t status;
TEST_CALLOC(src_buffer, src_len);
TEST_CALLOC(dst_buffer, dst_len);
fill_buffer_pattern(src_buffer, src_len);
status = psa_crypto_copy_input(src_buffer, src_len, dst_buffer, dst_len);
TEST_EQUAL(status, exp_status);
if (exp_status == PSA_SUCCESS) {
MBEDTLS_TEST_MEMORY_UNPOISON(src_buffer, src_len);
/* Note: We compare the first src_len bytes of each buffer, as this is what was copied. */
TEST_MEMORY_COMPARE(src_buffer, src_len, dst_buffer, src_len);
}
exit:
mbedtls_free(src_buffer);
mbedtls_free(dst_buffer);
}
/* END_CASE */
/* BEGIN_CASE */
void copy_output(int src_len, int dst_len, psa_status_t exp_status)
{
uint8_t *src_buffer = NULL;
uint8_t *dst_buffer = NULL;
psa_status_t status;
TEST_CALLOC(src_buffer, src_len);
TEST_CALLOC(dst_buffer, dst_len);
fill_buffer_pattern(src_buffer, src_len);
status = psa_crypto_copy_output(src_buffer, src_len, dst_buffer, dst_len);
TEST_EQUAL(status, exp_status);
if (exp_status == PSA_SUCCESS) {
MBEDTLS_TEST_MEMORY_UNPOISON(dst_buffer, dst_len);
/* Note: We compare the first src_len bytes of each buffer, as this is what was copied. */
TEST_MEMORY_COMPARE(src_buffer, src_len, dst_buffer, src_len);
}
exit:
mbedtls_free(src_buffer);
mbedtls_free(dst_buffer);
}
/* END_CASE */
/* BEGIN_CASE */
void local_input_alloc(int input_len, psa_status_t exp_status)
{
uint8_t *input = NULL;
psa_crypto_local_input_t local_input;
psa_status_t status;
local_input.buffer = NULL;
TEST_CALLOC(input, input_len);
fill_buffer_pattern(input, input_len);
status = psa_crypto_local_input_alloc(input, input_len, &local_input);
TEST_EQUAL(status, exp_status);
if (exp_status == PSA_SUCCESS) {
MBEDTLS_TEST_MEMORY_UNPOISON(input, input_len);
if (input_len != 0) {
TEST_ASSERT(local_input.buffer != input);
}
TEST_MEMORY_COMPARE(input, input_len,
local_input.buffer, local_input.length);
}
exit:
mbedtls_free(local_input.buffer);
mbedtls_free(input);
}
/* END_CASE */
/* BEGIN_CASE */
void local_input_free(int input_len)
{
psa_crypto_local_input_t local_input;
local_input.buffer = NULL;
local_input.length = input_len;
TEST_CALLOC(local_input.buffer, local_input.length);
psa_crypto_local_input_free(&local_input);
TEST_ASSERT(local_input.buffer == NULL);
TEST_EQUAL(local_input.length, 0);
exit:
mbedtls_free(local_input.buffer);
local_input.buffer = NULL;
local_input.length = 0;
}
/* END_CASE */
/* BEGIN_CASE */
void local_input_round_trip()
{
psa_crypto_local_input_t local_input;
uint8_t input[200];
psa_status_t status;
fill_buffer_pattern(input, sizeof(input));
status = psa_crypto_local_input_alloc(input, sizeof(input), &local_input);
TEST_EQUAL(status, PSA_SUCCESS);
MBEDTLS_TEST_MEMORY_UNPOISON(input, sizeof(input));
TEST_MEMORY_COMPARE(local_input.buffer, local_input.length,
input, sizeof(input));
TEST_ASSERT(local_input.buffer != input);
psa_crypto_local_input_free(&local_input);
TEST_ASSERT(local_input.buffer == NULL);
TEST_EQUAL(local_input.length, 0);
}
/* END_CASE */
/* BEGIN_CASE */
void local_output_alloc(int output_len, psa_status_t exp_status)
{
uint8_t *output = NULL;
psa_crypto_local_output_t local_output;
psa_status_t status;
local_output.buffer = NULL;
TEST_CALLOC(output, output_len);
status = psa_crypto_local_output_alloc(output, output_len, &local_output);
TEST_EQUAL(status, exp_status);
if (exp_status == PSA_SUCCESS) {
TEST_ASSERT(local_output.original == output);
TEST_EQUAL(local_output.length, output_len);
}
exit:
mbedtls_free(local_output.buffer);
local_output.original = NULL;
local_output.buffer = NULL;
local_output.length = 0;
mbedtls_free(output);
output = NULL;
}
/* END_CASE */
/* BEGIN_CASE */
void local_output_free(int output_len, int original_is_null,
psa_status_t exp_status)
{
uint8_t *output = NULL;
uint8_t *buffer_copy_for_comparison = NULL;
psa_crypto_local_output_t local_output = PSA_CRYPTO_LOCAL_OUTPUT_INIT;
psa_status_t status;
if (!original_is_null) {
TEST_CALLOC(output, output_len);
}
TEST_CALLOC(buffer_copy_for_comparison, output_len);
TEST_CALLOC(local_output.buffer, output_len);
local_output.length = output_len;
local_output.original = output;
if (local_output.length != 0) {
fill_buffer_pattern(local_output.buffer, local_output.length);
memcpy(buffer_copy_for_comparison, local_output.buffer, local_output.length);
}
status = psa_crypto_local_output_free(&local_output);
TEST_EQUAL(status, exp_status);
if (exp_status == PSA_SUCCESS) {
MBEDTLS_TEST_MEMORY_UNPOISON(output, output_len);
TEST_ASSERT(local_output.buffer == NULL);
TEST_EQUAL(local_output.length, 0);
TEST_MEMORY_COMPARE(buffer_copy_for_comparison, output_len,
output, output_len);
}
exit:
mbedtls_free(output);
mbedtls_free(buffer_copy_for_comparison);
mbedtls_free(local_output.buffer);
local_output.length = 0;
}
/* END_CASE */
/* BEGIN_CASE */
void local_output_round_trip()
{
psa_crypto_local_output_t local_output;
uint8_t output[200];
uint8_t *buffer_copy_for_comparison = NULL;
psa_status_t status;
status = psa_crypto_local_output_alloc(output, sizeof(output), &local_output);
TEST_EQUAL(status, PSA_SUCCESS);
TEST_ASSERT(local_output.buffer != output);
/* Simulate the function generating output */
fill_buffer_pattern(local_output.buffer, local_output.length);
TEST_CALLOC(buffer_copy_for_comparison, local_output.length);
memcpy(buffer_copy_for_comparison, local_output.buffer, local_output.length);
psa_crypto_local_output_free(&local_output);
TEST_ASSERT(local_output.buffer == NULL);
TEST_EQUAL(local_output.length, 0);
MBEDTLS_TEST_MEMORY_UNPOISON(output, sizeof(output));
/* Check that the buffer was correctly copied back */
TEST_MEMORY_COMPARE(output, sizeof(output),
buffer_copy_for_comparison, sizeof(output));
exit:
mbedtls_free(buffer_copy_for_comparison);
}
/* END_CASE */

View File

@@ -0,0 +1,23 @@
Memory poison+unpoison: offset=0 len=42
memory_poison_unpoison:0:42
Memory poison+unpoison: offset=0 len=1
memory_poison_unpoison:0:1
Memory poison+unpoison: offset=0 len=2
memory_poison_unpoison:0:2
Memory poison+unpoison: offset=1 len=1
memory_poison_unpoison:1:1
Memory poison+unpoison: offset=1 len=2
memory_poison_unpoison:1:2
Memory poison+unpoison: offset=7 len=1
memory_poison_unpoison:7:1
Memory poison+unpoison: offset=7 len=2
memory_poison_unpoison:7:2
Memory poison+unpoison: offset=0 len=0
memory_poison_unpoison:0:0

View File

@@ -0,0 +1,40 @@
/* BEGIN_HEADER */
/* Test some parts of the test framework. */
#include <test/helpers.h>
#include <test/memory.h>
/* END_HEADER */
/* BEGIN_DEPENDENCIES */
/* END_DEPENDENCIES */
/* BEGIN_CASE depends_on:MBEDTLS_TEST_MEMORY_CAN_POISON */
/* Test that poison+unpoison leaves the memory accessible. */
/* We can't test that poisoning makes the memory inaccessible:
* there's no sane way to catch an Asan/Valgrind complaint.
* That negative testing is done in programs/test/metatest.c. */
void memory_poison_unpoison(int align, int size)
{
unsigned char *buf = NULL;
const size_t buffer_size = align + size;
TEST_CALLOC(buf, buffer_size);
for (size_t i = 0; i < buffer_size; i++) {
buf[i] = (unsigned char) (i & 0xff);
}
const unsigned char *start = buf == NULL ? NULL : buf + align;
mbedtls_test_memory_poison(start, (size_t) size);
mbedtls_test_memory_unpoison(start, (size_t) size);
for (size_t i = 0; i < buffer_size; i++) {
TEST_EQUAL(buf[i], (unsigned char) (i & 0xff));
}
exit:
mbedtls_free(buf);
}
/* END_CASE */