Go to the documentation of this file.
86 #ifndef MBEDTLS_CTR_DRBG_H
87 #define MBEDTLS_CTR_DRBG_H
89 #if !defined(MBEDTLS_CONFIG_FILE)
92 #include MBEDTLS_CONFIG_FILE
97 #if defined(MBEDTLS_THREADING_C)
101 #define MBEDTLS_ERR_CTR_DRBG_ENTROPY_SOURCE_FAILED -0x0034
102 #define MBEDTLS_ERR_CTR_DRBG_REQUEST_TOO_BIG -0x0036
103 #define MBEDTLS_ERR_CTR_DRBG_INPUT_TOO_BIG -0x0038
104 #define MBEDTLS_ERR_CTR_DRBG_FILE_IO_ERROR -0x003A
106 #define MBEDTLS_CTR_DRBG_BLOCKSIZE 16
108 #if defined(MBEDTLS_CTR_DRBG_USE_128_BIT_KEY)
109 #define MBEDTLS_CTR_DRBG_KEYSIZE 16
116 #define MBEDTLS_CTR_DRBG_KEYSIZE 32
124 #define MBEDTLS_CTR_DRBG_KEYBITS ( MBEDTLS_CTR_DRBG_KEYSIZE * 8 )
125 #define MBEDTLS_CTR_DRBG_SEEDLEN ( MBEDTLS_CTR_DRBG_KEYSIZE + MBEDTLS_CTR_DRBG_BLOCKSIZE )
140 #if !defined(MBEDTLS_CTR_DRBG_ENTROPY_LEN)
141 #if defined(MBEDTLS_SHA512_C) && !defined(MBEDTLS_ENTROPY_FORCE_SHA256)
145 #define MBEDTLS_CTR_DRBG_ENTROPY_LEN 48
153 #if !defined(MBEDTLS_CTR_DRBG_USE_128_BIT_KEY)
158 #define MBEDTLS_CTR_DRBG_ENTROPY_LEN 32
162 #if !defined(MBEDTLS_CTR_DRBG_RESEED_INTERVAL)
163 #define MBEDTLS_CTR_DRBG_RESEED_INTERVAL 10000
167 #if !defined(MBEDTLS_CTR_DRBG_MAX_INPUT)
168 #define MBEDTLS_CTR_DRBG_MAX_INPUT 256
172 #if !defined(MBEDTLS_CTR_DRBG_MAX_REQUEST)
173 #define MBEDTLS_CTR_DRBG_MAX_REQUEST 1024
177 #if !defined(MBEDTLS_CTR_DRBG_MAX_SEED_INPUT)
178 #define MBEDTLS_CTR_DRBG_MAX_SEED_INPUT 384
184 #define MBEDTLS_CTR_DRBG_PR_OFF 0
186 #define MBEDTLS_CTR_DRBG_PR_ON 1
218 #if defined(MBEDTLS_THREADING_C)
267 #if MBEDTLS_CTR_DRBG_ENTROPY_LEN < MBEDTLS_CTR_DRBG_KEYSIZE * 3 / 2
304 int (*f_entropy)(
void *,
unsigned char *,
size_t),
306 const unsigned char *custom,
388 const unsigned char *additional,
size_t len );
406 const unsigned char *additional,
436 unsigned char *output,
size_t output_len,
437 const unsigned char *additional,
size_t add_len );
456 unsigned char *output,
size_t output_len );
459 #if ! defined(MBEDTLS_DEPRECATED_REMOVED)
460 #if defined(MBEDTLS_DEPRECATED_WARNING)
461 #define MBEDTLS_DEPRECATED __attribute__((deprecated))
463 #define MBEDTLS_DEPRECATED
482 const unsigned char *additional,
484 #undef MBEDTLS_DEPRECATED
487 #if defined(MBEDTLS_FS_IO)
518 #if defined(MBEDTLS_SELF_TEST)
532 int (*)(
void *,
unsigned char *,
size_t),
void *,
533 const unsigned char *,
size_t,
size_t );
int mbedtls_ctr_drbg_self_test(int verbose)
The CTR_DRBG checkup routine.
int mbedtls_ctr_drbg_reseed(mbedtls_ctr_drbg_context *ctx, const unsigned char *additional, size_t len)
This function reseeds the CTR_DRBG context, that is extracts data from the entropy source.
int mbedtls_ctr_drbg_seed(mbedtls_ctr_drbg_context *ctx, int(*f_entropy)(void *, unsigned char *, size_t), void *p_entropy, const unsigned char *custom, size_t len)
This function seeds and sets up the CTR_DRBG entropy source for future reseeds.
unsigned char counter[16]
MBEDTLS_DEPRECATED void mbedtls_ctr_drbg_update(mbedtls_ctr_drbg_context *ctx, const unsigned char *additional, size_t add_len)
This function updates the state of the CTR_DRBG context.
void mbedtls_ctr_drbg_set_entropy_len(mbedtls_ctr_drbg_context *ctx, size_t len)
This function sets the amount of entropy grabbed on each seed or reseed.
The CTR_DRBG context structure.
int mbedtls_ctr_drbg_update_ret(mbedtls_ctr_drbg_context *ctx, const unsigned char *additional, size_t add_len)
This function updates the state of the CTR_DRBG context.
This file contains AES definitions and functions.
#define MBEDTLS_DEPRECATED
int mbedtls_ctr_drbg_random(void *p_rng, unsigned char *output, size_t output_len)
This function uses CTR_DRBG to generate random data.
int mbedtls_ctr_drbg_write_seed_file(mbedtls_ctr_drbg_context *ctx, const char *path)
This function writes a seed file.
mbedtls_threading_mutex_t mutex
The AES context-type definition.
int mbedtls_ctr_drbg_random_with_add(void *p_rng, unsigned char *output, size_t output_len, const unsigned char *additional, size_t add_len)
This function updates a CTR_DRBG instance with additional data and uses it to generate random data.
void mbedtls_ctr_drbg_free(mbedtls_ctr_drbg_context *ctx)
This function clears CTR_CRBG context data.
int prediction_resistance
struct mbedtls_ctr_drbg_context mbedtls_ctr_drbg_context
The CTR_DRBG context structure.
void mbedtls_ctr_drbg_init(mbedtls_ctr_drbg_context *ctx)
This function initializes the CTR_DRBG context, and prepares it for mbedtls_ctr_drbg_seed() or mbedtl...
Threading abstraction layer.
void mbedtls_ctr_drbg_set_reseed_interval(mbedtls_ctr_drbg_context *ctx, int interval)
This function sets the reseed interval.
int mbedtls_ctr_drbg_update_seed_file(mbedtls_ctr_drbg_context *ctx, const char *path)
This function reads and updates a seed file. The seed is added to this instance.
void mbedtls_ctr_drbg_set_prediction_resistance(mbedtls_ctr_drbg_context *ctx, int resistance)
This function turns prediction resistance on or off. The default value is off.
int mbedtls_ctr_drbg_seed_entropy_len(mbedtls_ctr_drbg_context *, int(*)(void *, unsigned char *, size_t), void *, const unsigned char *, size_t, size_t)
Configuration options (set of defines)
mbedtls_aes_context aes_ctx
int(* f_entropy)(void *, unsigned char *, size_t)