1*b077aed3SPierre Pronchery=pod 2*b077aed3SPierre Pronchery 3*b077aed3SPierre Pronchery=head1 NAME 4*b077aed3SPierre Pronchery 5*b077aed3SPierre ProncheryEVP_RAND-TEST-RAND - The test EVP_RAND implementation 6*b077aed3SPierre Pronchery 7*b077aed3SPierre Pronchery=head1 DESCRIPTION 8*b077aed3SPierre Pronchery 9*b077aed3SPierre ProncherySupport for a test generator through the B<EVP_RAND> API. This generator is 10*b077aed3SPierre Proncheryfor test purposes only, it does not generate random numbers. 11*b077aed3SPierre Pronchery 12*b077aed3SPierre Pronchery=head2 Identity 13*b077aed3SPierre Pronchery 14*b077aed3SPierre Pronchery"TEST-RAND" is the name for this implementation; it can be used with the 15*b077aed3SPierre ProncheryEVP_RAND_fetch() function. 16*b077aed3SPierre Pronchery 17*b077aed3SPierre Pronchery=head2 Supported parameters 18*b077aed3SPierre Pronchery 19*b077aed3SPierre ProncheryThe supported parameters are: 20*b077aed3SPierre Pronchery 21*b077aed3SPierre Pronchery=over 4 22*b077aed3SPierre Pronchery 23*b077aed3SPierre Pronchery=item "state" (B<OSSL_RAND_PARAM_STATE>) <integer> 24*b077aed3SPierre Pronchery 25*b077aed3SPierre ProncheryThese parameter works as described in L<EVP_RAND(3)/PARAMETERS>. 26*b077aed3SPierre Pronchery 27*b077aed3SPierre Pronchery=item "strength" (B<OSSL_RAND_PARAM_STRENGTH>) <unsigned integer> 28*b077aed3SPierre Pronchery 29*b077aed3SPierre Pronchery=item "reseed_requests" (B<OSSL_DRBG_PARAM_RESEED_REQUESTS>) <unsigned integer> 30*b077aed3SPierre Pronchery 31*b077aed3SPierre Pronchery=item "reseed_time_interval" (B<OSSL_DRBG_PARAM_RESEED_TIME_INTERVAL>) <integer> 32*b077aed3SPierre Pronchery 33*b077aed3SPierre Pronchery=item "max_request" (B<OSSL_DRBG_PARAM_RESEED_REQUESTS>) <unsigned integer> 34*b077aed3SPierre Pronchery 35*b077aed3SPierre Pronchery=item "min_entropylen" (B<OSSL_DRBG_PARAM_MIN_ENTROPYLEN>) <unsigned integer> 36*b077aed3SPierre Pronchery 37*b077aed3SPierre Pronchery=item "max_entropylen" (B<OSSL_DRBG_PARAM_MAX_ENTROPYLEN>) <unsigned integer> 38*b077aed3SPierre Pronchery 39*b077aed3SPierre Pronchery=item "min_noncelen" (B<OSSL_DRBG_PARAM_MIN_NONCELEN>) <unsigned integer> 40*b077aed3SPierre Pronchery 41*b077aed3SPierre Pronchery=item "max_noncelen" (B<OSSL_DRBG_PARAM_MAX_NONCELEN>) <unsigned integer> 42*b077aed3SPierre Pronchery 43*b077aed3SPierre Pronchery=item "max_perslen" (B<OSSL_DRBG_PARAM_MAX_PERSLEN>) <unsigned integer> 44*b077aed3SPierre Pronchery 45*b077aed3SPierre Pronchery=item "max_adinlen" (B<OSSL_DRBG_PARAM_MAX_ADINLEN>) <unsigned integer> 46*b077aed3SPierre Pronchery 47*b077aed3SPierre Pronchery=item "reseed_counter" (B<OSSL_DRBG_PARAM_RESEED_COUNTER>) <unsigned integer> 48*b077aed3SPierre Pronchery 49*b077aed3SPierre ProncheryThese parameters work as described in L<EVP_RAND(3)/PARAMETERS>, except that 50*b077aed3SPierre Proncherythey can all be set as well as read. 51*b077aed3SPierre Pronchery 52*b077aed3SPierre Pronchery=item "test_entropy" (B<OSSL_RAND_PARAM_TEST_ENTROPY>) <octet string> 53*b077aed3SPierre Pronchery 54*b077aed3SPierre ProncherySets the bytes returned when the test generator is sent an entropy request. 55*b077aed3SPierre ProncheryThe current position is remembered across generate calls. 56*b077aed3SPierre ProncheryIf there are insufficient data present to satisfy a call, an error is returned. 57*b077aed3SPierre Pronchery 58*b077aed3SPierre Pronchery=item "test_nonce" (B<OSSL_RAND_PARAM_TEST_NONCE>) <octet string> 59*b077aed3SPierre Pronchery 60*b077aed3SPierre ProncherySets the bytes returned when the test generator is sent a nonce request. 61*b077aed3SPierre ProncheryEach nonce request will return all of the bytes. 62*b077aed3SPierre Pronchery 63*b077aed3SPierre Pronchery=back 64*b077aed3SPierre Pronchery 65*b077aed3SPierre Pronchery=head1 NOTES 66*b077aed3SPierre Pronchery 67*b077aed3SPierre ProncheryA context for a test generator can be obtained by calling: 68*b077aed3SPierre Pronchery 69*b077aed3SPierre Pronchery EVP_RAND *rand = EVP_RAND_fetch(NULL, "TEST-RAND", NULL); 70*b077aed3SPierre Pronchery EVP_RAND_CTX *rctx = EVP_RAND_CTX_new(rand); 71*b077aed3SPierre Pronchery 72*b077aed3SPierre Pronchery=head1 EXAMPLES 73*b077aed3SPierre Pronchery 74*b077aed3SPierre Pronchery EVP_RAND *rand; 75*b077aed3SPierre Pronchery EVP_RAND_CTX *rctx; 76*b077aed3SPierre Pronchery unsigned char bytes[100]; 77*b077aed3SPierre Pronchery OSSL_PARAM params[4], *p = params; 78*b077aed3SPierre Pronchery unsigned char entropy[1000] = { ... }; 79*b077aed3SPierre Pronchery unsigned char nonce[20] = { ... }; 80*b077aed3SPierre Pronchery unsigned int strength = 48; 81*b077aed3SPierre Pronchery 82*b077aed3SPierre Pronchery rand = EVP_RAND_fetch(NULL, "TEST-RAND", NULL); 83*b077aed3SPierre Pronchery rctx = EVP_RAND_CTX_new(rand, NULL); 84*b077aed3SPierre Pronchery EVP_RAND_free(rand); 85*b077aed3SPierre Pronchery 86*b077aed3SPierre Pronchery *p++ = OSSL_PARAM_construct_uint(OSSL_RAND_PARAM_STRENGTH, &strength); 87*b077aed3SPierre Pronchery *p++ = OSSL_PARAM_construct_octet_string(OSSL_RAND_PARAM_TEST_ENTROPY, 88*b077aed3SPierre Pronchery entropy, sizeof(entropy)); 89*b077aed3SPierre Pronchery *p++ = OSSL_PARAM_construct_octet_string(OSSL_RAND_PARAM_TEST_NONCE, 90*b077aed3SPierre Pronchery nonce, sizeof(nonce)); 91*b077aed3SPierre Pronchery *p = OSSL_PARAM_construct_end(); 92*b077aed3SPierre Pronchery EVP_RAND_instantiate(rctx, strength, 0, NULL, 0, params); 93*b077aed3SPierre Pronchery 94*b077aed3SPierre Pronchery EVP_RAND_generate(rctx, bytes, sizeof(bytes), strength, 0, NULL, 0); 95*b077aed3SPierre Pronchery 96*b077aed3SPierre Pronchery EVP_RAND_CTX_free(rctx); 97*b077aed3SPierre Pronchery 98*b077aed3SPierre Pronchery=head1 SEE ALSO 99*b077aed3SPierre Pronchery 100*b077aed3SPierre ProncheryL<EVP_RAND(3)>, 101*b077aed3SPierre ProncheryL<EVP_RAND(3)/PARAMETERS> 102*b077aed3SPierre Pronchery 103*b077aed3SPierre Pronchery=head1 HISTORY 104*b077aed3SPierre Pronchery 105*b077aed3SPierre ProncheryThis functionality was added in OpenSSL 3.0. 106*b077aed3SPierre Pronchery 107*b077aed3SPierre Pronchery=head1 COPYRIGHT 108*b077aed3SPierre Pronchery 109*b077aed3SPierre ProncheryCopyright 2020-2021 The OpenSSL Project Authors. All Rights Reserved. 110*b077aed3SPierre Pronchery 111*b077aed3SPierre ProncheryLicensed under the Apache License 2.0 (the "License"). You may not use 112*b077aed3SPierre Proncherythis file except in compliance with the License. You can obtain a copy 113*b077aed3SPierre Proncheryin the file LICENSE in the source distribution or at 114*b077aed3SPierre ProncheryL<https://www.openssl.org/source/license.html>. 115*b077aed3SPierre Pronchery 116*b077aed3SPierre Pronchery=cut 117