xref: /freebsd-src/crypto/openssl/doc/man7/EVP_RAND-HMAC-DRBG.pod (revision b077aed33b7b6aefca7b17ddb250cf521f938613)
1*b077aed3SPierre Pronchery=pod
2*b077aed3SPierre Pronchery
3*b077aed3SPierre Pronchery=head1 NAME
4*b077aed3SPierre Pronchery
5*b077aed3SPierre ProncheryEVP_RAND-HMAC-DRBG - The HMAC DRBG EVP_RAND implementation
6*b077aed3SPierre Pronchery
7*b077aed3SPierre Pronchery=head1 DESCRIPTION
8*b077aed3SPierre Pronchery
9*b077aed3SPierre ProncherySupport for the HMAC deterministic random bit generator through the
10*b077aed3SPierre ProncheryB<EVP_RAND> API.
11*b077aed3SPierre Pronchery
12*b077aed3SPierre Pronchery=head2 Identity
13*b077aed3SPierre Pronchery
14*b077aed3SPierre Pronchery"HMAC-DRBG" 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 Pronchery=item "strength" (B<OSSL_RAND_PARAM_STRENGTH>) <unsigned integer>
26*b077aed3SPierre Pronchery
27*b077aed3SPierre Pronchery=item "max_request" (B<OSSL_RAND_PARAM_MAX_REQUEST>) <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 "min_entropylen" (B<OSSL_DRBG_PARAM_MIN_ENTROPYLEN>) <unsigned integer>
34*b077aed3SPierre Pronchery
35*b077aed3SPierre Pronchery=item "max_entropylen" (B<OSSL_DRBG_PARAM_MAX_ENTROPYLEN>) <unsigned integer>
36*b077aed3SPierre Pronchery
37*b077aed3SPierre Pronchery=item "min_noncelen" (B<OSSL_DRBG_PARAM_MIN_NONCELEN>) <unsigned integer>
38*b077aed3SPierre Pronchery
39*b077aed3SPierre Pronchery=item "max_noncelen" (B<OSSL_DRBG_PARAM_MAX_NONCELEN>) <unsigned integer>
40*b077aed3SPierre Pronchery
41*b077aed3SPierre Pronchery=item "max_perslen" (B<OSSL_DRBG_PARAM_MAX_PERSLEN>) <unsigned integer>
42*b077aed3SPierre Pronchery
43*b077aed3SPierre Pronchery=item "max_adinlen" (B<OSSL_DRBG_PARAM_MAX_ADINLEN>) <unsigned integer>
44*b077aed3SPierre Pronchery
45*b077aed3SPierre Pronchery=item "reseed_counter" (B<OSSL_DRBG_PARAM_RESEED_COUNTER>) <unsigned integer>
46*b077aed3SPierre Pronchery
47*b077aed3SPierre Pronchery=item "properties" (B<OSSL_DRBG_PARAM_PROPERTIES>) <UTF8 string>
48*b077aed3SPierre Pronchery
49*b077aed3SPierre Pronchery=item "mac" (B<OSSL_DRBG_PARAM_MAC>) <UTF8 string>
50*b077aed3SPierre Pronchery
51*b077aed3SPierre Pronchery=item "digest" (B<OSSL_DRBG_PARAM_DIGEST>) <UTF8 string>
52*b077aed3SPierre Pronchery
53*b077aed3SPierre ProncheryThese parameters work as described in L<EVP_RAND(3)/PARAMETERS>.
54*b077aed3SPierre Pronchery
55*b077aed3SPierre Pronchery=back
56*b077aed3SPierre Pronchery
57*b077aed3SPierre Pronchery=head1 NOTES
58*b077aed3SPierre Pronchery
59*b077aed3SPierre ProncheryA context for HMAC DRBG can be obtained by calling:
60*b077aed3SPierre Pronchery
61*b077aed3SPierre Pronchery EVP_RAND *rand = EVP_RAND_fetch(NULL, "HMAC-DRBG", NULL);
62*b077aed3SPierre Pronchery EVP_RAND_CTX *rctx = EVP_RAND_CTX_new(rand);
63*b077aed3SPierre Pronchery
64*b077aed3SPierre Pronchery=head1 EXAMPLES
65*b077aed3SPierre Pronchery
66*b077aed3SPierre Pronchery EVP_RAND *rand;
67*b077aed3SPierre Pronchery EVP_RAND_CTX *rctx;
68*b077aed3SPierre Pronchery unsigned char bytes[100];
69*b077aed3SPierre Pronchery OSSL_PARAM params[3], *p = params;
70*b077aed3SPierre Pronchery unsigned int strength = 128;
71*b077aed3SPierre Pronchery
72*b077aed3SPierre Pronchery rand = EVP_RAND_fetch(NULL, "HMAC-DRBG", NULL);
73*b077aed3SPierre Pronchery rctx = EVP_RAND_CTX_new(rand, NULL);
74*b077aed3SPierre Pronchery EVP_RAND_free(rand);
75*b077aed3SPierre Pronchery
76*b077aed3SPierre Pronchery *p++ = OSSL_PARAM_construct_utf8_string(OSSL_DRBG_PARAM_MAC, SN_hmac, 0);
77*b077aed3SPierre Pronchery *p++ = OSSL_PARAM_construct_utf8_string(OSSL_DRBG_PARAM_DIGEST, SN_sha256, 0);
78*b077aed3SPierre Pronchery *p = OSSL_PARAM_construct_end();
79*b077aed3SPierre Pronchery EVP_RAND_instantiate(rctx, strength, 0, NULL, 0, params);
80*b077aed3SPierre Pronchery
81*b077aed3SPierre Pronchery EVP_RAND_generate(rctx, bytes, sizeof(bytes), strength, 0, NULL, 0);
82*b077aed3SPierre Pronchery
83*b077aed3SPierre Pronchery EVP_RAND_CTX_free(rctx);
84*b077aed3SPierre Pronchery
85*b077aed3SPierre Pronchery=head1 CONFORMING TO
86*b077aed3SPierre Pronchery
87*b077aed3SPierre ProncheryNIST SP 800-90A and SP 800-90B
88*b077aed3SPierre Pronchery
89*b077aed3SPierre Pronchery=head1 SEE ALSO
90*b077aed3SPierre Pronchery
91*b077aed3SPierre ProncheryL<EVP_RAND(3)>,
92*b077aed3SPierre ProncheryL<EVP_RAND(3)/PARAMETERS>
93*b077aed3SPierre Pronchery
94*b077aed3SPierre Pronchery=head1 COPYRIGHT
95*b077aed3SPierre Pronchery
96*b077aed3SPierre ProncheryCopyright 2020-2021 The OpenSSL Project Authors. All Rights Reserved.
97*b077aed3SPierre Pronchery
98*b077aed3SPierre ProncheryLicensed under the Apache License 2.0 (the "License").  You may not use
99*b077aed3SPierre Proncherythis file except in compliance with the License.  You can obtain a copy
100*b077aed3SPierre Proncheryin the file LICENSE in the source distribution or at
101*b077aed3SPierre ProncheryL<https://www.openssl.org/source/license.html>.
102*b077aed3SPierre Pronchery
103*b077aed3SPierre Pronchery=cut
104