RAND_SET_DRBG_TYPE(3ossl)
π RAND_set_DRBG_type π
okay so bestie, welcome to the 3ossl manual page for RAND_set_DRBG_type and RAND_set_seed_source_type β the two functions that let you pick which random number generator the library uses. yes, the RNG. the literal source of all randomness. main character energy fr fr π²β¨
πΈ NAME πΈ
RAND_set_DRBG_type, RAND_set_seed_source_type β specify the global random number generator types. that's it, that's the whole vibe. you're choosing the types, globally, for the whole lib. no pressure π
β¨ 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);
like look at these signatures. gorgeous. iconic. chef's kiss ππ
π¦ DESCRIPTION π¦
So. 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 β yes, fetched, like it's being summoned β and 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. all three. one call. slay π
And then 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. so like, the DRBG is the generator, and the seed source is what feeds it its initial β¨inspirationβ¨. they're a team. a duo. iykyk π«Ά
π RETURN VALUES π
These functions return 1 on success and 0 on failure. that's the whole thing. 1 = good vibes, 0 = not it. check your returns, bestie, always π
π NOTES π
okay this is the part where you actually have to pay attention, no cap:
- 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. so like. be early. be punctual. don't show up to the function call after the party already started π
- The default DRBG is
"CTR-DRBG"using the"AES-256-CTR"cipher. that's the out-of-the-box setup, the default fit, the no-thoughts-just-vibes choice π - 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. so you can bake in your own default at build time, or just let"SEED-SRC"do its thing π§
β οΈ real talk: calling these too late isn't a "meh, whatever" situation β it returns an error. plan your initialization order accordingly, bestie. the RNG waits for no one π
π₯ EXAMPLES π₯
unsigned char bytes[100];
RAND_set_seed_source_type(NULL, "JITTER", NULL);
RAND_bytes(bytes, 100);
see how easy that was? set the seed source to "JITTER", then just get your 100 bytes and go. periodt. π
β¨
π SEE ALSO π
go read those next, bestie, they're lowkey essential π¦
π HISTORY π
These functions were added in OpenSSL 3.0. so they're not ancient, they're just β¨establishedβ¨. a classic. π
β 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>.
aaaand that's the page! π«Ά this was OpenSSL 3.5.6, dated 2026-04-07, page RAND_SET_DRBG_TYPE(3ossl) β go forth and seed responsibly, babe ππΈ
π¦ where this page comes from
- freebsd 15.1: base 15.1
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms