Adjust spacing in tests/suites function sources

Signed-off-by: Michael Schuster <michael@schuster.ms>
This commit is contained in:
Michael Schuster 2024-06-04 02:41:10 +02:00 committed by Minos Galanakis
parent b1e33fb707
commit 31b1cb8601
17 changed files with 149 additions and 149 deletions

View File

@ -951,9 +951,9 @@ int mbedtls_test_move_handshake_to_state(mbedtls_ssl_context *ssl,
* Write application data. Increase write counter if necessary. * Write application data. Increase write counter if necessary.
*/ */
static int mbedtls_ssl_write_fragment(mbedtls_ssl_context *ssl, static int mbedtls_ssl_write_fragment(mbedtls_ssl_context *ssl,
unsigned char *buf, int buf_len, unsigned char *buf, int buf_len,
int *written, int *written,
const int expected_fragments) const int expected_fragments)
{ {
int ret; int ret;
/* Verify that calling mbedtls_ssl_write with a NULL buffer and zero length is /* Verify that calling mbedtls_ssl_write with a NULL buffer and zero length is
@ -998,9 +998,9 @@ exit:
* if necessary. * if necessary.
*/ */
static int mbedtls_ssl_read_fragment(mbedtls_ssl_context *ssl, static int mbedtls_ssl_read_fragment(mbedtls_ssl_context *ssl,
unsigned char *buf, int buf_len, unsigned char *buf, int buf_len,
int *read, int *fragments, int *read, int *fragments,
const int expected_fragments) const int expected_fragments)
{ {
int ret; int ret;
/* Verify that calling mbedtls_ssl_write with a NULL buffer and zero length is /* Verify that calling mbedtls_ssl_write with a NULL buffer and zero length is

View File

@ -55,8 +55,8 @@
/* Indicates whether we expect mbedtls_entropy_init /* Indicates whether we expect mbedtls_entropy_init
* to initialize some strong entropy source. */ * to initialize some strong entropy source. */
#if !defined(MBEDTLS_NO_DEFAULT_ENTROPY_SOURCES) && \ #if !defined(MBEDTLS_NO_DEFAULT_ENTROPY_SOURCES) && \
(!defined(MBEDTLS_NO_PLATFORM_ENTROPY) || \ (!defined(MBEDTLS_NO_PLATFORM_ENTROPY) || \
defined(MBEDTLS_ENTROPY_HARDWARE_ALT) || \ defined(MBEDTLS_ENTROPY_HARDWARE_ALT) || \
defined(ENTROPY_NV_SEED)) defined(ENTROPY_NV_SEED))
#define ENTROPY_HAVE_STRONG #define ENTROPY_HAVE_STRONG
#endif #endif

View File

@ -123,7 +123,7 @@ exit:
} }
static int get_len_step(const data_t *input, size_t buffer_size, static int get_len_step(const data_t *input, size_t buffer_size,
size_t actual_length) size_t actual_length)
{ {
unsigned char *buf = NULL; unsigned char *buf = NULL;
unsigned char *p = NULL; unsigned char *p = NULL;

View File

@ -27,7 +27,7 @@ exit:
} }
static int generic_write_finish_step(generic_write_data_t *data, static int generic_write_finish_step(generic_write_data_t *data,
const data_t *expected, int ret) const data_t *expected, int ret)
{ {
int ok = 0; int ok = 0;

View File

@ -45,8 +45,8 @@ typedef struct mbedtls_test_mpi_random {
* the format that mbedtls_mpi_read_string understands and is chunk_len long. * the format that mbedtls_mpi_read_string understands and is chunk_len long.
*/ */
static int mbedtls_test_mpi_miller_rabin_determinizer(void *state, static int mbedtls_test_mpi_miller_rabin_determinizer(void *state,
unsigned char *buf, unsigned char *buf,
size_t len) size_t len)
{ {
mbedtls_test_mpi_random *random = (mbedtls_test_mpi_random *) state; mbedtls_test_mpi_random *random = (mbedtls_test_mpi_random *) state;

View File

@ -2,8 +2,8 @@
#include "mbedtls/dhm.h" #include "mbedtls/dhm.h"
static int check_get_value(const mbedtls_dhm_context *ctx, static int check_get_value(const mbedtls_dhm_context *ctx,
mbedtls_dhm_parameter param, mbedtls_dhm_parameter param,
const mbedtls_mpi *expected) const mbedtls_mpi *expected)
{ {
mbedtls_mpi actual; mbedtls_mpi actual;
int ok = 0; int ok = 0;

View File

@ -222,8 +222,8 @@ exit:
#if defined(MBEDTLS_PSA_CRYPTO_C) #if defined(MBEDTLS_PSA_CRYPTO_C)
static psa_status_t pk_psa_import_key(const unsigned char *key_data, size_t key_len, static psa_status_t pk_psa_import_key(const unsigned char *key_data, size_t key_len,
psa_key_type_t type, psa_key_usage_t usage, psa_key_type_t type, psa_key_usage_t usage,
psa_algorithm_t alg, mbedtls_svc_key_id_t *key) psa_algorithm_t alg, mbedtls_svc_key_id_t *key)
{ {
psa_key_attributes_t attributes = PSA_KEY_ATTRIBUTES_INIT; psa_key_attributes_t attributes = PSA_KEY_ATTRIBUTES_INIT;
psa_status_t status; psa_status_t status;
@ -321,10 +321,10 @@ exit:
* \param[out] key Identifier of the "generated" (actually imported) PSA key. * \param[out] key Identifier of the "generated" (actually imported) PSA key.
*/ */
static psa_status_t pk_psa_setup(psa_key_type_t type, size_t bits, static psa_status_t pk_psa_setup(psa_key_type_t type, size_t bits,
psa_key_usage_t usage, psa_algorithm_t alg, psa_key_usage_t usage, psa_algorithm_t alg,
psa_algorithm_t enrollment_alg, psa_algorithm_t enrollment_alg,
mbedtls_svc_key_id_t persistent_key_id, mbedtls_svc_key_id_t persistent_key_id,
mbedtls_svc_key_id_t *key) mbedtls_svc_key_id_t *key)
{ {
psa_key_attributes_t attributes = PSA_KEY_ATTRIBUTES_INIT; psa_key_attributes_t attributes = PSA_KEY_ATTRIBUTES_INIT;
psa_status_t status = PSA_ERROR_GENERIC_ERROR; psa_status_t status = PSA_ERROR_GENERIC_ERROR;
@ -469,17 +469,17 @@ exit:
#if defined(MBEDTLS_RSA_C) #if defined(MBEDTLS_RSA_C)
static int mbedtls_rsa_decrypt_func(void *ctx, size_t *olen, static int mbedtls_rsa_decrypt_func(void *ctx, size_t *olen,
const unsigned char *input, unsigned char *output, const unsigned char *input, unsigned char *output,
size_t output_max_len) size_t output_max_len)
{ {
return mbedtls_rsa_pkcs1_decrypt((mbedtls_rsa_context *) ctx, return mbedtls_rsa_pkcs1_decrypt((mbedtls_rsa_context *) ctx,
mbedtls_test_rnd_std_rand, NULL, mbedtls_test_rnd_std_rand, NULL,
olen, input, output, output_max_len); olen, input, output, output_max_len);
} }
static int mbedtls_rsa_sign_func(void *ctx, static int mbedtls_rsa_sign_func(void *ctx,
int (*f_rng)(void *, unsigned char *, size_t), void *p_rng, int (*f_rng)(void *, unsigned char *, size_t), void *p_rng,
mbedtls_md_type_t md_alg, unsigned int hashlen, mbedtls_md_type_t md_alg, unsigned int hashlen,
const unsigned char *hash, unsigned char *sig) const unsigned char *hash, unsigned char *sig)
{ {
((void) f_rng); ((void) f_rng);
((void) p_rng); ((void) p_rng);

View File

@ -154,11 +154,11 @@ static int construct_fake_rsa_key(unsigned char *buffer,
#endif /* MBEDTLS_ASN1_WRITE_C */ #endif /* MBEDTLS_ASN1_WRITE_C */
static int exercise_mac_setup(psa_key_type_t key_type, static int exercise_mac_setup(psa_key_type_t key_type,
const unsigned char *key_bytes, const unsigned char *key_bytes,
size_t key_length, size_t key_length,
psa_algorithm_t alg, psa_algorithm_t alg,
psa_mac_operation_t *operation, psa_mac_operation_t *operation,
psa_status_t *status) psa_status_t *status)
{ {
mbedtls_svc_key_id_t key = MBEDTLS_SVC_KEY_ID_INIT; mbedtls_svc_key_id_t key = MBEDTLS_SVC_KEY_ID_INIT;
psa_key_attributes_t attributes = PSA_KEY_ATTRIBUTES_INIT; psa_key_attributes_t attributes = PSA_KEY_ATTRIBUTES_INIT;
@ -186,11 +186,11 @@ exit:
} }
static int exercise_cipher_setup(psa_key_type_t key_type, static int exercise_cipher_setup(psa_key_type_t key_type,
const unsigned char *key_bytes, const unsigned char *key_bytes,
size_t key_length, size_t key_length,
psa_algorithm_t alg, psa_algorithm_t alg,
psa_cipher_operation_t *operation, psa_cipher_operation_t *operation,
psa_status_t *status) psa_status_t *status)
{ {
mbedtls_svc_key_id_t key = MBEDTLS_SVC_KEY_ID_INIT; mbedtls_svc_key_id_t key = MBEDTLS_SVC_KEY_ID_INIT;
psa_key_attributes_t attributes = PSA_KEY_ATTRIBUTES_INIT; psa_key_attributes_t attributes = PSA_KEY_ATTRIBUTES_INIT;
@ -263,14 +263,14 @@ exit:
/* Assert that a key isn't reported as having a slot number. */ /* Assert that a key isn't reported as having a slot number. */
#if defined(MBEDTLS_PSA_CRYPTO_SE_C) #if defined(MBEDTLS_PSA_CRYPTO_SE_C)
#define ASSERT_NO_SLOT_NUMBER(attributes) \ #define ASSERT_NO_SLOT_NUMBER(attributes) \
do \ do \
{ \ { \
psa_key_slot_number_t ASSERT_NO_SLOT_NUMBER_slot_number; \ psa_key_slot_number_t ASSERT_NO_SLOT_NUMBER_slot_number; \
TEST_EQUAL(psa_get_key_slot_number( \ TEST_EQUAL(psa_get_key_slot_number( \
attributes, \ attributes, \
&ASSERT_NO_SLOT_NUMBER_slot_number), \ &ASSERT_NO_SLOT_NUMBER_slot_number), \
PSA_ERROR_INVALID_ARGUMENT); \ PSA_ERROR_INVALID_ARGUMENT); \
} \ } \
while (0) while (0)
#else /* MBEDTLS_PSA_CRYPTO_SE_C */ #else /* MBEDTLS_PSA_CRYPTO_SE_C */
#define ASSERT_NO_SLOT_NUMBER(attributes) \ #define ASSERT_NO_SLOT_NUMBER(attributes) \

View File

@ -80,17 +80,17 @@
* Unconditionally mask flag into the ambient variable * Unconditionally mask flag into the ambient variable
* classification_flags_tested. * classification_flags_tested.
*/ */
#define TEST_CLASSIFICATION_MACRO(cond, flag, alg, flags) \ #define TEST_CLASSIFICATION_MACRO(cond, flag, alg, flags) \
do \ do \
{ \ { \
if (cond) \ if (cond) \
{ \ { \
if ((flags) & (flag)) \ if ((flags) & (flag)) \
TEST_ASSERT(PSA_##flag(alg)); \ TEST_ASSERT(PSA_##flag(alg)); \
else \ else \
TEST_ASSERT(!PSA_##flag(alg)); \ TEST_ASSERT(!PSA_##flag(alg)); \
} \ } \
classification_flags_tested |= (flag); \ classification_flags_tested |= (flag); \
} \ } \
while (0) while (0)
@ -193,8 +193,8 @@ exit:;
} }
static void mac_algorithm_core(psa_algorithm_t alg, int classification_flags, static void mac_algorithm_core(psa_algorithm_t alg, int classification_flags,
psa_key_type_t key_type, size_t key_bits, psa_key_type_t key_type, size_t key_bits,
size_t length) size_t length)
{ {
/* Algorithm classification */ /* Algorithm classification */
TEST_ASSERT(!PSA_ALG_IS_HASH(alg)); TEST_ASSERT(!PSA_ALG_IS_HASH(alg));
@ -219,8 +219,8 @@ exit:;
} }
static void aead_algorithm_core(psa_algorithm_t alg, int classification_flags, static void aead_algorithm_core(psa_algorithm_t alg, int classification_flags,
psa_key_type_t key_type, size_t key_bits, psa_key_type_t key_type, size_t key_bits,
size_t tag_length) size_t tag_length)
{ {
/* Algorithm classification */ /* Algorithm classification */
TEST_ASSERT(!PSA_ALG_IS_HASH(alg)); TEST_ASSERT(!PSA_ALG_IS_HASH(alg));

View File

@ -27,11 +27,11 @@ static int test_equal_status(const char *test,
* run, it would be better to clarify the expectations and reconcile the * run, it would be better to clarify the expectations and reconcile the
* library and the test case generator. * library and the test case generator.
*/ */
#define TEST_STATUS(expr1, expr2) \ #define TEST_STATUS(expr1, expr2) \
do { \ do { \
if (!test_equal_status( #expr1 " == " #expr2, __LINE__, __FILE__, \ if (!test_equal_status( #expr1 " == " #expr2, __LINE__, __FILE__, \
expr1, expr2)) \ expr1, expr2)) \
goto exit; \ goto exit; \
} while (0) } while (0)
/* END_HEADER */ /* END_HEADER */

View File

@ -71,9 +71,9 @@ static const uint8_t jpake_client_id[] = { 'c', 'l', 'i', 'e', 'n', 't' };
* we're corrupting. * we're corrupting.
*/ */
#define DO_ROUND_CONDITIONAL_INJECT(this_stage, buf) \ #define DO_ROUND_CONDITIONAL_INJECT(this_stage, buf) \
if (this_stage == err_stage) \ if (this_stage == err_stage) \
{ \ { \
*(buf + 7) ^= 1; \ *(buf + 7) ^= 1; \
} }
#define DO_ROUND_CONDITIONAL_CHECK_FAILURE(this_stage, function) \ #define DO_ROUND_CONDITIONAL_CHECK_FAILURE(this_stage, function) \
@ -84,20 +84,20 @@ static const uint8_t jpake_client_id[] = { 'c', 'l', 'i', 'e', 'n', 't' };
} }
#define DO_ROUND_UPDATE_OFFSETS(main_buf_offset, step_offset, step_size) \ #define DO_ROUND_UPDATE_OFFSETS(main_buf_offset, step_offset, step_size) \
{ \ { \
step_offset = main_buf_offset; \ step_offset = main_buf_offset; \
main_buf_offset += step_size; \ main_buf_offset += step_size; \
} }
#define DO_ROUND_CHECK_FAILURE() \ #define DO_ROUND_CHECK_FAILURE() \
if (err_stage != ERR_NONE && status != PSA_SUCCESS) \ if (err_stage != ERR_NONE && status != PSA_SUCCESS) \
{ \ { \
TEST_EQUAL(status, expected_error_arg); \ TEST_EQUAL(status, expected_error_arg); \
break; \ break; \
} \ } \
else \ else \
{ \ { \
TEST_EQUAL(status, PSA_SUCCESS); \ TEST_EQUAL(status, PSA_SUCCESS); \
} }
#if defined(PSA_WANT_ALG_JPAKE) #if defined(PSA_WANT_ALG_JPAKE)
@ -550,15 +550,15 @@ exit:
* - terminated with failure otherwise (either no error was expected at this * - terminated with failure otherwise (either no error was expected at this
* stage or a different error code was expected) * stage or a different error code was expected)
*/ */
#define SETUP_ALWAYS_CHECK_STEP(test_function, this_check_err_stage) \ #define SETUP_ALWAYS_CHECK_STEP(test_function, this_check_err_stage) \
status = test_function; \ status = test_function; \
if (err_stage != this_check_err_stage) \ if (err_stage != this_check_err_stage) \
{ \ { \
PSA_ASSERT(status); \ PSA_ASSERT(status); \
} \ } \
else \ else \
{ \ { \
TEST_EQUAL(status, expected_error); \ TEST_EQUAL(status, expected_error); \
goto exit; \ goto exit; \
} }
@ -572,10 +572,10 @@ exit:
* The test succeeds if the returned error is exactly the expected one, * The test succeeds if the returned error is exactly the expected one,
* otherwise it fails. * otherwise it fails.
*/ */
#define SETUP_CONDITIONAL_CHECK_STEP(test_function, this_check_err_stage) \ #define SETUP_CONDITIONAL_CHECK_STEP(test_function, this_check_err_stage) \
if (err_stage == this_check_err_stage) \ if (err_stage == this_check_err_stage) \
{ \ { \
TEST_EQUAL(test_function, expected_error); \ TEST_EQUAL(test_function, expected_error); \
goto exit; \ goto exit; \
} }
/* END_HEADER */ /* END_HEADER */

View File

@ -14,8 +14,8 @@
#endif #endif
/* Same in library/psa_crypto.c */ /* Same in library/psa_crypto.c */
#if defined(MBEDTLS_PSA_BUILTIN_ALG_HKDF) || \ #if defined(MBEDTLS_PSA_BUILTIN_ALG_HKDF) || \
defined(MBEDTLS_PSA_BUILTIN_ALG_HKDF_EXTRACT) || \ defined(MBEDTLS_PSA_BUILTIN_ALG_HKDF_EXTRACT) || \
defined(MBEDTLS_PSA_BUILTIN_ALG_HKDF_EXPAND) defined(MBEDTLS_PSA_BUILTIN_ALG_HKDF_EXPAND)
#define BUILTIN_ALG_ANY_HKDF 1 #define BUILTIN_ALG_ANY_HKDF 1
#endif #endif
@ -36,11 +36,11 @@
/** The location and lifetime used for tests that use a single driver. */ /** The location and lifetime used for tests that use a single driver. */
#define TEST_DRIVER_LOCATION 1 #define TEST_DRIVER_LOCATION 1
#define TEST_SE_PERSISTENT_LIFETIME \ #define TEST_SE_PERSISTENT_LIFETIME \
(PSA_KEY_LIFETIME_FROM_PERSISTENCE_AND_LOCATION( \ (PSA_KEY_LIFETIME_FROM_PERSISTENCE_AND_LOCATION( \
PSA_KEY_PERSISTENCE_DEFAULT, TEST_DRIVER_LOCATION)) PSA_KEY_PERSISTENCE_DEFAULT, TEST_DRIVER_LOCATION))
#define TEST_SE_VOLATILE_LIFETIME \ #define TEST_SE_VOLATILE_LIFETIME \
(PSA_KEY_LIFETIME_FROM_PERSISTENCE_AND_LOCATION( \ (PSA_KEY_LIFETIME_FROM_PERSISTENCE_AND_LOCATION( \
PSA_KEY_PERSISTENCE_VOLATILE, TEST_DRIVER_LOCATION)) PSA_KEY_PERSISTENCE_VOLATILE, TEST_DRIVER_LOCATION))
@ -54,13 +54,13 @@
* *
* Use this macro to assert on guarantees provided by the core. * Use this macro to assert on guarantees provided by the core.
*/ */
#define DRIVER_ASSERT_RETURN(TEST) \ #define DRIVER_ASSERT_RETURN(TEST) \
do { \ do { \
if (!(TEST)) \ if (!(TEST)) \
{ \ { \
mbedtls_test_fail( #TEST, __LINE__, __FILE__); \ mbedtls_test_fail( #TEST, __LINE__, __FILE__); \
return PSA_ERROR_DETECTED_BY_DRIVER; \ return PSA_ERROR_DETECTED_BY_DRIVER; \
} \ } \
} while (0) } while (0)
/** Like #TEST_ASSERT for use in a driver method, with cleanup. /** Like #TEST_ASSERT for use in a driver method, with cleanup.
@ -70,14 +70,14 @@
* *
* Use this macro to assert on guarantees provided by the core. * Use this macro to assert on guarantees provided by the core.
*/ */
#define DRIVER_ASSERT(TEST) \ #define DRIVER_ASSERT(TEST) \
do { \ do { \
if (!(TEST)) \ if (!(TEST)) \
{ \ { \
mbedtls_test_fail( #TEST, __LINE__, __FILE__); \ mbedtls_test_fail( #TEST, __LINE__, __FILE__); \
status = PSA_ERROR_DETECTED_BY_DRIVER; \ status = PSA_ERROR_DETECTED_BY_DRIVER; \
goto exit; \ goto exit; \
} \ } \
} while (0) } while (0)
/** Like #PSA_ASSERT for a PSA API call that calls a driver underneath. /** Like #PSA_ASSERT for a PSA API call that calls a driver underneath.
@ -91,16 +91,16 @@
* case, the test driver code is expected to have called mbedtls_test_fail() * case, the test driver code is expected to have called mbedtls_test_fail()
* already, so we make sure not to overwrite the failure information. * already, so we make sure not to overwrite the failure information.
*/ */
#define PSA_ASSERT_VIA_DRIVER(expr, expected_status) \ #define PSA_ASSERT_VIA_DRIVER(expr, expected_status) \
do { \ do { \
psa_status_t PSA_ASSERT_VIA_DRIVER_status = (expr); \ psa_status_t PSA_ASSERT_VIA_DRIVER_status = (expr); \
if (PSA_ASSERT_VIA_DRIVER_status == PSA_ERROR_DETECTED_BY_DRIVER) \ if (PSA_ASSERT_VIA_DRIVER_status == PSA_ERROR_DETECTED_BY_DRIVER) \
goto exit; \ goto exit; \
if (PSA_ASSERT_VIA_DRIVER_status != (expected_status)) \ if (PSA_ASSERT_VIA_DRIVER_status != (expected_status)) \
{ \ { \
mbedtls_test_fail( #expr, __LINE__, __FILE__); \ mbedtls_test_fail( #expr, __LINE__, __FILE__); \
goto exit; \ goto exit; \
} \ } \
} while (0) } while (0)

View File

@ -6,7 +6,7 @@
/** The location and lifetime used for tests that use a single driver. */ /** The location and lifetime used for tests that use a single driver. */
#define TEST_DRIVER_LOCATION 1 #define TEST_DRIVER_LOCATION 1
#define TEST_SE_PERSISTENT_LIFETIME \ #define TEST_SE_PERSISTENT_LIFETIME \
(PSA_KEY_LIFETIME_FROM_PERSISTENCE_AND_LOCATION( \ (PSA_KEY_LIFETIME_FROM_PERSISTENCE_AND_LOCATION( \
PSA_KEY_PERSISTENCE_DEFAULT, TEST_DRIVER_LOCATION)) PSA_KEY_PERSISTENCE_DEFAULT, TEST_DRIVER_LOCATION))
@ -163,10 +163,10 @@ static psa_status_t mock_import(psa_drv_se_context_t *drv_context,
} }
static psa_status_t mock_export(psa_drv_se_context_t *context, static psa_status_t mock_export(psa_drv_se_context_t *context,
psa_key_slot_number_t slot_number, psa_key_slot_number_t slot_number,
uint8_t *p_data, uint8_t *p_data,
size_t data_size, size_t data_size,
size_t *p_data_length) size_t *p_data_length)
{ {
(void) context; (void) context;
(void) p_data; (void) p_data;
@ -180,10 +180,10 @@ static psa_status_t mock_export(psa_drv_se_context_t *context,
} }
static psa_status_t mock_export_public(psa_drv_se_context_t *context, static psa_status_t mock_export_public(psa_drv_se_context_t *context,
psa_key_slot_number_t slot_number, psa_key_slot_number_t slot_number,
uint8_t *p_data, uint8_t *p_data,
size_t data_size, size_t data_size,
size_t *p_data_length) size_t *p_data_length)
{ {
(void) context; (void) context;
(void) p_data; (void) p_data;
@ -197,13 +197,13 @@ static psa_status_t mock_export_public(psa_drv_se_context_t *context,
} }
static psa_status_t mock_sign(psa_drv_se_context_t *context, static psa_status_t mock_sign(psa_drv_se_context_t *context,
psa_key_slot_number_t key_slot, psa_key_slot_number_t key_slot,
psa_algorithm_t alg, psa_algorithm_t alg,
const uint8_t *p_hash, const uint8_t *p_hash,
size_t hash_length, size_t hash_length,
uint8_t *p_signature, uint8_t *p_signature,
size_t signature_size, size_t signature_size,
size_t *p_signature_length) size_t *p_signature_length)
{ {
(void) context; (void) context;
(void) p_hash; (void) p_hash;
@ -220,12 +220,12 @@ static psa_status_t mock_sign(psa_drv_se_context_t *context,
} }
static psa_status_t mock_verify(psa_drv_se_context_t *context, static psa_status_t mock_verify(psa_drv_se_context_t *context,
psa_key_slot_number_t key_slot, psa_key_slot_number_t key_slot,
psa_algorithm_t alg, psa_algorithm_t alg,
const uint8_t *p_hash, const uint8_t *p_hash,
size_t hash_length, size_t hash_length,
const uint8_t *p_signature, const uint8_t *p_signature,
size_t signature_length) size_t signature_length)
{ {
(void) context; (void) context;
(void) p_hash; (void) p_hash;
@ -241,10 +241,10 @@ static psa_status_t mock_verify(psa_drv_se_context_t *context,
} }
static psa_status_t mock_allocate(psa_drv_se_context_t *drv_context, static psa_status_t mock_allocate(psa_drv_se_context_t *drv_context,
void *persistent_data, void *persistent_data,
const psa_key_attributes_t *attributes, const psa_key_attributes_t *attributes,
psa_key_creation_method_t method, psa_key_creation_method_t method,
psa_key_slot_number_t *key_slot) psa_key_slot_number_t *key_slot)
{ {
(void) drv_context; (void) drv_context;
(void) persistent_data; (void) persistent_data;
@ -259,8 +259,8 @@ static psa_status_t mock_allocate(psa_drv_se_context_t *drv_context,
} }
static psa_status_t mock_destroy(psa_drv_se_context_t *context, static psa_status_t mock_destroy(psa_drv_se_context_t *context,
void *persistent_data, void *persistent_data,
psa_key_slot_number_t slot_number) psa_key_slot_number_t slot_number)
{ {
(void) context; (void) context;
(void) persistent_data; (void) persistent_data;

View File

@ -19,11 +19,11 @@
#define PSA_ITS_STORAGE_PREFIX "" #define PSA_ITS_STORAGE_PREFIX ""
#define PSA_ITS_STORAGE_FILENAME_PATTERN "%08lx%08lx" #define PSA_ITS_STORAGE_FILENAME_PATTERN "%08lx%08lx"
#define PSA_ITS_STORAGE_SUFFIX ".psa_its" #define PSA_ITS_STORAGE_SUFFIX ".psa_its"
#define PSA_ITS_STORAGE_FILENAME_LENGTH \ #define PSA_ITS_STORAGE_FILENAME_LENGTH \
(sizeof(PSA_ITS_STORAGE_PREFIX) - 1 + /*prefix without terminating 0*/ \ (sizeof(PSA_ITS_STORAGE_PREFIX) - 1 + /*prefix without terminating 0*/ \
16 + /*UID (64-bit number in hex)*/ \ 16 + /*UID (64-bit number in hex)*/ \
16 + /*UID (64-bit number in hex)*/ \ 16 + /*UID (64-bit number in hex)*/ \
sizeof(PSA_ITS_STORAGE_SUFFIX) - 1 + /*suffix without terminating 0*/ \ sizeof(PSA_ITS_STORAGE_SUFFIX) - 1 + /*suffix without terminating 0*/ \
1 /*terminating null byte*/) 1 /*terminating null byte*/)
#define PSA_ITS_STORAGE_TEMP \ #define PSA_ITS_STORAGE_TEMP \
PSA_ITS_STORAGE_PREFIX "tempfile" PSA_ITS_STORAGE_SUFFIX PSA_ITS_STORAGE_PREFIX "tempfile" PSA_ITS_STORAGE_SUFFIX

View File

@ -1623,11 +1623,11 @@ void ssl_tls13_derive_secret(int hash_alg,
unsigned char const *lbl = NULL; unsigned char const *lbl = NULL;
size_t lbl_len; size_t lbl_len;
#define MBEDTLS_SSL_TLS1_3_LABEL(name, string) \ #define MBEDTLS_SSL_TLS1_3_LABEL(name, string) \
if (label_idx == (int) tls13_label_ ## name) \ if (label_idx == (int) tls13_label_ ## name) \
{ \ { \
lbl = mbedtls_ssl_tls13_labels.name; \ lbl = mbedtls_ssl_tls13_labels.name; \
lbl_len = sizeof(mbedtls_ssl_tls13_labels.name); \ lbl_len = sizeof(mbedtls_ssl_tls13_labels.name); \
} }
MBEDTLS_SSL_TLS1_3_LABEL_LIST MBEDTLS_SSL_TLS1_3_LABEL_LIST
#undef MBEDTLS_SSL_TLS1_3_LABEL #undef MBEDTLS_SSL_TLS1_3_LABEL
@ -1667,7 +1667,7 @@ void ssl_tls13_derive_early_secrets(int hash_alg,
/* Double-check that we've passed sane parameters. */ /* Double-check that we've passed sane parameters. */
psa_algorithm_t alg = (psa_algorithm_t) hash_alg; psa_algorithm_t alg = (psa_algorithm_t) hash_alg;
size_t const hash_len = PSA_HASH_LENGTH(alg); size_t const hash_len = PSA_HASH_LENGTH(alg);
TEST_ASSERT(PSA_ALG_IS_HASH(alg) && TEST_ASSERT(PSA_ALG_IS_HASH(alg) &&
secret->len == hash_len && secret->len == hash_len &&
transcript->len == hash_len && transcript->len == hash_len &&
traffic_expected->len == hash_len && traffic_expected->len == hash_len &&
@ -1701,7 +1701,7 @@ void ssl_tls13_derive_handshake_secrets(int hash_alg,
/* Double-check that we've passed sane parameters. */ /* Double-check that we've passed sane parameters. */
psa_algorithm_t alg = (psa_algorithm_t) hash_alg; psa_algorithm_t alg = (psa_algorithm_t) hash_alg;
size_t const hash_len = PSA_HASH_LENGTH(alg); size_t const hash_len = PSA_HASH_LENGTH(alg);
TEST_ASSERT(PSA_ALG_IS_HASH(alg) && TEST_ASSERT(PSA_ALG_IS_HASH(alg) &&
secret->len == hash_len && secret->len == hash_len &&
transcript->len == hash_len && transcript->len == hash_len &&
client_expected->len == hash_len && client_expected->len == hash_len &&
@ -1736,7 +1736,7 @@ void ssl_tls13_derive_application_secrets(int hash_alg,
/* Double-check that we've passed sane parameters. */ /* Double-check that we've passed sane parameters. */
psa_algorithm_t alg = (psa_algorithm_t) hash_alg; psa_algorithm_t alg = (psa_algorithm_t) hash_alg;
size_t const hash_len = PSA_HASH_LENGTH(alg); size_t const hash_len = PSA_HASH_LENGTH(alg);
TEST_ASSERT(PSA_ALG_IS_HASH(alg) && TEST_ASSERT(PSA_ALG_IS_HASH(alg) &&
secret->len == hash_len && secret->len == hash_len &&
transcript->len == hash_len && transcript->len == hash_len &&
client_expected->len == hash_len && client_expected->len == hash_len &&
@ -1772,7 +1772,7 @@ void ssl_tls13_derive_resumption_secrets(int hash_alg,
/* Double-check that we've passed sane parameters. */ /* Double-check that we've passed sane parameters. */
psa_algorithm_t alg = (psa_algorithm_t) hash_alg; psa_algorithm_t alg = (psa_algorithm_t) hash_alg;
size_t const hash_len = PSA_HASH_LENGTH(alg); size_t const hash_len = PSA_HASH_LENGTH(alg);
TEST_ASSERT(PSA_ALG_IS_HASH(alg) && TEST_ASSERT(PSA_ALG_IS_HASH(alg) &&
secret->len == hash_len && secret->len == hash_len &&
transcript->len == hash_len && transcript->len == hash_len &&
resumption_expected->len == hash_len); resumption_expected->len == hash_len);
@ -1803,7 +1803,7 @@ void ssl_tls13_create_psk_binder(int hash_alg,
/* Double-check that we've passed sane parameters. */ /* Double-check that we've passed sane parameters. */
psa_algorithm_t alg = (psa_algorithm_t) hash_alg; psa_algorithm_t alg = (psa_algorithm_t) hash_alg;
size_t const hash_len = PSA_HASH_LENGTH(alg); size_t const hash_len = PSA_HASH_LENGTH(alg);
TEST_ASSERT(PSA_ALG_IS_HASH(alg) && TEST_ASSERT(PSA_ALG_IS_HASH(alg) &&
transcript->len == hash_len && transcript->len == hash_len &&
binder_expected->len == hash_len); binder_expected->len == hash_len);

View File

@ -91,7 +91,7 @@ static int ca_callback_fail(void *data, mbedtls_x509_crt const *child, mbedtls_x
} }
#if defined(MBEDTLS_X509_CRT_PARSE_C) #if defined(MBEDTLS_X509_CRT_PARSE_C)
static int ca_callback(void *data, mbedtls_x509_crt const *child, static int ca_callback(void *data, mbedtls_x509_crt const *child,
mbedtls_x509_crt **candidates) mbedtls_x509_crt **candidates)
{ {
int ret = 0; int ret = 0;
mbedtls_x509_crt *ca = (mbedtls_x509_crt *) data; mbedtls_x509_crt *ca = (mbedtls_x509_crt *) data;
@ -227,7 +227,7 @@ static int verify_print(void *data, mbedtls_x509_crt *crt, int certificate_depth
} }
static int verify_parse_san(mbedtls_x509_subject_alternative_name *san, static int verify_parse_san(mbedtls_x509_subject_alternative_name *san,
char **buf, size_t *size) char **buf, size_t *size)
{ {
int ret; int ret;
size_t i; size_t i;
@ -318,7 +318,7 @@ static int verify_parse_san(mbedtls_x509_subject_alternative_name *san,
} }
static int parse_crt_ext_cb(void *p_ctx, mbedtls_x509_crt const *crt, mbedtls_x509_buf const *oid, static int parse_crt_ext_cb(void *p_ctx, mbedtls_x509_crt const *crt, mbedtls_x509_buf const *oid,
int critical, const unsigned char *cp, const unsigned char *end) int critical, const unsigned char *cp, const unsigned char *end)
{ {
(void) crt; (void) crt;
(void) critical; (void) critical;
@ -418,7 +418,7 @@ static int parse_crt_ext_cb(void *p_ctx, mbedtls_x509_crt const *crt, mbedtls_x5
#if defined(MBEDTLS_X509_CSR_PARSE_C) #if defined(MBEDTLS_X509_CSR_PARSE_C)
static int parse_csr_ext_accept_cb(void *p_ctx, mbedtls_x509_csr const *csr, mbedtls_x509_buf const *oid, static int parse_csr_ext_accept_cb(void *p_ctx, mbedtls_x509_csr const *csr, mbedtls_x509_buf const *oid,
int critical, const unsigned char *cp, const unsigned char *end) int critical, const unsigned char *cp, const unsigned char *end)
{ {
(void) p_ctx; (void) p_ctx;
(void) csr; (void) csr;
@ -431,7 +431,7 @@ static int parse_csr_ext_accept_cb(void *p_ctx, mbedtls_x509_csr const *csr, mbe
} }
static int parse_csr_ext_reject_cb(void *p_ctx, mbedtls_x509_csr const *csr, mbedtls_x509_buf const *oid, static int parse_csr_ext_reject_cb(void *p_ctx, mbedtls_x509_csr const *csr, mbedtls_x509_buf const *oid,
int critical, const unsigned char *cp, const unsigned char *end) int critical, const unsigned char *cp, const unsigned char *end)
{ {
(void) p_ctx; (void) p_ctx;
(void) csr; (void) csr;

View File

@ -12,16 +12,16 @@
#if defined(MBEDTLS_RSA_C) #if defined(MBEDTLS_RSA_C)
static int mbedtls_rsa_decrypt_func(void *ctx, size_t *olen, static int mbedtls_rsa_decrypt_func(void *ctx, size_t *olen,
const unsigned char *input, unsigned char *output, const unsigned char *input, unsigned char *output,
size_t output_max_len) size_t output_max_len)
{ {
return mbedtls_rsa_pkcs1_decrypt((mbedtls_rsa_context *) ctx, NULL, NULL, return mbedtls_rsa_pkcs1_decrypt((mbedtls_rsa_context *) ctx, NULL, NULL,
olen, input, output, output_max_len); olen, input, output, output_max_len);
} }
static int mbedtls_rsa_sign_func(void *ctx, static int mbedtls_rsa_sign_func(void *ctx,
int (*f_rng)(void *, unsigned char *, size_t), void *p_rng, int (*f_rng)(void *, unsigned char *, size_t), void *p_rng,
mbedtls_md_type_t md_alg, unsigned int hashlen, mbedtls_md_type_t md_alg, unsigned int hashlen,
const unsigned char *hash, unsigned char *sig) const unsigned char *hash, unsigned char *sig)
{ {
return mbedtls_rsa_pkcs1_sign((mbedtls_rsa_context *) ctx, f_rng, p_rng, return mbedtls_rsa_pkcs1_sign((mbedtls_rsa_context *) ctx, f_rng, p_rng,
md_alg, hashlen, hash, sig); md_alg, hashlen, hash, sig);