5 EVP_RAND-SEED-SRC - The randomness seed source EVP_RAND implementation
9 Support for deterministic random number generator seeding through the
12 The seed sources used are specified at the time OpenSSL is configured for
13 building using the B<--with-rand-seed=> option. By default, operating system
14 randomness sources are used.
18 "SEED-SRC" is the name for this implementation; it can be used with the
19 EVP_RAND_fetch() function.
21 =head2 Supported parameters
23 The supported parameters are:
27 =item "state" (B<OSSL_RAND_PARAM_STATE>) <integer>
29 =item "strength" (B<OSSL_RAND_PARAM_STRENGTH>) <unsigned integer>
31 =item "max_request" (B<OSSL_RAND_PARAM_MAX_REQUEST>) <unsigned integer>
33 These parameters work as described in L<EVP_RAND(3)/PARAMETERS>.
39 A context for the seed source can be obtained by calling:
41 EVP_RAND *rand = EVP_RAND_fetch(NULL, "SEED-SRC", NULL);
42 EVP_RAND_CTX *rctx = EVP_RAND_CTX_new(rand);
47 EVP_RAND_CTX *seed, *rctx;
48 unsigned char bytes[100];
49 OSSL_PARAM params[2], *p = params;
50 unsigned int strength = 128;
52 /* Create a seed source */
53 rand = EVP_RAND_fetch(NULL, "SEED-SRC", NULL);
54 seed = EVP_RAND_CTX_new(rand, NULL);
57 /* Feed this into a DRBG */
58 rand = EVP_RAND_fetch(NULL, "CTR-DRBG", NULL);
59 rctx = EVP_RAND_CTX_new(rand, seed);
62 /* Configure the DRBG */
63 *p++ = OSSL_PARAM_construct_utf8_string(OSSL_DRBG_PARAM_CIPHER,
65 *p = OSSL_PARAM_construct_end();
66 EVP_RAND_instantiate(rctx, strength, 0, NULL, 0, params);
68 EVP_RAND_generate(rctx, bytes, sizeof(bytes), strength, 0, NULL, 0);
70 EVP_RAND_CTX_free(rctx);
71 EVP_RAND_CTX_free(seed);
76 L<EVP_RAND(3)/PARAMETERS>
80 Copyright 2020 The OpenSSL Project Authors. All Rights Reserved.
82 Licensed under the Apache License 2.0 (the "License"). You may not use
83 this file except in compliance with the License. You can obtain a copy
84 in the file LICENSE in the source distribution or at
85 L<https://www.openssl.org/source/license.html>.