RAND_set_DRBG_type¶
NAME¶
RAND_set_DRBG_type, RAND_set_seed_source_type - specify the global random number generator types
SYNOPSIS¶
#include <openssl/rand.h>
int RAND_set_DRBG_type(OSSL_LIB_CTX *ctx, const char *drbg, const char *propq,
const char *cipher, const char *digest);
int RAND_set_seed_source_type(OSSL_LIB_CTX *ctx, const char *seed,
const char *propq);
DESCRIPTION¶
RAND_set_DRBG_type() specifies the random bit generator that will be used within the library context ctx. A generator of name drbg with properties propq will be fetched. It will be instantiated with either cipher or digest as its underlying cryptographic algorithm. This specifies the type that will be used for the primary, public and private random instances.
RAND_set_seed_source_type() specifies the seed source that will be used within the library context ctx. The seed source of name seed with properties propq will be fetched and used to seed the primary random bit generator.
RETURN VALUES¶
These function return 1 on success and 0 on failure.
NOTES¶
These functions must be called before the random bit generators are first created in the library context. They will return an error if the call is made too late.
Note that with strict seeding, enabled via the seed_strict option of the random configuration section, used by default for the JITTER seed source or implied by an enable-fips-jitter build, a provider (for example the FIPS provider) requesting entropy or a nonce instantiates the seed source before the application's first use of it. RAND_set_seed_source_type() fails once this happens.
The default DRBG is "CTR-DRBG" using the "AES-256-CTR" cipher.
The default seed source can be configured when OpenSSL is compiled by setting -DOPENSSL_DEFAULT_SEED_SRC=SEED-SRC. If not set then "SEED-SRC" is used. The property query used when fetching the default seed source can similarly be set with -DOPENSSL_DEFAULT_SEED_PROPQ.
EXAMPLES¶
unsigned char bytes[100];
RAND_set_seed_source_type(NULL, "JITTER", NULL);
RAND_bytes(bytes, 100);
SEE ALSO¶
EVP_RAND(3), RAND_get0_primary(3)
HISTORY¶
These functions were added in OpenSSL 3.0.
COPYRIGHT¶
Copyright 2021-2026 The OpenSSL Project Authors. All Rights Reserved.
Licensed under the Apache License 2.0 (the "License"). You may not use this file except in compliance with the License. You can obtain a copy in the file LICENSE in the source distribution or at https://www.openssl.org/source/license.html.