EVP_RAND-TEST-RAND(7ossl)
π EVP_RAND-TEST-RAND π
okay so this is the OpenSSL manpage for the test EVP_RAND implementation β that's the whole vibe, bestie. it's EVP_RAND-TEST-RAND from the 7ossl manual, and we're gonna get into it.
β¨ NAME β¨
EVP_RAND-TEST-RAND β the test EVP_RAND implementation. that's it, that's the name, iconic.
π¦ DESCRIPTION π¦
so there's support for a test generator through the EVP_RAND API. and like, hear me loud and clear: this generator is for test purposes only β it does NOT generate random numbers. i cannot stress this enough, it's giving "decorative but make it cryptographic-adjacent". do not use it for actual secrets, periodt.
π Identity π
"TEST-RAND" is the name for this implementation β that's its whole government name β and you can use it with the EVP_RAND_fetch() function. slay.
πΈ Supported parameters πΈ
the supported parameters are:
"state"(OSSL_RAND_PARAM_STATE)<integer>"fips-indicator"(OSSL_RAND_PARAM_FIPS_APPROVED_INDICATOR)<integer>
these parameters work as described in "PARAMETERS" in EVP_RAND(3). (yes, both of them, together, one bullet, that's how the manpage rolls.)
"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>
these parameters work as described in "PARAMETERS" in EVP_RAND(3), except that they can all be set as well as read. so you're not just reading the vibes, you're setting them too. main character energy.
"test_entropy"(OSSL_RAND_PARAM_TEST_ENTROPY)<octet string>β sets the bytes returned when the test generator is sent an entropy request. the current position is remembered across generate calls (it keeps track, okurrr π ). and if there are insufficient data present to satisfy a call, an error is returned β no improvising, no vibes-based padding."test_nonce"(OSSL_RAND_PARAM_TEST_NONCE)<octet string>β sets the bytes returned when the test generator is sent a nonce request. each nonce request will return all of the bytes. the whole thing. no positional drama here."generate"(OSSL_RAND_PARAM_GENERATE)<integer>β if this parameter is zero, it will only emit the nonce and entropy data supplied via the aforementioned parameters. otherwise, low quality non-cryptographic pseudorandom output is produced. this parameter defaults to zero. π read that again: low quality, non-cryptographic β she's fun at parties but she is not your security team.
π§ NOTES π§
you can get yourself a context for a test generator by calling this, bestie:
EVP_RAND *rand = EVP_RAND_fetch(NULL, "TEST-RAND", NULL);
EVP_RAND_CTX *rctx = EVP_RAND_CTX_new(rand, NULL);
β EXAMPLES β
here's the full serve, cookbook-style:
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);
that's the whole routine: fetch, new, free the rand, construct the params, instantiate, generate, free the ctx. ate and left no crumbs. π₯
π SEE ALSO π
EVP_RAND(3), "PARAMETERS" in EVP_RAND(3)
π HISTORY π
this functionality was added in OpenSSL 3.0. so she's a 3.x girlie, born in the 3.0 era.
π 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! brought to you by the 3.5.6 manual, dated 2026-04-07, straight out of EVP_RAND-TEST-RAND(7ossl) β go forth and test responsibly, bestie, and remember: never use the test RAND for real secrets, i'm literally begging π
π¦ 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