blob: dda356e7556780ad5c1e1d466441deeba5b74768 [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 *
Rose Zadikf25eb6e2018-04-16 14:51:52 +01006 * CTR_DRBG is a standardized way of building a PRNG from a block-cipher
7 * in counter mode operation, as defined in <em>NIST SP 800-90A:
8 * Recommendation for Random Number Generation Using Deterministic Random
9 * Bit Generators</em>.
Rose Zadik2f8163d2018-01-25 21:55:14 +000010 *
Rose Zadikf25eb6e2018-04-16 14:51:52 +010011 * The Mbed TLS implementation of CTR_DRBG uses AES-256 as the underlying
12 * block cipher.
Darryl Greena40a1012018-01-05 15:33:17 +000013 */
14/*
Rose Zadik2f8163d2018-01-25 21:55:14 +000015 * Copyright (C) 2006-2018, Arm Limited (or its affiliates), All Rights Reserved
Manuel Pégourié-Gonnard37ff1402015-09-04 14:21:07 +020016 * SPDX-License-Identifier: Apache-2.0
17 *
18 * Licensed under the Apache License, Version 2.0 (the "License"); you may
19 * not use this file except in compliance with the License.
20 * You may obtain a copy of the License at
21 *
22 * http://www.apache.org/licenses/LICENSE-2.0
23 *
24 * Unless required by applicable law or agreed to in writing, software
25 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
26 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
27 * See the License for the specific language governing permissions and
28 * limitations under the License.
Paul Bakker0e04d0e2011-11-27 14:46:59 +000029 *
Rose Zadik2f8163d2018-01-25 21:55:14 +000030 * This file is part of Mbed TLS (https://tls.mbed.org)
Paul Bakker0e04d0e2011-11-27 14:46:59 +000031 */
Rose Zadik2f8163d2018-01-25 21:55:14 +000032
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +020033#ifndef MBEDTLS_CTR_DRBG_H
34#define MBEDTLS_CTR_DRBG_H
Paul Bakker0e04d0e2011-11-27 14:46:59 +000035
Paul Bakker0e04d0e2011-11-27 14:46:59 +000036#include "aes.h"
37
Manuel Pégourié-Gonnard0a4fb092015-05-07 12:50:31 +010038#if defined(MBEDTLS_THREADING_C)
39#include "mbedtls/threading.h"
40#endif
41
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +020042#define MBEDTLS_ERR_CTR_DRBG_ENTROPY_SOURCE_FAILED -0x0034 /**< The entropy source failed. */
Rose Zadik2f8163d2018-01-25 21:55:14 +000043#define MBEDTLS_ERR_CTR_DRBG_REQUEST_TOO_BIG -0x0036 /**< The requested random buffer length is too big. */
44#define MBEDTLS_ERR_CTR_DRBG_INPUT_TOO_BIG -0x0038 /**< The input (entropy + additional data) is too large. */
45#define MBEDTLS_ERR_CTR_DRBG_FILE_IO_ERROR -0x003A /**< Read or write error in file. */
Paul Bakker0e04d0e2011-11-27 14:46:59 +000046
Rose Zadik2f8163d2018-01-25 21:55:14 +000047#define MBEDTLS_CTR_DRBG_BLOCKSIZE 16 /**< The block size used by the cipher. */
48#define MBEDTLS_CTR_DRBG_KEYSIZE 32 /**< The key size used by the cipher. */
49#define MBEDTLS_CTR_DRBG_KEYBITS ( MBEDTLS_CTR_DRBG_KEYSIZE * 8 ) /**< The key size for the DRBG operation, in bits. */
50#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 +020051
Paul Bakker088c5c52014-04-25 11:11:10 +020052/**
53 * \name SECTION: Module settings
54 *
55 * The configuration options you can set for this module are in this section.
Rose Zadik2f8163d2018-01-25 21:55:14 +000056 * Either change them in config.h or define them using the compiler command
57 * line.
Paul Bakker088c5c52014-04-25 11:11:10 +020058 * \{
59 */
60
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +020061#if !defined(MBEDTLS_CTR_DRBG_ENTROPY_LEN)
62#if defined(MBEDTLS_SHA512_C) && !defined(MBEDTLS_ENTROPY_FORCE_SHA256)
Rose Zadik2f8163d2018-01-25 21:55:14 +000063#define MBEDTLS_CTR_DRBG_ENTROPY_LEN 48
64/**< The amount of entropy used per seed by default:
65 * <ul><li>48 with SHA-512.</li>
66 * <li>32 with SHA-256.</li></ul>
67 */
Paul Bakkerfb08fd22013-08-27 15:06:26 +020068#else
Rose Zadik2f8163d2018-01-25 21:55:14 +000069#define MBEDTLS_CTR_DRBG_ENTROPY_LEN 32
70/**< Amount of entropy used per seed by default:
71 * <ul><li>48 with SHA-512.</li>
72 * <li>32 with SHA-256.</li></ul>
73 */
Paul Bakkerfb08fd22013-08-27 15:06:26 +020074#endif
Paul Bakker088c5c52014-04-25 11:11:10 +020075#endif
76
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +020077#if !defined(MBEDTLS_CTR_DRBG_RESEED_INTERVAL)
Rose Zadik2f8163d2018-01-25 21:55:14 +000078#define MBEDTLS_CTR_DRBG_RESEED_INTERVAL 10000
79/**< The interval before reseed is performed by default. */
Paul Bakker088c5c52014-04-25 11:11:10 +020080#endif
81
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +020082#if !defined(MBEDTLS_CTR_DRBG_MAX_INPUT)
Rose Zadik2f8163d2018-01-25 21:55:14 +000083#define MBEDTLS_CTR_DRBG_MAX_INPUT 256
84/**< The maximum number of additional input Bytes. */
Paul Bakker088c5c52014-04-25 11:11:10 +020085#endif
86
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +020087#if !defined(MBEDTLS_CTR_DRBG_MAX_REQUEST)
Rose Zadik2f8163d2018-01-25 21:55:14 +000088#define MBEDTLS_CTR_DRBG_MAX_REQUEST 1024
89/**< The maximum number of requested Bytes per call. */
Paul Bakker088c5c52014-04-25 11:11:10 +020090#endif
91
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +020092#if !defined(MBEDTLS_CTR_DRBG_MAX_SEED_INPUT)
Rose Zadik2f8163d2018-01-25 21:55:14 +000093#define MBEDTLS_CTR_DRBG_MAX_SEED_INPUT 384
94/**< The maximum size of seed or reseed buffer. */
Paul Bakker088c5c52014-04-25 11:11:10 +020095#endif
96
97/* \} name SECTION: Module settings */
Paul Bakker0e04d0e2011-11-27 14:46:59 +000098
Rose Zadik2f8163d2018-01-25 21:55:14 +000099#define MBEDTLS_CTR_DRBG_PR_OFF 0
100/**< Prediction resistance is disabled. */
101#define MBEDTLS_CTR_DRBG_PR_ON 1
102/**< Prediction resistance is enabled. */
Paul Bakker0e04d0e2011-11-27 14:46:59 +0000103
104#ifdef __cplusplus
105extern "C" {
106#endif
107
108/**
Rose Zadik2f8163d2018-01-25 21:55:14 +0000109 * \brief The CTR_DRBG context structure.
Paul Bakker0e04d0e2011-11-27 14:46:59 +0000110 */
111typedef struct
112{
Rose Zadik2f8163d2018-01-25 21:55:14 +0000113 unsigned char counter[16]; /*!< The counter (V). */
114 int reseed_counter; /*!< The reseed counter. */
115 int prediction_resistance; /*!< This determines whether prediction
116 resistance is enabled, that is
117 whether to systematically reseed before
118 each random generation. */
119 size_t entropy_len; /*!< The amount of entropy grabbed on each
120 seed or reseed operation. */
121 int reseed_interval; /*!< The reseed interval. */
Paul Bakker0e04d0e2011-11-27 14:46:59 +0000122
Rose Zadik2f8163d2018-01-25 21:55:14 +0000123 mbedtls_aes_context aes_ctx; /*!< The AES context. */
Paul Bakker0e04d0e2011-11-27 14:46:59 +0000124
125 /*
126 * Callbacks (Entropy)
127 */
128 int (*f_entropy)(void *, unsigned char *, size_t);
Rose Zadik2f8163d2018-01-25 21:55:14 +0000129 /*!< The entropy callback function. */
Paul Bakker0e04d0e2011-11-27 14:46:59 +0000130
Rose Zadik2f8163d2018-01-25 21:55:14 +0000131 void *p_entropy; /*!< The context for the entropy function. */
Manuel Pégourié-Gonnard0a4fb092015-05-07 12:50:31 +0100132
133#if defined(MBEDTLS_THREADING_C)
134 mbedtls_threading_mutex_t mutex;
135#endif
Paul Bakker0e04d0e2011-11-27 14:46:59 +0000136}
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200137mbedtls_ctr_drbg_context;
Paul Bakker0e04d0e2011-11-27 14:46:59 +0000138
139/**
Rose Zadik2f8163d2018-01-25 21:55:14 +0000140 * \brief This function initializes the CTR_DRBG context,
141 * and prepares it for mbedtls_ctr_drbg_seed()
142 * or mbedtls_ctr_drbg_free().
Manuel Pégourié-Gonnard8d128ef2015-04-28 22:38:08 +0200143 *
Rose Zadik2f8163d2018-01-25 21:55:14 +0000144 * \param ctx The CTR_DRBG context to initialize.
Manuel Pégourié-Gonnard8d128ef2015-04-28 22:38:08 +0200145 */
146void mbedtls_ctr_drbg_init( mbedtls_ctr_drbg_context *ctx );
147
148/**
Rose Zadik2f8163d2018-01-25 21:55:14 +0000149 * \brief This function seeds and sets up the CTR_DRBG
150 * entropy source for future reseeds.
Paul Bakker9af723c2014-05-01 13:03:14 +0200151 *
Rose Zadik2f8163d2018-01-25 21:55:14 +0000152 * \note Personalization data can be provided in addition to the more generic
153 * entropy source, to make this instantiation as unique as possible.
Paul Bakker0e04d0e2011-11-27 14:46:59 +0000154 *
Rose Zadik2f8163d2018-01-25 21:55:14 +0000155 * \param ctx The CTR_DRBG context to seed.
156 * \param f_entropy The entropy callback, taking as arguments the
157 * \p p_entropy context, the buffer to fill, and the
158 length of the buffer.
159 * \param p_entropy The entropy context.
160 * \param custom Personalization data, that is device-specific
161 identifiers. Can be NULL.
162 * \param len The length of the personalization data.
Paul Bakker0e04d0e2011-11-27 14:46:59 +0000163 *
Rose Zadikc9474eb2018-03-27 10:58:22 +0100164 * \return \c 0 on success.
165 * \return #MBEDTLS_ERR_CTR_DRBG_ENTROPY_SOURCE_FAILED on failure.
Paul Bakker0e04d0e2011-11-27 14:46:59 +0000166 */
Manuel Pégourié-Gonnard8d128ef2015-04-28 22:38:08 +0200167int mbedtls_ctr_drbg_seed( mbedtls_ctr_drbg_context *ctx,
Paul Bakker0e04d0e2011-11-27 14:46:59 +0000168 int (*f_entropy)(void *, unsigned char *, size_t),
169 void *p_entropy,
Paul Bakker1bc9efc2011-12-03 11:29:32 +0000170 const unsigned char *custom,
Paul Bakker0e04d0e2011-11-27 14:46:59 +0000171 size_t len );
172
173/**
Rose Zadik2f8163d2018-01-25 21:55:14 +0000174 * \brief This function clears CTR_CRBG context data.
Paul Bakkerfff03662014-06-18 16:21:25 +0200175 *
Rose Zadik2f8163d2018-01-25 21:55:14 +0000176 * \param ctx The CTR_DRBG context to clear.
Paul Bakkerfff03662014-06-18 16:21:25 +0200177 */
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200178void mbedtls_ctr_drbg_free( mbedtls_ctr_drbg_context *ctx );
Paul Bakkerfff03662014-06-18 16:21:25 +0200179
180/**
Rose Zadik2f8163d2018-01-25 21:55:14 +0000181 * \brief This function turns prediction resistance on or off.
182 * The default value is off.
Paul Bakker0e04d0e2011-11-27 14:46:59 +0000183 *
Rose Zadik2f8163d2018-01-25 21:55:14 +0000184 * \note If enabled, entropy is gathered at the beginning of
185 * every call to mbedtls_ctr_drbg_random_with_add().
186 * Only use this if your entropy source has sufficient
187 * throughput.
Paul Bakker0e04d0e2011-11-27 14:46:59 +0000188 *
Rose Zadik2f8163d2018-01-25 21:55:14 +0000189 * \param ctx The CTR_DRBG context.
190 * \param resistance #MBEDTLS_CTR_DRBG_PR_ON or #MBEDTLS_CTR_DRBG_PR_OFF.
Paul Bakker0e04d0e2011-11-27 14:46:59 +0000191 */
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200192void mbedtls_ctr_drbg_set_prediction_resistance( mbedtls_ctr_drbg_context *ctx,
Paul Bakker0e04d0e2011-11-27 14:46:59 +0000193 int resistance );
194
195/**
Rose Zadik2f8163d2018-01-25 21:55:14 +0000196 * \brief This function sets the amount of entropy grabbed on each
197 * seed or reseed. The default value is
198 * #MBEDTLS_CTR_DRBG_ENTROPY_LEN.
Paul Bakker0e04d0e2011-11-27 14:46:59 +0000199 *
Rose Zadik2f8163d2018-01-25 21:55:14 +0000200 * \param ctx The CTR_DRBG context.
201 * \param len The amount of entropy to grab.
Paul Bakker0e04d0e2011-11-27 14:46:59 +0000202 */
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200203void mbedtls_ctr_drbg_set_entropy_len( mbedtls_ctr_drbg_context *ctx,
Paul Bakker0e04d0e2011-11-27 14:46:59 +0000204 size_t len );
205
206/**
Rose Zadik2f8163d2018-01-25 21:55:14 +0000207 * \brief This function sets the reseed interval.
208 * The default value is #MBEDTLS_CTR_DRBG_RESEED_INTERVAL.
Paul Bakker0e04d0e2011-11-27 14:46:59 +0000209 *
Rose Zadik2f8163d2018-01-25 21:55:14 +0000210 * \param ctx The CTR_DRBG context.
211 * \param interval The reseed interval.
Paul Bakker0e04d0e2011-11-27 14:46:59 +0000212 */
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200213void mbedtls_ctr_drbg_set_reseed_interval( mbedtls_ctr_drbg_context *ctx,
Paul Bakker0e04d0e2011-11-27 14:46:59 +0000214 int interval );
215
216/**
Rose Zadik2f8163d2018-01-25 21:55:14 +0000217 * \brief This function reseeds the CTR_DRBG context, that is
218 * extracts data from the entropy source.
Paul Bakker9af723c2014-05-01 13:03:14 +0200219 *
Rose Zadik2f8163d2018-01-25 21:55:14 +0000220 * \param ctx The CTR_DRBG context.
221 * \param additional Additional data to add to the state. Can be NULL.
222 * \param len The length of the additional data.
Paul Bakker0e04d0e2011-11-27 14:46:59 +0000223 *
Rose Zadikc9474eb2018-03-27 10:58:22 +0100224 * \return \c 0 on success.
225 * \return #MBEDTLS_ERR_CTR_DRBG_ENTROPY_SOURCE_FAILED on failure.
Paul Bakker0e04d0e2011-11-27 14:46:59 +0000226 */
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200227int mbedtls_ctr_drbg_reseed( mbedtls_ctr_drbg_context *ctx,
Paul Bakker1bc9efc2011-12-03 11:29:32 +0000228 const unsigned char *additional, size_t len );
Paul Bakker0e04d0e2011-11-27 14:46:59 +0000229
230/**
Rose Zadikc9474eb2018-03-27 10:58:22 +0100231 * \brief This function updates the state of the CTR_DRBG context.
Paul Bakker0e04d0e2011-11-27 14:46:59 +0000232 *
Rose Zadikc9474eb2018-03-27 10:58:22 +0100233 * \note If \p add_len is greater than
234 * #MBEDTLS_CTR_DRBG_MAX_SEED_INPUT, only the first
235 * #MBEDTLS_CTR_DRBG_MAX_SEED_INPUT Bytes are used.
236 * The remaining Bytes are silently discarded.
Manuel Pégourié-Gonnard5cb4b312014-11-25 17:41:50 +0100237 *
Rose Zadikc9474eb2018-03-27 10:58:22 +0100238 * \param ctx The CTR_DRBG context.
239 * \param additional The data to update the state with.
240 * \param add_len Length of \p additional data.
241 *
Paul Bakker0e04d0e2011-11-27 14:46:59 +0000242 */
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200243void mbedtls_ctr_drbg_update( mbedtls_ctr_drbg_context *ctx,
Paul Bakkerfc754a92011-12-05 13:23:51 +0000244 const unsigned char *additional, size_t add_len );
Paul Bakker0e04d0e2011-11-27 14:46:59 +0000245
246/**
Rose Zadik2f8163d2018-01-25 21:55:14 +0000247 * \brief This function updates a CTR_DRBG instance with additional
248 * data and uses it to generate random data.
Paul Bakker0e04d0e2011-11-27 14:46:59 +0000249 *
Rose Zadik2f8163d2018-01-25 21:55:14 +0000250 * \note The function automatically reseeds if the reseed counter is exceeded.
Paul Bakker0e04d0e2011-11-27 14:46:59 +0000251 *
Rose Zadik2f8163d2018-01-25 21:55:14 +0000252 * \param p_rng The CTR_DRBG context. This must be a pointer to a
253 * #mbedtls_ctr_drbg_context structure.
254 * \param output The buffer to fill.
255 * \param output_len The length of the buffer.
256 * \param additional Additional data to update. Can be NULL.
257 * \param add_len The length of the additional data.
Paul Bakker0e04d0e2011-11-27 14:46:59 +0000258 *
Rose Zadikc9474eb2018-03-27 10:58:22 +0100259 * \return \c 0 on success.
260 * \return #MBEDTLS_ERR_CTR_DRBG_ENTROPY_SOURCE_FAILED or
Rose Zadik2f8163d2018-01-25 21:55:14 +0000261 * #MBEDTLS_ERR_CTR_DRBG_REQUEST_TOO_BIG on failure.
Paul Bakker0e04d0e2011-11-27 14:46:59 +0000262 */
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200263int mbedtls_ctr_drbg_random_with_add( void *p_rng,
Paul Bakker0e04d0e2011-11-27 14:46:59 +0000264 unsigned char *output, size_t output_len,
Paul Bakker1bc9efc2011-12-03 11:29:32 +0000265 const unsigned char *additional, size_t add_len );
Paul Bakker0e04d0e2011-11-27 14:46:59 +0000266
267/**
Rose Zadik2f8163d2018-01-25 21:55:14 +0000268 * \brief This function uses CTR_DRBG to generate random data.
Paul Bakker0e04d0e2011-11-27 14:46:59 +0000269 *
Rose Zadik2f8163d2018-01-25 21:55:14 +0000270 * \note The function automatically reseeds if the reseed counter is exceeded.
Paul Bakker0e04d0e2011-11-27 14:46:59 +0000271 *
Rose Zadik2f8163d2018-01-25 21:55:14 +0000272 * \param p_rng The CTR_DRBG context. This must be a pointer to a
273 * #mbedtls_ctr_drbg_context structure.
274 * \param output The buffer to fill.
275 * \param output_len The length of the buffer.
Paul Bakker0e04d0e2011-11-27 14:46:59 +0000276 *
Rose Zadikc9474eb2018-03-27 10:58:22 +0100277 * \return \c 0 on success.
278 * \return #MBEDTLS_ERR_CTR_DRBG_ENTROPY_SOURCE_FAILED or
Rose Zadik2f8163d2018-01-25 21:55:14 +0000279 * #MBEDTLS_ERR_CTR_DRBG_REQUEST_TOO_BIG on failure.
Paul Bakker0e04d0e2011-11-27 14:46:59 +0000280 */
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200281int mbedtls_ctr_drbg_random( void *p_rng,
Paul Bakker0e04d0e2011-11-27 14:46:59 +0000282 unsigned char *output, size_t output_len );
283
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200284#if defined(MBEDTLS_FS_IO)
Paul Bakkerfc754a92011-12-05 13:23:51 +0000285/**
Rose Zadik2f8163d2018-01-25 21:55:14 +0000286 * \brief This function writes a seed file.
Paul Bakkerfc754a92011-12-05 13:23:51 +0000287 *
Rose Zadik2f8163d2018-01-25 21:55:14 +0000288 * \param ctx The CTR_DRBG context.
289 * \param path The name of the file.
Paul Bakkerfc754a92011-12-05 13:23:51 +0000290 *
Rose Zadikc9474eb2018-03-27 10:58:22 +0100291 * \return \c 0 on success.
Rose Zadikf25eb6e2018-04-16 14:51:52 +0100292 * \return #MBEDTLS_ERR_CTR_DRBG_FILE_IO_ERROR on file error.
293 * \return #MBEDTLS_ERR_CTR_DRBG_ENTROPY_SOURCE_FAILED on
Rose Zadik2f8163d2018-01-25 21:55:14 +0000294 * failure.
Paul Bakkerfc754a92011-12-05 13:23:51 +0000295 */
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200296int mbedtls_ctr_drbg_write_seed_file( mbedtls_ctr_drbg_context *ctx, const char *path );
Paul Bakkerfc754a92011-12-05 13:23:51 +0000297
298/**
Rose Zadik2f8163d2018-01-25 21:55:14 +0000299 * \brief This function reads and updates a seed file. The seed
300 * is added to this instance.
Paul Bakkerfc754a92011-12-05 13:23:51 +0000301 *
Rose Zadik2f8163d2018-01-25 21:55:14 +0000302 * \param ctx The CTR_DRBG context.
303 * \param path The name of the file.
Paul Bakkerfc754a92011-12-05 13:23:51 +0000304 *
Rose Zadikc9474eb2018-03-27 10:58:22 +0100305 * \return \c 0 on success.
306 * \return #MBEDTLS_ERR_CTR_DRBG_FILE_IO_ERROR on file error.
307 * \return #MBEDTLS_ERR_CTR_DRBG_ENTROPY_SOURCE_FAILED or
Rose Zadik2f8163d2018-01-25 21:55:14 +0000308 * #MBEDTLS_ERR_CTR_DRBG_INPUT_TOO_BIG on failure.
Paul Bakkerfc754a92011-12-05 13:23:51 +0000309 */
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200310int mbedtls_ctr_drbg_update_seed_file( mbedtls_ctr_drbg_context *ctx, const char *path );
311#endif /* MBEDTLS_FS_IO */
Paul Bakkerfc754a92011-12-05 13:23:51 +0000312
Ron Eldorfa8f6352017-06-20 15:48:46 +0300313#if defined(MBEDTLS_SELF_TEST)
314
Paul Bakker0e04d0e2011-11-27 14:46:59 +0000315/**
Rose Zadik2f8163d2018-01-25 21:55:14 +0000316 * \brief The CTR_DRBG checkup routine.
Paul Bakker0e04d0e2011-11-27 14:46:59 +0000317 *
Rose Zadikc9474eb2018-03-27 10:58:22 +0100318 * \return \c 0 on success.
319 * \return \c 1 on failure.
Paul Bakker0e04d0e2011-11-27 14:46:59 +0000320 */
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200321int mbedtls_ctr_drbg_self_test( int verbose );
Paul Bakker0e04d0e2011-11-27 14:46:59 +0000322
Ron Eldorfa8f6352017-06-20 15:48:46 +0300323#endif /* MBEDTLS_SELF_TEST */
324
Paul Bakker534f82c2013-06-25 16:47:55 +0200325/* Internal functions (do not call directly) */
Manuel Pégourié-Gonnard8d128ef2015-04-28 22:38:08 +0200326int mbedtls_ctr_drbg_seed_entropy_len( mbedtls_ctr_drbg_context *,
Paul Bakkerb9e4e2c2014-05-01 14:18:25 +0200327 int (*)(void *, unsigned char *, size_t), void *,
328 const unsigned char *, size_t, size_t );
Paul Bakker534f82c2013-06-25 16:47:55 +0200329
Paul Bakker0e04d0e2011-11-27 14:46:59 +0000330#ifdef __cplusplus
331}
332#endif
333
334#endif /* ctr_drbg.h */