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/fuzz/common.c b/programs/fuzz/common.c
index 70a5380..bbea39f 100644
--- a/programs/fuzz/common.c
+++ b/programs/fuzz/common.c
@@ -4,93 +4,95 @@
 #include <stdlib.h>
 #include "mbedtls/ctr_drbg.h"
 
-mbedtls_time_t dummy_constant_time( mbedtls_time_t* time )
+mbedtls_time_t dummy_constant_time(mbedtls_time_t *time)
 {
-    (void) time;
+    (void)time;
     return 0x5af2a056;
 }
 
 void dummy_init()
 {
 #if defined(MBEDTLS_PLATFORM_TIME_ALT)
-    mbedtls_platform_set_time( dummy_constant_time );
+    mbedtls_platform_set_time(dummy_constant_time);
 #else
     fprintf(stderr, "Warning: fuzzing without constant time\n");
 #endif
 }
 
-int dummy_send( void *ctx, const unsigned char *buf, size_t len )
+int dummy_send(void *ctx, const unsigned char *buf, size_t len)
 {
-    //silence warning about unused parameter
-    (void) ctx;
-    (void) buf;
+    // silence warning about unused parameter
+    (void)ctx;
+    (void)buf;
 
-    //pretends we wrote everything ok
-    if( len > INT_MAX ) {
-        return -1 ;
+    // pretends we wrote everything ok
+    if (len > INT_MAX) {
+        return -1;
     }
-    return (int) len ;
+    return (int)len;
 }
 
-int fuzz_recv( void *ctx, unsigned char *buf, size_t len )
+int fuzz_recv(void *ctx, unsigned char *buf, size_t len)
 {
-    //reads from the buffer from fuzzer
-    fuzzBufferOffset_t * biomemfuzz = (fuzzBufferOffset_t *) ctx;
+    // reads from the buffer from fuzzer
+    fuzzBufferOffset_t *biomemfuzz = (fuzzBufferOffset_t *)ctx;
 
-    if(biomemfuzz->Offset == biomemfuzz->Size) {
-        //EOF
-        return 0 ;
+    if (biomemfuzz->Offset == biomemfuzz->Size) {
+        // EOF
+        return 0;
     }
-    if( len > INT_MAX ) {
-        return -1 ;
+    if (len > INT_MAX) {
+        return -1;
     }
-    if( len + biomemfuzz->Offset > biomemfuzz->Size ) {
-        //do not overflow
+    if (len + biomemfuzz->Offset > biomemfuzz->Size) {
+        // do not overflow
         len = biomemfuzz->Size - biomemfuzz->Offset;
     }
     memcpy(buf, biomemfuzz->Data + biomemfuzz->Offset, len);
     biomemfuzz->Offset += len;
-    return (int) len ;
+    return (int)len;
 }
 
-int dummy_random( void *p_rng, unsigned char *output, size_t output_len )
+int dummy_random(void *p_rng, unsigned char *output, size_t output_len)
 {
     int ret;
     size_t i;
 
 #if defined(MBEDTLS_CTR_DRBG_C)
-    //use mbedtls_ctr_drbg_random to find bugs in it
+    // use mbedtls_ctr_drbg_random to find bugs in it
     ret = mbedtls_ctr_drbg_random(p_rng, output, output_len);
 #else
-    (void) p_rng;
+    (void)p_rng;
     ret = 0;
 #endif
-    for (i=0; i<output_len; i++) {
-        //replace result with pseudo random
-        output[i] = (unsigned char) rand();
+    for (i = 0; i < output_len; i++) {
+        // replace result with pseudo random
+        output[i] = (unsigned char)rand();
     }
-    return ret ;
+    return ret;
 }
 
-int dummy_entropy( void *data, unsigned char *output, size_t len )
+int dummy_entropy(void *data, unsigned char *output, size_t len)
 {
     size_t i;
-    (void) data;
+    (void)data;
 
-    //use mbedtls_entropy_func to find bugs in it
-    //test performance impact of entropy
-    //ret = mbedtls_entropy_func(data, output, len);
-    for (i=0; i<len; i++) {
-        //replace result with pseudo random
-        output[i] = (unsigned char) rand();
+    // use mbedtls_entropy_func to find bugs in it
+    // test performance impact of entropy
+    // ret = mbedtls_entropy_func(data, output, len);
+    for (i = 0; i < len; i++) {
+        // replace result with pseudo random
+        output[i] = (unsigned char)rand();
     }
-    return 0 ;
+    return 0;
 }
 
-int fuzz_recv_timeout( void *ctx, unsigned char *buf, size_t len,
-                      uint32_t timeout )
+int fuzz_recv_timeout(void *ctx,
+                      unsigned char *buf,
+                      size_t len,
+                      uint32_t timeout)
 {
-    (void) timeout;
+    (void)timeout;
 
     return fuzz_recv(ctx, buf, len);
 }
diff --git a/programs/fuzz/common.h b/programs/fuzz/common.h
index 5586c06..1c7d02f 100644
--- a/programs/fuzz/common.h
+++ b/programs/fuzz/common.h
@@ -1,19 +1,20 @@
 #include "mbedtls/platform_time.h"
 #include <stdint.h>
 
-typedef struct fuzzBufferOffset
-{
+typedef struct fuzzBufferOffset {
     const uint8_t *Data;
     size_t Size;
     size_t Offset;
 } fuzzBufferOffset_t;
 
-mbedtls_time_t dummy_constant_time( mbedtls_time_t* time );
+mbedtls_time_t dummy_constant_time(mbedtls_time_t *time);
 void dummy_init();
 
-int dummy_send( void *ctx, const unsigned char *buf, size_t len );
-int fuzz_recv( void *ctx, unsigned char *buf, size_t len );
-int dummy_random( void *p_rng, unsigned char *output, size_t output_len );
-int dummy_entropy( void *data, unsigned char *output, size_t len );
-int fuzz_recv_timeout( void *ctx, unsigned char *buf, size_t len,
-                      uint32_t timeout );
+int dummy_send(void *ctx, const unsigned char *buf, size_t len);
+int fuzz_recv(void *ctx, unsigned char *buf, size_t len);
+int dummy_random(void *p_rng, unsigned char *output, size_t output_len);
+int dummy_entropy(void *data, unsigned char *output, size_t len);
+int fuzz_recv_timeout(void *ctx,
+                      unsigned char *buf,
+                      size_t len,
+                      uint32_t timeout);
diff --git a/programs/fuzz/fuzz_client.c b/programs/fuzz/fuzz_client.c
index ab2d134..7702bf2 100644
--- a/programs/fuzz/fuzz_client.c
+++ b/programs/fuzz/fuzz_client.c
@@ -9,32 +9,26 @@
 #include <stdlib.h>
 #include <stdint.h>
 
-
-#if defined(MBEDTLS_SSL_CLI_C) && \
-    defined(MBEDTLS_ENTROPY_C) && \
+#if defined(MBEDTLS_SSL_CLI_C) && defined(MBEDTLS_ENTROPY_C) && \
     defined(MBEDTLS_CTR_DRBG_C)
 static int initialized = 0;
-#if defined(MBEDTLS_X509_CRT_PARSE_C) && defined(MBEDTLS_PEM_PARSE_C)
+#    if defined(MBEDTLS_X509_CRT_PARSE_C) && defined(MBEDTLS_PEM_PARSE_C)
 static mbedtls_x509_crt cacert;
-#endif
+#    endif
 const char *alpn_list[3];
 
-
-#if defined(MBEDTLS_KEY_EXCHANGE_SOME_PSK_ENABLED)
-const unsigned char psk[] = {
-    0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
-    0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f
-};
+#    if defined(MBEDTLS_KEY_EXCHANGE_SOME_PSK_ENABLED)
+const unsigned char psk[] = { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
+                              0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f };
 const char psk_id[] = "Client_identity";
-#endif
+#    endif
 
 const char *pers = "fuzz_client";
 #endif /* MBEDTLS_SSL_CLI_C && MBEDTLS_ENTROPY_C && MBEDTLS_CTR_DRBG_C */
 
-
-int LLVMFuzzerTestOneInput(const uint8_t *Data, size_t Size) {
-#if defined(MBEDTLS_SSL_CLI_C) && \
-    defined(MBEDTLS_ENTROPY_C) && \
+int LLVMFuzzerTestOneInput(const uint8_t *Data, size_t Size)
+{
+#if defined(MBEDTLS_SSL_CLI_C) && defined(MBEDTLS_ENTROPY_C) && \
     defined(MBEDTLS_CTR_DRBG_C)
     int ret;
     size_t len;
@@ -47,12 +41,13 @@
     uint16_t options;
 
     if (initialized == 0) {
-#if defined(MBEDTLS_X509_CRT_PARSE_C) && defined(MBEDTLS_PEM_PARSE_C)
-        mbedtls_x509_crt_init( &cacert );
-        if (mbedtls_x509_crt_parse( &cacert, (const unsigned char *) mbedtls_test_cas_pem,
-                                   mbedtls_test_cas_pem_len ) != 0)
+#    if defined(MBEDTLS_X509_CRT_PARSE_C) && defined(MBEDTLS_PEM_PARSE_C)
+        mbedtls_x509_crt_init(&cacert);
+        if (mbedtls_x509_crt_parse(&cacert,
+                                   (const unsigned char *)mbedtls_test_cas_pem,
+                                   mbedtls_test_cas_pem_len) != 0)
             return 1;
-#endif
+#    endif
 
         alpn_list[0] = "HTTP";
         alpn_list[1] = "fuzzalpn";
@@ -63,110 +58,114 @@
         initialized = 1;
     }
 
-    //we take 1 byte as options input
+    // we take 1 byte as options input
     if (Size < 2) {
         return 0;
     }
     options = (Data[Size - 2] << 8) | Data[Size - 1];
-    //Avoid warnings if compile options imply no options
-    (void) options;
+    // Avoid warnings if compile options imply no options
+    (void)options;
 
-    mbedtls_ssl_init( &ssl );
-    mbedtls_ssl_config_init( &conf );
-    mbedtls_ctr_drbg_init( &ctr_drbg );
-    mbedtls_entropy_init( &entropy );
+    mbedtls_ssl_init(&ssl);
+    mbedtls_ssl_config_init(&conf);
+    mbedtls_ctr_drbg_init(&ctr_drbg);
+    mbedtls_entropy_init(&entropy);
 
-    if( mbedtls_ctr_drbg_seed( &ctr_drbg, dummy_entropy, &entropy,
-                              (const unsigned char *) pers, strlen( pers ) ) != 0 )
+    if (mbedtls_ctr_drbg_seed(&ctr_drbg, dummy_entropy, &entropy,
+                              (const unsigned char *)pers, strlen(pers)) != 0)
         goto exit;
 
-    if( mbedtls_ssl_config_defaults( &conf,
-                                    MBEDTLS_SSL_IS_CLIENT,
+    if (mbedtls_ssl_config_defaults(&conf, MBEDTLS_SSL_IS_CLIENT,
                                     MBEDTLS_SSL_TRANSPORT_STREAM,
-                                    MBEDTLS_SSL_PRESET_DEFAULT ) != 0 )
+                                    MBEDTLS_SSL_PRESET_DEFAULT) != 0)
         goto exit;
 
-#if defined(MBEDTLS_KEY_EXCHANGE_SOME_PSK_ENABLED)
+#    if defined(MBEDTLS_KEY_EXCHANGE_SOME_PSK_ENABLED)
     if (options & 2) {
-        mbedtls_ssl_conf_psk( &conf, psk, sizeof( psk ),
-                             (const unsigned char *) psk_id, sizeof( psk_id ) - 1 );
+        mbedtls_ssl_conf_psk(&conf, psk, sizeof(psk),
+                             (const unsigned char *)psk_id, sizeof(psk_id) - 1);
     }
-#endif
+#    endif
 
-#if defined(MBEDTLS_X509_CRT_PARSE_C) && defined(MBEDTLS_PEM_PARSE_C)
+#    if defined(MBEDTLS_X509_CRT_PARSE_C) && defined(MBEDTLS_PEM_PARSE_C)
     if (options & 4) {
-        mbedtls_ssl_conf_ca_chain( &conf, &cacert, NULL );
-        mbedtls_ssl_conf_authmode( &conf, MBEDTLS_SSL_VERIFY_REQUIRED );
+        mbedtls_ssl_conf_ca_chain(&conf, &cacert, NULL);
+        mbedtls_ssl_conf_authmode(&conf, MBEDTLS_SSL_VERIFY_REQUIRED);
     } else
-#endif
+#    endif
     {
-        mbedtls_ssl_conf_authmode( &conf, MBEDTLS_SSL_VERIFY_NONE );
+        mbedtls_ssl_conf_authmode(&conf, MBEDTLS_SSL_VERIFY_NONE);
     }
-#if defined(MBEDTLS_SSL_EXTENDED_MASTER_SECRET)
-    mbedtls_ssl_conf_extended_master_secret( &conf, (options & 0x10) ? MBEDTLS_SSL_EXTENDED_MS_DISABLED : MBEDTLS_SSL_EXTENDED_MS_ENABLED);
-#endif
-#if defined(MBEDTLS_SSL_ENCRYPT_THEN_MAC)
-    mbedtls_ssl_conf_encrypt_then_mac( &conf, (options & 0x20) ? MBEDTLS_SSL_ETM_DISABLED : MBEDTLS_SSL_ETM_ENABLED);
-#endif
-#if defined(MBEDTLS_SSL_RENEGOTIATION)
-    mbedtls_ssl_conf_renegotiation( &conf, (options & 0x80) ? MBEDTLS_SSL_RENEGOTIATION_ENABLED : MBEDTLS_SSL_RENEGOTIATION_DISABLED );
-#endif
-#if defined(MBEDTLS_SSL_SESSION_TICKETS)
-    mbedtls_ssl_conf_session_tickets( &conf, (options & 0x100) ? MBEDTLS_SSL_SESSION_TICKETS_DISABLED : MBEDTLS_SSL_SESSION_TICKETS_ENABLED );
-#endif
-#if defined(MBEDTLS_SSL_ALPN)
+#    if defined(MBEDTLS_SSL_EXTENDED_MASTER_SECRET)
+    mbedtls_ssl_conf_extended_master_secret(
+        &conf, (options & 0x10) ? MBEDTLS_SSL_EXTENDED_MS_DISABLED :
+                                  MBEDTLS_SSL_EXTENDED_MS_ENABLED);
+#    endif
+#    if defined(MBEDTLS_SSL_ENCRYPT_THEN_MAC)
+    mbedtls_ssl_conf_encrypt_then_mac(&conf, (options & 0x20) ?
+                                                 MBEDTLS_SSL_ETM_DISABLED :
+                                                 MBEDTLS_SSL_ETM_ENABLED);
+#    endif
+#    if defined(MBEDTLS_SSL_RENEGOTIATION)
+    mbedtls_ssl_conf_renegotiation(
+        &conf, (options & 0x80) ? MBEDTLS_SSL_RENEGOTIATION_ENABLED :
+                                  MBEDTLS_SSL_RENEGOTIATION_DISABLED);
+#    endif
+#    if defined(MBEDTLS_SSL_SESSION_TICKETS)
+    mbedtls_ssl_conf_session_tickets(
+        &conf, (options & 0x100) ? MBEDTLS_SSL_SESSION_TICKETS_DISABLED :
+                                   MBEDTLS_SSL_SESSION_TICKETS_ENABLED);
+#    endif
+#    if defined(MBEDTLS_SSL_ALPN)
     if (options & 0x200) {
-        mbedtls_ssl_conf_alpn_protocols( &conf, alpn_list );
+        mbedtls_ssl_conf_alpn_protocols(&conf, alpn_list);
     }
-#endif
-    //There may be other options to add :
+#    endif
+    // There may be other options to add :
     // mbedtls_ssl_conf_cert_profile, mbedtls_ssl_conf_sig_hashes
 
     srand(1);
-    mbedtls_ssl_conf_rng( &conf, dummy_random, &ctr_drbg );
+    mbedtls_ssl_conf_rng(&conf, dummy_random, &ctr_drbg);
 
-    if( mbedtls_ssl_setup( &ssl, &conf ) != 0 )
+    if (mbedtls_ssl_setup(&ssl, &conf) != 0)
         goto exit;
 
-#if defined(MBEDTLS_X509_CRT_PARSE_C) && defined(MBEDTLS_PEM_PARSE_C)
+#    if defined(MBEDTLS_X509_CRT_PARSE_C) && defined(MBEDTLS_PEM_PARSE_C)
     if ((options & 1) == 0) {
-        if( mbedtls_ssl_set_hostname( &ssl, "localhost" ) != 0 )
+        if (mbedtls_ssl_set_hostname(&ssl, "localhost") != 0)
             goto exit;
     }
-#endif
+#    endif
 
     biomemfuzz.Data = Data;
-    biomemfuzz.Size = Size-2;
+    biomemfuzz.Size = Size - 2;
     biomemfuzz.Offset = 0;
-    mbedtls_ssl_set_bio( &ssl, &biomemfuzz, dummy_send, fuzz_recv, NULL );
+    mbedtls_ssl_set_bio(&ssl, &biomemfuzz, dummy_send, fuzz_recv, NULL);
 
-    ret = mbedtls_ssl_handshake( &ssl );
-    if( ret == 0 )
-    {
-        //keep reading data from server until the end
-        do
-        {
-            len = sizeof( buf ) - 1;
-            ret = mbedtls_ssl_read( &ssl, buf, len );
+    ret = mbedtls_ssl_handshake(&ssl);
+    if (ret == 0) {
+        // keep reading data from server until the end
+        do {
+            len = sizeof(buf) - 1;
+            ret = mbedtls_ssl_read(&ssl, buf, len);
 
-            if( ret == MBEDTLS_ERR_SSL_WANT_READ )
+            if (ret == MBEDTLS_ERR_SSL_WANT_READ)
                 continue;
-            else if( ret <= 0 )
-                //EOF or error
+            else if (ret <= 0)
+                // EOF or error
                 break;
-        }
-        while( 1 );
+        } while (1);
     }
 
 exit:
-    mbedtls_entropy_free( &entropy );
-    mbedtls_ctr_drbg_free( &ctr_drbg );
-    mbedtls_ssl_config_free( &conf );
-    mbedtls_ssl_free( &ssl );
+    mbedtls_entropy_free(&entropy);
+    mbedtls_ctr_drbg_free(&ctr_drbg);
+    mbedtls_ssl_config_free(&conf);
+    mbedtls_ssl_free(&ssl);
 
 #else
-    (void) Data;
-    (void) Size;
+    (void)Data;
+    (void)Size;
 #endif /* MBEDTLS_SSL_CLI_C && MBEDTLS_ENTROPY_C && MBEDTLS_CTR_DRBG_C */
 
     return 0;
diff --git a/programs/fuzz/fuzz_dtlsclient.c b/programs/fuzz/fuzz_dtlsclient.c
index 16f6014..780cfa3 100644
--- a/programs/fuzz/fuzz_dtlsclient.c
+++ b/programs/fuzz/fuzz_dtlsclient.c
@@ -6,31 +6,26 @@
 #include "common.h"
 #include "mbedtls/ssl.h"
 #if defined(MBEDTLS_SSL_PROTO_DTLS)
-#include "mbedtls/entropy.h"
-#include "mbedtls/ctr_drbg.h"
-#include "mbedtls/timing.h"
-#include "test/certs.h"
+#    include "mbedtls/entropy.h"
+#    include "mbedtls/ctr_drbg.h"
+#    include "mbedtls/timing.h"
+#    include "test/certs.h"
 
-#if defined(MBEDTLS_SSL_CLI_C) && \
-    defined(MBEDTLS_ENTROPY_C) && \
-    defined(MBEDTLS_CTR_DRBG_C) && \
-    defined(MBEDTLS_TIMING_C)
+#    if defined(MBEDTLS_SSL_CLI_C) && defined(MBEDTLS_ENTROPY_C) && \
+        defined(MBEDTLS_CTR_DRBG_C) && defined(MBEDTLS_TIMING_C)
 static int initialized = 0;
-#if defined(MBEDTLS_X509_CRT_PARSE_C) && defined(MBEDTLS_PEM_PARSE_C)
+#        if defined(MBEDTLS_X509_CRT_PARSE_C) && defined(MBEDTLS_PEM_PARSE_C)
 static mbedtls_x509_crt cacert;
-#endif
+#        endif
 
 const char *pers = "fuzz_dtlsclient";
-#endif
+#    endif
 #endif // MBEDTLS_SSL_PROTO_DTLS
 
-
-
-int LLVMFuzzerTestOneInput(const uint8_t *Data, size_t Size) {
-#if defined(MBEDTLS_SSL_PROTO_DTLS) && \
-    defined(MBEDTLS_SSL_CLI_C) && \
-    defined(MBEDTLS_ENTROPY_C) && \
-    defined(MBEDTLS_CTR_DRBG_C) && \
+int LLVMFuzzerTestOneInput(const uint8_t *Data, size_t Size)
+{
+#if defined(MBEDTLS_SSL_PROTO_DTLS) && defined(MBEDTLS_SSL_CLI_C) && \
+    defined(MBEDTLS_ENTROPY_C) && defined(MBEDTLS_CTR_DRBG_C) &&     \
     defined(MBEDTLS_TIMING_C)
     int ret;
     size_t len;
@@ -43,82 +38,80 @@
     fuzzBufferOffset_t biomemfuzz;
 
     if (initialized == 0) {
-#if defined(MBEDTLS_X509_CRT_PARSE_C) && defined(MBEDTLS_PEM_PARSE_C)
-        mbedtls_x509_crt_init( &cacert );
-        if (mbedtls_x509_crt_parse( &cacert, (const unsigned char *) mbedtls_test_cas_pem,
-                                   mbedtls_test_cas_pem_len ) != 0)
+#    if defined(MBEDTLS_X509_CRT_PARSE_C) && defined(MBEDTLS_PEM_PARSE_C)
+        mbedtls_x509_crt_init(&cacert);
+        if (mbedtls_x509_crt_parse(&cacert,
+                                   (const unsigned char *)mbedtls_test_cas_pem,
+                                   mbedtls_test_cas_pem_len) != 0)
             return 1;
-#endif
+#    endif
         dummy_init();
 
         initialized = 1;
     }
 
-    mbedtls_ssl_init( &ssl );
-    mbedtls_ssl_config_init( &conf );
-    mbedtls_ctr_drbg_init( &ctr_drbg );
-    mbedtls_entropy_init( &entropy );
+    mbedtls_ssl_init(&ssl);
+    mbedtls_ssl_config_init(&conf);
+    mbedtls_ctr_drbg_init(&ctr_drbg);
+    mbedtls_entropy_init(&entropy);
 
     srand(1);
-    if( mbedtls_ctr_drbg_seed( &ctr_drbg, dummy_entropy, &entropy,
-                              (const unsigned char *) pers, strlen( pers ) ) != 0 )
+    if (mbedtls_ctr_drbg_seed(&ctr_drbg, dummy_entropy, &entropy,
+                              (const unsigned char *)pers, strlen(pers)) != 0)
         goto exit;
 
-    if( mbedtls_ssl_config_defaults( &conf,
-                                    MBEDTLS_SSL_IS_CLIENT,
+    if (mbedtls_ssl_config_defaults(&conf, MBEDTLS_SSL_IS_CLIENT,
                                     MBEDTLS_SSL_TRANSPORT_DATAGRAM,
-                                    MBEDTLS_SSL_PRESET_DEFAULT ) != 0 )
+                                    MBEDTLS_SSL_PRESET_DEFAULT) != 0)
         goto exit;
 
-#if defined(MBEDTLS_X509_CRT_PARSE_C) && defined(MBEDTLS_PEM_PARSE_C)
-    mbedtls_ssl_conf_ca_chain( &conf, &cacert, NULL );
-#endif
-    mbedtls_ssl_conf_authmode( &conf, MBEDTLS_SSL_VERIFY_NONE );
-    mbedtls_ssl_conf_rng( &conf, dummy_random, &ctr_drbg );
+#    if defined(MBEDTLS_X509_CRT_PARSE_C) && defined(MBEDTLS_PEM_PARSE_C)
+    mbedtls_ssl_conf_ca_chain(&conf, &cacert, NULL);
+#    endif
+    mbedtls_ssl_conf_authmode(&conf, MBEDTLS_SSL_VERIFY_NONE);
+    mbedtls_ssl_conf_rng(&conf, dummy_random, &ctr_drbg);
 
-    if( mbedtls_ssl_setup( &ssl, &conf ) != 0 )
+    if (mbedtls_ssl_setup(&ssl, &conf) != 0)
         goto exit;
 
-    mbedtls_ssl_set_timer_cb( &ssl, &timer, mbedtls_timing_set_delay,
-                             mbedtls_timing_get_delay );
+    mbedtls_ssl_set_timer_cb(&ssl, &timer, mbedtls_timing_set_delay,
+                             mbedtls_timing_get_delay);
 
-#if defined(MBEDTLS_X509_CRT_PARSE_C) && defined(MBEDTLS_PEM_PARSE_C)
-    if( mbedtls_ssl_set_hostname( &ssl, "localhost" ) != 0 )
+#    if defined(MBEDTLS_X509_CRT_PARSE_C) && defined(MBEDTLS_PEM_PARSE_C)
+    if (mbedtls_ssl_set_hostname(&ssl, "localhost") != 0)
         goto exit;
-#endif
+#    endif
 
     biomemfuzz.Data = Data;
     biomemfuzz.Size = Size;
     biomemfuzz.Offset = 0;
-    mbedtls_ssl_set_bio( &ssl, &biomemfuzz, dummy_send, fuzz_recv, fuzz_recv_timeout );
+    mbedtls_ssl_set_bio(&ssl, &biomemfuzz, dummy_send, fuzz_recv,
+                        fuzz_recv_timeout);
 
-    ret = mbedtls_ssl_handshake( &ssl );
-    if( ret == 0 )
-    {
-        //keep reading data from server until the end
-        do
-        {
-            len = sizeof( buf ) - 1;
-            ret = mbedtls_ssl_read( &ssl, buf, len );
+    ret = mbedtls_ssl_handshake(&ssl);
+    if (ret == 0) {
+        // keep reading data from server until the end
+        do {
+            len = sizeof(buf) - 1;
+            ret = mbedtls_ssl_read(&ssl, buf, len);
 
-            if( ret == MBEDTLS_ERR_SSL_WANT_READ )
+            if (ret == MBEDTLS_ERR_SSL_WANT_READ)
                 continue;
-            else if( ret <= 0 )
-                //EOF or error
+            else if (ret <= 0)
+                // EOF or error
                 break;
-        }
-        while( 1 );
+        } while (1);
     }
 
 exit:
-    mbedtls_entropy_free( &entropy );
-    mbedtls_ctr_drbg_free( &ctr_drbg );
-    mbedtls_ssl_config_free( &conf );
-    mbedtls_ssl_free( &ssl );
+    mbedtls_entropy_free(&entropy);
+    mbedtls_ctr_drbg_free(&ctr_drbg);
+    mbedtls_ssl_config_free(&conf);
+    mbedtls_ssl_free(&ssl);
 
 #else
-    (void) Data;
-    (void) Size;
+    (void)Data;
+    (void)Size;
 #endif
     return 0;
 }
diff --git a/programs/fuzz/fuzz_dtlsserver.c b/programs/fuzz/fuzz_dtlsserver.c
index 9a6e894..8416dfb 100644
--- a/programs/fuzz/fuzz_dtlsserver.c
+++ b/programs/fuzz/fuzz_dtlsserver.c
@@ -7,31 +7,27 @@
 #include "mbedtls/ssl.h"
 #include "test/certs.h"
 #if defined(MBEDTLS_SSL_PROTO_DTLS)
-#include "mbedtls/entropy.h"
-#include "mbedtls/ctr_drbg.h"
-#include "mbedtls/timing.h"
-#include "mbedtls/ssl_cookie.h"
+#    include "mbedtls/entropy.h"
+#    include "mbedtls/ctr_drbg.h"
+#    include "mbedtls/timing.h"
+#    include "mbedtls/ssl_cookie.h"
 
-
-#if defined(MBEDTLS_SSL_SRV_C) && \
-    defined(MBEDTLS_ENTROPY_C) && \
-    defined(MBEDTLS_CTR_DRBG_C) && \
-    defined(MBEDTLS_TIMING_C)
+#    if defined(MBEDTLS_SSL_SRV_C) && defined(MBEDTLS_ENTROPY_C) && \
+        defined(MBEDTLS_CTR_DRBG_C) && defined(MBEDTLS_TIMING_C)
 const char *pers = "fuzz_dtlsserver";
-const unsigned char client_ip[4] = {0x7F, 0, 0, 1};
+const unsigned char client_ip[4] = { 0x7F, 0, 0, 1 };
 static int initialized = 0;
-#if defined(MBEDTLS_X509_CRT_PARSE_C) && defined(MBEDTLS_PEM_PARSE_C)
+#        if defined(MBEDTLS_X509_CRT_PARSE_C) && defined(MBEDTLS_PEM_PARSE_C)
 static mbedtls_x509_crt srvcert;
 static mbedtls_pk_context pkey;
-#endif
-#endif
+#        endif
+#    endif
 #endif // MBEDTLS_SSL_PROTO_DTLS
 
-int LLVMFuzzerTestOneInput(const uint8_t *Data, size_t Size) {
-#if defined(MBEDTLS_SSL_PROTO_DTLS) && \
-    defined(MBEDTLS_SSL_SRV_C) && \
-    defined(MBEDTLS_ENTROPY_C) && \
-    defined(MBEDTLS_CTR_DRBG_C) && \
+int LLVMFuzzerTestOneInput(const uint8_t *Data, size_t Size)
+{
+#if defined(MBEDTLS_SSL_PROTO_DTLS) && defined(MBEDTLS_SSL_SRV_C) && \
+    defined(MBEDTLS_ENTROPY_C) && defined(MBEDTLS_CTR_DRBG_C) &&     \
     defined(MBEDTLS_TIMING_C)
     int ret;
     size_t len;
@@ -45,107 +41,108 @@
     fuzzBufferOffset_t biomemfuzz;
 
     if (initialized == 0) {
-#if defined(MBEDTLS_X509_CRT_PARSE_C) && defined(MBEDTLS_PEM_PARSE_C)
-        mbedtls_x509_crt_init( &srvcert );
-        mbedtls_pk_init( &pkey );
-        if (mbedtls_x509_crt_parse( &srvcert, (const unsigned char *) mbedtls_test_srv_crt,
-                                   mbedtls_test_srv_crt_len ) != 0)
+#    if defined(MBEDTLS_X509_CRT_PARSE_C) && defined(MBEDTLS_PEM_PARSE_C)
+        mbedtls_x509_crt_init(&srvcert);
+        mbedtls_pk_init(&pkey);
+        if (mbedtls_x509_crt_parse(&srvcert,
+                                   (const unsigned char *)mbedtls_test_srv_crt,
+                                   mbedtls_test_srv_crt_len) != 0)
             return 1;
-        if (mbedtls_x509_crt_parse( &srvcert, (const unsigned char *) mbedtls_test_cas_pem,
-                                   mbedtls_test_cas_pem_len ) != 0)
+        if (mbedtls_x509_crt_parse(&srvcert,
+                                   (const unsigned char *)mbedtls_test_cas_pem,
+                                   mbedtls_test_cas_pem_len) != 0)
             return 1;
-        if (mbedtls_pk_parse_key( &pkey, (const unsigned char *) mbedtls_test_srv_key,
-                                 mbedtls_test_srv_key_len, NULL, 0,
-                                 dummy_random, NULL ) != 0)
+        if (mbedtls_pk_parse_key(
+                &pkey, (const unsigned char *)mbedtls_test_srv_key,
+                mbedtls_test_srv_key_len, NULL, 0, dummy_random, NULL) != 0)
             return 1;
-#endif
+#    endif
         dummy_init();
 
         initialized = 1;
     }
-    mbedtls_ssl_init( &ssl );
-    mbedtls_ssl_config_init( &conf );
-    mbedtls_ctr_drbg_init( &ctr_drbg );
-    mbedtls_entropy_init( &entropy );
-    mbedtls_ssl_cookie_init( &cookie_ctx );
+    mbedtls_ssl_init(&ssl);
+    mbedtls_ssl_config_init(&conf);
+    mbedtls_ctr_drbg_init(&ctr_drbg);
+    mbedtls_entropy_init(&entropy);
+    mbedtls_ssl_cookie_init(&cookie_ctx);
 
-    if( mbedtls_ctr_drbg_seed( &ctr_drbg, dummy_entropy, &entropy,
-                              (const unsigned char *) pers, strlen( pers ) ) != 0 )
+    if (mbedtls_ctr_drbg_seed(&ctr_drbg, dummy_entropy, &entropy,
+                              (const unsigned char *)pers, strlen(pers)) != 0)
         goto exit;
 
-
-    if( mbedtls_ssl_config_defaults( &conf,
-                                    MBEDTLS_SSL_IS_SERVER,
+    if (mbedtls_ssl_config_defaults(&conf, MBEDTLS_SSL_IS_SERVER,
                                     MBEDTLS_SSL_TRANSPORT_DATAGRAM,
-                                    MBEDTLS_SSL_PRESET_DEFAULT ) != 0 )
+                                    MBEDTLS_SSL_PRESET_DEFAULT) != 0)
         goto exit;
 
-
     srand(1);
-    mbedtls_ssl_conf_rng( &conf, dummy_random, &ctr_drbg );
+    mbedtls_ssl_conf_rng(&conf, dummy_random, &ctr_drbg);
 
-#if defined(MBEDTLS_X509_CRT_PARSE_C) && defined(MBEDTLS_PEM_PARSE_C)
-    mbedtls_ssl_conf_ca_chain( &conf, srvcert.next, NULL );
-    if( mbedtls_ssl_conf_own_cert( &conf, &srvcert, &pkey ) != 0 )
+#    if defined(MBEDTLS_X509_CRT_PARSE_C) && defined(MBEDTLS_PEM_PARSE_C)
+    mbedtls_ssl_conf_ca_chain(&conf, srvcert.next, NULL);
+    if (mbedtls_ssl_conf_own_cert(&conf, &srvcert, &pkey) != 0)
         goto exit;
-#endif
+#    endif
 
-    if( mbedtls_ssl_cookie_setup( &cookie_ctx, dummy_random, &ctr_drbg ) != 0 )
+    if (mbedtls_ssl_cookie_setup(&cookie_ctx, dummy_random, &ctr_drbg) != 0)
         goto exit;
 
-    mbedtls_ssl_conf_dtls_cookies( &conf, mbedtls_ssl_cookie_write, mbedtls_ssl_cookie_check, &cookie_ctx );
+    mbedtls_ssl_conf_dtls_cookies(&conf, mbedtls_ssl_cookie_write,
+                                  mbedtls_ssl_cookie_check, &cookie_ctx);
 
-    if( mbedtls_ssl_setup( &ssl, &conf ) != 0 )
+    if (mbedtls_ssl_setup(&ssl, &conf) != 0)
         goto exit;
 
-    mbedtls_ssl_set_timer_cb( &ssl, &timer, mbedtls_timing_set_delay,
-                             mbedtls_timing_get_delay );
+    mbedtls_ssl_set_timer_cb(&ssl, &timer, mbedtls_timing_set_delay,
+                             mbedtls_timing_get_delay);
 
     biomemfuzz.Data = Data;
     biomemfuzz.Size = Size;
     biomemfuzz.Offset = 0;
-    mbedtls_ssl_set_bio( &ssl, &biomemfuzz, dummy_send, fuzz_recv, fuzz_recv_timeout );
-    if( mbedtls_ssl_set_client_transport_id( &ssl, client_ip, sizeof(client_ip) ) != 0 )
+    mbedtls_ssl_set_bio(&ssl, &biomemfuzz, dummy_send, fuzz_recv,
+                        fuzz_recv_timeout);
+    if (mbedtls_ssl_set_client_transport_id(&ssl, client_ip,
+                                            sizeof(client_ip)) != 0)
         goto exit;
 
-    ret = mbedtls_ssl_handshake( &ssl );
+    ret = mbedtls_ssl_handshake(&ssl);
 
     if (ret == MBEDTLS_ERR_SSL_HELLO_VERIFY_REQUIRED) {
         biomemfuzz.Offset = ssl.next_record_offset;
-        mbedtls_ssl_session_reset( &ssl );
-        mbedtls_ssl_set_bio( &ssl, &biomemfuzz, dummy_send, fuzz_recv, fuzz_recv_timeout );
-        if( mbedtls_ssl_set_client_transport_id( &ssl, client_ip, sizeof(client_ip) ) != 0 )
+        mbedtls_ssl_session_reset(&ssl);
+        mbedtls_ssl_set_bio(&ssl, &biomemfuzz, dummy_send, fuzz_recv,
+                            fuzz_recv_timeout);
+        if (mbedtls_ssl_set_client_transport_id(&ssl, client_ip,
+                                                sizeof(client_ip)) != 0)
             goto exit;
 
-        ret = mbedtls_ssl_handshake( &ssl );
+        ret = mbedtls_ssl_handshake(&ssl);
 
-        if( ret == 0 )
-        {
-            //keep reading data from server until the end
-            do
-            {
-                len = sizeof( buf ) - 1;
-                ret = mbedtls_ssl_read( &ssl, buf, len );
-                if( ret == MBEDTLS_ERR_SSL_WANT_READ )
+        if (ret == 0) {
+            // keep reading data from server until the end
+            do {
+                len = sizeof(buf) - 1;
+                ret = mbedtls_ssl_read(&ssl, buf, len);
+                if (ret == MBEDTLS_ERR_SSL_WANT_READ)
                     continue;
-                else if( ret <= 0 )
-                    //EOF or error
+                else if (ret <= 0)
+                    // EOF or error
                     break;
-            }
-            while( 1 );
+            } while (1);
         }
     }
 
 exit:
-    mbedtls_ssl_cookie_free( &cookie_ctx );
-    mbedtls_entropy_free( &entropy );
-    mbedtls_ctr_drbg_free( &ctr_drbg );
-    mbedtls_ssl_config_free( &conf );
-    mbedtls_ssl_free( &ssl );
+    mbedtls_ssl_cookie_free(&cookie_ctx);
+    mbedtls_entropy_free(&entropy);
+    mbedtls_ctr_drbg_free(&ctr_drbg);
+    mbedtls_ssl_config_free(&conf);
+    mbedtls_ssl_free(&ssl);
 
 #else
-    (void) Data;
-    (void) Size;
+    (void)Data;
+    (void)Size;
 #endif
     return 0;
 }
diff --git a/programs/fuzz/fuzz_privkey.c b/programs/fuzz/fuzz_privkey.c
index b9a160e..d84ba7b 100644
--- a/programs/fuzz/fuzz_privkey.c
+++ b/programs/fuzz/fuzz_privkey.c
@@ -5,75 +5,80 @@
 #include "mbedtls/pk.h"
 #include "common.h"
 
-//4 Kb should be enough for every bug ;-)
+// 4 Kb should be enough for every bug ;-)
 #define MAX_LEN 0x1000
 
-
-int LLVMFuzzerTestOneInput(const uint8_t *Data, size_t Size) {
+int LLVMFuzzerTestOneInput(const uint8_t *Data, size_t Size)
+{
 #ifdef MBEDTLS_PK_PARSE_C
     int ret;
     mbedtls_pk_context pk;
 
     if (Size > MAX_LEN) {
-        //only work on small inputs
+        // only work on small inputs
         Size = MAX_LEN;
     }
 
-    mbedtls_pk_init( &pk );
-    ret = mbedtls_pk_parse_key( &pk, Data, Size, NULL, 0,
-                                dummy_random, NULL );
+    mbedtls_pk_init(&pk);
+    ret = mbedtls_pk_parse_key(&pk, Data, Size, NULL, 0, dummy_random, NULL);
     if (ret == 0) {
-#if defined(MBEDTLS_RSA_C)
-        if( mbedtls_pk_get_type( &pk ) == MBEDTLS_PK_RSA )
-        {
+#    if defined(MBEDTLS_RSA_C)
+        if (mbedtls_pk_get_type(&pk) == MBEDTLS_PK_RSA) {
             mbedtls_mpi N, P, Q, D, E, DP, DQ, QP;
             mbedtls_rsa_context *rsa;
 
-            mbedtls_mpi_init( &N ); mbedtls_mpi_init( &P ); mbedtls_mpi_init( &Q );
-            mbedtls_mpi_init( &D ); mbedtls_mpi_init( &E ); mbedtls_mpi_init( &DP );
-            mbedtls_mpi_init( &DQ ); mbedtls_mpi_init( &QP );
+            mbedtls_mpi_init(&N);
+            mbedtls_mpi_init(&P);
+            mbedtls_mpi_init(&Q);
+            mbedtls_mpi_init(&D);
+            mbedtls_mpi_init(&E);
+            mbedtls_mpi_init(&DP);
+            mbedtls_mpi_init(&DQ);
+            mbedtls_mpi_init(&QP);
 
-            rsa = mbedtls_pk_rsa( pk );
-            if ( mbedtls_rsa_export( rsa, &N, &P, &Q, &D, &E ) != 0 ) {
+            rsa = mbedtls_pk_rsa(pk);
+            if (mbedtls_rsa_export(rsa, &N, &P, &Q, &D, &E) != 0) {
                 abort();
             }
-            if ( mbedtls_rsa_export_crt( rsa, &DP, &DQ, &QP ) != 0 ) {
+            if (mbedtls_rsa_export_crt(rsa, &DP, &DQ, &QP) != 0) {
                 abort();
             }
 
-            mbedtls_mpi_free( &N ); mbedtls_mpi_free( &P ); mbedtls_mpi_free( &Q );
-            mbedtls_mpi_free( &D ); mbedtls_mpi_free( &E ); mbedtls_mpi_free( &DP );
-            mbedtls_mpi_free( &DQ ); mbedtls_mpi_free( &QP );
-        }
-        else
-#endif
-#if defined(MBEDTLS_ECP_C)
-        if( mbedtls_pk_get_type( &pk ) == MBEDTLS_PK_ECKEY ||
-            mbedtls_pk_get_type( &pk ) == MBEDTLS_PK_ECKEY_DH )
-        {
-            mbedtls_ecp_keypair *ecp = mbedtls_pk_ec( pk );
+            mbedtls_mpi_free(&N);
+            mbedtls_mpi_free(&P);
+            mbedtls_mpi_free(&Q);
+            mbedtls_mpi_free(&D);
+            mbedtls_mpi_free(&E);
+            mbedtls_mpi_free(&DP);
+            mbedtls_mpi_free(&DQ);
+            mbedtls_mpi_free(&QP);
+        } else
+#    endif
+#    if defined(MBEDTLS_ECP_C)
+            if (mbedtls_pk_get_type(&pk) == MBEDTLS_PK_ECKEY ||
+                mbedtls_pk_get_type(&pk) == MBEDTLS_PK_ECKEY_DH) {
+            mbedtls_ecp_keypair *ecp = mbedtls_pk_ec(pk);
             mbedtls_ecp_group_id grp_id = ecp->grp.id;
             const mbedtls_ecp_curve_info *curve_info =
-                mbedtls_ecp_curve_info_from_grp_id( grp_id );
+                mbedtls_ecp_curve_info_from_grp_id(grp_id);
 
             /* If the curve is not supported, the key should not have been
              * accepted. */
-            if( curve_info == NULL )
-                abort( );
-        }
-        else
-#endif
+            if (curve_info == NULL)
+                abort();
+        } else
+#    endif
         {
             /* The key is valid but is not of a supported type.
              * This should not happen. */
-            abort( );
+            abort();
         }
     }
-    mbedtls_pk_free( &pk );
+    mbedtls_pk_free(&pk);
 #else
-    (void) Data;
-    (void) Size;
-#endif //MBEDTLS_PK_PARSE_C
+    (void)Data;
+    (void)Size;
+#endif // MBEDTLS_PK_PARSE_C
 
     return 0;
 }
diff --git a/programs/fuzz/fuzz_pubkey.c b/programs/fuzz/fuzz_pubkey.c
index 655d5d6..9e0548a 100644
--- a/programs/fuzz/fuzz_pubkey.c
+++ b/programs/fuzz/fuzz_pubkey.c
@@ -4,74 +4,83 @@
 #include <stdlib.h>
 #include "mbedtls/pk.h"
 
-int LLVMFuzzerTestOneInput(const uint8_t *Data, size_t Size) {
+int LLVMFuzzerTestOneInput(const uint8_t *Data, size_t Size)
+{
 #ifdef MBEDTLS_PK_PARSE_C
     int ret;
     mbedtls_pk_context pk;
 
-    mbedtls_pk_init( &pk );
-    ret = mbedtls_pk_parse_public_key( &pk, Data, Size );
+    mbedtls_pk_init(&pk);
+    ret = mbedtls_pk_parse_public_key(&pk, Data, Size);
     if (ret == 0) {
-#if defined(MBEDTLS_RSA_C)
-        if( mbedtls_pk_get_type( &pk ) == MBEDTLS_PK_RSA )
-        {
+#    if defined(MBEDTLS_RSA_C)
+        if (mbedtls_pk_get_type(&pk) == MBEDTLS_PK_RSA) {
             mbedtls_mpi N, P, Q, D, E, DP, DQ, QP;
             mbedtls_rsa_context *rsa;
 
-            mbedtls_mpi_init( &N ); mbedtls_mpi_init( &P ); mbedtls_mpi_init( &Q );
-            mbedtls_mpi_init( &D ); mbedtls_mpi_init( &E ); mbedtls_mpi_init( &DP );
-            mbedtls_mpi_init( &DQ ); mbedtls_mpi_init( &QP );
+            mbedtls_mpi_init(&N);
+            mbedtls_mpi_init(&P);
+            mbedtls_mpi_init(&Q);
+            mbedtls_mpi_init(&D);
+            mbedtls_mpi_init(&E);
+            mbedtls_mpi_init(&DP);
+            mbedtls_mpi_init(&DQ);
+            mbedtls_mpi_init(&QP);
 
-            rsa = mbedtls_pk_rsa( pk );
-            if ( mbedtls_rsa_export( rsa, &N, NULL, NULL, NULL, &E ) != 0 ) {
+            rsa = mbedtls_pk_rsa(pk);
+            if (mbedtls_rsa_export(rsa, &N, NULL, NULL, NULL, &E) != 0) {
                 abort();
             }
-            if ( mbedtls_rsa_export( rsa, &N, &P, &Q, &D, &E ) != MBEDTLS_ERR_RSA_BAD_INPUT_DATA ) {
+            if (mbedtls_rsa_export(rsa, &N, &P, &Q, &D, &E) !=
+                MBEDTLS_ERR_RSA_BAD_INPUT_DATA) {
                 abort();
             }
-            if ( mbedtls_rsa_export_crt( rsa, &DP, &DQ, &QP ) != MBEDTLS_ERR_RSA_BAD_INPUT_DATA ) {
+            if (mbedtls_rsa_export_crt(rsa, &DP, &DQ, &QP) !=
+                MBEDTLS_ERR_RSA_BAD_INPUT_DATA) {
                 abort();
             }
 
-            mbedtls_mpi_free( &N ); mbedtls_mpi_free( &P ); mbedtls_mpi_free( &Q );
-            mbedtls_mpi_free( &D ); mbedtls_mpi_free( &E ); mbedtls_mpi_free( &DP );
-            mbedtls_mpi_free( &DQ ); mbedtls_mpi_free( &QP );
+            mbedtls_mpi_free(&N);
+            mbedtls_mpi_free(&P);
+            mbedtls_mpi_free(&Q);
+            mbedtls_mpi_free(&D);
+            mbedtls_mpi_free(&E);
+            mbedtls_mpi_free(&DP);
+            mbedtls_mpi_free(&DQ);
+            mbedtls_mpi_free(&QP);
 
-        }
-        else
-#endif
-#if defined(MBEDTLS_ECP_C)
-        if( mbedtls_pk_get_type( &pk ) == MBEDTLS_PK_ECKEY ||
-            mbedtls_pk_get_type( &pk ) == MBEDTLS_PK_ECKEY_DH )
-        {
-            mbedtls_ecp_keypair *ecp = mbedtls_pk_ec( pk );
+        } else
+#    endif
+#    if defined(MBEDTLS_ECP_C)
+            if (mbedtls_pk_get_type(&pk) == MBEDTLS_PK_ECKEY ||
+                mbedtls_pk_get_type(&pk) == MBEDTLS_PK_ECKEY_DH) {
+            mbedtls_ecp_keypair *ecp = mbedtls_pk_ec(pk);
             mbedtls_ecp_group_id grp_id = ecp->grp.id;
             const mbedtls_ecp_curve_info *curve_info =
-                mbedtls_ecp_curve_info_from_grp_id( grp_id );
+                mbedtls_ecp_curve_info_from_grp_id(grp_id);
 
             /* If the curve is not supported, the key should not have been
              * accepted. */
-            if( curve_info == NULL )
-                abort( );
+            if (curve_info == NULL)
+                abort();
 
             /* It's a public key, so the private value should not have
              * been changed from its initialization to 0. */
-            if( mbedtls_mpi_cmp_int( &ecp->d, 0 ) != 0 )
-                abort( );
-        }
-        else
-#endif
+            if (mbedtls_mpi_cmp_int(&ecp->d, 0) != 0)
+                abort();
+        } else
+#    endif
         {
             /* The key is valid but is not of a supported type.
              * This should not happen. */
-            abort( );
+            abort();
         }
     }
-    mbedtls_pk_free( &pk );
+    mbedtls_pk_free(&pk);
 #else
-    (void) Data;
-    (void) Size;
-#endif //MBEDTLS_PK_PARSE_C
+    (void)Data;
+    (void)Size;
+#endif // MBEDTLS_PK_PARSE_C
 
     return 0;
 }
diff --git a/programs/fuzz/fuzz_server.c b/programs/fuzz/fuzz_server.c
index e6eb5a7..b9153de 100644
--- a/programs/fuzz/fuzz_server.c
+++ b/programs/fuzz/fuzz_server.c
@@ -10,31 +10,26 @@
 #include <stdlib.h>
 #include <stdint.h>
 
-
-#if defined(MBEDTLS_SSL_SRV_C) && \
-    defined(MBEDTLS_ENTROPY_C) && \
+#if defined(MBEDTLS_SSL_SRV_C) && defined(MBEDTLS_ENTROPY_C) && \
     defined(MBEDTLS_CTR_DRBG_C)
 const char *pers = "fuzz_server";
 static int initialized = 0;
-#if defined(MBEDTLS_X509_CRT_PARSE_C) && defined(MBEDTLS_PEM_PARSE_C)
+#    if defined(MBEDTLS_X509_CRT_PARSE_C) && defined(MBEDTLS_PEM_PARSE_C)
 static mbedtls_x509_crt srvcert;
 static mbedtls_pk_context pkey;
-#endif
+#    endif
 const char *alpn_list[3];
 
-#if defined(MBEDTLS_KEY_EXCHANGE_SOME_PSK_ENABLED)
-const unsigned char psk[] = {
-    0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
-    0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f
-};
+#    if defined(MBEDTLS_KEY_EXCHANGE_SOME_PSK_ENABLED)
+const unsigned char psk[] = { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
+                              0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f };
 const char psk_id[] = "Client_identity";
-#endif
+#    endif
 #endif // MBEDTLS_SSL_SRV_C && MBEDTLS_ENTROPY_C && MBEDTLS_CTR_DRBG_C
 
-
-int LLVMFuzzerTestOneInput(const uint8_t *Data, size_t Size) {
-#if defined(MBEDTLS_SSL_SRV_C) && \
-    defined(MBEDTLS_ENTROPY_C) && \
+int LLVMFuzzerTestOneInput(const uint8_t *Data, size_t Size)
+{
+#if defined(MBEDTLS_SSL_SRV_C) && defined(MBEDTLS_ENTROPY_C) && \
     defined(MBEDTLS_CTR_DRBG_C)
     int ret;
     size_t len;
@@ -42,41 +37,45 @@
     mbedtls_ssl_config conf;
     mbedtls_ctr_drbg_context ctr_drbg;
     mbedtls_entropy_context entropy;
-#if defined(MBEDTLS_SSL_SESSION_TICKETS)
+#    if defined(MBEDTLS_SSL_SESSION_TICKETS)
     mbedtls_ssl_ticket_context ticket_ctx;
-#endif
+#    endif
     unsigned char buf[4096];
     fuzzBufferOffset_t biomemfuzz;
     uint8_t options;
 
-    //we take 1 byte as options input
+    // we take 1 byte as options input
     if (Size < 1) {
         return 0;
     }
     options = Data[Size - 1];
 
     if (initialized == 0) {
-        mbedtls_ctr_drbg_init( &ctr_drbg );
-        mbedtls_entropy_init( &entropy );
+        mbedtls_ctr_drbg_init(&ctr_drbg);
+        mbedtls_entropy_init(&entropy);
 
-        if( mbedtls_ctr_drbg_seed( &ctr_drbg, dummy_entropy, &entropy,
-                                  (const unsigned char *) pers, strlen( pers ) ) != 0 )
+        if (mbedtls_ctr_drbg_seed(&ctr_drbg, dummy_entropy, &entropy,
+                                  (const unsigned char *)pers,
+                                  strlen(pers)) != 0)
             return 1;
 
-#if defined(MBEDTLS_X509_CRT_PARSE_C) && defined(MBEDTLS_PEM_PARSE_C)
-        mbedtls_x509_crt_init( &srvcert );
-        mbedtls_pk_init( &pkey );
-        if (mbedtls_x509_crt_parse( &srvcert, (const unsigned char *) mbedtls_test_srv_crt,
-                                   mbedtls_test_srv_crt_len ) != 0)
+#    if defined(MBEDTLS_X509_CRT_PARSE_C) && defined(MBEDTLS_PEM_PARSE_C)
+        mbedtls_x509_crt_init(&srvcert);
+        mbedtls_pk_init(&pkey);
+        if (mbedtls_x509_crt_parse(&srvcert,
+                                   (const unsigned char *)mbedtls_test_srv_crt,
+                                   mbedtls_test_srv_crt_len) != 0)
             return 1;
-        if (mbedtls_x509_crt_parse( &srvcert, (const unsigned char *) mbedtls_test_cas_pem,
-                                   mbedtls_test_cas_pem_len ) != 0)
+        if (mbedtls_x509_crt_parse(&srvcert,
+                                   (const unsigned char *)mbedtls_test_cas_pem,
+                                   mbedtls_test_cas_pem_len) != 0)
             return 1;
-        if (mbedtls_pk_parse_key( &pkey, (const unsigned char *) mbedtls_test_srv_key,
+        if (mbedtls_pk_parse_key(&pkey,
+                                 (const unsigned char *)mbedtls_test_srv_key,
                                  mbedtls_test_srv_key_len, NULL, 0,
-                                 dummy_random, &ctr_drbg ) != 0)
+                                 dummy_random, &ctr_drbg) != 0)
             return 1;
-#endif
+#    endif
 
         alpn_list[0] = "HTTP";
         alpn_list[1] = "fuzzalpn";
@@ -86,103 +85,103 @@
 
         initialized = 1;
     }
-    mbedtls_ssl_init( &ssl );
-    mbedtls_ssl_config_init( &conf );
-#if defined(MBEDTLS_SSL_SESSION_TICKETS)
-    mbedtls_ssl_ticket_init( &ticket_ctx );
-#endif
+    mbedtls_ssl_init(&ssl);
+    mbedtls_ssl_config_init(&conf);
+#    if defined(MBEDTLS_SSL_SESSION_TICKETS)
+    mbedtls_ssl_ticket_init(&ticket_ctx);
+#    endif
 
-    if( mbedtls_ssl_config_defaults( &conf,
-                                    MBEDTLS_SSL_IS_SERVER,
+    if (mbedtls_ssl_config_defaults(&conf, MBEDTLS_SSL_IS_SERVER,
                                     MBEDTLS_SSL_TRANSPORT_STREAM,
-                                    MBEDTLS_SSL_PRESET_DEFAULT ) != 0 )
+                                    MBEDTLS_SSL_PRESET_DEFAULT) != 0)
         goto exit;
 
     srand(1);
-    mbedtls_ssl_conf_rng( &conf, dummy_random, &ctr_drbg );
+    mbedtls_ssl_conf_rng(&conf, dummy_random, &ctr_drbg);
 
-#if defined(MBEDTLS_X509_CRT_PARSE_C) && defined(MBEDTLS_PEM_PARSE_C)
-    mbedtls_ssl_conf_ca_chain( &conf, srvcert.next, NULL );
-    if( mbedtls_ssl_conf_own_cert( &conf, &srvcert, &pkey ) != 0 )
+#    if defined(MBEDTLS_X509_CRT_PARSE_C) && defined(MBEDTLS_PEM_PARSE_C)
+    mbedtls_ssl_conf_ca_chain(&conf, srvcert.next, NULL);
+    if (mbedtls_ssl_conf_own_cert(&conf, &srvcert, &pkey) != 0)
         goto exit;
-#endif
+#    endif
 
-    mbedtls_ssl_conf_cert_req_ca_list( &conf, (options & 0x1) ? MBEDTLS_SSL_CERT_REQ_CA_LIST_ENABLED : MBEDTLS_SSL_CERT_REQ_CA_LIST_DISABLED );
-#if defined(MBEDTLS_SSL_ALPN)
+    mbedtls_ssl_conf_cert_req_ca_list(
+        &conf, (options & 0x1) ? MBEDTLS_SSL_CERT_REQ_CA_LIST_ENABLED :
+                                 MBEDTLS_SSL_CERT_REQ_CA_LIST_DISABLED);
+#    if defined(MBEDTLS_SSL_ALPN)
     if (options & 0x2) {
-        mbedtls_ssl_conf_alpn_protocols( &conf, alpn_list );
+        mbedtls_ssl_conf_alpn_protocols(&conf, alpn_list);
     }
-#endif
-#if defined(MBEDTLS_SSL_SESSION_TICKETS)
-    if( options & 0x4 )
-    {
-        if( mbedtls_ssl_ticket_setup( &ticket_ctx,
-                                     dummy_random, &ctr_drbg,
-                                     MBEDTLS_CIPHER_AES_256_GCM,
-                                     86400 ) != 0 )
+#    endif
+#    if defined(MBEDTLS_SSL_SESSION_TICKETS)
+    if (options & 0x4) {
+        if (mbedtls_ssl_ticket_setup(&ticket_ctx, dummy_random, &ctr_drbg,
+                                     MBEDTLS_CIPHER_AES_256_GCM, 86400) != 0)
             goto exit;
 
-        mbedtls_ssl_conf_session_tickets_cb( &conf,
-                                            mbedtls_ssl_ticket_write,
+        mbedtls_ssl_conf_session_tickets_cb(&conf, mbedtls_ssl_ticket_write,
                                             mbedtls_ssl_ticket_parse,
-                                            &ticket_ctx );
+                                            &ticket_ctx);
     }
-#endif
-#if defined(MBEDTLS_SSL_EXTENDED_MASTER_SECRET)
-    mbedtls_ssl_conf_extended_master_secret( &conf, (options & 0x10) ? MBEDTLS_SSL_EXTENDED_MS_DISABLED : MBEDTLS_SSL_EXTENDED_MS_ENABLED);
-#endif
-#if defined(MBEDTLS_SSL_ENCRYPT_THEN_MAC)
-    mbedtls_ssl_conf_encrypt_then_mac( &conf, (options & 0x20) ? MBEDTLS_SSL_ETM_ENABLED : MBEDTLS_SSL_ETM_DISABLED);
-#endif
-#if defined(MBEDTLS_KEY_EXCHANGE_SOME_PSK_ENABLED)
+#    endif
+#    if defined(MBEDTLS_SSL_EXTENDED_MASTER_SECRET)
+    mbedtls_ssl_conf_extended_master_secret(
+        &conf, (options & 0x10) ? MBEDTLS_SSL_EXTENDED_MS_DISABLED :
+                                  MBEDTLS_SSL_EXTENDED_MS_ENABLED);
+#    endif
+#    if defined(MBEDTLS_SSL_ENCRYPT_THEN_MAC)
+    mbedtls_ssl_conf_encrypt_then_mac(&conf, (options & 0x20) ?
+                                                 MBEDTLS_SSL_ETM_ENABLED :
+                                                 MBEDTLS_SSL_ETM_DISABLED);
+#    endif
+#    if defined(MBEDTLS_KEY_EXCHANGE_SOME_PSK_ENABLED)
     if (options & 0x40) {
-        mbedtls_ssl_conf_psk( &conf, psk, sizeof( psk ),
-                             (const unsigned char *) psk_id, sizeof( psk_id ) - 1 );
+        mbedtls_ssl_conf_psk(&conf, psk, sizeof(psk),
+                             (const unsigned char *)psk_id, sizeof(psk_id) - 1);
     }
-#endif
-#if defined(MBEDTLS_SSL_RENEGOTIATION)
-    mbedtls_ssl_conf_renegotiation( &conf, (options & 0x80) ? MBEDTLS_SSL_RENEGOTIATION_ENABLED : MBEDTLS_SSL_RENEGOTIATION_DISABLED );
-#endif
+#    endif
+#    if defined(MBEDTLS_SSL_RENEGOTIATION)
+    mbedtls_ssl_conf_renegotiation(
+        &conf, (options & 0x80) ? MBEDTLS_SSL_RENEGOTIATION_ENABLED :
+                                  MBEDTLS_SSL_RENEGOTIATION_DISABLED);
+#    endif
 
-    if( mbedtls_ssl_setup( &ssl, &conf ) != 0 )
+    if (mbedtls_ssl_setup(&ssl, &conf) != 0)
         goto exit;
 
     biomemfuzz.Data = Data;
-    biomemfuzz.Size = Size-1;
+    biomemfuzz.Size = Size - 1;
     biomemfuzz.Offset = 0;
-    mbedtls_ssl_set_bio( &ssl, &biomemfuzz, dummy_send, fuzz_recv, NULL );
+    mbedtls_ssl_set_bio(&ssl, &biomemfuzz, dummy_send, fuzz_recv, NULL);
 
-    mbedtls_ssl_session_reset( &ssl );
-    ret = mbedtls_ssl_handshake( &ssl );
-    if( ret == 0 )
-    {
-        //keep reading data from server until the end
-        do
-        {
-            len = sizeof( buf ) - 1;
-            ret = mbedtls_ssl_read( &ssl, buf, len );
+    mbedtls_ssl_session_reset(&ssl);
+    ret = mbedtls_ssl_handshake(&ssl);
+    if (ret == 0) {
+        // keep reading data from server until the end
+        do {
+            len = sizeof(buf) - 1;
+            ret = mbedtls_ssl_read(&ssl, buf, len);
 
-            if( ret == MBEDTLS_ERR_SSL_WANT_READ )
+            if (ret == MBEDTLS_ERR_SSL_WANT_READ)
                 continue;
-            else if( ret <= 0 )
-                //EOF or error
+            else if (ret <= 0)
+                // EOF or error
                 break;
-        }
-        while( 1 );
+        } while (1);
     }
 
 exit:
-#if defined(MBEDTLS_SSL_SESSION_TICKETS)
-    mbedtls_ssl_ticket_free( &ticket_ctx );
-#endif
-    mbedtls_entropy_free( &entropy );
-    mbedtls_ctr_drbg_free( &ctr_drbg );
-    mbedtls_ssl_config_free( &conf );
-    mbedtls_ssl_free( &ssl );
+#    if defined(MBEDTLS_SSL_SESSION_TICKETS)
+    mbedtls_ssl_ticket_free(&ticket_ctx);
+#    endif
+    mbedtls_entropy_free(&entropy);
+    mbedtls_ctr_drbg_free(&ctr_drbg);
+    mbedtls_ssl_config_free(&conf);
+    mbedtls_ssl_free(&ssl);
 
 #else
-    (void) Data;
-    (void) Size;
+    (void)Data;
+    (void)Size;
 #endif /* MBEDTLS_SSL_SRV_C && MBEDTLS_ENTROPY_C && MBEDTLS_CTR_DRBG_C */
 
     return 0;
diff --git a/programs/fuzz/fuzz_x509crl.c b/programs/fuzz/fuzz_x509crl.c
index 65fc37f..f9c0ed4 100644
--- a/programs/fuzz/fuzz_x509crl.c
+++ b/programs/fuzz/fuzz_x509crl.c
@@ -3,26 +3,27 @@
 #include <stdint.h>
 #include "mbedtls/x509_crl.h"
 
-int LLVMFuzzerTestOneInput(const uint8_t *Data, size_t Size) {
+int LLVMFuzzerTestOneInput(const uint8_t *Data, size_t Size)
+{
 #ifdef MBEDTLS_X509_CRL_PARSE_C
     int ret;
     mbedtls_x509_crl crl;
     unsigned char buf[4096];
 
-    mbedtls_x509_crl_init( &crl );
-    ret = mbedtls_x509_crl_parse( &crl, Data, Size );
-#if !defined(MBEDTLS_X509_REMOVE_INFO)
+    mbedtls_x509_crl_init(&crl);
+    ret = mbedtls_x509_crl_parse(&crl, Data, Size);
+#    if !defined(MBEDTLS_X509_REMOVE_INFO)
     if (ret == 0) {
-        ret = mbedtls_x509_crl_info( (char *) buf, sizeof( buf ) - 1, " ", &crl );
+        ret = mbedtls_x509_crl_info((char *)buf, sizeof(buf) - 1, " ", &crl);
     }
+#    else
+    ((void)ret);
+    ((void)buf);
+#    endif /* !MBEDTLS_X509_REMOVE_INFO */
+    mbedtls_x509_crl_free(&crl);
 #else
-    ((void) ret);
-    ((void) buf);
-#endif /* !MBEDTLS_X509_REMOVE_INFO */
-    mbedtls_x509_crl_free( &crl );
-#else
-    (void) Data;
-    (void) Size;
+    (void)Data;
+    (void)Size;
 #endif
 
     return 0;
diff --git a/programs/fuzz/fuzz_x509crt.c b/programs/fuzz/fuzz_x509crt.c
index bd8bdff..b3b8c77 100644
--- a/programs/fuzz/fuzz_x509crt.c
+++ b/programs/fuzz/fuzz_x509crt.c
@@ -3,26 +3,27 @@
 #include <stdint.h>
 #include "mbedtls/x509_crt.h"
 
-int LLVMFuzzerTestOneInput(const uint8_t *Data, size_t Size) {
+int LLVMFuzzerTestOneInput(const uint8_t *Data, size_t Size)
+{
 #ifdef MBEDTLS_X509_CRT_PARSE_C
     int ret;
     mbedtls_x509_crt crt;
     unsigned char buf[4096];
 
-    mbedtls_x509_crt_init( &crt );
-    ret = mbedtls_x509_crt_parse( &crt, Data, Size );
-#if !defined(MBEDTLS_X509_REMOVE_INFO)
+    mbedtls_x509_crt_init(&crt);
+    ret = mbedtls_x509_crt_parse(&crt, Data, Size);
+#    if !defined(MBEDTLS_X509_REMOVE_INFO)
     if (ret == 0) {
-        ret = mbedtls_x509_crt_info( (char *) buf, sizeof( buf ) - 1, " ", &crt );
+        ret = mbedtls_x509_crt_info((char *)buf, sizeof(buf) - 1, " ", &crt);
     }
+#    else
+    ((void)ret);
+    ((void)buf);
+#    endif /* !MBEDTLS_X509_REMOVE_INFO */
+    mbedtls_x509_crt_free(&crt);
 #else
-    ((void) ret);
-    ((void) buf);
-#endif /* !MBEDTLS_X509_REMOVE_INFO */
-    mbedtls_x509_crt_free( &crt );
-#else
-    (void) Data;
-    (void) Size;
+    (void)Data;
+    (void)Size;
 #endif
 
     return 0;
diff --git a/programs/fuzz/fuzz_x509csr.c b/programs/fuzz/fuzz_x509csr.c
index a9205be..fc28c62 100644
--- a/programs/fuzz/fuzz_x509csr.c
+++ b/programs/fuzz/fuzz_x509csr.c
@@ -3,26 +3,27 @@
 #include <stdint.h>
 #include "mbedtls/x509_csr.h"
 
-int LLVMFuzzerTestOneInput(const uint8_t *Data, size_t Size) {
+int LLVMFuzzerTestOneInput(const uint8_t *Data, size_t Size)
+{
 #ifdef MBEDTLS_X509_CSR_PARSE_C
     int ret;
     mbedtls_x509_csr csr;
     unsigned char buf[4096];
 
-    mbedtls_x509_csr_init( &csr );
-    ret = mbedtls_x509_csr_parse( &csr, Data, Size );
-#if !defined(MBEDTLS_X509_REMOVE_INFO)
+    mbedtls_x509_csr_init(&csr);
+    ret = mbedtls_x509_csr_parse(&csr, Data, Size);
+#    if !defined(MBEDTLS_X509_REMOVE_INFO)
     if (ret == 0) {
-        ret = mbedtls_x509_csr_info( (char *) buf, sizeof( buf ) - 1, " ", &csr );
+        ret = mbedtls_x509_csr_info((char *)buf, sizeof(buf) - 1, " ", &csr);
     }
+#    else
+    ((void)ret);
+    ((void)buf);
+#    endif /* !MBEDTLS_X509_REMOVE_INFO */
+    mbedtls_x509_csr_free(&csr);
 #else
-    ((void) ret);
-    ((void) buf);
-#endif /* !MBEDTLS_X509_REMOVE_INFO */
-    mbedtls_x509_csr_free( &csr );
-#else
-    (void) Data;
-    (void) Size;
+    (void)Data;
+    (void)Size;
 #endif
 
     return 0;
diff --git a/programs/fuzz/onefile.c b/programs/fuzz/onefile.c
index efd8dbb..d2c0b58 100644
--- a/programs/fuzz/onefile.c
+++ b/programs/fuzz/onefile.c
@@ -9,16 +9,16 @@
 
 int LLVMFuzzerTestOneInput(const uint8_t *Data, size_t Size);
 
-int main(int argc, char** argv)
+int main(int argc, char **argv)
 {
-    FILE * fp;
+    FILE *fp;
     uint8_t *Data;
     size_t Size;
 
     if (argc != 2) {
         return 1;
     }
-    //opens the file, get its size, and reads it into a buffer
+    // opens the file, get its size, and reads it into a buffer
     fp = fopen(argv[1], "rb");
     if (fp == NULL) {
         return 2;
@@ -28,7 +28,7 @@
         return 2;
     }
     Size = ftell(fp);
-    if (Size == (size_t) -1) {
+    if (Size == (size_t)-1) {
         fclose(fp);
         return 2;
     }
@@ -47,10 +47,9 @@
         return 2;
     }
 
-    //lauch fuzzer
+    // lauch fuzzer
     LLVMFuzzerTestOneInput(Data, Size);
     free(Data);
     fclose(fp);
     return 0;
 }
-