1RAND_GET0_PRIMARY(3ossl)            OpenSSL           RAND_GET0_PRIMARY(3ossl)
2
3
4

NAME

6       RAND_get0_primary, RAND_get0_public, RAND_get0_private,
7       RAND_set0_public, RAND_set0_private - get access to the global
8       EVP_RAND_CTX instances
9

SYNOPSIS

11        #include <openssl/rand.h>
12
13        EVP_RAND_CTX *RAND_get0_primary(OSSL_LIB_CTX *ctx);
14        EVP_RAND_CTX *RAND_get0_public(OSSL_LIB_CTX *ctx);
15        EVP_RAND_CTX *RAND_get0_private(OSSL_LIB_CTX *ctx);
16        int RAND_set0_public(OSSL_LIB_CTX *ctx, EVP_RAND_CTX *rand);
17        int RAND_set0_private(OSSL_LIB_CTX *ctx, EVP_RAND_CTX *rand);
18

DESCRIPTION

20       The default RAND API implementation (RAND_OpenSSL()) utilizes three
21       shared DRBG instances which are accessed via the RAND API:
22
23       The public and private DRBG are thread-local instances, which are used
24       by RAND_bytes() and RAND_priv_bytes(), respectively.  The primary DRBG
25       is a global instance, which is not intended to be used directly, but is
26       used internally to reseed the other two instances.
27
28       The three get functions provide access to the shared DRBG instances.
29
30       The two set functions allow the public and private DRBG instances to be
31       replaced by another random number generator.
32

RETURN VALUES

34       RAND_get0_primary() returns a pointer to the primary DRBG instance for
35       the given OSSL_LIB_CTX ctx.
36
37       RAND_get0_public() returns a pointer to the public DRBG instance for
38       the given OSSL_LIB_CTX ctx.
39
40       RAND_get0_private() returns a pointer to the private DRBG instance for
41       the given OSSL_LIB_CTX ctx.
42
43       RAND_set0_public() and RAND_set0_private() return 1 on success and 0 on
44       error.
45

NOTES

47       It is not thread-safe to access the primary DRBG instance.  The public
48       and private DRBG instance can be accessed safely, because they are
49       thread-local. Note however, that changes to these two instances apply
50       only to the current thread.
51
52       For that reason it is recommended not to change the settings of these
53       three instances directly.  Instead, an application should change the
54       default settings for new DRBG instances at initialization time, before
55       creating additional threads.
56
57       During initialization, it is possible to change the reseed interval and
58       reseed time interval.  It is also possible to exchange the reseeding
59       callbacks entirely.
60
61       To set the type of DRBG that will be instantiated, use the
62       RAND_set_DRBG_type(3) call before accessing the random number
63       generation infrastructure.
64
65       The two set functions, operate on the the current thread.  If you want
66       to use the same random number generator across all threads, each thread
67       must individually call the set functions.
68

SEE ALSO

70       EVP_RAND(3), RAND_set_DRBG_type(3)
71

HISTORY

73       RAND_set0_public() and RAND_set0_private() were added in OpenSSL 3.1.
74
75       The remaining functions were added in OpenSSL 3.0.
76
78       Copyright 2020-2022 The OpenSSL Project Authors. All Rights Reserved.
79
80       Licensed under the Apache License 2.0 (the "License").  You may not use
81       this file except in compliance with the License.  You can obtain a copy
82       in the file LICENSE in the source distribution or at
83       <https://www.openssl.org/source/license.html>.
84
85
86
873.1.1                             2023-08-31          RAND_GET0_PRIMARY(3ossl)
Impressum