Delete old KDF bridge EVP_PKEY_METHODS
[openssl.git] / include / crypto / rand.h
1 /*
2  * Copyright 2016-2020 The OpenSSL Project Authors. All Rights Reserved.
3  *
4  * Licensed under the Apache License 2.0 (the "License").  You may not use
5  * this file except in compliance with the License.  You can obtain a copy
6  * in the file LICENSE in the source distribution or at
7  * https://www.openssl.org/source/license.html
8  */
9
10 /*
11  * Licensed under the Apache License 2.0 (the "License");
12  * you may not use this file except in compliance with the License.
13  * You may obtain a copy of the License at
14  * https://www.openssl.org/source/license.html
15  * or in the file LICENSE in the source distribution.
16  */
17
18 #ifndef OSSL_CRYPTO_RAND_H
19 # define OSSL_CRYPTO_RAND_H
20
21 # include <openssl/rand.h>
22
23 /*
24  * Defines related to seed sources
25  */
26 #ifndef DEVRANDOM
27 /*
28  * set this to a comma-separated list of 'random' device files to try out. By
29  * default, we will try to read at least one of these files
30  */
31 # define DEVRANDOM "/dev/urandom", "/dev/random", "/dev/hwrng", "/dev/srandom"
32 # if defined(__linux) && !defined(__ANDROID__)
33 #  ifndef DEVRANDOM_WAIT
34 #   define DEVRANDOM_WAIT   "/dev/random"
35 #  endif
36 /*
37  * Linux kernels 4.8 and later changes how their random device works and there
38  * is no reliable way to tell that /dev/urandom has been seeded -- getentropy(2)
39  * should be used instead.
40  */
41 #  ifndef DEVRANDOM_SAFE_KERNEL
42 #   define DEVRANDOM_SAFE_KERNEL        4, 8
43 #  endif
44 /*
45  * Some operating systems do not permit select(2) on their random devices,
46  * defining this to zero will force the use of read(2) to extract one byte
47  * from /dev/random.
48  */
49 #  ifndef DEVRANDM_WAIT_USE_SELECT
50 #   define DEVRANDM_WAIT_USE_SELECT     1
51 #  endif
52 /*
53  * Define the shared memory identifier used to indicate if the operating
54  * system has properly seeded the DEVRANDOM source.
55  */
56 #  ifndef OPENSSL_RAND_SEED_DEVRANDOM_SHM_ID
57 #   define OPENSSL_RAND_SEED_DEVRANDOM_SHM_ID 114
58 #  endif
59
60 # endif
61 #endif
62
63 #if !defined(OPENSSL_NO_EGD) && !defined(DEVRANDOM_EGD)
64 /*
65  * set this to a comma-separated list of 'egd' sockets to try out. These
66  * sockets will be tried in the order listed in case accessing the device
67  * files listed in DEVRANDOM did not return enough randomness.
68  */
69 # define DEVRANDOM_EGD "/var/run/egd-pool", "/dev/egd-pool", "/etc/egd-pool", "/etc/entropy"
70 #endif
71
72 void rand_cleanup_int(void);
73
74 /*
75  * Initialise the random pool reseeding sources.
76  *
77  * Returns 1 on success and 0 on failure.
78  */
79 int rand_pool_init(void);
80
81 /*
82  * Finalise the random pool reseeding sources.
83  */
84 void rand_pool_cleanup(void);
85
86 /*
87  * Control the random pool use of open file descriptors.
88  */
89 void rand_pool_keep_random_devices_open(int keep);
90
91 #endif