2018-02-28 02:02:24 +08:00
|
|
|
=pod
|
|
|
|
|
|
|
|
=head1 NAME
|
|
|
|
|
2019-05-29 23:03:57 +08:00
|
|
|
RAND_DRBG_new_ex,
|
2018-02-28 02:02:24 +08:00
|
|
|
RAND_DRBG_new,
|
2019-05-29 23:03:57 +08:00
|
|
|
RAND_DRBG_secure_new_ex,
|
2018-02-28 02:02:24 +08:00
|
|
|
RAND_DRBG_secure_new,
|
|
|
|
RAND_DRBG_set,
|
|
|
|
RAND_DRBG_set_defaults,
|
|
|
|
RAND_DRBG_instantiate,
|
|
|
|
RAND_DRBG_uninstantiate,
|
|
|
|
RAND_DRBG_free
|
|
|
|
- initialize and cleanup a RAND_DRBG instance
|
|
|
|
|
|
|
|
=head1 SYNOPSIS
|
|
|
|
|
|
|
|
#include <openssl/rand_drbg.h>
|
|
|
|
|
2019-05-29 23:03:57 +08:00
|
|
|
RAND_DRBG *RAND_DRBG_new_ex(OPENSSL_CTX *ctx,
|
|
|
|
int type,
|
|
|
|
unsigned int flags,
|
|
|
|
RAND_DRBG *parent);
|
2018-02-28 02:02:24 +08:00
|
|
|
|
|
|
|
RAND_DRBG *RAND_DRBG_new(int type,
|
|
|
|
unsigned int flags,
|
|
|
|
RAND_DRBG *parent);
|
|
|
|
|
2019-05-29 23:03:57 +08:00
|
|
|
RAND_DRBG *RAND_DRBG_secure_new_ex(OPENSSL_CTX *ctx,
|
|
|
|
int type,
|
|
|
|
unsigned int flags,
|
|
|
|
RAND_DRBG *parent);
|
|
|
|
|
2018-02-28 02:02:24 +08:00
|
|
|
RAND_DRBG *RAND_DRBG_secure_new(int type,
|
|
|
|
unsigned int flags,
|
|
|
|
RAND_DRBG *parent);
|
|
|
|
|
|
|
|
int RAND_DRBG_set(RAND_DRBG *drbg,
|
|
|
|
int type, unsigned int flags);
|
|
|
|
|
|
|
|
int RAND_DRBG_set_defaults(int type, unsigned int flags);
|
|
|
|
|
|
|
|
int RAND_DRBG_instantiate(RAND_DRBG *drbg,
|
|
|
|
const unsigned char *pers, size_t perslen);
|
|
|
|
|
|
|
|
int RAND_DRBG_uninstantiate(RAND_DRBG *drbg);
|
|
|
|
|
|
|
|
void RAND_DRBG_free(RAND_DRBG *drbg);
|
|
|
|
|
|
|
|
|
|
|
|
=head1 DESCRIPTION
|
|
|
|
|
2019-05-29 23:03:57 +08:00
|
|
|
RAND_DRBG_new_ex() and RAND_DRBG_secure_new_ex()
|
2018-02-28 02:02:24 +08:00
|
|
|
create a new DRBG instance of the given B<type>, allocated from the heap resp.
|
2019-05-29 23:03:57 +08:00
|
|
|
the secure heap, for the given OPENSSL_CTX <ctx>
|
|
|
|
(using OPENSSL_zalloc() resp. OPENSSL_secure_zalloc()). The <ctx> parameter can
|
|
|
|
be NULL in which case the default OPENSSL_CTX is used. RAND_DRBG_new() and
|
|
|
|
RAND_DRBG_secure_new() are the same as RAND_DRBG_new_ex() and
|
|
|
|
RAND_DRBG_secure_new_ex() except that the default OPENSSL_CTX is always used.
|
2018-02-28 02:02:24 +08:00
|
|
|
|
|
|
|
RAND_DRBG_set() initializes the B<drbg> with the given B<type> and B<flags>.
|
|
|
|
|
|
|
|
RAND_DRBG_set_defaults() sets the default B<type> and B<flags> for new DRBG
|
|
|
|
instances.
|
|
|
|
|
2018-07-24 09:16:38 +08:00
|
|
|
The DRBG types are AES-CTR, HMAC and HASH so B<type> can be one of the
|
|
|
|
following values:
|
|
|
|
|
|
|
|
NID_aes_128_ctr, NID_aes_192_ctr, NID_aes_256_ctr, NID_sha1, NID_sha224,
|
|
|
|
NID_sha256, NID_sha384, NID_sha512, NID_sha512_224, NID_sha512_256,
|
|
|
|
NID_sha3_224, NID_sha3_256, NID_sha3_384 or NID_sha3_512.
|
|
|
|
|
2018-10-02 07:25:59 +08:00
|
|
|
If this method is not called then the default type is given by NID_aes_256_ctr
|
|
|
|
and the default flags are zero.
|
2018-07-24 09:16:38 +08:00
|
|
|
|
2018-02-28 02:02:24 +08:00
|
|
|
Before the DRBG can be used to generate random bits, it is necessary to set
|
|
|
|
its type and to instantiate it.
|
|
|
|
|
|
|
|
The optional B<flags> argument specifies a set of bit flags which can be
|
2018-07-24 09:16:38 +08:00
|
|
|
joined using the | operator. The supported flags are:
|
|
|
|
|
|
|
|
=over 4
|
|
|
|
|
|
|
|
=item RAND_DRBG_FLAG_CTR_NO_DF
|
|
|
|
|
|
|
|
Disables the use of the derivation function ctr_df. For an explanation,
|
|
|
|
see [NIST SP 800-90A Rev. 1].
|
|
|
|
|
|
|
|
=item RAND_DRBG_FLAG_HMAC
|
|
|
|
|
|
|
|
Enables use of HMAC instead of the HASH DRBG.
|
|
|
|
|
|
|
|
=item RAND_DRBG_FLAG_MASTER
|
|
|
|
|
|
|
|
=item RAND_DRBG_FLAG_PUBLIC
|
|
|
|
|
|
|
|
=item RAND_DRBG_FLAG_PRIVATE
|
|
|
|
|
|
|
|
These 3 flags can be used to set the individual DRBG types created. Multiple
|
|
|
|
calls are required to set the types to different values. If none of these 3
|
2018-10-02 07:25:59 +08:00
|
|
|
flags are used, then the same type and flags are used for all 3 DRBGs in the
|
|
|
|
B<drbg> chain (<master>, <public> and <private>).
|
2018-07-24 09:16:38 +08:00
|
|
|
|
|
|
|
=back
|
2018-02-28 02:02:24 +08:00
|
|
|
|
|
|
|
If a B<parent> instance is specified then this will be used instead of
|
|
|
|
the default entropy source for reseeding the B<drbg>. It is said that the
|
|
|
|
B<drbg> is I<chained> to its B<parent>.
|
|
|
|
For more information, see the NOTES section.
|
|
|
|
|
|
|
|
|
|
|
|
RAND_DRBG_instantiate()
|
|
|
|
seeds the B<drbg> instance using random input from trusted entropy sources.
|
|
|
|
Optionally, a personalization string B<pers> of length B<perslen> can be
|
|
|
|
specified.
|
|
|
|
To omit the personalization string, set B<pers>=NULL and B<perslen>=0;
|
|
|
|
|
|
|
|
RAND_DRBG_uninstantiate()
|
|
|
|
clears the internal state of the B<drbg> and puts it back in the
|
|
|
|
uninstantiated state.
|
|
|
|
|
|
|
|
=head1 RETURN VALUES
|
|
|
|
|
|
|
|
|
2019-05-29 23:03:57 +08:00
|
|
|
RAND_DRBG_new_ex(), RAND_DRBG_new(), RAND_DRBG_secure_new_ex() and
|
|
|
|
RAND_DRBG_secure_new() return a pointer to a DRBG instance allocated on the
|
|
|
|
heap, resp. secure heap.
|
2018-02-28 02:02:24 +08:00
|
|
|
|
|
|
|
RAND_DRBG_set(),
|
|
|
|
RAND_DRBG_instantiate(), and
|
|
|
|
RAND_DRBG_uninstantiate()
|
|
|
|
return 1 on success, and 0 on failure.
|
|
|
|
|
|
|
|
RAND_DRBG_free() does not return a value.
|
|
|
|
|
|
|
|
=head1 NOTES
|
|
|
|
|
|
|
|
The DRBG design supports I<chaining>, which means that a DRBG instance can
|
|
|
|
use another B<parent> DRBG instance instead of the default entropy source
|
|
|
|
to obtain fresh random input for reseeding, provided that B<parent> DRBG
|
|
|
|
instance was properly instantiated, either from a trusted entropy source,
|
|
|
|
or from yet another parent DRBG instance.
|
|
|
|
For a detailed description of the reseeding process, see L<RAND_DRBG(7)>.
|
|
|
|
|
|
|
|
The default DRBG type and flags are applied only during creation of a DRBG
|
|
|
|
instance.
|
|
|
|
To ensure that they are applied to the global and thread-local DRBG instances
|
|
|
|
(<master>, resp. <public> and <private>), it is necessary to call
|
|
|
|
RAND_DRBG_set_defaults() before creating any thread and before calling any
|
|
|
|
cryptographic routines that obtain random data directly or indirectly.
|
|
|
|
|
|
|
|
=head1 SEE ALSO
|
|
|
|
|
|
|
|
L<OPENSSL_zalloc(3)>,
|
|
|
|
L<OPENSSL_secure_zalloc(3)>,
|
|
|
|
L<RAND_DRBG_generate(3)>,
|
|
|
|
L<RAND_DRBG(7)>
|
|
|
|
|
2019-04-09 22:13:55 +08:00
|
|
|
=head1 HISTORY
|
|
|
|
|
|
|
|
The RAND_DRBG functions were added in OpenSSL 1.1.1.
|
|
|
|
|
2018-02-28 02:02:24 +08:00
|
|
|
=head1 COPYRIGHT
|
|
|
|
|
2019-04-09 22:13:55 +08:00
|
|
|
Copyright 2017-2019 The OpenSSL Project Authors. All Rights Reserved.
|
2018-02-28 02:02:24 +08:00
|
|
|
|
2018-12-06 21:04:44 +08:00
|
|
|
Licensed under the Apache License 2.0 (the "License"). You may not use
|
2018-02-28 02:02:24 +08:00
|
|
|
this file except in compliance with the License. You can obtain a copy
|
|
|
|
in the file LICENSE in the source distribution or at
|
|
|
|
L<https://www.openssl.org/source/license.html>.
|
|
|
|
|
|
|
|
=cut
|