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/include/mbedtls/hmac_drbg.h b/include/mbedtls/hmac_drbg.h
index 8c0e72d..39401cb 100644
--- a/include/mbedtls/hmac_drbg.h
+++ b/include/mbedtls/hmac_drbg.h
@@ -32,55 +32,56 @@
#include "mbedtls/md.h"
#if defined(MBEDTLS_THREADING_C)
-#include "mbedtls/threading.h"
+# include "mbedtls/threading.h"
#endif
/*
* Error codes
*/
/** Too many random requested in single call. */
-#define MBEDTLS_ERR_HMAC_DRBG_REQUEST_TOO_BIG -0x0003
+#define MBEDTLS_ERR_HMAC_DRBG_REQUEST_TOO_BIG -0x0003
/** Input too large (Entropy + additional). */
-#define MBEDTLS_ERR_HMAC_DRBG_INPUT_TOO_BIG -0x0005
+#define MBEDTLS_ERR_HMAC_DRBG_INPUT_TOO_BIG -0x0005
/** Read/write error in file. */
-#define MBEDTLS_ERR_HMAC_DRBG_FILE_IO_ERROR -0x0007
+#define MBEDTLS_ERR_HMAC_DRBG_FILE_IO_ERROR -0x0007
/** The entropy source failed. */
-#define MBEDTLS_ERR_HMAC_DRBG_ENTROPY_SOURCE_FAILED -0x0009
+#define MBEDTLS_ERR_HMAC_DRBG_ENTROPY_SOURCE_FAILED -0x0009
/**
* \name SECTION: Module settings
*
* The configuration options you can set for this module are in this section.
- * Either change them in mbedtls_config.h or define them on the compiler command line.
+ * Either change them in mbedtls_config.h or define them on the compiler command
+ * line.
* \{
*/
#if !defined(MBEDTLS_HMAC_DRBG_RESEED_INTERVAL)
/** Interval before reseed is performed by default */
-#define MBEDTLS_HMAC_DRBG_RESEED_INTERVAL 10000
+# define MBEDTLS_HMAC_DRBG_RESEED_INTERVAL 10000
#endif
#if !defined(MBEDTLS_HMAC_DRBG_MAX_INPUT)
/** Maximum number of additional input bytes */
-#define MBEDTLS_HMAC_DRBG_MAX_INPUT 256
+# define MBEDTLS_HMAC_DRBG_MAX_INPUT 256
#endif
#if !defined(MBEDTLS_HMAC_DRBG_MAX_REQUEST)
/** Maximum number of requested bytes per call */
-#define MBEDTLS_HMAC_DRBG_MAX_REQUEST 1024
+# define MBEDTLS_HMAC_DRBG_MAX_REQUEST 1024
#endif
#if !defined(MBEDTLS_HMAC_DRBG_MAX_SEED_INPUT)
/** Maximum size of (re)seed buffer */
-#define MBEDTLS_HMAC_DRBG_MAX_SEED_INPUT 384
+# define MBEDTLS_HMAC_DRBG_MAX_SEED_INPUT 384
#endif
/* \} name SECTION: Module settings */
/** No prediction resistance */
-#define MBEDTLS_HMAC_DRBG_PR_OFF 0
+#define MBEDTLS_HMAC_DRBG_PR_OFF 0
/** Prediction resistance enabled */
-#define MBEDTLS_HMAC_DRBG_PR_ON 1
+#define MBEDTLS_HMAC_DRBG_PR_ON 1
#ifdef __cplusplus
extern "C" {
@@ -89,23 +90,29 @@
/**
* HMAC_DRBG context.
*/
-typedef struct mbedtls_hmac_drbg_context
-{
+typedef struct mbedtls_hmac_drbg_context {
/* Working state: the key K is not stored explicitly,
* but is implied by the HMAC context */
- mbedtls_md_context_t MBEDTLS_PRIVATE(md_ctx); /*!< HMAC context (inc. K) */
- unsigned char MBEDTLS_PRIVATE(V)[MBEDTLS_MD_MAX_SIZE]; /*!< V in the spec */
- int MBEDTLS_PRIVATE(reseed_counter); /*!< reseed counter */
+ mbedtls_md_context_t MBEDTLS_PRIVATE(md_ctx); /*!< HMAC context (inc. K) */
+ unsigned char MBEDTLS_PRIVATE(V)[MBEDTLS_MD_MAX_SIZE]; /*!< V in the spec */
+ int MBEDTLS_PRIVATE(reseed_counter); /*!< reseed counter */
/* Administrative state */
- size_t MBEDTLS_PRIVATE(entropy_len); /*!< entropy bytes grabbed on each (re)seed */
- int MBEDTLS_PRIVATE(prediction_resistance); /*!< enable prediction resistance (Automatic
- reseed before every random generation) */
- int MBEDTLS_PRIVATE(reseed_interval); /*!< reseed interval */
+ size_t MBEDTLS_PRIVATE(entropy_len); /*!< entropy bytes grabbed on each
+ (re)seed */
+ int MBEDTLS_PRIVATE(prediction_resistance); /*!< enable prediction
+ resistance (Automatic reseed before every
+ random generation) */
+ int MBEDTLS_PRIVATE(reseed_interval); /*!< reseed interval */
/* Callbacks */
- int (*MBEDTLS_PRIVATE(f_entropy))(void *, unsigned char *, size_t); /*!< entropy function */
- void *MBEDTLS_PRIVATE(p_entropy); /*!< context for the entropy function */
+ int (*MBEDTLS_PRIVATE(f_entropy))(void *,
+ unsigned char *,
+ size_t); /*!<
+ entropy
+ function
+ */
+ void *MBEDTLS_PRIVATE(p_entropy); /*!< context for the entropy function */
#if defined(MBEDTLS_THREADING_C)
/* Invariant: the mutex is initialized if and only if
@@ -126,13 +133,14 @@
* This function makes the context ready for mbedtls_hmac_drbg_seed(),
* mbedtls_hmac_drbg_seed_buf() or mbedtls_hmac_drbg_free().
*
- * \note The reseed interval is #MBEDTLS_HMAC_DRBG_RESEED_INTERVAL
+ * \note The reseed interval is
+ * #MBEDTLS_HMAC_DRBG_RESEED_INTERVAL
* by default. Override this value by calling
* mbedtls_hmac_drbg_set_reseed_interval().
*
* \param ctx HMAC_DRBG context to be initialized.
*/
-void mbedtls_hmac_drbg_init( mbedtls_hmac_drbg_context *ctx );
+void mbedtls_hmac_drbg_init(mbedtls_hmac_drbg_context *ctx);
/**
* \brief HMAC_DRBG initial seeding.
@@ -202,12 +210,12 @@
* \return #MBEDTLS_ERR_HMAC_DRBG_ENTROPY_SOURCE_FAILED
* if the call to \p f_entropy failed.
*/
-int mbedtls_hmac_drbg_seed( mbedtls_hmac_drbg_context *ctx,
- const mbedtls_md_info_t * md_info,
- int (*f_entropy)(void *, unsigned char *, size_t),
- void *p_entropy,
- const unsigned char *custom,
- size_t len );
+int mbedtls_hmac_drbg_seed(mbedtls_hmac_drbg_context *ctx,
+ const mbedtls_md_info_t *md_info,
+ int (*f_entropy)(void *, unsigned char *, size_t),
+ void *p_entropy,
+ const unsigned char *custom,
+ size_t len);
/**
* \brief Initilisation of simpified HMAC_DRBG (never reseeds).
@@ -237,9 +245,10 @@
* \return #MBEDTLS_ERR_MD_ALLOC_FAILED if there was not enough
* memory to allocate context data.
*/
-int mbedtls_hmac_drbg_seed_buf( mbedtls_hmac_drbg_context *ctx,
- const mbedtls_md_info_t * md_info,
- const unsigned char *data, size_t data_len );
+int mbedtls_hmac_drbg_seed_buf(mbedtls_hmac_drbg_context *ctx,
+ const mbedtls_md_info_t *md_info,
+ const unsigned char *data,
+ size_t data_len);
/**
* \brief This function turns prediction resistance on or off.
@@ -254,8 +263,8 @@
* \param ctx The HMAC_DRBG context.
* \param resistance #MBEDTLS_HMAC_DRBG_PR_ON or #MBEDTLS_HMAC_DRBG_PR_OFF.
*/
-void mbedtls_hmac_drbg_set_prediction_resistance( mbedtls_hmac_drbg_context *ctx,
- int resistance );
+void mbedtls_hmac_drbg_set_prediction_resistance(mbedtls_hmac_drbg_context *ctx,
+ int resistance);
/**
* \brief This function sets the amount of entropy grabbed on each
@@ -266,8 +275,8 @@
* \param ctx The HMAC_DRBG context.
* \param len The amount of entropy to grab, in bytes.
*/
-void mbedtls_hmac_drbg_set_entropy_len( mbedtls_hmac_drbg_context *ctx,
- size_t len );
+void mbedtls_hmac_drbg_set_entropy_len(mbedtls_hmac_drbg_context *ctx,
+ size_t len);
/**
* \brief Set the reseed interval.
@@ -281,8 +290,8 @@
* \param ctx The HMAC_DRBG context.
* \param interval The reseed interval.
*/
-void mbedtls_hmac_drbg_set_reseed_interval( mbedtls_hmac_drbg_context *ctx,
- int interval );
+void mbedtls_hmac_drbg_set_reseed_interval(mbedtls_hmac_drbg_context *ctx,
+ int interval);
/**
* \brief This function updates the state of the HMAC_DRBG context.
@@ -301,8 +310,9 @@
* \return \c 0 on success, or an error from the underlying
* hash calculation.
*/
-int mbedtls_hmac_drbg_update( mbedtls_hmac_drbg_context *ctx,
- const unsigned char *additional, size_t add_len );
+int mbedtls_hmac_drbg_update(mbedtls_hmac_drbg_context *ctx,
+ const unsigned char *additional,
+ size_t add_len);
/**
* \brief This function reseeds the HMAC_DRBG context, that is
@@ -328,8 +338,9 @@
* \return #MBEDTLS_ERR_HMAC_DRBG_ENTROPY_SOURCE_FAILED
* if a call to the entropy function failed.
*/
-int mbedtls_hmac_drbg_reseed( mbedtls_hmac_drbg_context *ctx,
- const unsigned char *additional, size_t len );
+int mbedtls_hmac_drbg_reseed(mbedtls_hmac_drbg_context *ctx,
+ const unsigned char *additional,
+ size_t len);
/**
* \brief This function updates an HMAC_DRBG instance with additional
@@ -362,10 +373,11 @@
* \return #MBEDTLS_ERR_HMAC_DRBG_INPUT_TOO_BIG if
* \p add_len > #MBEDTLS_HMAC_DRBG_MAX_INPUT.
*/
-int mbedtls_hmac_drbg_random_with_add( void *p_rng,
- unsigned char *output, size_t output_len,
- const unsigned char *additional,
- size_t add_len );
+int mbedtls_hmac_drbg_random_with_add(void *p_rng,
+ unsigned char *output,
+ size_t output_len,
+ const unsigned char *additional,
+ size_t add_len);
/**
* \brief This function uses HMAC_DRBG to generate random data.
@@ -394,7 +406,9 @@
* \return #MBEDTLS_ERR_HMAC_DRBG_REQUEST_TOO_BIG if
* \p out_len > #MBEDTLS_HMAC_DRBG_MAX_REQUEST.
*/
-int mbedtls_hmac_drbg_random( void *p_rng, unsigned char *output, size_t out_len );
+int mbedtls_hmac_drbg_random(void *p_rng,
+ unsigned char *output,
+ size_t out_len);
/**
* \brief This function resets HMAC_DRBG context to the state immediately
@@ -402,7 +416,7 @@
*
* \param ctx The HMAC_DRBG context to free.
*/
-void mbedtls_hmac_drbg_free( mbedtls_hmac_drbg_context *ctx );
+void mbedtls_hmac_drbg_free(mbedtls_hmac_drbg_context *ctx);
#if defined(MBEDTLS_FS_IO)
/**
@@ -416,7 +430,8 @@
* \return #MBEDTLS_ERR_HMAC_DRBG_ENTROPY_SOURCE_FAILED on reseed
* failure.
*/
-int mbedtls_hmac_drbg_write_seed_file( mbedtls_hmac_drbg_context *ctx, const char *path );
+int mbedtls_hmac_drbg_write_seed_file(mbedtls_hmac_drbg_context *ctx,
+ const char *path);
/**
* \brief This function reads and updates a seed file. The seed
@@ -432,10 +447,10 @@
* \return #MBEDTLS_ERR_HMAC_DRBG_INPUT_TOO_BIG if the existing
* seed file is too large.
*/
-int mbedtls_hmac_drbg_update_seed_file( mbedtls_hmac_drbg_context *ctx, const char *path );
+int mbedtls_hmac_drbg_update_seed_file(mbedtls_hmac_drbg_context *ctx,
+ const char *path);
#endif /* MBEDTLS_FS_IO */
-
#if defined(MBEDTLS_SELF_TEST)
/**
* \brief The HMAC_DRBG Checkup routine.
@@ -443,7 +458,7 @@
* \return \c 0 if successful.
* \return \c 1 if the test failed.
*/
-int mbedtls_hmac_drbg_self_test( int verbose );
+int mbedtls_hmac_drbg_self_test(int verbose);
#endif
#ifdef __cplusplus