]> git.ipfire.org Git - thirdparty/openssl.git/blame - doc/man3/RAND_DRBG_generate.pod
In documentation, consistently refer to OpenSSL 3.0
[thirdparty/openssl.git] / doc / man3 / RAND_DRBG_generate.pod
CommitLineData
a73d990e
DMSP
1=pod
2
3=head1 NAME
4
5RAND_DRBG_generate,
6RAND_DRBG_bytes
7- generate random bytes using the given drbg instance
8
9=head1 SYNOPSIS
10
11 #include <openssl/rand_drbg.h>
12
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);
17
18 int RAND_DRBG_bytes(RAND_DRBG *drbg,
19 unsigned char *out, size_t outlen);
20
21
22=head1 DESCRIPTION
23
24RAND_DRBG_generate() generates B<outlen> random bytes using the given
25DRBG instance B<drbg> and stores them in the buffer at B<out>.
26
27Before generating the output, the DRBG instance checks whether the maximum
28number of generate requests (I<reseed interval>) or the maximum timespan
29(I<reseed time interval>) since its last seeding have been reached.
30If this is the case, the DRBG reseeds automatically.
31Additionally, an immediate reseeding can be requested by setting the
65175163
P
32B<prediction_resistance> flag to 1.
33Requesting prediction resistance is a relative expensive operation.
34See NOTES section for more details.
a73d990e
DMSP
35
36The caller can optionally provide additional data to be used for reseeding
37by passing a pointer B<adin> to a buffer of length B<adinlen>.
38This additional data is mixed into the internal state of the random
39generator but does not contribute to the entropy count.
40The additional data can be omitted by setting B<adin> to NULL and
41B<adinlen> to 0;
42
43RAND_DRBG_bytes() generates B<outlen> random bytes using the given
44DRBG instance B<drbg> and stores them in the buffer at B<out>.
45This function is a wrapper around the RAND_DRBG_generate() call,
46which collects some additional data from low entropy sources
47(e.g., a high resolution timer) and calls
48RAND_DRBG_generate(drbg, out, outlen, 0, adin, adinlen).
49
50
51=head1 RETURN VALUES
52
53RAND_DRBG_generate() and RAND_DRBG_bytes() return 1 on success,
54and 0 on failure.
55
56=head1 NOTES
57
58The I<reseed interval> and I<reseed time interval> of the B<drbg> are set to
59reasonable default values, which in general do not have to be adjusted.
60If necessary, they can be changed using L<RAND_DRBG_set_reseed_interval(3)>
61and L<RAND_DRBG_set_reseed_time_interval(3)>, respectively.
62
63A request for prediction resistance can only be satisfied by pulling fresh
65175163
P
64entropy from a live entropy source (section 5.5.2 of [NIST SP 800-90C]).
65It is up to the user to ensure that a live entropy source is configured
66and is being used.
a73d990e 67
a73d990e
DMSP
68=head1 SEE ALSO
69
70L<RAND_bytes(3)>,
71L<RAND_DRBG_set_reseed_interval(3)>,
72L<RAND_DRBG_set_reseed_time_interval(3)>,
73L<RAND_DRBG(7)>
74
b5c4bbbe
JL
75=head1 HISTORY
76
77The RAND_DRBG functions were added in OpenSSL 1.1.1.
78
4674aaf4 79Prediction resistance is supported from OpenSSL 3.0.
b5c4bbbe 80
a73d990e
DMSP
81=head1 COPYRIGHT
82
b5c4bbbe 83Copyright 2017-2019 The OpenSSL Project Authors. All Rights Reserved.
a73d990e 84
4746f25a 85Licensed under the Apache License 2.0 (the "License"). You may not use
a73d990e
DMSP
86this file except in compliance with the License. You can obtain a copy
87in the file LICENSE in the source distribution or at
88L<https://www.openssl.org/source/license.html>.
89
90=cut