7 - generate random bytes using the given drbg instance
11 #include <openssl/rand_drbg.h>
13 int RAND_DRBG_generate(RAND_DRBG *drbg,
14 unsigned char *out, size_t outlen,
15 int prediction_resistance,
16 const unsigned char *adin, size_t adinlen);
18 int RAND_DRBG_bytes(RAND_DRBG *drbg,
19 unsigned char *out, size_t outlen);
24 RAND_DRBG_generate() generates B<outlen> random bytes using the given
25 DRBG instance B<drbg> and stores them in the buffer at B<out>.
27 Before generating the output, the DRBG instance checks whether the maximum
28 number of generate requests (I<reseed interval>) or the maximum timespan
29 (I<reseed time interval>) since its last seeding have been reached.
30 If this is the case, the DRBG reseeds automatically.
31 Additionally, an immediate reseeding can be requested by setting the
32 B<prediction_resistance> flag to 1.
33 Requesting prediction resistance is a relative expensive operation.
34 See NOTES section for more details.
36 The caller can optionally provide additional data to be used for reseeding
37 by passing a pointer B<adin> to a buffer of length B<adinlen>.
38 This additional data is mixed into the internal state of the random
39 generator but does not contribute to the entropy count.
40 The additional data can be omitted by setting B<adin> to NULL and
43 RAND_DRBG_bytes() generates B<outlen> random bytes using the given
44 DRBG instance B<drbg> and stores them in the buffer at B<out>.
45 This function is a wrapper around the RAND_DRBG_generate() call,
46 which collects some additional data from low entropy sources
47 (e.g., a high resolution timer) and calls
48 RAND_DRBG_generate(drbg, out, outlen, 0, adin, adinlen).
53 RAND_DRBG_generate() and RAND_DRBG_bytes() return 1 on success,
58 The I<reseed interval> and I<reseed time interval> of the B<drbg> are set to
59 reasonable default values, which in general do not have to be adjusted.
60 If necessary, they can be changed using L<RAND_DRBG_set_reseed_interval(3)>
61 and L<RAND_DRBG_set_reseed_time_interval(3)>, respectively.
63 A request for prediction resistance can only be satisfied by pulling fresh
64 entropy from a live entropy source (section 5.5.2 of [NIST SP 800-90C]).
65 It is up to the user to ensure that a live entropy source is configured
71 L<RAND_DRBG_set_reseed_interval(3)>,
72 L<RAND_DRBG_set_reseed_time_interval(3)>,
77 The RAND_DRBG functions were added in OpenSSL 1.1.1.
79 Prediction resistance is supported from OpenSSL 3.0.
83 Copyright 2017-2019 The OpenSSL Project Authors. All Rights Reserved.
85 Licensed under the Apache License 2.0 (the "License"). You may not use
86 this file except in compliance with the License. You can obtain a copy
87 in the file LICENSE in the source distribution or at
88 L<https://www.openssl.org/source/license.html>.