]> git.ipfire.org Git - thirdparty/openssl.git/blame - crypto/include/internal/rand_int.h
Document changes to SSL_OP_NO_TICKET for TLSv1.3
[thirdparty/openssl.git] / crypto / include / internal / rand_int.h
CommitLineData
aa6bb135 1/*
b0edda11 2 * Copyright 2016-2018 The OpenSSL Project Authors. All Rights Reserved.
aa6bb135
RS
3 *
4 * Licensed under the OpenSSL license (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
f3cd81d6
MC
10/*
11 * Licensed under the OpenSSL licenses, (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
6decf943
DMSP
18#ifndef HEADER_RAND_INT_H
19# define HEADER_RAND_INT_H
20
21# include <openssl/rand.h>
22
23/* forward declaration */
24typedef struct rand_pool_st RAND_POOL;
f3cd81d6 25
b3599dbb 26void rand_cleanup_int(void);
c16de9d8 27void rand_drbg_cleanup_int(void);
7caf122e 28void drbg_delete_thread_state(void);
a35f607c 29void rand_fork(void);
6decf943
DMSP
30
31/* Hardware-based seeding functions. */
32size_t rand_acquire_entropy_from_tsc(RAND_POOL *pool);
33size_t rand_acquire_entropy_from_cpu(RAND_POOL *pool);
34
35/* DRBG entropy callbacks. */
36size_t rand_drbg_get_entropy(RAND_DRBG *drbg,
37 unsigned char **pout,
eb238134
KR
38 int entropy, size_t min_len, size_t max_len,
39 int prediction_resistance);
6decf943
DMSP
40void rand_drbg_cleanup_entropy(RAND_DRBG *drbg,
41 unsigned char *out, size_t outlen);
5bc6bcf8
DMSP
42size_t rand_drbg_get_nonce(RAND_DRBG *drbg,
43 unsigned char **pout,
44 int entropy, size_t min_len, size_t max_len);
45void rand_drbg_cleanup_nonce(RAND_DRBG *drbg,
46 unsigned char *out, size_t outlen);
47
6decf943
DMSP
48size_t rand_drbg_get_additional_data(unsigned char **pout, size_t max_len);
49
5bc6bcf8 50void rand_drbg_cleanup_additional_data(unsigned char *out, size_t outlen);
6decf943
DMSP
51
52/*
53 * RAND_POOL functions
54 */
55RAND_POOL *rand_pool_new(int entropy_requested, size_t min_len, size_t max_len);
56void rand_pool_free(RAND_POOL *pool);
57
58const unsigned char *rand_pool_buffer(RAND_POOL *pool);
59unsigned char *rand_pool_detach(RAND_POOL *pool);
60
61size_t rand_pool_entropy(RAND_POOL *pool);
62size_t rand_pool_length(RAND_POOL *pool);
63
64size_t rand_pool_entropy_available(RAND_POOL *pool);
65size_t rand_pool_entropy_needed(RAND_POOL *pool);
6ebb49f3
RL
66/* |entropy_factor| expresses how many bits of data contain 1 bit of entropy */
67size_t rand_pool_bytes_needed(RAND_POOL *pool, unsigned int entropy_factor);
6decf943
DMSP
68size_t rand_pool_bytes_remaining(RAND_POOL *pool);
69
4845aeba
RL
70int rand_pool_add(RAND_POOL *pool,
71 const unsigned char *buffer, size_t len, size_t entropy);
6decf943 72unsigned char *rand_pool_add_begin(RAND_POOL *pool, size_t len);
4845aeba 73int rand_pool_add_end(RAND_POOL *pool, size_t len, size_t entropy);
6decf943
DMSP
74
75
76/*
77 * Add random bytes to the pool to acquire requested amount of entropy
78 *
79 * This function is platform specific and tries to acquire the requested
80 * amount of entropy by polling platform specific entropy sources.
81 *
82 * If the function succeeds in acquiring at least |entropy_requested| bits
83 * of entropy, the total entropy count is returned. If it fails, it returns
84 * an entropy count of 0.
85 */
86size_t rand_pool_acquire_entropy(RAND_POOL *pool);
87
5bc6bcf8
DMSP
88/*
89 * Add some application specific nonce data
90 *
91 * This function is platform specific and adds some application specific
92 * data to the nonce used for instantiating the drbg.
93 *
94 * This data currently consists of the process and thread id, and a high
95 * resolution timestamp. The data does not include an atomic counter,
96 * because that is added by the calling function rand_drbg_get_nonce().
97 *
98 * Returns 1 on success and 0 on failure.
99 */
100int rand_pool_add_nonce_data(RAND_POOL *pool);
101
102
103/*
104 * Add some platform specific additional data
105 *
106 * This function is platform specific and adds some random noise to the
107 * additional data used for generating random bytes and for reseeding
108 * the drbg.
109 *
110 * Returns 1 on success and 0 on failure.
111 */
112int rand_pool_add_additional_data(RAND_POOL *pool);
113
6decf943 114#endif