mbed TLS v2.16.1
Main Page
Related Pages
Modules
Data Structures
Files
File List
Globals
include
mbedtls
hmac_drbg.h
Go to the documentation of this file.
1
6
/*
7
* Copyright (C) 2006-2015, ARM Limited, All Rights Reserved
8
* SPDX-License-Identifier: GPL-2.0
9
*
10
* This program is free software; you can redistribute it and/or modify
11
* it under the terms of the GNU General Public License as published by
12
* the Free Software Foundation; either version 2 of the License, or
13
* (at your option) any later version.
14
*
15
* This program is distributed in the hope that it will be useful,
16
* but WITHOUT ANY WARRANTY; without even the implied warranty of
17
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18
* GNU General Public License for more details.
19
*
20
* You should have received a copy of the GNU General Public License along
21
* with this program; if not, write to the Free Software Foundation, Inc.,
22
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
23
*
24
* This file is part of mbed TLS (https://tls.mbed.org)
25
*/
26
#ifndef MBEDTLS_HMAC_DRBG_H
27
#define MBEDTLS_HMAC_DRBG_H
28
29
#if !defined(MBEDTLS_CONFIG_FILE)
30
#include "
config.h
"
31
#else
32
#include MBEDTLS_CONFIG_FILE
33
#endif
34
35
#include "
md.h
"
36
37
#if defined(MBEDTLS_THREADING_C)
38
#include "
threading.h
"
39
#endif
40
41
/*
42
* Error codes
43
*/
44
#define MBEDTLS_ERR_HMAC_DRBG_REQUEST_TOO_BIG -0x0003
45
#define MBEDTLS_ERR_HMAC_DRBG_INPUT_TOO_BIG -0x0005
46
#define MBEDTLS_ERR_HMAC_DRBG_FILE_IO_ERROR -0x0007
47
#define MBEDTLS_ERR_HMAC_DRBG_ENTROPY_SOURCE_FAILED -0x0009
57
#if !defined(MBEDTLS_HMAC_DRBG_RESEED_INTERVAL)
58
#define MBEDTLS_HMAC_DRBG_RESEED_INTERVAL 10000
59
#endif
60
61
#if !defined(MBEDTLS_HMAC_DRBG_MAX_INPUT)
62
#define MBEDTLS_HMAC_DRBG_MAX_INPUT 256
63
#endif
64
65
#if !defined(MBEDTLS_HMAC_DRBG_MAX_REQUEST)
66
#define MBEDTLS_HMAC_DRBG_MAX_REQUEST 1024
67
#endif
68
69
#if !defined(MBEDTLS_HMAC_DRBG_MAX_SEED_INPUT)
70
#define MBEDTLS_HMAC_DRBG_MAX_SEED_INPUT 384
71
#endif
72
73
/* \} name SECTION: Module settings */
74
75
#define MBEDTLS_HMAC_DRBG_PR_OFF 0
76
#define MBEDTLS_HMAC_DRBG_PR_ON 1
78
#ifdef __cplusplus
79
extern
"C"
{
80
#endif
81
85
typedef
struct
mbedtls_hmac_drbg_context
86
{
87
/* Working state: the key K is not stored explicitely,
88
* but is implied by the HMAC context */
89
mbedtls_md_context_t
md_ctx
;
90
unsigned
char
V
[
MBEDTLS_MD_MAX_SIZE
];
91
int
reseed_counter
;
93
/* Administrative state */
94
size_t
entropy_len
;
95
int
prediction_resistance
;
97
int
reseed_interval
;
99
/* Callbacks */
100
int (*
f_entropy
)(
void
*,
unsigned
char
*, size_t);
101
void
*
p_entropy
;
103
#if defined(MBEDTLS_THREADING_C)
104
mbedtls_threading_mutex_t mutex;
105
#endif
106
}
mbedtls_hmac_drbg_context
;
107
116
void
mbedtls_hmac_drbg_init
(
mbedtls_hmac_drbg_context
*ctx );
117
142
int
mbedtls_hmac_drbg_seed
(
mbedtls_hmac_drbg_context
*ctx,
143
const
mbedtls_md_info_t
* md_info,
144
int
(*f_entropy)(
void
*,
unsigned
char
*,
size_t
),
145
void
*p_entropy,
146
const
unsigned
char
*custom,
147
size_t
len );
148
162
int
mbedtls_hmac_drbg_seed_buf
(
mbedtls_hmac_drbg_context
*ctx,
163
const
mbedtls_md_info_t
* md_info,
164
const
unsigned
char
*data,
size_t
data_len );
165
175
void
mbedtls_hmac_drbg_set_prediction_resistance
(
mbedtls_hmac_drbg_context
*ctx,
176
int
resistance );
177
186
void
mbedtls_hmac_drbg_set_entropy_len
(
mbedtls_hmac_drbg_context
*ctx,
187
size_t
len );
188
196
void
mbedtls_hmac_drbg_set_reseed_interval
(
mbedtls_hmac_drbg_context
*ctx,
197
int
interval );
198
212
int
mbedtls_hmac_drbg_update_ret
(
mbedtls_hmac_drbg_context
*ctx,
213
const
unsigned
char
*additional,
size_t
add_len );
214
225
int
mbedtls_hmac_drbg_reseed
(
mbedtls_hmac_drbg_context
*ctx,
226
const
unsigned
char
*additional,
size_t
len );
227
244
int
mbedtls_hmac_drbg_random_with_add
(
void
*p_rng,
245
unsigned
char
*output,
size_t
output_len,
246
const
unsigned
char
*additional,
247
size_t
add_len );
248
262
int
mbedtls_hmac_drbg_random
(
void
*p_rng,
unsigned
char
*output,
size_t
out_len );
263
269
void
mbedtls_hmac_drbg_free
(
mbedtls_hmac_drbg_context
*ctx );
270
271
#if ! defined(MBEDTLS_DEPRECATED_REMOVED)
272
#if defined(MBEDTLS_DEPRECATED_WARNING)
273
#define MBEDTLS_DEPRECATED __attribute__((deprecated))
274
#else
275
#define MBEDTLS_DEPRECATED
276
#endif
277
290
MBEDTLS_DEPRECATED
void
mbedtls_hmac_drbg_update
(
291
mbedtls_hmac_drbg_context
*ctx,
292
const
unsigned
char
*additional,
size_t
add_len );
293
#undef MBEDTLS_DEPRECATED
294
#endif
/* !MBEDTLS_DEPRECATED_REMOVED */
295
296
#if defined(MBEDTLS_FS_IO)
297
306
int
mbedtls_hmac_drbg_write_seed_file
(
mbedtls_hmac_drbg_context
*ctx,
const
char
*path );
307
319
int
mbedtls_hmac_drbg_update_seed_file
(
mbedtls_hmac_drbg_context
*ctx,
const
char
*path );
320
#endif
/* MBEDTLS_FS_IO */
321
322
323
#if defined(MBEDTLS_SELF_TEST)
324
329
int
mbedtls_hmac_drbg_self_test
(
int
verbose );
330
#endif
331
332
#ifdef __cplusplus
333
}
334
#endif
335
336
#endif
/* hmac_drbg.h */
Generated on Tue Aug 13 2019 20:47:14 for mbed TLS v2.16.1 by
1.8.3.1