RAND_SET_DRBG_TYPE(3ossl)
π NAME π
okay so welcome to the RAND_SET_DRBG_TYPE(3ossl) page, bestie β¨ the main characters are RAND_set_DRBG_type and RAND_set_seed_source_type, and their whole thing is to specify the global random number generator types π no cap.
π SYNOPSIS π
first you pull in the header π«Ά
#include <openssl/rand.h>
then the function signatures are literally:
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() does the βwhich DRBG are we usingβ thing for the library context ctx π«Ά It 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. Thatβs the whole assignment, periodt π
RAND_set_seed_source_type() handles the seed-source side of the vibe check π± It 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 functions return 1 on success and 0 on failure. Thatβs it, thatβs the whole dramatic arc πβ¨
π¦ NOTES π¦
- timing is everything, bestie β 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. Like, do not wait until after the RNG has already entered the chat π
- The default DRBG is
"CTR-DRBG"using the"AES-256-CTR"cipher. iconic defaults, honestly π - 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.
π EXAMPLES π
hereβs the example exactly as the page gives it β seed source set to "JITTER", then bytes go brrr π§
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) β go read these next, iykyk π
β HISTORY β
These functions were added in OpenSSL 3.0. periodt.
π COPYRIGHT π
Copyright 2021-2024 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>.
π and thatβs the whole RAND_SET_DRBG_TYPE(3ossl) moment, bestie β this gem is from OpenSSL 3.5.0, dated 2026-09-25. go forth and enjoy the DRBG vibes π§β¨
π¦ where this page comes from
- opensuse-leap 16.0: openssl-3-doc 3.5.0-160000.11.1 Β· Apache-2.0
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms