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