EVP_RAND-TEST-RAND(7ossl)
π EVP_RAND-TEST-RAND π
okay so real talk β this is the manpage for EVP_RAND-TEST-RAND, and it lives in the 7ossl manual (that's the OpenSSL corner of manpage-land, iykyk). Buckle up bestie, it's a fake random generator and it's kind of iconic for it. π
β¨ NAME β¨
EVP_RAND-TEST-RAND β the test EVP_RAND implementation. yes, the whole personality is "I am a test". π
π¦ DESCRIPTION π¦
So there's support for a test generator that you reach through the EVP_RAND API. And listen. This generator is for test purposes only β it does not generate random numbers. Like, at all. That's the entire bit. Not me being dramatic, that's literally the spec. π
πΈ Identity πΈ
"TEST-RAND" is the name of this implementation. That's the string you hand to EVP_RAND_fetch(). no cap, that's it, that's the identity. β¨
π Supported parameters π
Here's everything it supports, and yes we're listing all of them because you deserve the full picture:
"state"(OSSL_RAND_PARAM_STATE)<integer>β works as described in "PARAMETERS" inEVP_RAND(3)."fips-indicator"(OSSL_RAND_PARAM_FIPS_APPROVED_INDICATOR)<integer>β also works as described in "PARAMETERS" inEVP_RAND(3).
Those two? Straight up the standard behaviour from EVP_RAND(3), no twists.
Now the next bunch β these all work as described in "PARAMETERS" in EVP_RAND(3) except that they can all be set as well as read. Read and write, both directions, we love a two-way street:
"strength"(OSSL_RAND_PARAM_STRENGTH)<unsigned integer>"reseed_requests"(OSSL_DRBG_PARAM_RESEED_REQUESTS)<unsigned integer>"reseed_time_interval"(OSSL_DRBG_PARAM_RESEED_TIME_INTERVAL)<integer>"max_request"(OSSL_DRBG_PARAM_RESEED_REQUESTS)<unsigned 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>
And then the three that are actually the fun ones:
"test_entropy"(OSSL_RAND_PARAM_TEST_ENTROPY)<octet string>β this sets the bytes that come back when the test generator gets an entropy request. The current position is remembered across generate calls, so it's not restarting every time (main character memory π ). And if there aren't enough data present to satisfy a call? Error. Straight up returned. π"test_nonce"(OSSL_RAND_PARAM_TEST_NONCE)<octet string>β this sets the bytes returned when the test generator gets a nonce request. Every single nonce request returns all of the bytes. all of them. no rationing. π₯"generate"(OSSL_RAND_PARAM_GENERATE)<integer>β if this parameter is zero, it only emits the nonce and entropy data you fed it via the parameters above. Otherwise, low quality non-cryptographic pseudorandom output gets produced. This parameter defaults to zero. β
heads up bestie: "low quality non-cryptographic pseudorandom output" is exactly what it says. do not be putting this in production crypto. it's a test generator, it's cosplaying. π«Ά
π NOTES π
You get yourself a context for a test generator like this:
EVP_RAND *rand = EVP_RAND_fetch(NULL, "TEST-RAND", NULL);
EVP_RAND_CTX *rctx = EVP_RAND_CTX_new(rand, NULL);
two lines, that's the whole ritual. π§
π EXAMPLES π
full example, here you go, do not perceive me:
EVP_RAND *rand;
EVP_RAND_CTX *rctx;
unsigned char bytes[100];
OSSL_PARAM params[4], *p = params;
unsigned char entropy[1000] = { ... };
unsigned char nonce[20] = { ... };
unsigned int strength = 48;
rand = EVP_RAND_fetch(NULL, "TEST-RAND", NULL);
rctx = EVP_RAND_CTX_new(rand, NULL);
EVP_RAND_free(rand);
*p++ = OSSL_PARAM_construct_uint(OSSL_RAND_PARAM_STRENGTH, &strength);
*p++ = OSSL_PARAM_construct_octet_string(OSSL_RAND_PARAM_TEST_ENTROPY,
entropy, sizeof(entropy));
*p++ = OSSL_PARAM_construct_octet_string(OSSL_RAND_PARAM_TEST_NONCE,
nonce, sizeof(nonce));
*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);
not the { ... } in there β that's literally how it's written here, you fill in your own bytes. obsessed. π
π SEE ALSO π
EVP_RAND(3), and "PARAMETERS" in EVP_RAND(3). go read those, they ate. β¨
π¦ HISTORY π¦
This functionality was added in OpenSSL 3.0. so it's been here a minute. β
π COPYRIGHT π
Copyright 2020-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 page, bestie π
β brought to you by OpenSSL 3.5.9, dated 2026-09-29, filed under EVP_RAND-TEST-RAND(7ossl). mwah, go write some tests πβ¨
π¦ 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