5 EVP_RAND-TEST-RAND - The test EVP_RAND implementation
9 Support for a test generator through the B<EVP_RAND> API. This generator is
10 for test purposes only, it does not generate random numbers.
14 "TEST-RAND" is the name for this implementation; it can be used with the
15 EVP_RAND_fetch() function.
17 =head2 Supported parameters
19 The supported parameters are:
23 =item "state" (B<OSSL_RAND_PARAM_STATE>) <integer>
25 These parameter works as described in L<EVP_RAND(3)/PARAMETERS>.
27 =item "strength" (B<OSSL_RAND_PARAM_STRENGTH>) <unsigned integer>
29 =item "reseed_requests" (B<OSSL_DRBG_PARAM_RESEED_REQUESTS>) <unsigned integer>
31 =item "reseed_time_interval" (B<OSSL_DRBG_PARAM_RESEED_TIME_INTERVAL>) <integer>
33 =item "max_request" (B<OSSL_DRBG_PARAM_RESEED_REQUESTS>) <unsigned integer>
35 =item "min_entropylen" (B<OSSL_DRBG_PARAM_MIN_ENTROPYLEN>) <unsigned integer>
37 =item "max_entropylen" (B<OSSL_DRBG_PARAM_MAX_ENTROPYLEN>) <unsigned integer>
39 =item "min_noncelen" (B<OSSL_DRBG_PARAM_MIN_NONCELEN>) <unsigned integer>
41 =item "max_noncelen" (B<OSSL_DRBG_PARAM_MAX_NONCELEN>) <unsigned integer>
43 =item "max_perslen" (B<OSSL_DRBG_PARAM_MAX_PERSLEN>) <unsigned integer>
45 =item "max_adinlen" (B<OSSL_DRBG_PARAM_MAX_ADINLEN>) <unsigned integer>
47 =item "reseed_counter" (B<OSSL_DRBG_PARAM_RESEED_CTR>) <unsigned integer>
49 These parameters work as described in L<EVP_RAND(3)/PARAMETERS>, except that
50 they can all be set as well as read.
52 =item "test_entropy" (B<OSSL_RAND_PARAM_TEST_ENTROPY>) <octet string>
54 Sets the bytes returned when the test generator is sent an entropy request.
55 When entropy is requested, these bytes are treated as a cyclic buffer and they
56 are repeated as required. The current position is remembered across generate
59 =item "test_nonce" (B<OSSL_RAND_PARAM_TEST_NONCE>) <octet string>
61 Sets the bytes returned when the test generator is sent a nonce request.
62 Each nonce request will return all of the bytes.
68 A context for a test generator can be obtained by calling:
70 EVP_RAND *rand = EVP_RAND_fetch(NULL, "TEST-RAND", NULL);
71 EVP_RAND_CTX *rctx = EVP_RAND_CTX_new(rand);
77 unsigned char bytes[100];
78 OSSL_PARAM params[4], *p = params;
79 unsigned char entropy[1000] = { ... };
80 unsigned char nonce[20] = { ... };
81 unsigned int strength = 48;
83 rand = EVP_RAND_fetch(NULL, "TEST-RAND", NULL);
84 rctx = EVP_RAND_CTX_new(rand, NULL);
87 *p++ = OSSL_PARAM_construct_uint(OSSL_RAND_PARAM_STRENGTH, &strength);
88 *p++ = OSSL_PARAM_construct_octet_string(OSSL_RAND_PARAM_TEST_ENTROPY,
89 entropy, sizeof(entropy));
90 *p++ = OSSL_PARAM_construct_octet_string(OSSL_RAND_PARAM_TEST_NONCE,
91 nonce, sizeof(nonce));
92 *p = OSSL_PARAM_construct_end();
93 EVP_RAND_set_ctx_params(rctx, params);
95 EVP_RAND_generate(rctx, bytes, sizeof(bytes), strength, 0, NULL, 0);
97 EVP_RAND_CTX_free(rctx);
102 L<EVP_RAND(3)/PARAMETERS>
106 Copyright 2020 The OpenSSL Project Authors. All Rights Reserved.
108 Licensed under the Apache License 2.0 (the "License"). You may not use
109 this file except in compliance with the License. You can obtain a copy
110 in the file LICENSE in the source distribution or at
111 L<https://www.openssl.org/source/license.html>.