mirror of
https://github.com/Mbed-TLS/mbedtls.git
synced 2025-07-29 11:41:15 +03:00
Align 3.6 tests/{src,include} with development PR
Signed-off-by: David Horstmann <david.horstmann@arm.com>
This commit is contained in:
@ -1,9 +1,24 @@
|
||||
/**
|
||||
* This file is intended to be used to build PSA test driver libraries. It is
|
||||
* intended to be appended by the test build system to the crypto_config.h file
|
||||
* of the Mbed TLS library the test library will be linked to. It mirrors the
|
||||
* PSA_ACCEL_* macros defining the cryptographic operations the test library
|
||||
* supports.
|
||||
* This file is intended to be used to build PSA external test driver
|
||||
* libraries (libtestdriver1).
|
||||
*
|
||||
* It is intended to be appended by the test build system to the
|
||||
* crypto_config.h file of the Mbed TLS library the test library will be
|
||||
* linked to (see `tests/Makefile` libtestdriver1 target). This is done in
|
||||
* order to insert it at the right time: after the main configuration
|
||||
* (PSA_WANT) but before the logic that determines what built-ins to enable
|
||||
* based on PSA_WANT and MBEDTLS_PSA_ACCEL macros.
|
||||
*
|
||||
* It reverses the PSA_ACCEL_* macros defining the cryptographic operations
|
||||
* that will be accelerated in the main library:
|
||||
* - When something is accelerated in the main library, we need it supported
|
||||
* in libtestdriver1, so we disable the accel macro in order to the built-in
|
||||
* to be enabled.
|
||||
* - When something is NOT accelerated in the main library, we don't need it
|
||||
* in libtestdriver1, so we enable its accel macro in order to the built-in
|
||||
* to be disabled, to keep libtestdriver1 minimal. (We can't adjust the
|
||||
* PSA_WANT macros as they need to be the same between libtestdriver1 and
|
||||
* the main library, since they determine the ABI between the two.)
|
||||
*/
|
||||
|
||||
#include "psa/crypto_legacy.h"
|
||||
|
@ -11,7 +11,7 @@
|
||||
|
||||
#include "test/helpers.h"
|
||||
|
||||
#if defined(MBEDTLS_PSA_CRYPTO_C)
|
||||
#if defined(MBEDTLS_PSA_CRYPTO_CLIENT)
|
||||
#include "test/psa_helpers.h"
|
||||
#include <psa/crypto.h>
|
||||
#endif
|
||||
@ -40,12 +40,15 @@
|
||||
mbedtls_psa_crypto_free(); \
|
||||
} \
|
||||
while (0)
|
||||
#else /*MBEDTLS_PSA_CRYPTO_C */
|
||||
#elif defined(MBEDTLS_PSA_CRYPTO_CLIENT) /* MBEDTLS_PSA_CRYPTO_CLIENT && !MBEDTLS_PSA_CRYPTO_C */
|
||||
#define PSA_INIT() PSA_ASSERT(psa_crypto_init())
|
||||
#define PSA_DONE() mbedtls_psa_crypto_free();
|
||||
#else /* MBEDTLS_PSA_CRYPTO_CLIENT && !MBEDTLS_PSA_CRYPTO_C */
|
||||
#define PSA_INIT() ((void) 0)
|
||||
#define PSA_DONE() ((void) 0)
|
||||
#endif /* MBEDTLS_PSA_CRYPTO_C */
|
||||
|
||||
#if defined(MBEDTLS_PSA_CRYPTO_C)
|
||||
#if defined(MBEDTLS_PSA_CRYPTO_CLIENT)
|
||||
|
||||
#if defined(MBEDTLS_PSA_CRYPTO_STORAGE_C)
|
||||
|
||||
@ -293,18 +296,19 @@ uint64_t mbedtls_test_parse_binary_string(data_t *bin_string);
|
||||
* \param alg The AEAD algorithm.
|
||||
* \param nonce_length The nonce length in number of bytes.
|
||||
*/
|
||||
|
||||
#if defined(MBEDTLS_GCM_ALT) || \
|
||||
defined(MBEDTLS_PSA_ACCEL_ALG_GCM)
|
||||
#define MBEDTLS_TEST_HAVE_ALT_GCM 1
|
||||
#define MBEDTLS_TEST_HAVE_ACCEL_GCM 1
|
||||
#else
|
||||
#define MBEDTLS_TEST_HAVE_ALT_GCM 0
|
||||
#define MBEDTLS_TEST_HAVE_ACCEL_GCM 0
|
||||
#endif
|
||||
|
||||
#define MBEDTLS_TEST_PSA_SKIP_IF_ALT_GCM_NOT_12BYTES_NONCE(alg, \
|
||||
nonce_length) \
|
||||
do \
|
||||
{ \
|
||||
if ((MBEDTLS_TEST_HAVE_ALT_GCM) && \
|
||||
if ((MBEDTLS_TEST_HAVE_ACCEL_GCM) && \
|
||||
(PSA_ALG_AEAD_WITH_SHORTENED_TAG((alg), 0) == \
|
||||
PSA_ALG_AEAD_WITH_SHORTENED_TAG(PSA_ALG_GCM, 0)) && \
|
||||
((nonce_length) != 12)) \
|
||||
@ -315,7 +319,7 @@ uint64_t mbedtls_test_parse_binary_string(data_t *bin_string);
|
||||
} \
|
||||
while (0)
|
||||
|
||||
#endif /* MBEDTLS_PSA_CRYPTO_C */
|
||||
#endif /* MBEDTLS_PSA_CRYPTO_CLIENT */
|
||||
|
||||
/** \def USE_PSA_INIT
|
||||
*
|
||||
@ -334,18 +338,9 @@ uint64_t mbedtls_test_parse_binary_string(data_t *bin_string);
|
||||
* This is like #PSA_DONE except it does nothing under the same conditions as
|
||||
* #USE_PSA_INIT.
|
||||
*/
|
||||
#if defined(MBEDTLS_USE_PSA_CRYPTO)
|
||||
#if defined(MBEDTLS_USE_PSA_CRYPTO) || defined(MBEDTLS_SSL_PROTO_TLS1_3)
|
||||
#define USE_PSA_INIT() PSA_INIT()
|
||||
#define USE_PSA_DONE() PSA_DONE()
|
||||
#elif defined(MBEDTLS_SSL_PROTO_TLS1_3)
|
||||
/* TLS 1.3 must work without having called psa_crypto_init(), for backward
|
||||
* compatibility with Mbed TLS <= 3.5 when connecting with a peer that
|
||||
* supports both TLS 1.2 and TLS 1.3. See mbedtls_ssl_tls13_crypto_init()
|
||||
* and https://github.com/Mbed-TLS/mbedtls/issues/9072 . */
|
||||
#define USE_PSA_INIT() ((void) 0)
|
||||
/* TLS 1.3 may have initialized the PSA subsystem. Shut it down cleanly,
|
||||
* otherwise Asan and Valgrind would notice a resource leak. */
|
||||
#define USE_PSA_DONE() PSA_DONE()
|
||||
#else /* MBEDTLS_USE_PSA_CRYPTO || MBEDTLS_SSL_PROTO_TLS1_3 */
|
||||
/* Define empty macros so that we can use them in the preamble and teardown
|
||||
* of every test function that uses PSA conditionally based on
|
||||
@ -417,12 +412,13 @@ uint64_t mbedtls_test_parse_binary_string(data_t *bin_string);
|
||||
* This is like #PSA_DONE except it does nothing under the same conditions as
|
||||
* #MD_OR_USE_PSA_INIT.
|
||||
*/
|
||||
#if defined(MBEDTLS_MD_SOME_PSA)
|
||||
#if defined(MBEDTLS_MD_SOME_PSA) || \
|
||||
defined(MBEDTLS_USE_PSA_CRYPTO) || defined(MBEDTLS_SSL_PROTO_TLS1_3)
|
||||
#define MD_OR_USE_PSA_INIT() PSA_INIT()
|
||||
#define MD_OR_USE_PSA_DONE() PSA_DONE()
|
||||
#else
|
||||
#define MD_OR_USE_PSA_INIT() USE_PSA_INIT()
|
||||
#define MD_OR_USE_PSA_DONE() USE_PSA_DONE()
|
||||
#define MD_OR_USE_PSA_INIT() ((void) 0)
|
||||
#define MD_OR_USE_PSA_DONE() ((void) 0)
|
||||
#endif
|
||||
|
||||
/** \def AES_PSA_INIT
|
||||
|
@ -363,13 +363,22 @@ psa_status_t mbedtls_test_wrap_psa_generate_key_custom(
|
||||
#define psa_generate_key_custom(arg0_attributes, arg1_custom, arg2_custom_data, arg3_custom_data_length, arg4_key) \
|
||||
mbedtls_test_wrap_psa_generate_key_custom(arg0_attributes, arg1_custom, arg2_custom_data, arg3_custom_data_length, arg4_key)
|
||||
|
||||
psa_status_t mbedtls_test_wrap_psa_generate_key_ext(
|
||||
const psa_key_attributes_t *arg0_attributes,
|
||||
const psa_key_production_parameters_t *arg1_params,
|
||||
size_t arg2_params_data_length,
|
||||
mbedtls_svc_key_id_t *arg3_key);
|
||||
#define psa_generate_key_ext(arg0_attributes, arg1_params, arg2_params_data_length, arg3_key) \
|
||||
mbedtls_test_wrap_psa_generate_key_ext(arg0_attributes, arg1_params, arg2_params_data_length, arg3_key)
|
||||
psa_status_t mbedtls_test_wrap_psa_generate_key_iop_abort(
|
||||
psa_generate_key_iop_t *arg0_operation);
|
||||
#define psa_generate_key_iop_abort(arg0_operation) \
|
||||
mbedtls_test_wrap_psa_generate_key_iop_abort(arg0_operation)
|
||||
|
||||
psa_status_t mbedtls_test_wrap_psa_generate_key_iop_complete(
|
||||
psa_generate_key_iop_t *arg0_operation,
|
||||
psa_key_id_t *arg1_key);
|
||||
#define psa_generate_key_iop_complete(arg0_operation, arg1_key) \
|
||||
mbedtls_test_wrap_psa_generate_key_iop_complete(arg0_operation, arg1_key)
|
||||
|
||||
psa_status_t mbedtls_test_wrap_psa_generate_key_iop_setup(
|
||||
psa_generate_key_iop_t *arg0_operation,
|
||||
const psa_key_attributes_t *arg1_attributes);
|
||||
#define psa_generate_key_iop_setup(arg0_operation, arg1_attributes) \
|
||||
mbedtls_test_wrap_psa_generate_key_iop_setup(arg0_operation, arg1_attributes)
|
||||
|
||||
psa_status_t mbedtls_test_wrap_psa_generate_random(
|
||||
uint8_t *arg0_output,
|
||||
@ -449,6 +458,37 @@ psa_status_t mbedtls_test_wrap_psa_import_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_agreement(
|
||||
mbedtls_svc_key_id_t arg0_private_key,
|
||||
const uint8_t *arg1_peer_key,
|
||||
size_t arg2_peer_key_length,
|
||||
psa_algorithm_t arg3_alg,
|
||||
const psa_key_attributes_t *arg4_attributes,
|
||||
mbedtls_svc_key_id_t *arg5_key);
|
||||
#define psa_key_agreement(arg0_private_key, arg1_peer_key, arg2_peer_key_length, arg3_alg, arg4_attributes, arg5_key) \
|
||||
mbedtls_test_wrap_psa_key_agreement(arg0_private_key, arg1_peer_key, arg2_peer_key_length, arg3_alg, arg4_attributes, arg5_key)
|
||||
|
||||
psa_status_t mbedtls_test_wrap_psa_key_agreement_iop_abort(
|
||||
psa_key_agreement_iop_t *arg0_operation);
|
||||
#define psa_key_agreement_iop_abort(arg0_operation) \
|
||||
mbedtls_test_wrap_psa_key_agreement_iop_abort(arg0_operation)
|
||||
|
||||
psa_status_t mbedtls_test_wrap_psa_key_agreement_iop_complete(
|
||||
psa_key_agreement_iop_t *arg0_operation,
|
||||
psa_key_id_t *arg1_key);
|
||||
#define psa_key_agreement_iop_complete(arg0_operation, arg1_key) \
|
||||
mbedtls_test_wrap_psa_key_agreement_iop_complete(arg0_operation, arg1_key)
|
||||
|
||||
psa_status_t mbedtls_test_wrap_psa_key_agreement_iop_setup(
|
||||
psa_key_agreement_iop_t *arg0_operation,
|
||||
psa_key_id_t arg1_private_key,
|
||||
const uint8_t *arg2_peer_key,
|
||||
size_t arg3_peer_key_length,
|
||||
psa_algorithm_t arg4_alg,
|
||||
const psa_key_attributes_t *arg5_attributes);
|
||||
#define psa_key_agreement_iop_setup(arg0_operation, arg1_private_key, arg2_peer_key, arg3_peer_key_length, arg4_alg, arg5_attributes) \
|
||||
mbedtls_test_wrap_psa_key_agreement_iop_setup(arg0_operation, arg1_private_key, arg2_peer_key, arg3_peer_key_length, arg4_alg, arg5_attributes)
|
||||
|
||||
psa_status_t mbedtls_test_wrap_psa_key_derivation_abort(
|
||||
psa_key_derivation_operation_t *arg0_operation);
|
||||
#define psa_key_derivation_abort(arg0_operation) \
|
||||
@ -515,15 +555,6 @@ psa_status_t mbedtls_test_wrap_psa_key_derivation_output_key_custom(
|
||||
#define psa_key_derivation_output_key_custom(arg0_attributes, arg1_operation, arg2_custom, arg3_custom_data, arg4_custom_data_length, arg5_key) \
|
||||
mbedtls_test_wrap_psa_key_derivation_output_key_custom(arg0_attributes, arg1_operation, arg2_custom, arg3_custom_data, arg4_custom_data_length, arg5_key)
|
||||
|
||||
psa_status_t mbedtls_test_wrap_psa_key_derivation_output_key_ext(
|
||||
const psa_key_attributes_t *arg0_attributes,
|
||||
psa_key_derivation_operation_t *arg1_operation,
|
||||
const psa_key_production_parameters_t *arg2_params,
|
||||
size_t arg3_params_data_length,
|
||||
mbedtls_svc_key_id_t *arg4_key);
|
||||
#define psa_key_derivation_output_key_ext(arg0_attributes, arg1_operation, arg2_params, arg3_params_data_length, arg4_key) \
|
||||
mbedtls_test_wrap_psa_key_derivation_output_key_ext(arg0_attributes, arg1_operation, arg2_params, arg3_params_data_length, arg4_key)
|
||||
|
||||
psa_status_t mbedtls_test_wrap_psa_key_derivation_set_capacity(
|
||||
psa_key_derivation_operation_t *arg0_operation,
|
||||
size_t arg1_capacity);
|
||||
|
Reference in New Issue
Block a user