RetroArch
hmac_drbg.h
Go to the documentation of this file.
1 
23 #ifndef MBEDTLS_HMAC_DRBG_H
24 #define MBEDTLS_HMAC_DRBG_H
25 
26 #include "md.h"
27 
28 #if defined(MBEDTLS_THREADING_C)
29 #include "mbedtls/threading.h"
30 #endif
31 
32 /*
33  * Error codes
34  */
35 #define MBEDTLS_ERR_HMAC_DRBG_REQUEST_TOO_BIG -0x0003
36 #define MBEDTLS_ERR_HMAC_DRBG_INPUT_TOO_BIG -0x0005
37 #define MBEDTLS_ERR_HMAC_DRBG_FILE_IO_ERROR -0x0007
38 #define MBEDTLS_ERR_HMAC_DRBG_ENTROPY_SOURCE_FAILED -0x0009
48 #if !defined(MBEDTLS_HMAC_DRBG_RESEED_INTERVAL)
49 #define MBEDTLS_HMAC_DRBG_RESEED_INTERVAL 10000
50 #endif
51 
52 #if !defined(MBEDTLS_HMAC_DRBG_MAX_INPUT)
53 #define MBEDTLS_HMAC_DRBG_MAX_INPUT 256
54 #endif
55 
56 #if !defined(MBEDTLS_HMAC_DRBG_MAX_REQUEST)
57 #define MBEDTLS_HMAC_DRBG_MAX_REQUEST 1024
58 #endif
59 
60 #if !defined(MBEDTLS_HMAC_DRBG_MAX_SEED_INPUT)
61 #define MBEDTLS_HMAC_DRBG_MAX_SEED_INPUT 384
62 #endif
63 
64 /* \} name SECTION: Module settings */
65 
66 #define MBEDTLS_HMAC_DRBG_PR_OFF 0
67 #define MBEDTLS_HMAC_DRBG_PR_ON 1
69 #ifdef __cplusplus
70 extern "C" {
71 #endif
72 
76 typedef struct
77 {
78  /* Working state: the key K is not stored explicitely,
79  * but is implied by the HMAC context */
81  unsigned char V[MBEDTLS_MD_MAX_SIZE];
84  /* Administrative state */
85  size_t entropy_len;
90  /* Callbacks */
91  int (*f_entropy)(void *, unsigned char *, size_t);
92  void *p_entropy;
94 #if defined(MBEDTLS_THREADING_C)
95  mbedtls_threading_mutex_t mutex;
96 #endif
98 
108 
134  const mbedtls_md_info_t * md_info,
135  int (*f_entropy)(void *, unsigned char *, size_t),
136  void *p_entropy,
137  const unsigned char *custom,
138  size_t len );
139 
154  const mbedtls_md_info_t * md_info,
155  const unsigned char *data, size_t data_len );
156 
167  int resistance );
168 
178  size_t len );
179 
188  int interval );
189 
201  const unsigned char *additional, size_t add_len );
202 
214  const unsigned char *additional, size_t len );
215 
232 int mbedtls_hmac_drbg_random_with_add( void *p_rng,
233  unsigned char *output, size_t output_len,
234  const unsigned char *additional,
235  size_t add_len );
236 
250 int mbedtls_hmac_drbg_random( void *p_rng, unsigned char *output, size_t out_len );
251 
258 
259 #if defined(MBEDTLS_FS_IO)
260 
270 
283 #endif /* MBEDTLS_FS_IO */
284 
285 
286 #if defined(MBEDTLS_SELF_TEST)
287 
292 int mbedtls_hmac_drbg_self_test( int verbose );
293 #endif
294 
295 #ifdef __cplusplus
296 }
297 #endif
298 
299 #endif /* hmac_drbg.h */
int mbedtls_hmac_drbg_self_test(int verbose)
Definition: hmac_drbg.c:466
#define MBEDTLS_MD_MAX_SIZE
Definition: md.h:55
Threading abstraction layer.
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)
HMAC_DRBG generate random with additional update input.
Definition: hmac_drbg.c:246
int reseed_interval
Definition: hmac_drbg.h:88
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)
Initilisation of simpified HMAC_DRBG (never reseeds). (For use with deterministic ECDSA....
Definition: hmac_drbg.c:98
GLsizei const GLchar ** path
Definition: glext.h:7901
static const size_t add_len[NB_TESTS]
Definition: ccm.c:382
GLenum GLsizei len
Definition: glext.h:7389
int mbedtls_hmac_drbg_reseed(mbedtls_hmac_drbg_context *ctx, const unsigned char *additional, size_t len)
HMAC_DRBG reseeding (extracts data from entropy source)
Definition: hmac_drbg.c:123
static sys_sem mutex
Definition: memp.c:120
Definition: ibxm.h:9
AVFormatContext * ctx
Definition: record_ffmpeg.c:247
void mbedtls_hmac_drbg_free(mbedtls_hmac_drbg_context *ctx)
Free an HMAC_DRBG context.
Definition: hmac_drbg.c:329
Generic message digest wrapper.
mbedtls_md_context_t md_ctx
Definition: hmac_drbg.h:80
void mbedtls_hmac_drbg_set_reseed_interval(mbedtls_hmac_drbg_context *ctx, int interval)
Set the reseed interval (Default: MBEDTLS_HMAC_DRBG_RESEED_INTERVAL)
Definition: hmac_drbg.c:237
void mbedtls_hmac_drbg_init(mbedtls_hmac_drbg_context *ctx)
HMAC_DRBG context initialization Makes the context ready for mbedtls_hmac_drbg_seed(),...
Definition: hmac_drbg.c:58
Definition: hmac_drbg.h:76
void mbedtls_hmac_drbg_update(mbedtls_hmac_drbg_context *ctx, const unsigned char *additional, size_t add_len)
HMAC_DRBG update state.
Definition: hmac_drbg.c:70
void * p_entropy
Definition: hmac_drbg.h:92
int mbedtls_hmac_drbg_random(void *p_rng, unsigned char *output, size_t out_len)
HMAC_DRBG generate random.
Definition: hmac_drbg.c:306
Definition: md_internal.h:46
int reseed_counter
Definition: hmac_drbg.h:82
std::string output
Definition: Config.FromFile.cpp:44
size_t entropy_len
Definition: hmac_drbg.h:85
void mbedtls_hmac_drbg_set_prediction_resistance(mbedtls_hmac_drbg_context *ctx, int resistance)
Enable / disable prediction resistance (Default: Off)
Definition: hmac_drbg.c:220
Definition: md.h:66
int mbedtls_hmac_drbg_update_seed_file(mbedtls_hmac_drbg_context *ctx, const char *path)
Definition: hmac_drbg.c:367
void mbedtls_hmac_drbg_set_entropy_len(mbedtls_hmac_drbg_context *ctx, size_t len)
Set the amount of entropy grabbed on each reseed (Default: given by the security strength,...
Definition: hmac_drbg.c:229
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)
HMAC_DRBG initial seeding Seed and setup entropy source for future reseeds.
Definition: hmac_drbg.c:164
static const unsigned char additional[MAX_TESTS][64]
Definition: gcm.c:559
int prediction_resistance
Definition: hmac_drbg.h:86
int mbedtls_hmac_drbg_write_seed_file(mbedtls_hmac_drbg_context *ctx, const char *path)
Definition: hmac_drbg.c:342