EVP_RAND-CTR-DRBG(7ossl)
π EVP_RAND-CTR-DRBG β the CTR DRBG glow-up, explained π
okay so bestie, this is the EVP_RAND-CTR-DRBG page from the OpenSSL manual set (section 7ossl), and it's literally all about the counter deterministic random bit generator and how it shows up through the EVP_RAND API. grab a lil snack, we're getting into it π
β¨ NAME β¨
EVP_RAND-CTR-DRBG β the CTR DRBG EVP_RAND implementation. that's it, that's the whole vibe. π
π¦ DESCRIPTION π¦
so this is the support for the counter deterministic random bit generator, delivered through the EVP_RAND API. iconic behavior, no cap.
π Identity π
"CTR-DRBG" is the name of this implementation β that's the string you pass in, and you can use it with the EVP_RAND_fetch() function. remember the name, bestie, it's the whole key to the door π
πΈ Supported parameters πΈ
the parameters that are supported are, and yes, we're listing every single one because we don't skip:
"state"(OSSL_RAND_PARAM_STATE)<integer>"strength"(OSSL_RAND_PARAM_STRENGTH)<unsigned integer>"max_request"(OSSL_RAND_PARAM_MAX_REQUEST)<unsigned integer>"reseed_requests"(OSSL_DRBG_PARAM_RESEED_REQUESTS)<unsigned integer>"reseed_time_interval"(OSSL_DRBG_PARAM_RESEED_TIME_INTERVAL)<integer>"min_entropylen"(OSSL_DRBG_PARAM_MIN_ENTROPYLEN)<unsigned integer>"max_entropylen"(OSSL_DRBG_PARAM_MAX_ENTROPYLEN)<unsigned integer>"min_noncelen"(OSSL_DRBG_PARAM_MIN_NONCELEN)<unsigned integer>"max_noncelen"(OSSL_DRBG_PARAM_MAX_NONCELEN)<unsigned integer>"max_perslen"(OSSL_DRBG_PARAM_MAX_PERSLEN)<unsigned integer>"max_adinlen"(OSSL_DRBG_PARAM_MAX_ADINLEN)<unsigned integer>"reseed_counter"(OSSL_DRBG_PARAM_RESEED_COUNTER)<unsigned integer>"properties"(OSSL_DRBG_PARAM_PROPERTIES)<UTF8 string>"cipher"(OSSL_DRBG_PARAM_CIPHER)<UTF8 string>
these parameters work as described in "PARAMETERS" in EVP_RAND(3). go read that one too, i'm not gatekeeping π«Ά
and then there's the two special ones:
"use_derivation_function"(OSSL_DRBG_PARAM_USE_DF)<integer>β this Boolean is the yes-or-no for whether a derivation function should be used or not. a nonzero value (which is the default, fyi) uses the derivation function. a zero value does not. simple as that, bestie."fips-indicator"(OSSL_DRBG_PARAM_FIPS_APPROVED_INDICATOR)<integer>β the OpenSSL FIPS provider returns1if the operation is FIPS approved, or0otherwise. see"FIPS indicators"infips_module(7)for the full tea β
π₯ NOTES π₯
you get yourself a context for CTR DRBG by calling, like, this:
EVP_RAND *rand = EVP_RAND_fetch(NULL, "CTR-DRBG", NULL);
EVP_RAND_CTX *rctx = EVP_RAND_CTX_new(rand, NULL);
and here's the part where you go "noted, bestie":
the default CTR-DRBG implementation attempts to fetch the required internal algorithms from the provider they are built into (eg the default provider) regardless of the properties provided. but if that provider doesn't implement the required algorithms, then properties will be used to find a different implementation. so like, properties are the backup plan, not the main character in that specific case. π
β EXAMPLES β
okay this is the part where it all comes together, look at this whole beautiful sequence:
EVP_RAND *rand;
EVP_RAND_CTX *rctx;
unsigned char bytes[100];
OSSL_PARAM params[2], *p = params;
unsigned int strength = 128;
rand = EVP_RAND_fetch(NULL, "CTR-DRBG", NULL);
rctx = EVP_RAND_CTX_new(rand, NULL);
EVP_RAND_free(rand);
*p++ = OSSL_PARAM_construct_utf8_string(OSSL_DRBG_PARAM_CIPHER,
SN_aes_256_ctr, 0);
*p = OSSL_PARAM_construct_end();
EVP_RAND_instantiate(rctx, strength, 0, NULL, 0, params);
EVP_RAND_generate(rctx, bytes, sizeof(bytes), strength, 0, NULL, 0);
EVP_RAND_CTX_free(rctx);
fetch it, wrap it in a context, free the original handle, set your cipher param to SN_aes_256_ctr, EVP_RAND_instantiate it with strength 128, generate those 100 bytes, then EVP_RAND_CTX_free at the end because we clean up after ourselves in this house π§
π CONFORMING TO π
NIST SP 800-90A and SP 800-90B. standards-approved randomness, we love to see it.
π SEE ALSO π
EVP_RAND(3)"PARAMETERS"inEVP_RAND(3)
π COPYRIGHT π
Copyright 2020-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>.
and that's the page, bestie π version 3.5.9, dated 2026-09-29, from the EVP_RAND-CTR-DRBG(7ossl) corner of the OpenSSL universe β go forth and DRBG responsibly β¨π
π¦ where this page comes from
- alpine 3.23: openssl-doc 3.5.9-r0 Β· Apache-2.0
- alpine 3.24: openssl-doc 3.5.9-r0 Β· Apache-2.0
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms