Apply clang formatting.
Executed with:
`find . -regextype posix-egrep -regex ".*\.([hc]|fmt|function)" | xargs -L1 clang-format-12 -i`
Signed-off-by: Mateusz Starzyk <mateusz.starzyk@mobica.com>
diff --git a/programs/ssl/ssl_test_lib.h b/programs/ssl/ssl_test_lib.h
index f9e031b..b3395f7 100644
--- a/programs/ssl/ssl_test_lib.h
+++ b/programs/ssl/ssl_test_lib.h
@@ -23,120 +23,114 @@
#include "mbedtls/build_info.h"
#if defined(MBEDTLS_PLATFORM_C)
-#include "mbedtls/platform.h"
+# include "mbedtls/platform.h"
#else
-#include <stdio.h>
-#include <stdlib.h>
-#define mbedtls_calloc calloc
-#define mbedtls_free free
-#define mbedtls_time time
-#define mbedtls_time_t time_t
-#define mbedtls_printf printf
-#define mbedtls_fprintf fprintf
-#define mbedtls_snprintf snprintf
-#define mbedtls_exit exit
-#define MBEDTLS_EXIT_SUCCESS EXIT_SUCCESS
-#define MBEDTLS_EXIT_FAILURE EXIT_FAILURE
+# include <stdio.h>
+# include <stdlib.h>
+# define mbedtls_calloc calloc
+# define mbedtls_free free
+# define mbedtls_time time
+# define mbedtls_time_t time_t
+# define mbedtls_printf printf
+# define mbedtls_fprintf fprintf
+# define mbedtls_snprintf snprintf
+# define mbedtls_exit exit
+# define MBEDTLS_EXIT_SUCCESS EXIT_SUCCESS
+# define MBEDTLS_EXIT_FAILURE EXIT_FAILURE
#endif
#undef HAVE_RNG
-#if defined(MBEDTLS_PSA_CRYPTO_EXTERNAL_RNG) && \
- ( defined(MBEDTLS_USE_PSA_CRYPTO) || \
- defined(MBEDTLS_TEST_USE_PSA_CRYPTO_RNG) )
-#define HAVE_RNG
+#if defined(MBEDTLS_PSA_CRYPTO_EXTERNAL_RNG) && \
+ (defined(MBEDTLS_USE_PSA_CRYPTO) || \
+ defined(MBEDTLS_TEST_USE_PSA_CRYPTO_RNG))
+# define HAVE_RNG
#elif defined(MBEDTLS_ENTROPY_C) && defined(MBEDTLS_CTR_DRBG_C)
-#define HAVE_RNG
-#elif defined(MBEDTLS_ENTROPY_C) && defined(MBEDTLS_HMAC_DRBG_C) && \
- ( defined(MBEDTLS_SHA256_C) || defined(MBEDTLS_SHA512_C) )
-#define HAVE_RNG
+# define HAVE_RNG
+#elif defined(MBEDTLS_ENTROPY_C) && defined(MBEDTLS_HMAC_DRBG_C) && \
+ (defined(MBEDTLS_SHA256_C) || defined(MBEDTLS_SHA512_C))
+# define HAVE_RNG
#endif
-#if !defined(MBEDTLS_NET_C) || \
- !defined(MBEDTLS_SSL_TLS_C) || \
+#if !defined(MBEDTLS_NET_C) || !defined(MBEDTLS_SSL_TLS_C) || \
defined(MBEDTLS_PSA_CRYPTO_KEY_ID_ENCODES_OWNER)
-#define MBEDTLS_SSL_TEST_IMPOSSIBLE \
- "MBEDTLS_NET_C and/or " \
- "MBEDTLS_SSL_TLS_C not defined, " \
- "and/or MBEDTLS_PSA_CRYPTO_KEY_ID_ENCODES_OWNER defined.\n"
+# define MBEDTLS_SSL_TEST_IMPOSSIBLE \
+ "MBEDTLS_NET_C and/or " \
+ "MBEDTLS_SSL_TLS_C not defined, " \
+ "and/or MBEDTLS_PSA_CRYPTO_KEY_ID_ENCODES_OWNER defined.\n"
#elif !defined(HAVE_RNG)
-#define MBEDTLS_SSL_TEST_IMPOSSIBLE \
- "No random generator is available.\n"
+# define MBEDTLS_SSL_TEST_IMPOSSIBLE "No random generator is available.\n"
#else
-#undef MBEDTLS_SSL_TEST_IMPOSSIBLE
+# undef MBEDTLS_SSL_TEST_IMPOSSIBLE
-#undef HAVE_RNG
+# undef HAVE_RNG
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
+# include <stdio.h>
+# include <stdlib.h>
+# include <string.h>
-#include "mbedtls/net_sockets.h"
-#include "mbedtls/ssl.h"
-#include "mbedtls/entropy.h"
-#include "mbedtls/ctr_drbg.h"
-#include "mbedtls/hmac_drbg.h"
-#include "mbedtls/x509.h"
-#include "mbedtls/error.h"
-#include "mbedtls/debug.h"
-#include "mbedtls/timing.h"
-#include "mbedtls/base64.h"
-#include "test/certs.h"
+# include "mbedtls/net_sockets.h"
+# include "mbedtls/ssl.h"
+# include "mbedtls/entropy.h"
+# include "mbedtls/ctr_drbg.h"
+# include "mbedtls/hmac_drbg.h"
+# include "mbedtls/x509.h"
+# include "mbedtls/error.h"
+# include "mbedtls/debug.h"
+# include "mbedtls/timing.h"
+# include "mbedtls/base64.h"
+# include "test/certs.h"
-#if defined(MBEDTLS_USE_PSA_CRYPTO) || defined(MBEDTLS_TEST_USE_PSA_CRYPTO_RNG)
-#include "psa/crypto.h"
-#include "mbedtls/psa_util.h"
-#endif
+# if defined(MBEDTLS_USE_PSA_CRYPTO) || \
+ defined(MBEDTLS_TEST_USE_PSA_CRYPTO_RNG)
+# include "psa/crypto.h"
+# include "mbedtls/psa_util.h"
+# endif
-#if defined(MBEDTLS_MEMORY_BUFFER_ALLOC_C)
-#include "mbedtls/memory_buffer_alloc.h"
-#endif
+# if defined(MBEDTLS_MEMORY_BUFFER_ALLOC_C)
+# include "mbedtls/memory_buffer_alloc.h"
+# endif
-#include <test/helpers.h>
+# include <test/helpers.h>
-#include "../test/query_config.h"
+# include "../test/query_config.h"
-#if defined(MBEDTLS_SSL_EXPORT_KEYS)
+# if defined(MBEDTLS_SSL_EXPORT_KEYS)
-typedef struct eap_tls_keys
-{
+typedef struct eap_tls_keys {
unsigned char master_secret[48];
unsigned char randbytes[64];
mbedtls_tls_prf_types tls_prf_type;
} eap_tls_keys;
-#if defined( MBEDTLS_SSL_DTLS_SRTP )
+# if defined(MBEDTLS_SSL_DTLS_SRTP)
/* Supported SRTP mode needs a maximum of :
* - 16 bytes for key (AES-128)
* - 14 bytes SALT
* One for sender, one for receiver context
*/
-#define MBEDTLS_TLS_SRTP_MAX_KEY_MATERIAL_LENGTH 60
+# define MBEDTLS_TLS_SRTP_MAX_KEY_MATERIAL_LENGTH 60
-typedef struct dtls_srtp_keys
-{
+typedef struct dtls_srtp_keys {
unsigned char master_secret[48];
unsigned char randbytes[64];
mbedtls_tls_prf_types tls_prf_type;
} dtls_srtp_keys;
-#endif /* MBEDTLS_SSL_DTLS_SRTP */
+# endif /* MBEDTLS_SSL_DTLS_SRTP */
-#endif /* MBEDTLS_SSL_EXPORT_KEYS */
+# endif /* MBEDTLS_SSL_EXPORT_KEYS */
-typedef struct
-{
+typedef struct {
mbedtls_ssl_context *ssl;
mbedtls_net_context *net;
} io_ctx_t;
-void my_debug( void *ctx, int level,
- const char *file, int line,
- const char *str );
+void my_debug(void *ctx, int level, const char *file, int line, const char *str);
-mbedtls_time_t dummy_constant_time( mbedtls_time_t* time );
+mbedtls_time_t dummy_constant_time(mbedtls_time_t *time);
-#if defined(MBEDTLS_USE_PSA_CRYPTO)
+# if defined(MBEDTLS_USE_PSA_CRYPTO)
/* If MBEDTLS_TEST_USE_PSA_CRYPTO_RNG is defined, the SSL test programs will use
* mbedtls_psa_get_random() rather than entropy+DRBG as a random generator.
*
@@ -158,25 +152,24 @@
* perspective: either PSA is preferred for TLS (both for crypto and for
* random generation) or it isn't.
*/
-#define MBEDTLS_TEST_USE_PSA_CRYPTO_RNG
-#endif
+# define MBEDTLS_TEST_USE_PSA_CRYPTO_RNG
+# endif
/** A context for random number generation (RNG).
*/
-typedef struct
-{
-#if defined(MBEDTLS_TEST_USE_PSA_CRYPTO_RNG)
+typedef struct {
+# if defined(MBEDTLS_TEST_USE_PSA_CRYPTO_RNG)
unsigned char dummy;
-#else /* MBEDTLS_TEST_USE_PSA_CRYPTO_RNG */
+# else /* MBEDTLS_TEST_USE_PSA_CRYPTO_RNG */
mbedtls_entropy_context entropy;
-#if defined(MBEDTLS_CTR_DRBG_C)
+# if defined(MBEDTLS_CTR_DRBG_C)
mbedtls_ctr_drbg_context drbg;
-#elif defined(MBEDTLS_HMAC_DRBG_C)
+# elif defined(MBEDTLS_HMAC_DRBG_C)
mbedtls_hmac_drbg_context drbg;
-#else
-#error "No DRBG available"
-#endif
-#endif /* MBEDTLS_TEST_USE_PSA_CRYPTO_RNG */
+# else
+# error "No DRBG available"
+# endif
+# endif /* MBEDTLS_TEST_USE_PSA_CRYPTO_RNG */
} rng_context_t;
/** Initialize the RNG.
@@ -184,7 +177,7 @@
* This function only initializes the memory used by the RNG context.
* Before using the RNG, it must be seeded with rng_seed().
*/
-void rng_init( rng_context_t *rng );
+void rng_init(rng_context_t *rng);
/* Seed the random number generator.
*
@@ -200,14 +193,14 @@
*
* return 0 on success, a negative value on error.
*/
-int rng_seed( rng_context_t *rng, int reproducible, const char *pers );
+int rng_seed(rng_context_t *rng, int reproducible, const char *pers);
/** Deinitialize the RNG. Free any embedded resource.
*
* \param rng The RNG context to deinitialize. It must have been
* initialized with rng_init().
*/
-void rng_free( rng_context_t *rng );
+void rng_free(rng_context_t *rng);
/** Generate random data.
*
@@ -222,42 +215,44 @@
* \return \c 0 on success.
* \return An Mbed TLS error code on error.
*/
-int rng_get( void *p_rng, unsigned char *output, size_t output_len );
+int rng_get(void *p_rng, unsigned char *output, size_t output_len);
-#if defined(MBEDTLS_USE_PSA_CRYPTO) && defined(MBEDTLS_PSA_CRYPTO_EXTERNAL_RNG)
+# if defined(MBEDTLS_USE_PSA_CRYPTO) && \
+ defined(MBEDTLS_PSA_CRYPTO_EXTERNAL_RNG)
/* The test implementation of the PSA external RNG is insecure. When
* MBEDTLS_PSA_CRYPTO_EXTERNAL_RNG is enabled, before using any PSA crypto
* function that makes use of an RNG, you must call
* mbedtls_test_enable_insecure_external_rng(). */
-#include <test/fake_external_rng_for_test.h>
-#endif
+# include <test/fake_external_rng_for_test.h>
+# endif
-#if defined(MBEDTLS_X509_TRUSTED_CERTIFICATE_CALLBACK)
-int ca_callback( void *data, mbedtls_x509_crt const *child,
- mbedtls_x509_crt **candidates );
-#endif /* MBEDTLS_X509_TRUSTED_CERTIFICATE_CALLBACK */
+# if defined(MBEDTLS_X509_TRUSTED_CERTIFICATE_CALLBACK)
+int ca_callback(void *data,
+ mbedtls_x509_crt const *child,
+ mbedtls_x509_crt **candidates);
+# endif /* MBEDTLS_X509_TRUSTED_CERTIFICATE_CALLBACK */
/*
* Test recv/send functions that make sure each try returns
* WANT_READ/WANT_WRITE at least once before sucesseding
*/
-int delayed_recv( void *ctx, unsigned char *buf, size_t len );
-int delayed_send( void *ctx, const unsigned char *buf, size_t len );
+int delayed_recv(void *ctx, unsigned char *buf, size_t len);
+int delayed_send(void *ctx, const unsigned char *buf, size_t len);
/*
* Wait for an event from the underlying transport or the timer
* (Used in event-driven IO mode).
*/
-int idle( mbedtls_net_context *fd,
-#if defined(MBEDTLS_TIMING_C)
- mbedtls_timing_delay_context *timer,
-#endif
- int idle_reason );
+int idle(mbedtls_net_context *fd,
+# if defined(MBEDTLS_TIMING_C)
+ mbedtls_timing_delay_context *timer,
+# endif
+ int idle_reason);
-#if defined(MBEDTLS_TEST_HOOKS)
+# if defined(MBEDTLS_TEST_HOOKS)
/** Initialize whatever test hooks are enabled by the compile-time
* configuration and make sense for the TLS test programs. */
-void test_hooks_init( void );
+void test_hooks_init(void);
/** Check if any test hooks detected a problem.
*
@@ -275,16 +270,16 @@
* \return Nonzero if a problem was detected.
* \c 0 if no problem was detected.
*/
-int test_hooks_failure_detected( void );
+int test_hooks_failure_detected(void);
/** Free any resources allocated for the sake of test hooks.
*
* Call this at the end of the program so that resource leak analyzers
* don't complain.
*/
-void test_hooks_free( void );
+void test_hooks_free(void);
-#endif /* !MBEDTLS_TEST_HOOKS */
+# endif /* !MBEDTLS_TEST_HOOKS */
#endif /* MBEDTLS_SSL_TEST_IMPOSSIBLE conditions: else */
#endif /* MBEDTLS_PROGRAMS_SSL_SSL_TEST_LIB_H */