prov: move the entropy source out of the FIPS provider
[openssl.git] / providers / implementations / include / prov / seeding.h
1 /*
2  * Copyright 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 #include "prov/provider_ctx.h"
11 #include "crypto/rand_pool.h"
12
13 /* Hardware-based seeding functions. */
14 size_t prov_acquire_entropy_from_tsc(RAND_POOL *pool);
15 size_t prov_acquire_entropy_from_cpu(RAND_POOL *pool);
16
17 /* DRBG entropy callbacks. */
18 size_t prov_drbg_get_additional_data(RAND_POOL *pool, unsigned char **pout);
19
20 void prov_drbg_cleanup_additional_data(RAND_POOL *pool, unsigned char *out);
21
22 /*
23  * Add some platform specific additional data
24  *
25  * This function is platform specific and adds some random noise to the
26  * additional data used for generating random bytes and for reseeding
27  * the drbg.
28  *
29  * Returns 1 on success and 0 on failure.
30  */
31 int rand_pool_add_additional_data(RAND_POOL *pool);
32
33 /*
34  * External seeding functions from the core dispatch table.
35  */
36 int ossl_prov_seeding_from_dispatch(const OSSL_DISPATCH *fns);
37
38 size_t ossl_prov_get_entropy(PROV_CTX *prov_ctx, unsigned char **pout,
39                              int entropy, size_t min_len, size_t max_len);
40 void ossl_prov_cleanup_entropy(PROV_CTX *prov_ctx, unsigned char *buf,
41                                size_t len);
42 size_t ossl_prov_get_nonce(PROV_CTX *prov_ctx, unsigned char **pout,
43                            size_t min_len, size_t max_len,
44                            const void *salt, size_t salt_len);
45 void ossl_prov_cleanup_nonce(PROV_CTX *prov_ctx, unsigned char *buf,
46                              size_t len);