blob: 5f611dd01862e9123a6056c13a6a3967fcc9a385 [file] [log] [blame]
Paul Bakker0e04d0e2011-11-27 14:46:59 +00001/**
2 * \file ctr_drbg.h
3 *
Rose Zadikc9474eb2018-03-27 10:58:22 +01004 * \brief This file contains CTR_DRBG definitions and functions.
5 *
6 * CTR_DRBG is based on AES-256, as defined in <em>NIST SP 800-90A:
7 * Recommendation for Random Number Generation Using Deterministic
8 * Random Bit Generators</em>.
Rose Zadik2f8163d2018-01-25 21:55:14 +00009 *
Darryl Greena40a1012018-01-05 15:33:17 +000010 */
11/*
Rose Zadik2f8163d2018-01-25 21:55:14 +000012 * Copyright (C) 2006-2018, Arm Limited (or its affiliates), All Rights Reserved
Manuel Pégourié-Gonnard37ff1402015-09-04 14:21:07 +020013 * SPDX-License-Identifier: Apache-2.0
14 *
15 * Licensed under the Apache License, Version 2.0 (the "License"); you may
16 * not use this file except in compliance with the License.
17 * You may obtain a copy of the License at
18 *
19 * http://www.apache.org/licenses/LICENSE-2.0
20 *
21 * Unless required by applicable law or agreed to in writing, software
22 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
23 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
24 * See the License for the specific language governing permissions and
25 * limitations under the License.
Paul Bakker0e04d0e2011-11-27 14:46:59 +000026 *
Rose Zadik2f8163d2018-01-25 21:55:14 +000027 * This file is part of Mbed TLS (https://tls.mbed.org)
Paul Bakker0e04d0e2011-11-27 14:46:59 +000028 */
Rose Zadik2f8163d2018-01-25 21:55:14 +000029
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +020030#ifndef MBEDTLS_CTR_DRBG_H
31#define MBEDTLS_CTR_DRBG_H
Paul Bakker0e04d0e2011-11-27 14:46:59 +000032
Paul Bakker0e04d0e2011-11-27 14:46:59 +000033#include "aes.h"
34
Manuel Pégourié-Gonnard0a4fb092015-05-07 12:50:31 +010035#if defined(MBEDTLS_THREADING_C)
36#include "mbedtls/threading.h"
37#endif
38
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +020039#define MBEDTLS_ERR_CTR_DRBG_ENTROPY_SOURCE_FAILED -0x0034 /**< The entropy source failed. */
Rose Zadik2f8163d2018-01-25 21:55:14 +000040#define MBEDTLS_ERR_CTR_DRBG_REQUEST_TOO_BIG -0x0036 /**< The requested random buffer length is too big. */
41#define MBEDTLS_ERR_CTR_DRBG_INPUT_TOO_BIG -0x0038 /**< The input (entropy + additional data) is too large. */
42#define MBEDTLS_ERR_CTR_DRBG_FILE_IO_ERROR -0x003A /**< Read or write error in file. */
Paul Bakker0e04d0e2011-11-27 14:46:59 +000043
Rose Zadik2f8163d2018-01-25 21:55:14 +000044#define MBEDTLS_CTR_DRBG_BLOCKSIZE 16 /**< The block size used by the cipher. */
45#define MBEDTLS_CTR_DRBG_KEYSIZE 32 /**< The key size used by the cipher. */
46#define MBEDTLS_CTR_DRBG_KEYBITS ( MBEDTLS_CTR_DRBG_KEYSIZE * 8 ) /**< The key size for the DRBG operation, in bits. */
47#define MBEDTLS_CTR_DRBG_SEEDLEN ( MBEDTLS_CTR_DRBG_KEYSIZE + MBEDTLS_CTR_DRBG_BLOCKSIZE ) /**< The seed length, calculated as (counter + AES key). */
Paul Bakker9bcf16c2013-06-24 19:31:17 +020048
Paul Bakker088c5c52014-04-25 11:11:10 +020049/**
50 * \name SECTION: Module settings
51 *
52 * The configuration options you can set for this module are in this section.
Rose Zadik2f8163d2018-01-25 21:55:14 +000053 * Either change them in config.h or define them using the compiler command
54 * line.
Paul Bakker088c5c52014-04-25 11:11:10 +020055 * \{
56 */
57
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +020058#if !defined(MBEDTLS_CTR_DRBG_ENTROPY_LEN)
59#if defined(MBEDTLS_SHA512_C) && !defined(MBEDTLS_ENTROPY_FORCE_SHA256)
Rose Zadik2f8163d2018-01-25 21:55:14 +000060#define MBEDTLS_CTR_DRBG_ENTROPY_LEN 48
61/**< The amount of entropy used per seed by default:
62 * <ul><li>48 with SHA-512.</li>
63 * <li>32 with SHA-256.</li></ul>
64 */
Paul Bakkerfb08fd22013-08-27 15:06:26 +020065#else
Rose Zadik2f8163d2018-01-25 21:55:14 +000066#define MBEDTLS_CTR_DRBG_ENTROPY_LEN 32
67/**< Amount of entropy used per seed by default:
68 * <ul><li>48 with SHA-512.</li>
69 * <li>32 with SHA-256.</li></ul>
70 */
Paul Bakkerfb08fd22013-08-27 15:06:26 +020071#endif
Paul Bakker088c5c52014-04-25 11:11:10 +020072#endif
73
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +020074#if !defined(MBEDTLS_CTR_DRBG_RESEED_INTERVAL)
Rose Zadik2f8163d2018-01-25 21:55:14 +000075#define MBEDTLS_CTR_DRBG_RESEED_INTERVAL 10000
76/**< The interval before reseed is performed by default. */
Paul Bakker088c5c52014-04-25 11:11:10 +020077#endif
78
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +020079#if !defined(MBEDTLS_CTR_DRBG_MAX_INPUT)
Rose Zadik2f8163d2018-01-25 21:55:14 +000080#define MBEDTLS_CTR_DRBG_MAX_INPUT 256
81/**< The maximum number of additional input Bytes. */
Paul Bakker088c5c52014-04-25 11:11:10 +020082#endif
83
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +020084#if !defined(MBEDTLS_CTR_DRBG_MAX_REQUEST)
Rose Zadik2f8163d2018-01-25 21:55:14 +000085#define MBEDTLS_CTR_DRBG_MAX_REQUEST 1024
86/**< The maximum number of requested Bytes per call. */
Paul Bakker088c5c52014-04-25 11:11:10 +020087#endif
88
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +020089#if !defined(MBEDTLS_CTR_DRBG_MAX_SEED_INPUT)
Rose Zadik2f8163d2018-01-25 21:55:14 +000090#define MBEDTLS_CTR_DRBG_MAX_SEED_INPUT 384
91/**< The maximum size of seed or reseed buffer. */
Paul Bakker088c5c52014-04-25 11:11:10 +020092#endif
93
94/* \} name SECTION: Module settings */
Paul Bakker0e04d0e2011-11-27 14:46:59 +000095
Rose Zadik2f8163d2018-01-25 21:55:14 +000096#define MBEDTLS_CTR_DRBG_PR_OFF 0
97/**< Prediction resistance is disabled. */
98#define MBEDTLS_CTR_DRBG_PR_ON 1
99/**< Prediction resistance is enabled. */
Paul Bakker0e04d0e2011-11-27 14:46:59 +0000100
101#ifdef __cplusplus
102extern "C" {
103#endif
104
105/**
Rose Zadik2f8163d2018-01-25 21:55:14 +0000106 * \brief The CTR_DRBG context structure.
Paul Bakker0e04d0e2011-11-27 14:46:59 +0000107 */
108typedef struct
109{
Rose Zadik2f8163d2018-01-25 21:55:14 +0000110 unsigned char counter[16]; /*!< The counter (V). */
111 int reseed_counter; /*!< The reseed counter. */
112 int prediction_resistance; /*!< This determines whether prediction
113 resistance is enabled, that is
114 whether to systematically reseed before
115 each random generation. */
116 size_t entropy_len; /*!< The amount of entropy grabbed on each
117 seed or reseed operation. */
118 int reseed_interval; /*!< The reseed interval. */
Paul Bakker0e04d0e2011-11-27 14:46:59 +0000119
Rose Zadik2f8163d2018-01-25 21:55:14 +0000120 mbedtls_aes_context aes_ctx; /*!< The AES context. */
Paul Bakker0e04d0e2011-11-27 14:46:59 +0000121
122 /*
123 * Callbacks (Entropy)
124 */
125 int (*f_entropy)(void *, unsigned char *, size_t);
Rose Zadik2f8163d2018-01-25 21:55:14 +0000126 /*!< The entropy callback function. */
Paul Bakker0e04d0e2011-11-27 14:46:59 +0000127
Rose Zadik2f8163d2018-01-25 21:55:14 +0000128 void *p_entropy; /*!< The context for the entropy function. */
Manuel Pégourié-Gonnard0a4fb092015-05-07 12:50:31 +0100129
130#if defined(MBEDTLS_THREADING_C)
131 mbedtls_threading_mutex_t mutex;
132#endif
Paul Bakker0e04d0e2011-11-27 14:46:59 +0000133}
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200134mbedtls_ctr_drbg_context;
Paul Bakker0e04d0e2011-11-27 14:46:59 +0000135
136/**
Rose Zadik2f8163d2018-01-25 21:55:14 +0000137 * \brief This function initializes the CTR_DRBG context,
138 * and prepares it for mbedtls_ctr_drbg_seed()
139 * or mbedtls_ctr_drbg_free().
Manuel Pégourié-Gonnard8d128ef2015-04-28 22:38:08 +0200140 *
Rose Zadik2f8163d2018-01-25 21:55:14 +0000141 * \param ctx The CTR_DRBG context to initialize.
Manuel Pégourié-Gonnard8d128ef2015-04-28 22:38:08 +0200142 */
143void mbedtls_ctr_drbg_init( mbedtls_ctr_drbg_context *ctx );
144
145/**
Rose Zadik2f8163d2018-01-25 21:55:14 +0000146 * \brief This function seeds and sets up the CTR_DRBG
147 * entropy source for future reseeds.
Paul Bakker9af723c2014-05-01 13:03:14 +0200148 *
Rose Zadik2f8163d2018-01-25 21:55:14 +0000149 * \note Personalization data can be provided in addition to the more generic
150 * entropy source, to make this instantiation as unique as possible.
Paul Bakker0e04d0e2011-11-27 14:46:59 +0000151 *
Rose Zadik2f8163d2018-01-25 21:55:14 +0000152 * \param ctx The CTR_DRBG context to seed.
153 * \param f_entropy The entropy callback, taking as arguments the
154 * \p p_entropy context, the buffer to fill, and the
155 length of the buffer.
156 * \param p_entropy The entropy context.
157 * \param custom Personalization data, that is device-specific
158 identifiers. Can be NULL.
159 * \param len The length of the personalization data.
Paul Bakker0e04d0e2011-11-27 14:46:59 +0000160 *
Rose Zadikc9474eb2018-03-27 10:58:22 +0100161 * \return \c 0 on success.
162 * \return #MBEDTLS_ERR_CTR_DRBG_ENTROPY_SOURCE_FAILED on failure.
Paul Bakker0e04d0e2011-11-27 14:46:59 +0000163 */
Manuel Pégourié-Gonnard8d128ef2015-04-28 22:38:08 +0200164int mbedtls_ctr_drbg_seed( mbedtls_ctr_drbg_context *ctx,
Paul Bakker0e04d0e2011-11-27 14:46:59 +0000165 int (*f_entropy)(void *, unsigned char *, size_t),
166 void *p_entropy,
Paul Bakker1bc9efc2011-12-03 11:29:32 +0000167 const unsigned char *custom,
Paul Bakker0e04d0e2011-11-27 14:46:59 +0000168 size_t len );
169
170/**
Rose Zadik2f8163d2018-01-25 21:55:14 +0000171 * \brief This function clears CTR_CRBG context data.
Paul Bakkerfff03662014-06-18 16:21:25 +0200172 *
Rose Zadik2f8163d2018-01-25 21:55:14 +0000173 * \param ctx The CTR_DRBG context to clear.
Paul Bakkerfff03662014-06-18 16:21:25 +0200174 */
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200175void mbedtls_ctr_drbg_free( mbedtls_ctr_drbg_context *ctx );
Paul Bakkerfff03662014-06-18 16:21:25 +0200176
177/**
Rose Zadik2f8163d2018-01-25 21:55:14 +0000178 * \brief This function turns prediction resistance on or off.
179 * The default value is off.
Paul Bakker0e04d0e2011-11-27 14:46:59 +0000180 *
Rose Zadik2f8163d2018-01-25 21:55:14 +0000181 * \note If enabled, entropy is gathered at the beginning of
182 * every call to mbedtls_ctr_drbg_random_with_add().
183 * Only use this if your entropy source has sufficient
184 * throughput.
Paul Bakker0e04d0e2011-11-27 14:46:59 +0000185 *
Rose Zadik2f8163d2018-01-25 21:55:14 +0000186 * \param ctx The CTR_DRBG context.
187 * \param resistance #MBEDTLS_CTR_DRBG_PR_ON or #MBEDTLS_CTR_DRBG_PR_OFF.
Paul Bakker0e04d0e2011-11-27 14:46:59 +0000188 */
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200189void mbedtls_ctr_drbg_set_prediction_resistance( mbedtls_ctr_drbg_context *ctx,
Paul Bakker0e04d0e2011-11-27 14:46:59 +0000190 int resistance );
191
192/**
Rose Zadik2f8163d2018-01-25 21:55:14 +0000193 * \brief This function sets the amount of entropy grabbed on each
194 * seed or reseed. The default value is
195 * #MBEDTLS_CTR_DRBG_ENTROPY_LEN.
Paul Bakker0e04d0e2011-11-27 14:46:59 +0000196 *
Rose Zadik2f8163d2018-01-25 21:55:14 +0000197 * \param ctx The CTR_DRBG context.
198 * \param len The amount of entropy to grab.
Paul Bakker0e04d0e2011-11-27 14:46:59 +0000199 */
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200200void mbedtls_ctr_drbg_set_entropy_len( mbedtls_ctr_drbg_context *ctx,
Paul Bakker0e04d0e2011-11-27 14:46:59 +0000201 size_t len );
202
203/**
Rose Zadik2f8163d2018-01-25 21:55:14 +0000204 * \brief This function sets the reseed interval.
205 * The default value is #MBEDTLS_CTR_DRBG_RESEED_INTERVAL.
Paul Bakker0e04d0e2011-11-27 14:46:59 +0000206 *
Rose Zadik2f8163d2018-01-25 21:55:14 +0000207 * \param ctx The CTR_DRBG context.
208 * \param interval The reseed interval.
Paul Bakker0e04d0e2011-11-27 14:46:59 +0000209 */
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200210void mbedtls_ctr_drbg_set_reseed_interval( mbedtls_ctr_drbg_context *ctx,
Paul Bakker0e04d0e2011-11-27 14:46:59 +0000211 int interval );
212
213/**
Rose Zadik2f8163d2018-01-25 21:55:14 +0000214 * \brief This function reseeds the CTR_DRBG context, that is
215 * extracts data from the entropy source.
Paul Bakker9af723c2014-05-01 13:03:14 +0200216 *
Rose Zadik2f8163d2018-01-25 21:55:14 +0000217 * \param ctx The CTR_DRBG context.
218 * \param additional Additional data to add to the state. Can be NULL.
219 * \param len The length of the additional data.
Paul Bakker0e04d0e2011-11-27 14:46:59 +0000220 *
Rose Zadikc9474eb2018-03-27 10:58:22 +0100221 * \return \c 0 on success.
222 * \return #MBEDTLS_ERR_CTR_DRBG_ENTROPY_SOURCE_FAILED on failure.
Paul Bakker0e04d0e2011-11-27 14:46:59 +0000223 */
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200224int mbedtls_ctr_drbg_reseed( mbedtls_ctr_drbg_context *ctx,
Paul Bakker1bc9efc2011-12-03 11:29:32 +0000225 const unsigned char *additional, size_t len );
Paul Bakker0e04d0e2011-11-27 14:46:59 +0000226
227/**
Rose Zadikc9474eb2018-03-27 10:58:22 +0100228 * \brief This function updates the state of the CTR_DRBG context.
Paul Bakker0e04d0e2011-11-27 14:46:59 +0000229 *
Rose Zadikc9474eb2018-03-27 10:58:22 +0100230 * \note If \p add_len is greater than
231 * #MBEDTLS_CTR_DRBG_MAX_SEED_INPUT, only the first
232 * #MBEDTLS_CTR_DRBG_MAX_SEED_INPUT Bytes are used.
233 * The remaining Bytes are silently discarded.
Manuel Pégourié-Gonnard5cb4b312014-11-25 17:41:50 +0100234 *
Rose Zadikc9474eb2018-03-27 10:58:22 +0100235 * \param ctx The CTR_DRBG context.
236 * \param additional The data to update the state with.
237 * \param add_len Length of \p additional data.
238 *
Paul Bakker0e04d0e2011-11-27 14:46:59 +0000239 */
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200240void mbedtls_ctr_drbg_update( mbedtls_ctr_drbg_context *ctx,
Paul Bakkerfc754a92011-12-05 13:23:51 +0000241 const unsigned char *additional, size_t add_len );
Paul Bakker0e04d0e2011-11-27 14:46:59 +0000242
243/**
Rose Zadik2f8163d2018-01-25 21:55:14 +0000244 * \brief This function updates a CTR_DRBG instance with additional
245 * data and uses it to generate random data.
Paul Bakker0e04d0e2011-11-27 14:46:59 +0000246 *
Rose Zadik2f8163d2018-01-25 21:55:14 +0000247 * \note The function automatically reseeds if the reseed counter is exceeded.
Paul Bakker0e04d0e2011-11-27 14:46:59 +0000248 *
Rose Zadik2f8163d2018-01-25 21:55:14 +0000249 * \param p_rng The CTR_DRBG context. This must be a pointer to a
250 * #mbedtls_ctr_drbg_context structure.
251 * \param output The buffer to fill.
252 * \param output_len The length of the buffer.
253 * \param additional Additional data to update. Can be NULL.
254 * \param add_len The length of the additional data.
Paul Bakker0e04d0e2011-11-27 14:46:59 +0000255 *
Rose Zadikc9474eb2018-03-27 10:58:22 +0100256 * \return \c 0 on success.
257 * \return #MBEDTLS_ERR_CTR_DRBG_ENTROPY_SOURCE_FAILED or
Rose Zadik2f8163d2018-01-25 21:55:14 +0000258 * #MBEDTLS_ERR_CTR_DRBG_REQUEST_TOO_BIG on failure.
Paul Bakker0e04d0e2011-11-27 14:46:59 +0000259 */
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200260int mbedtls_ctr_drbg_random_with_add( void *p_rng,
Paul Bakker0e04d0e2011-11-27 14:46:59 +0000261 unsigned char *output, size_t output_len,
Paul Bakker1bc9efc2011-12-03 11:29:32 +0000262 const unsigned char *additional, size_t add_len );
Paul Bakker0e04d0e2011-11-27 14:46:59 +0000263
264/**
Rose Zadik2f8163d2018-01-25 21:55:14 +0000265 * \brief This function uses CTR_DRBG to generate random data.
Paul Bakker0e04d0e2011-11-27 14:46:59 +0000266 *
Rose Zadik2f8163d2018-01-25 21:55:14 +0000267 * \note The function automatically reseeds if the reseed counter is exceeded.
Paul Bakker0e04d0e2011-11-27 14:46:59 +0000268 *
Rose Zadik2f8163d2018-01-25 21:55:14 +0000269 * \param p_rng The CTR_DRBG context. This must be a pointer to a
270 * #mbedtls_ctr_drbg_context structure.
271 * \param output The buffer to fill.
272 * \param output_len The length of the buffer.
Paul Bakker0e04d0e2011-11-27 14:46:59 +0000273 *
Rose Zadikc9474eb2018-03-27 10:58:22 +0100274 * \return \c 0 on success.
275 * \return #MBEDTLS_ERR_CTR_DRBG_ENTROPY_SOURCE_FAILED or
Rose Zadik2f8163d2018-01-25 21:55:14 +0000276 * #MBEDTLS_ERR_CTR_DRBG_REQUEST_TOO_BIG on failure.
Paul Bakker0e04d0e2011-11-27 14:46:59 +0000277 */
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200278int mbedtls_ctr_drbg_random( void *p_rng,
Paul Bakker0e04d0e2011-11-27 14:46:59 +0000279 unsigned char *output, size_t output_len );
280
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200281#if defined(MBEDTLS_FS_IO)
Paul Bakkerfc754a92011-12-05 13:23:51 +0000282/**
Rose Zadik2f8163d2018-01-25 21:55:14 +0000283 * \brief This function writes a seed file.
Paul Bakkerfc754a92011-12-05 13:23:51 +0000284 *
Rose Zadik2f8163d2018-01-25 21:55:14 +0000285 * \param ctx The CTR_DRBG context.
286 * \param path The name of the file.
Paul Bakkerfc754a92011-12-05 13:23:51 +0000287 *
Rose Zadikc9474eb2018-03-27 10:58:22 +0100288 * \return \c 0 on success.
289 * \return #MBEDTLS_ERR_CTR_DRBG_FILE_IO_ERROR on file error, or
Rose Zadik2f8163d2018-01-25 21:55:14 +0000290 * #MBEDTLS_ERR_CTR_DRBG_ENTROPY_SOURCE_FAILED on
291 * failure.
Paul Bakkerfc754a92011-12-05 13:23:51 +0000292 */
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200293int mbedtls_ctr_drbg_write_seed_file( mbedtls_ctr_drbg_context *ctx, const char *path );
Paul Bakkerfc754a92011-12-05 13:23:51 +0000294
295/**
Rose Zadik2f8163d2018-01-25 21:55:14 +0000296 * \brief This function reads and updates a seed file. The seed
297 * is added to this instance.
Paul Bakkerfc754a92011-12-05 13:23:51 +0000298 *
Rose Zadik2f8163d2018-01-25 21:55:14 +0000299 * \param ctx The CTR_DRBG context.
300 * \param path The name of the file.
Paul Bakkerfc754a92011-12-05 13:23:51 +0000301 *
Rose Zadikc9474eb2018-03-27 10:58:22 +0100302 * \return \c 0 on success.
303 * \return #MBEDTLS_ERR_CTR_DRBG_FILE_IO_ERROR on file error.
304 * \return #MBEDTLS_ERR_CTR_DRBG_ENTROPY_SOURCE_FAILED or
Rose Zadik2f8163d2018-01-25 21:55:14 +0000305 * #MBEDTLS_ERR_CTR_DRBG_INPUT_TOO_BIG on failure.
Paul Bakkerfc754a92011-12-05 13:23:51 +0000306 */
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200307int mbedtls_ctr_drbg_update_seed_file( mbedtls_ctr_drbg_context *ctx, const char *path );
308#endif /* MBEDTLS_FS_IO */
Paul Bakkerfc754a92011-12-05 13:23:51 +0000309
Paul Bakker0e04d0e2011-11-27 14:46:59 +0000310/**
Rose Zadik2f8163d2018-01-25 21:55:14 +0000311 * \brief The CTR_DRBG checkup routine.
Paul Bakker0e04d0e2011-11-27 14:46:59 +0000312 *
Rose Zadikc9474eb2018-03-27 10:58:22 +0100313 * \return \c 0 on success.
314 * \return \c 1 on failure.
Paul Bakker0e04d0e2011-11-27 14:46:59 +0000315 */
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200316int mbedtls_ctr_drbg_self_test( int verbose );
Paul Bakker0e04d0e2011-11-27 14:46:59 +0000317
Paul Bakker534f82c2013-06-25 16:47:55 +0200318/* Internal functions (do not call directly) */
Manuel Pégourié-Gonnard8d128ef2015-04-28 22:38:08 +0200319int mbedtls_ctr_drbg_seed_entropy_len( mbedtls_ctr_drbg_context *,
Paul Bakkerb9e4e2c2014-05-01 14:18:25 +0200320 int (*)(void *, unsigned char *, size_t), void *,
321 const unsigned char *, size_t, size_t );
Paul Bakker534f82c2013-06-25 16:47:55 +0200322
Paul Bakker0e04d0e2011-11-27 14:46:59 +0000323#ifdef __cplusplus
324}
325#endif
326
327#endif /* ctr_drbg.h */