Switch to the new code style
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
diff --git a/tests/include/spe/crypto_spe.h b/tests/include/spe/crypto_spe.h
index 1aee8a5..a79ce17 100644
--- a/tests/include/spe/crypto_spe.h
+++ b/tests/include/spe/crypto_spe.h
@@ -34,110 +34,110 @@
#define PSA_FUNCTION_NAME(x) mbedcrypto__ ## x
#define psa_crypto_init \
- PSA_FUNCTION_NAME(psa_crypto_init)
+ PSA_FUNCTION_NAME(psa_crypto_init)
#define psa_key_derivation_get_capacity \
- PSA_FUNCTION_NAME(psa_key_derivation_get_capacity)
+ PSA_FUNCTION_NAME(psa_key_derivation_get_capacity)
#define psa_key_derivation_set_capacity \
- PSA_FUNCTION_NAME(psa_key_derivation_set_capacity)
+ PSA_FUNCTION_NAME(psa_key_derivation_set_capacity)
#define psa_key_derivation_input_bytes \
- PSA_FUNCTION_NAME(psa_key_derivation_input_bytes)
+ PSA_FUNCTION_NAME(psa_key_derivation_input_bytes)
#define psa_key_derivation_output_bytes \
- PSA_FUNCTION_NAME(psa_key_derivation_output_bytes)
+ PSA_FUNCTION_NAME(psa_key_derivation_output_bytes)
#define psa_key_derivation_input_key \
- PSA_FUNCTION_NAME(psa_key_derivation_input_key)
+ PSA_FUNCTION_NAME(psa_key_derivation_input_key)
#define psa_key_derivation_output_key \
- PSA_FUNCTION_NAME(psa_key_derivation_output_key)
+ PSA_FUNCTION_NAME(psa_key_derivation_output_key)
#define psa_key_derivation_setup \
- PSA_FUNCTION_NAME(psa_key_derivation_setup)
+ PSA_FUNCTION_NAME(psa_key_derivation_setup)
#define psa_key_derivation_abort \
- PSA_FUNCTION_NAME(psa_key_derivation_abort)
+ PSA_FUNCTION_NAME(psa_key_derivation_abort)
#define psa_key_derivation_key_agreement \
- PSA_FUNCTION_NAME(psa_key_derivation_key_agreement)
+ PSA_FUNCTION_NAME(psa_key_derivation_key_agreement)
#define psa_raw_key_agreement \
- PSA_FUNCTION_NAME(psa_raw_key_agreement)
+ PSA_FUNCTION_NAME(psa_raw_key_agreement)
#define psa_generate_random \
- PSA_FUNCTION_NAME(psa_generate_random)
+ PSA_FUNCTION_NAME(psa_generate_random)
#define psa_aead_encrypt \
- PSA_FUNCTION_NAME(psa_aead_encrypt)
+ PSA_FUNCTION_NAME(psa_aead_encrypt)
#define psa_aead_decrypt \
- PSA_FUNCTION_NAME(psa_aead_decrypt)
+ PSA_FUNCTION_NAME(psa_aead_decrypt)
#define psa_open_key \
- PSA_FUNCTION_NAME(psa_open_key)
+ PSA_FUNCTION_NAME(psa_open_key)
#define psa_close_key \
- PSA_FUNCTION_NAME(psa_close_key)
+ PSA_FUNCTION_NAME(psa_close_key)
#define psa_import_key \
- PSA_FUNCTION_NAME(psa_import_key)
+ PSA_FUNCTION_NAME(psa_import_key)
#define psa_destroy_key \
- PSA_FUNCTION_NAME(psa_destroy_key)
+ PSA_FUNCTION_NAME(psa_destroy_key)
#define psa_get_key_attributes \
- PSA_FUNCTION_NAME(psa_get_key_attributes)
+ PSA_FUNCTION_NAME(psa_get_key_attributes)
#define psa_reset_key_attributes \
- PSA_FUNCTION_NAME(psa_reset_key_attributes)
+ PSA_FUNCTION_NAME(psa_reset_key_attributes)
#define psa_export_key \
- PSA_FUNCTION_NAME(psa_export_key)
+ PSA_FUNCTION_NAME(psa_export_key)
#define psa_export_public_key \
- PSA_FUNCTION_NAME(psa_export_public_key)
+ PSA_FUNCTION_NAME(psa_export_public_key)
#define psa_purge_key \
- PSA_FUNCTION_NAME(psa_purge_key)
+ PSA_FUNCTION_NAME(psa_purge_key)
#define psa_copy_key \
- PSA_FUNCTION_NAME(psa_copy_key)
+ PSA_FUNCTION_NAME(psa_copy_key)
#define psa_cipher_operation_init \
- PSA_FUNCTION_NAME(psa_cipher_operation_init)
+ PSA_FUNCTION_NAME(psa_cipher_operation_init)
#define psa_cipher_generate_iv \
- PSA_FUNCTION_NAME(psa_cipher_generate_iv)
+ PSA_FUNCTION_NAME(psa_cipher_generate_iv)
#define psa_cipher_set_iv \
- PSA_FUNCTION_NAME(psa_cipher_set_iv)
+ PSA_FUNCTION_NAME(psa_cipher_set_iv)
#define psa_cipher_encrypt_setup \
- PSA_FUNCTION_NAME(psa_cipher_encrypt_setup)
+ PSA_FUNCTION_NAME(psa_cipher_encrypt_setup)
#define psa_cipher_decrypt_setup \
- PSA_FUNCTION_NAME(psa_cipher_decrypt_setup)
+ PSA_FUNCTION_NAME(psa_cipher_decrypt_setup)
#define psa_cipher_update \
- PSA_FUNCTION_NAME(psa_cipher_update)
+ PSA_FUNCTION_NAME(psa_cipher_update)
#define psa_cipher_finish \
- PSA_FUNCTION_NAME(psa_cipher_finish)
+ PSA_FUNCTION_NAME(psa_cipher_finish)
#define psa_cipher_abort \
- PSA_FUNCTION_NAME(psa_cipher_abort)
+ PSA_FUNCTION_NAME(psa_cipher_abort)
#define psa_hash_operation_init \
- PSA_FUNCTION_NAME(psa_hash_operation_init)
+ PSA_FUNCTION_NAME(psa_hash_operation_init)
#define psa_hash_setup \
- PSA_FUNCTION_NAME(psa_hash_setup)
+ PSA_FUNCTION_NAME(psa_hash_setup)
#define psa_hash_update \
- PSA_FUNCTION_NAME(psa_hash_update)
+ PSA_FUNCTION_NAME(psa_hash_update)
#define psa_hash_finish \
- PSA_FUNCTION_NAME(psa_hash_finish)
+ PSA_FUNCTION_NAME(psa_hash_finish)
#define psa_hash_verify \
- PSA_FUNCTION_NAME(psa_hash_verify)
+ PSA_FUNCTION_NAME(psa_hash_verify)
#define psa_hash_abort \
- PSA_FUNCTION_NAME(psa_hash_abort)
+ PSA_FUNCTION_NAME(psa_hash_abort)
#define psa_hash_clone \
- PSA_FUNCTION_NAME(psa_hash_clone)
+ PSA_FUNCTION_NAME(psa_hash_clone)
#define psa_hash_compute \
- PSA_FUNCTION_NAME(psa_hash_compute)
+ PSA_FUNCTION_NAME(psa_hash_compute)
#define psa_hash_compare \
- PSA_FUNCTION_NAME(psa_hash_compare)
+ PSA_FUNCTION_NAME(psa_hash_compare)
#define psa_mac_operation_init \
- PSA_FUNCTION_NAME(psa_mac_operation_init)
+ PSA_FUNCTION_NAME(psa_mac_operation_init)
#define psa_mac_sign_setup \
- PSA_FUNCTION_NAME(psa_mac_sign_setup)
+ PSA_FUNCTION_NAME(psa_mac_sign_setup)
#define psa_mac_verify_setup \
- PSA_FUNCTION_NAME(psa_mac_verify_setup)
+ PSA_FUNCTION_NAME(psa_mac_verify_setup)
#define psa_mac_update \
- PSA_FUNCTION_NAME(psa_mac_update)
+ PSA_FUNCTION_NAME(psa_mac_update)
#define psa_mac_sign_finish \
- PSA_FUNCTION_NAME(psa_mac_sign_finish)
+ PSA_FUNCTION_NAME(psa_mac_sign_finish)
#define psa_mac_verify_finish \
- PSA_FUNCTION_NAME(psa_mac_verify_finish)
+ PSA_FUNCTION_NAME(psa_mac_verify_finish)
#define psa_mac_abort \
- PSA_FUNCTION_NAME(psa_mac_abort)
+ PSA_FUNCTION_NAME(psa_mac_abort)
#define psa_sign_hash \
- PSA_FUNCTION_NAME(psa_sign_hash)
+ PSA_FUNCTION_NAME(psa_sign_hash)
#define psa_verify_hash \
- PSA_FUNCTION_NAME(psa_verify_hash)
+ PSA_FUNCTION_NAME(psa_verify_hash)
#define psa_asymmetric_encrypt \
- PSA_FUNCTION_NAME(psa_asymmetric_encrypt)
+ PSA_FUNCTION_NAME(psa_asymmetric_encrypt)
#define psa_asymmetric_decrypt \
- PSA_FUNCTION_NAME(psa_asymmetric_decrypt)
+ PSA_FUNCTION_NAME(psa_asymmetric_decrypt)
#define psa_generate_key \
- PSA_FUNCTION_NAME(psa_generate_key)
+ PSA_FUNCTION_NAME(psa_generate_key)
#endif /* CRYPTO_SPE_H */
diff --git a/tests/include/test/asn1_helpers.h b/tests/include/test/asn1_helpers.h
index 91ae260..dee3cbd 100644
--- a/tests/include/test/asn1_helpers.h
+++ b/tests/include/test/asn1_helpers.h
@@ -43,8 +43,8 @@
*
* \return \c 0 if the test failed, otherwise 1.
*/
-int mbedtls_test_asn1_skip_integer( unsigned char **p, const unsigned char *end,
- size_t min_bits, size_t max_bits,
- int must_be_odd );
+int mbedtls_test_asn1_skip_integer(unsigned char **p, const unsigned char *end,
+ size_t min_bits, size_t max_bits,
+ int must_be_odd);
#endif /* ASN1_HELPERS_H */
diff --git a/tests/include/test/drivers/aead.h b/tests/include/test/drivers/aead.h
index 2207cb3..182bed2 100644
--- a/tests/include/test/drivers/aead.h
+++ b/tests/include/test/drivers/aead.h
@@ -41,10 +41,10 @@
#define MBEDTLS_TEST_DRIVER_AEAD_INIT { 0, 0, 0 }
static inline mbedtls_test_driver_aead_hooks_t
- mbedtls_test_driver_aead_hooks_init( void )
+mbedtls_test_driver_aead_hooks_init(void)
{
const mbedtls_test_driver_aead_hooks_t v = MBEDTLS_TEST_DRIVER_AEAD_INIT;
- return( v );
+ return v;
}
extern mbedtls_test_driver_aead_hooks_t mbedtls_test_driver_aead_hooks;
@@ -56,7 +56,7 @@
const uint8_t *nonce, size_t nonce_length,
const uint8_t *additional_data, size_t additional_data_length,
const uint8_t *plaintext, size_t plaintext_length,
- uint8_t *ciphertext, size_t ciphertext_size, size_t *ciphertext_length );
+ uint8_t *ciphertext, size_t ciphertext_size, size_t *ciphertext_length);
psa_status_t mbedtls_test_transparent_aead_decrypt(
const psa_key_attributes_t *attributes,
@@ -65,7 +65,7 @@
const uint8_t *nonce, size_t nonce_length,
const uint8_t *additional_data, size_t additional_data_length,
const uint8_t *ciphertext, size_t ciphertext_length,
- uint8_t *plaintext, size_t plaintext_size, size_t *plaintext_length );
+ uint8_t *plaintext, size_t plaintext_size, size_t *plaintext_length);
#endif /* PSA_CRYPTO_DRIVER_TEST */
#endif /* PSA_CRYPTO_TEST_DRIVERS_AEAD_H */
diff --git a/tests/include/test/drivers/cipher.h b/tests/include/test/drivers/cipher.h
index c1aa616..2bd7b62 100644
--- a/tests/include/test/drivers/cipher.h
+++ b/tests/include/test/drivers/cipher.h
@@ -45,10 +45,10 @@
#define MBEDTLS_TEST_DRIVER_CIPHER_INIT { NULL, 0, PSA_SUCCESS, 0 }
static inline mbedtls_test_driver_cipher_hooks_t
- mbedtls_test_driver_cipher_hooks_init( void )
+mbedtls_test_driver_cipher_hooks_init(void)
{
const mbedtls_test_driver_cipher_hooks_t v = MBEDTLS_TEST_DRIVER_CIPHER_INIT;
- return( v );
+ return v;
}
extern mbedtls_test_driver_cipher_hooks_t mbedtls_test_driver_cipher_hooks;
@@ -81,7 +81,7 @@
psa_algorithm_t alg);
psa_status_t mbedtls_test_transparent_cipher_abort(
- mbedtls_transparent_test_driver_cipher_operation_t *operation );
+ mbedtls_transparent_test_driver_cipher_operation_t *operation);
psa_status_t mbedtls_test_transparent_cipher_set_iv(
mbedtls_transparent_test_driver_cipher_operation_t *operation,
diff --git a/tests/include/test/drivers/hash.h b/tests/include/test/drivers/hash.h
index 865cd74..de7ebc5 100644
--- a/tests/include/test/drivers/hash.h
+++ b/tests/include/test/drivers/hash.h
@@ -41,10 +41,10 @@
#define MBEDTLS_TEST_DRIVER_HASH_INIT { 0, 0, 0 }
static inline mbedtls_test_driver_hash_hooks_t
- mbedtls_test_driver_hash_hooks_init( void )
+mbedtls_test_driver_hash_hooks_init(void)
{
const mbedtls_test_driver_hash_hooks_t v = MBEDTLS_TEST_DRIVER_HASH_INIT;
- return( v );
+ return v;
}
extern mbedtls_test_driver_hash_hooks_t mbedtls_test_driver_hash_hooks;
@@ -52,29 +52,29 @@
psa_status_t mbedtls_test_transparent_hash_compute(
psa_algorithm_t alg,
const uint8_t *input, size_t input_length,
- uint8_t *hash, size_t hash_size, size_t *hash_length );
+ uint8_t *hash, size_t hash_size, size_t *hash_length);
psa_status_t mbedtls_test_transparent_hash_setup(
mbedtls_transparent_test_driver_hash_operation_t *operation,
- psa_algorithm_t alg );
+ psa_algorithm_t alg);
psa_status_t mbedtls_test_transparent_hash_clone(
const mbedtls_transparent_test_driver_hash_operation_t *source_operation,
- mbedtls_transparent_test_driver_hash_operation_t *target_operation );
+ mbedtls_transparent_test_driver_hash_operation_t *target_operation);
psa_status_t mbedtls_test_transparent_hash_update(
mbedtls_transparent_test_driver_hash_operation_t *operation,
const uint8_t *input,
- size_t input_length );
+ size_t input_length);
psa_status_t mbedtls_test_transparent_hash_finish(
mbedtls_transparent_test_driver_hash_operation_t *operation,
uint8_t *hash,
size_t hash_size,
- size_t *hash_length );
+ size_t *hash_length);
psa_status_t mbedtls_test_transparent_hash_abort(
- mbedtls_transparent_test_driver_hash_operation_t *operation );
+ mbedtls_transparent_test_driver_hash_operation_t *operation);
#endif /* PSA_CRYPTO_DRIVER_TEST */
#endif /* PSA_CRYPTO_TEST_DRIVERS_HASH_H */
diff --git a/tests/include/test/drivers/key_management.h b/tests/include/test/drivers/key_management.h
index c8dfbb3..d10ba4b 100644
--- a/tests/include/test/drivers/key_management.h
+++ b/tests/include/test/drivers/key_management.h
@@ -52,43 +52,43 @@
* used as a location of an opaque test drivers. */
#define MBEDTLS_TEST_DRIVER_KEY_MANAGEMENT_INIT { NULL, 0, PSA_SUCCESS, 0, 0x800000 }
static inline mbedtls_test_driver_key_management_hooks_t
- mbedtls_test_driver_key_management_hooks_init( void )
+mbedtls_test_driver_key_management_hooks_init(void)
{
const mbedtls_test_driver_key_management_hooks_t
v = MBEDTLS_TEST_DRIVER_KEY_MANAGEMENT_INIT;
- return( v );
+ return v;
}
extern mbedtls_test_driver_key_management_hooks_t
mbedtls_test_driver_key_management_hooks;
-psa_status_t mbedtls_test_transparent_init( void );
-void mbedtls_test_transparent_free( void );
-psa_status_t mbedtls_test_opaque_init( void );
-void mbedtls_test_opaque_free( void );
+psa_status_t mbedtls_test_transparent_init(void);
+void mbedtls_test_transparent_free(void);
+psa_status_t mbedtls_test_opaque_init(void);
+void mbedtls_test_opaque_free(void);
psa_status_t mbedtls_test_transparent_generate_key(
const psa_key_attributes_t *attributes,
- uint8_t *key, size_t key_size, size_t *key_length );
+ uint8_t *key, size_t key_size, size_t *key_length);
psa_status_t mbedtls_test_opaque_generate_key(
const psa_key_attributes_t *attributes,
- uint8_t *key, size_t key_size, size_t *key_length );
+ uint8_t *key, size_t key_size, size_t *key_length);
psa_status_t mbedtls_test_opaque_export_key(
const psa_key_attributes_t *attributes,
const uint8_t *key, size_t key_length,
- uint8_t *data, size_t data_size, size_t *data_length );
+ uint8_t *data, size_t data_size, size_t *data_length);
psa_status_t mbedtls_test_transparent_export_public_key(
const psa_key_attributes_t *attributes,
const uint8_t *key, size_t key_length,
- uint8_t *data, size_t data_size, size_t *data_length );
+ uint8_t *data, size_t data_size, size_t *data_length);
psa_status_t mbedtls_test_opaque_export_public_key(
const psa_key_attributes_t *attributes,
const uint8_t *key, size_t key_length,
- uint8_t *data, size_t data_size, size_t *data_length );
+ uint8_t *data, size_t data_size, size_t *data_length);
psa_status_t mbedtls_test_transparent_import_key(
const psa_key_attributes_t *attributes,
@@ -102,7 +102,7 @@
psa_status_t mbedtls_test_opaque_get_builtin_key(
psa_drv_slot_number_t slot_number,
psa_key_attributes_t *attributes,
- uint8_t *key_buffer, size_t key_buffer_size, size_t *key_buffer_length );
+ uint8_t *key_buffer, size_t key_buffer_size, size_t *key_buffer_length);
#endif /* PSA_CRYPTO_DRIVER_TEST */
#endif /* PSA_CRYPTO_TEST_DRIVERS_KEY_MANAGEMENT_H */
diff --git a/tests/include/test/drivers/mac.h b/tests/include/test/drivers/mac.h
index 7733dd3..8af1335 100644
--- a/tests/include/test/drivers/mac.h
+++ b/tests/include/test/drivers/mac.h
@@ -41,10 +41,10 @@
#define MBEDTLS_TEST_DRIVER_MAC_INIT { 0, 0, 0 }
static inline mbedtls_test_driver_mac_hooks_t
- mbedtls_test_driver_mac_hooks_init( void )
+mbedtls_test_driver_mac_hooks_init(void)
{
const mbedtls_test_driver_mac_hooks_t v = MBEDTLS_TEST_DRIVER_MAC_INIT;
- return( v );
+ return v;
}
extern mbedtls_test_driver_mac_hooks_t mbedtls_test_driver_mac_hooks;
@@ -58,40 +58,40 @@
size_t input_length,
uint8_t *mac,
size_t mac_size,
- size_t *mac_length );
+ size_t *mac_length);
psa_status_t mbedtls_test_transparent_mac_sign_setup(
mbedtls_transparent_test_driver_mac_operation_t *operation,
const psa_key_attributes_t *attributes,
const uint8_t *key_buffer,
size_t key_buffer_size,
- psa_algorithm_t alg );
+ psa_algorithm_t alg);
psa_status_t mbedtls_test_transparent_mac_verify_setup(
mbedtls_transparent_test_driver_mac_operation_t *operation,
const psa_key_attributes_t *attributes,
const uint8_t *key_buffer,
size_t key_buffer_size,
- psa_algorithm_t alg );
+ psa_algorithm_t alg);
psa_status_t mbedtls_test_transparent_mac_update(
mbedtls_transparent_test_driver_mac_operation_t *operation,
const uint8_t *input,
- size_t input_length );
+ size_t input_length);
psa_status_t mbedtls_test_transparent_mac_sign_finish(
mbedtls_transparent_test_driver_mac_operation_t *operation,
uint8_t *mac,
size_t mac_size,
- size_t *mac_length );
+ size_t *mac_length);
psa_status_t mbedtls_test_transparent_mac_verify_finish(
mbedtls_transparent_test_driver_mac_operation_t *operation,
const uint8_t *mac,
- size_t mac_length );
+ size_t mac_length);
psa_status_t mbedtls_test_transparent_mac_abort(
- mbedtls_transparent_test_driver_mac_operation_t *operation );
+ mbedtls_transparent_test_driver_mac_operation_t *operation);
psa_status_t mbedtls_test_opaque_mac_compute(
const psa_key_attributes_t *attributes,
@@ -102,40 +102,40 @@
size_t input_length,
uint8_t *mac,
size_t mac_size,
- size_t *mac_length );
+ size_t *mac_length);
psa_status_t mbedtls_test_opaque_mac_sign_setup(
mbedtls_opaque_test_driver_mac_operation_t *operation,
const psa_key_attributes_t *attributes,
const uint8_t *key_buffer,
size_t key_buffer_size,
- psa_algorithm_t alg );
+ psa_algorithm_t alg);
psa_status_t mbedtls_test_opaque_mac_verify_setup(
mbedtls_opaque_test_driver_mac_operation_t *operation,
const psa_key_attributes_t *attributes,
const uint8_t *key_buffer,
size_t key_buffer_size,
- psa_algorithm_t alg );
+ psa_algorithm_t alg);
psa_status_t mbedtls_test_opaque_mac_update(
mbedtls_opaque_test_driver_mac_operation_t *operation,
const uint8_t *input,
- size_t input_length );
+ size_t input_length);
psa_status_t mbedtls_test_opaque_mac_sign_finish(
mbedtls_opaque_test_driver_mac_operation_t *operation,
uint8_t *mac,
size_t mac_size,
- size_t *mac_length );
+ size_t *mac_length);
psa_status_t mbedtls_test_opaque_mac_verify_finish(
mbedtls_opaque_test_driver_mac_operation_t *operation,
const uint8_t *mac,
- size_t mac_length );
+ size_t mac_length);
psa_status_t mbedtls_test_opaque_mac_abort(
- mbedtls_opaque_test_driver_mac_operation_t *operation );
+ mbedtls_opaque_test_driver_mac_operation_t *operation);
#endif /* PSA_CRYPTO_DRIVER_TEST */
#endif /* PSA_CRYPTO_TEST_DRIVERS_MAC_H */
diff --git a/tests/include/test/drivers/signature.h b/tests/include/test/drivers/signature.h
index 5e64edc..4a2465b 100644
--- a/tests/include/test/drivers/signature.h
+++ b/tests/include/test/drivers/signature.h
@@ -42,11 +42,11 @@
#define MBEDTLS_TEST_DRIVER_SIGNATURE_INIT { NULL, 0, PSA_SUCCESS, 0 }
static inline mbedtls_test_driver_signature_hooks_t
- mbedtls_test_driver_signature_hooks_init( void )
+mbedtls_test_driver_signature_hooks_init(void)
{
const mbedtls_test_driver_signature_hooks_t
v = MBEDTLS_TEST_DRIVER_SIGNATURE_INIT;
- return( v );
+ return v;
}
extern mbedtls_test_driver_signature_hooks_t
@@ -63,7 +63,7 @@
size_t input_length,
uint8_t *signature,
size_t signature_size,
- size_t *signature_length );
+ size_t *signature_length);
psa_status_t mbedtls_test_opaque_signature_sign_message(
const psa_key_attributes_t *attributes,
@@ -74,7 +74,7 @@
size_t input_length,
uint8_t *signature,
size_t signature_size,
- size_t *signature_length );
+ size_t *signature_length);
psa_status_t mbedtls_test_transparent_signature_verify_message(
const psa_key_attributes_t *attributes,
@@ -84,7 +84,7 @@
const uint8_t *input,
size_t input_length,
const uint8_t *signature,
- size_t signature_length );
+ size_t signature_length);
psa_status_t mbedtls_test_opaque_signature_verify_message(
const psa_key_attributes_t *attributes,
@@ -94,35 +94,35 @@
const uint8_t *input,
size_t input_length,
const uint8_t *signature,
- size_t signature_length );
+ size_t signature_length);
psa_status_t mbedtls_test_transparent_signature_sign_hash(
const psa_key_attributes_t *attributes,
const uint8_t *key, size_t key_length,
psa_algorithm_t alg,
const uint8_t *hash, size_t hash_length,
- uint8_t *signature, size_t signature_size, size_t *signature_length );
+ uint8_t *signature, size_t signature_size, size_t *signature_length);
psa_status_t mbedtls_test_opaque_signature_sign_hash(
const psa_key_attributes_t *attributes,
const uint8_t *key, size_t key_length,
psa_algorithm_t alg,
const uint8_t *hash, size_t hash_length,
- uint8_t *signature, size_t signature_size, size_t *signature_length );
+ uint8_t *signature, size_t signature_size, size_t *signature_length);
psa_status_t mbedtls_test_transparent_signature_verify_hash(
const psa_key_attributes_t *attributes,
const uint8_t *key, size_t key_length,
psa_algorithm_t alg,
const uint8_t *hash, size_t hash_length,
- const uint8_t *signature, size_t signature_length );
+ const uint8_t *signature, size_t signature_length);
psa_status_t mbedtls_test_opaque_signature_verify_hash(
const psa_key_attributes_t *attributes,
const uint8_t *key, size_t key_length,
psa_algorithm_t alg,
const uint8_t *hash, size_t hash_length,
- const uint8_t *signature, size_t signature_length );
+ const uint8_t *signature, size_t signature_length);
#endif /* PSA_CRYPTO_DRIVER_TEST */
#endif /* PSA_CRYPTO_TEST_DRIVERS_SIGNATURE_H */
diff --git a/tests/include/test/drivers/size.h b/tests/include/test/drivers/size.h
index b2665bd..9d0adcf 100644
--- a/tests/include/test/drivers/size.h
+++ b/tests/include/test/drivers/size.h
@@ -31,7 +31,7 @@
size_t mbedtls_test_size_function(
const psa_key_type_t key_type,
- const size_t key_bits );
+ const size_t key_bits);
#endif /* PSA_CRYPTO_DRIVER_TEST */
#endif /* PSA_CRYPTO_TEST_DRIVERS_SIZE_H */
diff --git a/tests/include/test/fake_external_rng_for_test.h b/tests/include/test/fake_external_rng_for_test.h
index faeef22..ad8e1c6 100644
--- a/tests/include/test/fake_external_rng_for_test.h
+++ b/tests/include/test/fake_external_rng_for_test.h
@@ -44,13 +44,13 @@
* of the PSA subsystem. You may disable it temporarily to simulate a
* depleted entropy source.
*/
-void mbedtls_test_enable_insecure_external_rng( void );
+void mbedtls_test_enable_insecure_external_rng(void);
/** Disable the insecure implementation of mbedtls_psa_external_get_random().
*
* See mbedtls_test_enable_insecure_external_rng().
*/
-void mbedtls_test_disable_insecure_external_rng( void );
+void mbedtls_test_disable_insecure_external_rng(void);
#endif /* MBEDTLS_PSA_CRYPTO_EXTERNAL_RNG */
#endif /* FAKE_EXTERNAL_RNG_FOR_TEST_H */
diff --git a/tests/include/test/helpers.h b/tests/include/test/helpers.h
index 7a87c5b..9d60c20 100644
--- a/tests/include/test/helpers.h
+++ b/tests/include/test/helpers.h
@@ -46,21 +46,18 @@
#endif
/** The type of test case arguments that contain binary data. */
-typedef struct data_tag
-{
- uint8_t * x;
+typedef struct data_tag {
+ uint8_t *x;
uint32_t len;
} data_t;
-typedef enum
-{
+typedef enum {
MBEDTLS_TEST_RESULT_SUCCESS = 0,
MBEDTLS_TEST_RESULT_FAILED,
MBEDTLS_TEST_RESULT_SKIPPED
} mbedtls_test_result_t;
-typedef struct
-{
+typedef struct {
mbedtls_test_result_t result;
const char *test;
const char *filename;
@@ -75,8 +72,8 @@
mbedtls_test_info_t;
extern mbedtls_test_info_t mbedtls_test_info;
-int mbedtls_test_platform_setup( void );
-void mbedtls_test_platform_teardown( void );
+int mbedtls_test_platform_setup(void);
+void mbedtls_test_platform_teardown(void);
/**
* \brief Record the current test case as a failure.
@@ -94,7 +91,7 @@
* \param line_no Line number where the failure originated.
* \param filename Filename where the failure originated.
*/
-void mbedtls_test_fail( const char *test, int line_no, const char* filename );
+void mbedtls_test_fail(const char *test, int line_no, const char *filename);
/**
* \brief Record the current test case as skipped.
@@ -107,7 +104,7 @@
* \param line_no Line number where the test case was skipped.
* \param filename Filename where the test case was skipped.
*/
-void mbedtls_test_skip( const char *test, int line_no, const char* filename );
+void mbedtls_test_skip(const char *test, int line_no, const char *filename);
/**
* \brief Set the test step number for failure reports.
@@ -119,12 +116,12 @@
*
* \param step The step number to report.
*/
-void mbedtls_test_set_step( unsigned long step );
+void mbedtls_test_set_step(unsigned long step);
/**
* \brief Reset mbedtls_test_info to a ready/starting state.
*/
-void mbedtls_test_info_reset( void );
+void mbedtls_test_info_reset(void);
/**
* \brief Record the current test case as a failure if two integers
@@ -144,8 +141,8 @@
*
* \return \c 1 if the values are equal, otherwise \c 0.
*/
-int mbedtls_test_equal( const char *test, int line_no, const char* filename,
- unsigned long long value1, unsigned long long value2 );
+int mbedtls_test_equal(const char *test, int line_no, const char *filename,
+ unsigned long long value1, unsigned long long value2);
/**
* \brief Record the current test case as a failure based
@@ -165,8 +162,8 @@
*
* \return \c 1 if \p value1 <= \p value2, otherwise \c 0.
*/
-int mbedtls_test_le_u( const char *test, int line_no, const char* filename,
- unsigned long long value1, unsigned long long value2 );
+int mbedtls_test_le_u(const char *test, int line_no, const char *filename,
+ unsigned long long value1, unsigned long long value2);
/**
* \brief Record the current test case as a failure based
@@ -186,8 +183,8 @@
*
* \return \c 1 if \p value1 <= \p value2, otherwise \c 0.
*/
-int mbedtls_test_le_s( const char *test, int line_no, const char* filename,
- long long value1, long long value2 );
+int mbedtls_test_le_s(const char *test, int line_no, const char *filename,
+ long long value1, long long value2);
/**
* \brief This function decodes the hexadecimal representation of
@@ -207,12 +204,12 @@
* \return \c -1 if the output buffer is too small or the input string
* is not a valid hexadecimal representation.
*/
-int mbedtls_test_unhexify( unsigned char *obuf, size_t obufmax,
- const char *ibuf, size_t *len );
+int mbedtls_test_unhexify(unsigned char *obuf, size_t obufmax,
+ const char *ibuf, size_t *len);
-void mbedtls_test_hexify( unsigned char *obuf,
- const unsigned char *ibuf,
- int len );
+void mbedtls_test_hexify(unsigned char *obuf,
+ const unsigned char *ibuf,
+ int len);
/**
* Allocate and zeroize a buffer.
@@ -221,7 +218,7 @@
*
* For convenience, dies if allocation fails.
*/
-unsigned char *mbedtls_test_zero_alloc( size_t len );
+unsigned char *mbedtls_test_zero_alloc(size_t len);
/**
* Allocate and fill a buffer from hex data.
@@ -233,15 +230,14 @@
*
* For convenience, dies if allocation fails.
*/
-unsigned char *mbedtls_test_unhexify_alloc( const char *ibuf, size_t *olen );
+unsigned char *mbedtls_test_unhexify_alloc(const char *ibuf, size_t *olen);
-int mbedtls_test_hexcmp( uint8_t * a, uint8_t * b,
- uint32_t a_len, uint32_t b_len );
+int mbedtls_test_hexcmp(uint8_t *a, uint8_t *b,
+ uint32_t a_len, uint32_t b_len);
#if defined(MBEDTLS_CHECK_PARAMS)
-typedef struct
-{
+typedef struct {
const char *failure_condition;
const char *file;
int line;
@@ -257,7 +253,7 @@
* mbedtls_param_failed() that cancels it.
*/
void mbedtls_test_param_failed_get_location_record(
- mbedtls_test_param_failed_location_record_t *location_record );
+ mbedtls_test_param_failed_location_record_t *location_record);
/**
* \brief State that a call to mbedtls_param_failed() is expected.
@@ -266,7 +262,7 @@
* mbedtls_test_param_failed_check_expected_call() or
* mbedtls_param_failed that cancel it.
*/
-void mbedtls_test_param_failed_expect_call( void );
+void mbedtls_test_param_failed_expect_call(void);
/**
* \brief Check whether mbedtls_param_failed() has been called as expected.
@@ -279,7 +275,7 @@
* mbedtls_param_failed() has been called.
* \c -1 Otherwise.
*/
-int mbedtls_test_param_failed_check_expected_call( void );
+int mbedtls_test_param_failed_check_expected_call(void);
/**
* \brief Get the address of the object of type jmp_buf holding the execution
@@ -308,7 +304,7 @@
* \return Address of the object of type jmp_buf holding the execution state
* information used by mbedtls_param_failed() to do a long jump.
*/
-void* mbedtls_test_param_failed_get_state_buf( void );
+void *mbedtls_test_param_failed_get_state_buf(void);
/**
* \brief Reset the execution state used by mbedtls_param_failed() to do a
@@ -324,7 +320,7 @@
* mbedtls_param_failed() will not trigger a long jump with
* undefined behavior but rather a long jump that will rather fault.
*/
-void mbedtls_test_param_failed_reset_state( void );
+void mbedtls_test_param_failed_reset_state(void);
#endif /* MBEDTLS_CHECK_PARAMS */
#if defined(MBEDTLS_PSA_CRYPTO_C) && defined(MBEDTLS_PSA_CRYPTO_EXTERNAL_RNG)
@@ -334,11 +330,11 @@
#if defined(MBEDTLS_TEST_MUTEX_USAGE)
/** Permanently activate the mutex usage verification framework. See
* threading_helpers.c for information. */
-void mbedtls_test_mutex_usage_init( void );
+void mbedtls_test_mutex_usage_init(void);
/** Call this function after executing a test case to check for mutex usage
* errors. */
-void mbedtls_test_mutex_usage_check( void );
+void mbedtls_test_mutex_usage_check(void);
#endif /* MBEDTLS_TEST_MUTEX_USAGE */
#if defined(MBEDTLS_TEST_HOOKS)
@@ -353,8 +349,8 @@
*
* \note If the check fails, fail the test currently being run.
*/
-void mbedtls_test_err_add_check( int high, int low,
- const char *file, int line);
+void mbedtls_test_err_add_check(int high, int low,
+ const char *file, int line);
#endif
#if defined(MBEDTLS_BIGNUM_C)
@@ -379,7 +375,7 @@
*
* \return \c 0 on success, an \c MBEDTLS_ERR_MPI_xxx error code otherwise.
*/
-int mbedtls_test_read_mpi( mbedtls_mpi *X, const char *s );
+int mbedtls_test_read_mpi(mbedtls_mpi *X, const char *s);
/** Nonzero if the current test case had an input parsed with
* mbedtls_test_read_mpi() that is a negative 0 (`"-"`, `"-0"`, `"-00"`, etc.,
diff --git a/tests/include/test/macros.h b/tests/include/test/macros.h
index f9de646..2354205 100644
--- a/tests/include/test/macros.h
+++ b/tests/include/test/macros.h
@@ -62,14 +62,14 @@
*
* \param TEST The test expression to be tested.
*/
-#define TEST_ASSERT( TEST ) \
+#define TEST_ASSERT(TEST) \
do { \
- if( ! (TEST) ) \
- { \
- mbedtls_test_fail( #TEST, __LINE__, __FILE__ ); \
- goto exit; \
- } \
- } while( 0 )
+ if (!(TEST)) \
+ { \
+ mbedtls_test_fail( #TEST, __LINE__, __FILE__); \
+ goto exit; \
+ } \
+ } while (0)
/** Evaluate two integer expressions and fail the test case if they have
* different values.
@@ -80,12 +80,12 @@
* \param expr1 An integral-typed expression to evaluate.
* \param expr2 Another integral-typed expression to evaluate.
*/
-#define TEST_EQUAL( expr1, expr2 ) \
+#define TEST_EQUAL(expr1, expr2) \
do { \
- if( ! mbedtls_test_equal( #expr1 " == " #expr2, __LINE__, __FILE__, \
- expr1, expr2 ) ) \
- goto exit; \
- } while( 0 )
+ if (!mbedtls_test_equal( #expr1 " == " #expr2, __LINE__, __FILE__, \
+ expr1, expr2)) \
+ goto exit; \
+ } while (0)
/** Evaluate two unsigned integer expressions and fail the test case
* if they are not in increasing order (left <= right).
@@ -93,12 +93,12 @@
* \param expr1 An integral-typed expression to evaluate.
* \param expr2 Another integral-typed expression to evaluate.
*/
-#define TEST_LE_U( expr1, expr2 ) \
+#define TEST_LE_U(expr1, expr2) \
do { \
- if( ! mbedtls_test_le_u( #expr1 " <= " #expr2, __LINE__, __FILE__, \
- expr1, expr2 ) ) \
- goto exit; \
- } while( 0 )
+ if (!mbedtls_test_le_u( #expr1 " <= " #expr2, __LINE__, __FILE__, \
+ expr1, expr2)) \
+ goto exit; \
+ } while (0)
/** Evaluate two signed integer expressions and fail the test case
* if they are not in increasing order (left <= right).
@@ -106,12 +106,12 @@
* \param expr1 An integral-typed expression to evaluate.
* \param expr2 Another integral-typed expression to evaluate.
*/
-#define TEST_LE_S( expr1, expr2 ) \
+#define TEST_LE_S(expr1, expr2) \
do { \
- if( ! mbedtls_test_le_s( #expr1 " <= " #expr2, __LINE__, __FILE__, \
- expr1, expr2 ) ) \
- goto exit; \
- } while( 0 )
+ if (!mbedtls_test_le_s( #expr1 " <= " #expr2, __LINE__, __FILE__, \
+ expr1, expr2)) \
+ goto exit; \
+ } while (0)
/** Allocate memory dynamically and fail the test case if this fails.
* The allocated memory will be filled with zeros.
@@ -133,36 +133,36 @@
* This expression may be evaluated multiple times.
*
*/
-#define ASSERT_ALLOC( pointer, length ) \
+#define ASSERT_ALLOC(pointer, length) \
do \
{ \
- TEST_ASSERT( ( pointer ) == NULL ); \
- if( ( length ) != 0 ) \
+ TEST_ASSERT((pointer) == NULL); \
+ if ((length) != 0) \
{ \
- ( pointer ) = mbedtls_calloc( sizeof( *( pointer ) ), \
- ( length ) ); \
- TEST_ASSERT( ( pointer ) != NULL ); \
+ (pointer) = mbedtls_calloc(sizeof(*(pointer)), \
+ (length)); \
+ TEST_ASSERT((pointer) != NULL); \
} \
} \
- while( 0 )
+ while (0)
/** Allocate memory dynamically. If the allocation fails, skip the test case.
*
* This macro behaves like #ASSERT_ALLOC, except that if the allocation
* fails, it marks the test as skipped rather than failed.
*/
-#define ASSERT_ALLOC_WEAK( pointer, length ) \
+#define ASSERT_ALLOC_WEAK(pointer, length) \
do \
{ \
- TEST_ASSERT( ( pointer ) == NULL ); \
- if( ( length ) != 0 ) \
+ TEST_ASSERT((pointer) == NULL); \
+ if ((length) != 0) \
{ \
- ( pointer ) = mbedtls_calloc( sizeof( *( pointer ) ), \
- ( length ) ); \
- TEST_ASSUME( ( pointer ) != NULL ); \
+ (pointer) = mbedtls_calloc(sizeof(*(pointer)), \
+ (length)); \
+ TEST_ASSUME((pointer) != NULL); \
} \
} \
- while( 0 )
+ while (0)
/** Compare two buffers and fail the test case if they differ.
*
@@ -176,14 +176,14 @@
* \param size2 Size of the second buffer in bytes.
* This expression may be evaluated multiple times.
*/
-#define ASSERT_COMPARE( p1, size1, p2, size2 ) \
+#define ASSERT_COMPARE(p1, size1, p2, size2) \
do \
{ \
- TEST_ASSERT( ( size1 ) == ( size2 ) ); \
- if( ( size1 ) != 0 ) \
- TEST_ASSERT( memcmp( ( p1 ), ( p2 ), ( size1 ) ) == 0 ); \
+ TEST_ASSERT((size1) == (size2)); \
+ if ((size1) != 0) \
+ TEST_ASSERT(memcmp((p1), (p2), (size1)) == 0); \
} \
- while( 0 )
+ while (0)
/**
* \brief This macro tests the expression passed to it and skips the
@@ -191,14 +191,14 @@
*
* \param TEST The test expression to be tested.
*/
-#define TEST_ASSUME( TEST ) \
+#define TEST_ASSUME(TEST) \
do { \
- if( ! (TEST) ) \
+ if (!(TEST)) \
{ \
- mbedtls_test_skip( #TEST, __LINE__, __FILE__ ); \
+ mbedtls_test_skip( #TEST, __LINE__, __FILE__); \
goto exit; \
} \
- } while( 0 )
+ } while (0)
#if defined(MBEDTLS_CHECK_PARAMS) && !defined(MBEDTLS_PARAM_FAILED_ALT)
/**
@@ -221,17 +221,17 @@
*
* \param TEST The test expression to be tested.
*/
-#define TEST_INVALID_PARAM_RET( PARAM_ERR_VALUE, TEST ) \
+#define TEST_INVALID_PARAM_RET(PARAM_ERR_VALUE, TEST) \
do { \
- mbedtls_test_param_failed_expect_call( ); \
- if( ( ( TEST ) != ( PARAM_ERR_VALUE ) ) || \
- ( mbedtls_test_param_failed_check_expected_call( ) != 0 ) ) \
+ mbedtls_test_param_failed_expect_call(); \
+ if (((TEST) != (PARAM_ERR_VALUE)) || \
+ (mbedtls_test_param_failed_check_expected_call() != 0)) \
{ \
- mbedtls_test_fail( #TEST, __LINE__, __FILE__ ); \
+ mbedtls_test_fail( #TEST, __LINE__, __FILE__); \
goto exit; \
} \
- mbedtls_test_param_failed_check_expected_call( ); \
- } while( 0 )
+ mbedtls_test_param_failed_check_expected_call(); \
+ } while (0)
/**
* \brief This macro tests the statement passed to it as a test step or
@@ -253,18 +253,18 @@
*
* \param TEST The test expression to be tested.
*/
-#define TEST_INVALID_PARAM( TEST ) \
+#define TEST_INVALID_PARAM(TEST) \
do { \
- memcpy( jmp_tmp, mbedtls_test_param_failed_get_state_buf( ), \
- sizeof( jmp_tmp ) ); \
- if( setjmp( mbedtls_test_param_failed_get_state_buf( ) ) == 0 ) \
+ memcpy(jmp_tmp, mbedtls_test_param_failed_get_state_buf(), \
+ sizeof(jmp_tmp)); \
+ if (setjmp(mbedtls_test_param_failed_get_state_buf()) == 0) \
{ \
TEST; \
- mbedtls_test_fail( #TEST, __LINE__, __FILE__ ); \
+ mbedtls_test_fail( #TEST, __LINE__, __FILE__); \
goto exit; \
} \
- mbedtls_test_param_failed_reset_state( ); \
- } while( 0 )
+ mbedtls_test_param_failed_reset_state(); \
+ } while (0)
#endif /* MBEDTLS_CHECK_PARAMS && !MBEDTLS_PARAM_FAILED_ALT */
/**
@@ -298,15 +298,15 @@
*
* \param TEST The test expression to be tested.
*/
-#define TEST_VALID_PARAM( TEST ) \
- TEST_ASSERT( ( TEST, 1 ) );
+#define TEST_VALID_PARAM(TEST) \
+ TEST_ASSERT((TEST, 1));
-#define TEST_HELPER_ASSERT(a) if( !( a ) ) \
-{ \
- mbedtls_fprintf( stderr, "Assertion Failed at %s:%d - %s\n", \
- __FILE__, __LINE__, #a ); \
- mbedtls_exit( 1 ); \
-}
+#define TEST_HELPER_ASSERT(a) if (!(a)) \
+ { \
+ mbedtls_fprintf(stderr, "Assertion Failed at %s:%d - %s\n", \
+ __FILE__, __LINE__, #a); \
+ mbedtls_exit(1); \
+ }
/** \def ARRAY_LENGTH
* Return the number of elements of a static or stack array.
@@ -317,34 +317,34 @@
*/
/* A correct implementation of ARRAY_LENGTH, but which silently gives
* a nonsensical result if called with a pointer rather than an array. */
-#define ARRAY_LENGTH_UNSAFE( array ) \
- ( sizeof( array ) / sizeof( *( array ) ) )
+#define ARRAY_LENGTH_UNSAFE(array) \
+ (sizeof(array) / sizeof(*(array)))
#if defined(__GNUC__)
/* Test if arg and &(arg)[0] have the same type. This is true if arg is
* an array but not if it's a pointer. */
-#define IS_ARRAY_NOT_POINTER( arg ) \
- ( ! __builtin_types_compatible_p( __typeof__( arg ), \
- __typeof__( &( arg )[0] ) ) )
+#define IS_ARRAY_NOT_POINTER(arg) \
+ (!__builtin_types_compatible_p(__typeof__(arg), \
+ __typeof__(&(arg)[0])))
/* A compile-time constant with the value 0. If `const_expr` is not a
* compile-time constant with a nonzero value, cause a compile-time error. */
-#define STATIC_ASSERT_EXPR( const_expr ) \
- ( 0 && sizeof( struct { unsigned int STATIC_ASSERT : 1 - 2 * ! ( const_expr ); } ) )
+#define STATIC_ASSERT_EXPR(const_expr) \
+ (0 && sizeof(struct { unsigned int STATIC_ASSERT : 1 - 2 * !(const_expr); }))
/* Return the scalar value `value` (possibly promoted). This is a compile-time
* constant if `value` is. `condition` must be a compile-time constant.
* If `condition` is false, arrange to cause a compile-time error. */
-#define STATIC_ASSERT_THEN_RETURN( condition, value ) \
- ( STATIC_ASSERT_EXPR( condition ) ? 0 : ( value ) )
+#define STATIC_ASSERT_THEN_RETURN(condition, value) \
+ (STATIC_ASSERT_EXPR(condition) ? 0 : (value))
-#define ARRAY_LENGTH( array ) \
- ( STATIC_ASSERT_THEN_RETURN( IS_ARRAY_NOT_POINTER( array ), \
- ARRAY_LENGTH_UNSAFE( array ) ) )
+#define ARRAY_LENGTH(array) \
+ (STATIC_ASSERT_THEN_RETURN(IS_ARRAY_NOT_POINTER(array), \
+ ARRAY_LENGTH_UNSAFE(array)))
#else
/* If we aren't sure the compiler supports our non-standard tricks,
* fall back to the unsafe implementation. */
-#define ARRAY_LENGTH( array ) ARRAY_LENGTH_UNSAFE( array )
+#define ARRAY_LENGTH(array) ARRAY_LENGTH_UNSAFE(array)
#endif
/** Return the smaller of two values.
@@ -354,7 +354,7 @@
*
* \return The smaller of \p x and \p y.
*/
-#define MIN( x, y ) ( ( x ) < ( y ) ? ( x ) : ( y ) )
+#define MIN(x, y) ((x) < (y) ? (x) : (y))
/** Return the larger of two values.
*
@@ -363,29 +363,29 @@
*
* \return The larger of \p x and \p y.
*/
-#define MAX( x, y ) ( ( x ) > ( y ) ? ( x ) : ( y ) )
+#define MAX(x, y) ((x) > (y) ? (x) : (y))
/*
* 32-bit integer manipulation macros (big endian)
*/
#ifndef GET_UINT32_BE
-#define GET_UINT32_BE(n,b,i) \
-{ \
- (n) = ( (uint32_t) (b)[(i) ] << 24 ) \
- | ( (uint32_t) (b)[(i) + 1] << 16 ) \
- | ( (uint32_t) (b)[(i) + 2] << 8 ) \
- | ( (uint32_t) (b)[(i) + 3] ); \
-}
+#define GET_UINT32_BE(n, b, i) \
+ { \
+ (n) = ((uint32_t) (b)[(i)] << 24) \
+ | ((uint32_t) (b)[(i) + 1] << 16) \
+ | ((uint32_t) (b)[(i) + 2] << 8) \
+ | ((uint32_t) (b)[(i) + 3]); \
+ }
#endif
#ifndef PUT_UINT32_BE
-#define PUT_UINT32_BE(n,b,i) \
-{ \
- (b)[(i) ] = (unsigned char) ( (n) >> 24 ); \
- (b)[(i) + 1] = (unsigned char) ( (n) >> 16 ); \
- (b)[(i) + 2] = (unsigned char) ( (n) >> 8 ); \
- (b)[(i) + 3] = (unsigned char) ( (n) ); \
-}
+#define PUT_UINT32_BE(n, b, i) \
+ { \
+ (b)[(i)] = (unsigned char) ((n) >> 24); \
+ (b)[(i) + 1] = (unsigned char) ((n) >> 16); \
+ (b)[(i) + 2] = (unsigned char) ((n) >> 8); \
+ (b)[(i) + 3] = (unsigned char) ((n)); \
+ }
#endif
#endif /* TEST_MACROS_H */
diff --git a/tests/include/test/psa_crypto_helpers.h b/tests/include/test/psa_crypto_helpers.h
index 7dc829b..08179e2 100644
--- a/tests/include/test/psa_crypto_helpers.h
+++ b/tests/include/test/psa_crypto_helpers.h
@@ -36,11 +36,11 @@
#if defined(MBEDTLS_PSA_CRYPTO_STORAGE_C)
/* Internal function for #TEST_USES_KEY_ID. Return 1 on success, 0 on failure. */
-int mbedtls_test_uses_key_id( mbedtls_svc_key_id_t key_id );
+int mbedtls_test_uses_key_id(mbedtls_svc_key_id_t key_id);
/** Destroy persistent keys recorded with #TEST_USES_KEY_ID.
*/
-void mbedtls_test_psa_purge_key_storage( void );
+void mbedtls_test_psa_purge_key_storage(void);
/** Purge the in-memory cache of persistent keys recorded with
* #TEST_USES_KEY_ID.
@@ -48,7 +48,7 @@
* Call this function before calling PSA_DONE() if it's ok for
* persistent keys to still exist at this point.
*/
-void mbedtls_test_psa_purge_key_cache( void );
+void mbedtls_test_psa_purge_key_cache(void);
/** \def TEST_USES_KEY_ID
*
@@ -75,18 +75,18 @@
*
* \param key_id The PSA key identifier to record.
*/
-#define TEST_USES_KEY_ID( key_id ) \
- TEST_ASSERT( mbedtls_test_uses_key_id( key_id ) )
+#define TEST_USES_KEY_ID(key_id) \
+ TEST_ASSERT(mbedtls_test_uses_key_id(key_id))
#else /* MBEDTLS_PSA_CRYPTO_STORAGE_C */
-#define TEST_USES_KEY_ID( key_id ) ( (void) ( key_id ) )
-#define mbedtls_test_psa_purge_key_storage( ) ( (void) 0 )
-#define mbedtls_test_psa_purge_key_cache( ) ( (void) 0 )
+#define TEST_USES_KEY_ID(key_id) ((void) (key_id))
+#define mbedtls_test_psa_purge_key_storage() ((void) 0)
+#define mbedtls_test_psa_purge_key_cache() ((void) 0)
#endif /* MBEDTLS_PSA_CRYPTO_STORAGE_C */
-#define PSA_INIT( ) PSA_ASSERT( psa_crypto_init( ) )
+#define PSA_INIT() PSA_ASSERT(psa_crypto_init())
/** Check for things that have not been cleaned up properly in the
* PSA subsystem.
@@ -95,7 +95,7 @@
* \return A string literal explaining what has not been cleaned up
* if applicable.
*/
-const char *mbedtls_test_helper_is_psa_leaking( void );
+const char *mbedtls_test_helper_is_psa_leaking(void);
/** Check that no PSA Crypto key slots are in use.
*
@@ -104,13 +104,13 @@
* `TEST_ASSERT( ! mbedtls_test_helper_is_psa_leaking( ) )`
* but with a more informative message.
*/
-#define ASSERT_PSA_PRISTINE( ) \
+#define ASSERT_PSA_PRISTINE() \
do \
{ \
- if( test_fail_if_psa_leaking( __LINE__, __FILE__ ) ) \
- goto exit; \
+ if (test_fail_if_psa_leaking(__LINE__, __FILE__)) \
+ goto exit; \
} \
- while( 0 )
+ while (0)
/** Shut down the PSA Crypto subsystem and destroy persistent keys.
* Expect a clean shutdown, with no slots in use.
@@ -122,14 +122,14 @@
* \note Persistent keys must be recorded with #TEST_USES_KEY_ID before
* creating them.
*/
-#define PSA_DONE( ) \
+#define PSA_DONE() \
do \
{ \
- test_fail_if_psa_leaking( __LINE__, __FILE__ ); \
- mbedtls_test_psa_purge_key_storage( ); \
- mbedtls_psa_crypto_free( ); \
+ test_fail_if_psa_leaking(__LINE__, __FILE__); \
+ mbedtls_test_psa_purge_key_storage(); \
+ mbedtls_psa_crypto_free(); \
} \
- while( 0 )
+ while (0)
/** Shut down the PSA Crypto subsystem, allowing persistent keys to survive.
* Expect a clean shutdown, with no slots in use.
@@ -137,22 +137,22 @@
* If some key slots are still in use, record the test case as failed and
* jump to the `exit` label.
*/
-#define PSA_SESSION_DONE( ) \
+#define PSA_SESSION_DONE() \
do \
{ \
- mbedtls_test_psa_purge_key_cache( ); \
- ASSERT_PSA_PRISTINE( ); \
- mbedtls_psa_crypto_free( ); \
+ mbedtls_test_psa_purge_key_cache(); \
+ ASSERT_PSA_PRISTINE(); \
+ mbedtls_psa_crypto_free(); \
} \
- while( 0 )
+ while (0)
#if defined(RECORD_PSA_STATUS_COVERAGE_LOG)
-psa_status_t mbedtls_test_record_status( psa_status_t status,
- const char *func,
- const char *file, int line,
- const char *expr );
+psa_status_t mbedtls_test_record_status(psa_status_t status,
+ const char *func,
+ const char *file, int line,
+ const char *expr);
/** Return value logging wrapper macro.
*
@@ -178,8 +178,8 @@
* a value of type #psa_status_t.
* \return The value of \p expr.
*/
-#define RECORD_STATUS( string, expr ) \
- mbedtls_test_record_status( ( expr ), string, __FILE__, __LINE__, #expr )
+#define RECORD_STATUS(string, expr) \
+ mbedtls_test_record_status((expr), string, __FILE__, __LINE__, #expr)
#include "instrument_record_status.h"
@@ -191,7 +191,7 @@
* permissions of other usage policies
* (like PSA_KEY_USAGE_SIGN_HASH involves PSA_KEY_USAGE_SIGN_MESSAGE).
*/
-psa_key_usage_t mbedtls_test_update_key_usage_flags( psa_key_usage_t usage_flags );
+psa_key_usage_t mbedtls_test_update_key_usage_flags(psa_key_usage_t usage_flags);
/** Skip a test case if the given key is a 192 bits AES key and the AES
* implementation is at least partially provided by an accelerator or
@@ -220,18 +220,18 @@
#define MBEDTLS_TEST_HAVE_ALT_AES 0
#endif
-#define MBEDTLS_TEST_PSA_SKIP_IF_ALT_AES_192( key_type, key_bits ) \
+#define MBEDTLS_TEST_PSA_SKIP_IF_ALT_AES_192(key_type, key_bits) \
do \
{ \
- if( ( MBEDTLS_TEST_HAVE_ALT_AES ) && \
- ( ( key_type ) == PSA_KEY_TYPE_AES ) && \
- ( key_bits == 192 ) ) \
+ if ((MBEDTLS_TEST_HAVE_ALT_AES) && \
+ ((key_type) == PSA_KEY_TYPE_AES) && \
+ (key_bits == 192)) \
{ \
- mbedtls_test_skip( "AES-192 not supported", __LINE__, __FILE__ ); \
+ mbedtls_test_skip("AES-192 not supported", __LINE__, __FILE__); \
goto exit; \
} \
} \
- while( 0 )
+ while (0)
/** Skip a test case if a GCM operation with a nonce length different from
* 12 bytes fails and was performed by an accelerator or alternative
@@ -262,20 +262,20 @@
#define MBEDTLS_TEST_HAVE_ALT_GCM 0
#endif
-#define MBEDTLS_TEST_PSA_SKIP_IF_ALT_GCM_NOT_12BYTES_NONCE( alg, \
- nonce_length ) \
+#define MBEDTLS_TEST_PSA_SKIP_IF_ALT_GCM_NOT_12BYTES_NONCE(alg, \
+ nonce_length) \
do \
{ \
- if( ( MBEDTLS_TEST_HAVE_ALT_GCM ) && \
- ( PSA_ALG_AEAD_WITH_SHORTENED_TAG( ( alg ) , 0 ) == \
- PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 0 ) ) && \
- ( ( nonce_length ) != 12 ) ) \
+ if ((MBEDTLS_TEST_HAVE_ALT_GCM) && \
+ (PSA_ALG_AEAD_WITH_SHORTENED_TAG((alg), 0) == \
+ PSA_ALG_AEAD_WITH_SHORTENED_TAG(PSA_ALG_GCM, 0)) && \
+ ((nonce_length) != 12)) \
{ \
- mbedtls_test_skip( "GCM with non-12-byte IV is not supported", __LINE__, __FILE__ ); \
+ mbedtls_test_skip("GCM with non-12-byte IV is not supported", __LINE__, __FILE__); \
goto exit; \
} \
} \
- while( 0 )
+ while (0)
#endif /* MBEDTLS_PSA_CRYPTO_C */
@@ -292,14 +292,14 @@
* #MBEDTLS_USE_PSA_CRYPTO is disabled.
*/
#if defined(MBEDTLS_USE_PSA_CRYPTO)
-#define USE_PSA_INIT( ) PSA_INIT( )
-#define USE_PSA_DONE( ) PSA_DONE( )
+#define USE_PSA_INIT() PSA_INIT()
+#define USE_PSA_DONE() PSA_DONE()
#else /* MBEDTLS_USE_PSA_CRYPTO */
/* Define empty macros so that we can use them in the preamble and teardown
* of every test function that uses PSA conditionally based on
* MBEDTLS_USE_PSA_CRYPTO. */
-#define USE_PSA_INIT( ) ( (void) 0 )
-#define USE_PSA_DONE( ) ( (void) 0 )
+#define USE_PSA_INIT() ((void) 0)
+#define USE_PSA_DONE() ((void) 0)
#endif /* !MBEDTLS_USE_PSA_CRYPTO */
#endif /* PSA_CRYPTO_HELPERS_H */
diff --git a/tests/include/test/psa_exercise_key.h b/tests/include/test/psa_exercise_key.h
index 4306c1a..179df18 100644
--- a/tests/include/test/psa_exercise_key.h
+++ b/tests/include/test/psa_exercise_key.h
@@ -109,7 +109,7 @@
* This is used in some smoke tests.
*/
#if defined(KNOWN_SUPPORTED_HASH_ALG) && defined(PSA_WANT_ALG_HMAC)
-#define KNOWN_SUPPORTED_MAC_ALG ( PSA_ALG_HMAC( KNOWN_SUPPORTED_HASH_ALG ) )
+#define KNOWN_SUPPORTED_MAC_ALG (PSA_ALG_HMAC(KNOWN_SUPPORTED_HASH_ALG))
#define KNOWN_SUPPORTED_MAC_KEY_TYPE PSA_KEY_TYPE_HMAC
#elif defined(KNOWN_SUPPORTED_BLOCK_CIPHER) && defined(MBEDTLS_CMAC_C)
#define KNOWN_SUPPORTED_MAC_ALG PSA_ALG_CMAC
@@ -168,12 +168,12 @@
* \return \c 1 on success, \c 0 on failure.
*/
int mbedtls_test_psa_setup_key_derivation_wrap(
- psa_key_derivation_operation_t* operation,
+ psa_key_derivation_operation_t *operation,
mbedtls_svc_key_id_t key,
psa_algorithm_t alg,
- const unsigned char* input1, size_t input1_length,
- const unsigned char* input2, size_t input2_length,
- size_t capacity );
+ const unsigned char *input1, size_t input1_length,
+ const unsigned char *input2, size_t input2_length,
+ size_t capacity);
/** Perform a key agreement using the given key pair against its public key
* using psa_raw_key_agreement().
@@ -189,7 +189,7 @@
*/
psa_status_t mbedtls_test_psa_raw_key_agreement_with_self(
psa_algorithm_t alg,
- mbedtls_svc_key_id_t key );
+ mbedtls_svc_key_id_t key);
/** Perform a key agreement using the given key pair against its public key
* using psa_key_derivation_raw_key().
@@ -208,7 +208,7 @@
*/
psa_status_t mbedtls_test_psa_key_agreement_with_self(
psa_key_derivation_operation_t *operation,
- mbedtls_svc_key_id_t key );
+ mbedtls_svc_key_id_t key);
/** Perform sanity checks on the given key representation.
*
@@ -230,7 +230,7 @@
*/
int mbedtls_test_psa_exported_key_sanity_check(
psa_key_type_t type, size_t bits,
- const uint8_t *exported, size_t exported_length );
+ const uint8_t *exported, size_t exported_length);
/** Do smoke tests on a key.
*
@@ -259,11 +259,11 @@
* \retval 0 The key failed the smoke tests.
* \retval 1 The key passed the smoke tests.
*/
-int mbedtls_test_psa_exercise_key( mbedtls_svc_key_id_t key,
- psa_key_usage_t usage,
- psa_algorithm_t alg );
+int mbedtls_test_psa_exercise_key(mbedtls_svc_key_id_t key,
+ psa_key_usage_t usage,
+ psa_algorithm_t alg);
-psa_key_usage_t mbedtls_test_psa_usage_to_exercise( psa_key_type_t type,
- psa_algorithm_t alg );
+psa_key_usage_t mbedtls_test_psa_usage_to_exercise(psa_key_type_t type,
+ psa_algorithm_t alg);
#endif /* PSA_EXERCISE_KEY_H */
diff --git a/tests/include/test/psa_helpers.h b/tests/include/test/psa_helpers.h
index f438a71..2665fac 100644
--- a/tests/include/test/psa_helpers.h
+++ b/tests/include/test/psa_helpers.h
@@ -31,6 +31,6 @@
* to a \c psa_xxx function that returns a value of type
* #psa_status_t.
*/
-#define PSA_ASSERT( expr ) TEST_EQUAL( ( expr ), PSA_SUCCESS )
+#define PSA_ASSERT(expr) TEST_EQUAL((expr), PSA_SUCCESS)
#endif /* PSA_HELPERS_H */
diff --git a/tests/include/test/random.h b/tests/include/test/random.h
index 6428280..4f7b55c 100644
--- a/tests/include/test/random.h
+++ b/tests/include/test/random.h
@@ -34,12 +34,11 @@
#include <stddef.h>
#include <stdint.h>
-typedef struct
-{
+typedef struct {
unsigned char *buf; /* Pointer to a buffer of length bytes. */
size_t length;
/* If fallback_f_rng is NULL, fail after delivering length bytes. */
- int ( *fallback_f_rng )( void*, unsigned char *, size_t );
+ int (*fallback_f_rng)(void *, unsigned char *, size_t);
void *fallback_p_rng;
} mbedtls_test_rnd_buf_info;
@@ -50,8 +49,7 @@
* Do not forget endianness!
* State( v0, v1 ) should be set to zero.
*/
-typedef struct
-{
+typedef struct {
uint32_t key[16];
uint32_t v0, v1;
} mbedtls_test_rnd_pseudo_info;
@@ -65,18 +63,18 @@
*
* rng_state shall be NULL.
*/
-int mbedtls_test_rnd_std_rand( void *rng_state,
- unsigned char *output,
- size_t len );
+int mbedtls_test_rnd_std_rand(void *rng_state,
+ unsigned char *output,
+ size_t len);
/**
* This function only returns zeros.
*
* \p rng_state shall be \c NULL.
*/
-int mbedtls_test_rnd_zero_rand( void *rng_state,
- unsigned char *output,
- size_t len );
+int mbedtls_test_rnd_zero_rand(void *rng_state,
+ unsigned char *output,
+ size_t len);
/**
* This function returns random data based on a buffer it receives.
@@ -90,9 +88,9 @@
* #mbedtls_test_rnd_buf_info structure if there is one, and
* will return #MBEDTLS_ERR_ENTROPY_SOURCE_FAILED otherwise.
*/
-int mbedtls_test_rnd_buffer_rand( void *rng_state,
- unsigned char *output,
- size_t len );
+int mbedtls_test_rnd_buffer_rand(void *rng_state,
+ unsigned char *output,
+ size_t len);
/**
* This function returns random based on a pseudo random function.
@@ -102,8 +100,8 @@
*
* \p rng_state shall be a pointer to a #mbedtls_test_rnd_pseudo_info structure.
*/
-int mbedtls_test_rnd_pseudo_rand( void *rng_state,
- unsigned char *output,
- size_t len );
+int mbedtls_test_rnd_pseudo_rand(void *rng_state,
+ unsigned char *output,
+ size_t len);
#endif /* TEST_RANDOM_H */