1EVP_RAND-HMAC-DRBG(7ossl) OpenSSL EVP_RAND-HMAC-DRBG(7ossl)
2
3
4
6 EVP_RAND-HMAC-DRBG - The HMAC DRBG EVP_RAND implementation
7
9 Support for the HMAC deterministic random bit generator through the
10 EVP_RAND API.
11
12 Identity
13 "HMAC-DRBG" is the name for this implementation; it can be used with
14 the EVP_RAND_fetch() function.
15
16 Supported parameters
17 The supported parameters are:
18
19 "state" (OSSL_RAND_PARAM_STATE) <integer>
20 "strength" (OSSL_RAND_PARAM_STRENGTH) <unsigned integer>
21 "max_request" (OSSL_RAND_PARAM_MAX_REQUEST) <unsigned integer>
22 "reseed_requests" (OSSL_DRBG_PARAM_RESEED_REQUESTS) <unsigned integer>
23 "reseed_time_interval" (OSSL_DRBG_PARAM_RESEED_TIME_INTERVAL) <integer>
24 "min_entropylen" (OSSL_DRBG_PARAM_MIN_ENTROPYLEN) <unsigned integer>
25 "max_entropylen" (OSSL_DRBG_PARAM_MAX_ENTROPYLEN) <unsigned integer>
26 "min_noncelen" (OSSL_DRBG_PARAM_MIN_NONCELEN) <unsigned integer>
27 "max_noncelen" (OSSL_DRBG_PARAM_MAX_NONCELEN) <unsigned integer>
28 "max_perslen" (OSSL_DRBG_PARAM_MAX_PERSLEN) <unsigned integer>
29 "max_adinlen" (OSSL_DRBG_PARAM_MAX_ADINLEN) <unsigned integer>
30 "reseed_counter" (OSSL_DRBG_PARAM_RESEED_COUNTER) <unsigned integer>
31 "properties" (OSSL_DRBG_PARAM_PROPERTIES) <UTF8 string>
32 "mac" (OSSL_DRBG_PARAM_MAC) <UTF8 string>
33 "digest" (OSSL_DRBG_PARAM_DIGEST) <UTF8 string>
34 These parameters work as described in "PARAMETERS" in EVP_RAND(3).
35
37 When using the FIPS provider, only these digests are permitted (as per
38 FIPS 140-3 IG D.R
39 <https://csrc.nist.gov/CSRC/media/Projects/cryptographic-module-
40 validation-program/documents/fips%20140-3/FIPS%20140-3%20IG.pdf>):
41
42 SHA-1
43 SHA2-256
44 SHA2-512
45 SHA3-256
46 SHA3-512
47
48 A context for HMAC DRBG can be obtained by calling:
49
50 EVP_RAND *rand = EVP_RAND_fetch(NULL, "HMAC-DRBG", NULL);
51 EVP_RAND_CTX *rctx = EVP_RAND_CTX_new(rand);
52
54 EVP_RAND *rand;
55 EVP_RAND_CTX *rctx;
56 unsigned char bytes[100];
57 OSSL_PARAM params[3], *p = params;
58 unsigned int strength = 128;
59
60 rand = EVP_RAND_fetch(NULL, "HMAC-DRBG", NULL);
61 rctx = EVP_RAND_CTX_new(rand, NULL);
62 EVP_RAND_free(rand);
63
64 *p++ = OSSL_PARAM_construct_utf8_string(OSSL_DRBG_PARAM_MAC, SN_hmac, 0);
65 *p++ = OSSL_PARAM_construct_utf8_string(OSSL_DRBG_PARAM_DIGEST, SN_sha256, 0);
66 *p = OSSL_PARAM_construct_end();
67 EVP_RAND_instantiate(rctx, strength, 0, NULL, 0, params);
68
69 EVP_RAND_generate(rctx, bytes, sizeof(bytes), strength, 0, NULL, 0);
70
71 EVP_RAND_CTX_free(rctx);
72
74 NIST SP 800-90A and SP 800-90B
75
77 EVP_RAND(3), "PARAMETERS" in EVP_RAND(3), openssl-fipsinstall(1)
78
80 OpenSSL 3.1.1 introduced the -no_drbg_truncated_digests option to
81 fipsinstall which restricts the permitted digests when using the FIPS
82 provider in a complaint manner. For details refer to FIPS 140-3 IG D.R
83 <https://csrc.nist.gov/CSRC/media/Projects/cryptographic-module-
84 validation-program/documents/fips%20140-3/FIPS%20140-3%20IG.pdf>).
85
87 Copyright 2020-2023 The OpenSSL Project Authors. All Rights Reserved.
88
89 Licensed under the Apache License 2.0 (the "License"). You may not use
90 this file except in compliance with the License. You can obtain a copy
91 in the file LICENSE in the source distribution or at
92 <https://www.openssl.org/source/license.html>.
93
94
95
963.1.1 2023-08-31 EVP_RAND-HMAC-DRBG(7ossl)