VirtualBox

source: vbox/trunk/src/libs/openssl-3.0.1/include/crypto/rand.h@ 94081

最後變更 在這個檔案從94081是 91772,由 vboxsync 提交於 3 年 前

openssl-1.1.1l: Applied and adjusted our OpenSSL changes to 1.1.1l. bugref:10126

檔案大小: 4.4 KB
 
1/*
2 * Copyright 2016-2019 The OpenSSL Project Authors. All Rights Reserved.
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
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
18#ifndef OSSL_CRYPTO_RAND_H
19# define OSSL_CRYPTO_RAND_H
20
21# include <openssl/rand.h>
22
23/* forward declaration */
24typedef struct rand_pool_st RAND_POOL;
25
26void rand_cleanup_int(void);
27void rand_drbg_cleanup_int(void);
28void drbg_delete_thread_state(void);
29
30/* Hardware-based seeding functions. */
31size_t rand_acquire_entropy_from_tsc(RAND_POOL *pool);
32size_t rand_acquire_entropy_from_cpu(RAND_POOL *pool);
33
34/* DRBG entropy callbacks. */
35size_t rand_drbg_get_entropy(RAND_DRBG *drbg,
36 unsigned char **pout,
37 int entropy, size_t min_len, size_t max_len,
38 int prediction_resistance);
39void rand_drbg_cleanup_entropy(RAND_DRBG *drbg,
40 unsigned char *out, size_t outlen);
41size_t rand_drbg_get_nonce(RAND_DRBG *drbg,
42 unsigned char **pout,
43 int entropy, size_t min_len, size_t max_len);
44void rand_drbg_cleanup_nonce(RAND_DRBG *drbg,
45 unsigned char *out, size_t outlen);
46
47size_t rand_drbg_get_additional_data(RAND_POOL *pool, unsigned char **pout);
48
49void rand_drbg_cleanup_additional_data(RAND_POOL *pool, unsigned char *out);
50
51/*
52 * RAND_POOL functions
53 */
54RAND_POOL *rand_pool_new(int entropy_requested, int secure,
55 size_t min_len, size_t max_len);
56RAND_POOL *rand_pool_attach(const unsigned char *buffer, size_t len,
57 size_t entropy);
58void rand_pool_free(RAND_POOL *pool);
59
60const unsigned char *rand_pool_buffer(RAND_POOL *pool);
61unsigned char *rand_pool_detach(RAND_POOL *pool);
62void rand_pool_reattach(RAND_POOL *pool, unsigned char *buffer);
63
64size_t rand_pool_entropy(RAND_POOL *pool);
65size_t rand_pool_length(RAND_POOL *pool);
66
67size_t rand_pool_entropy_available(RAND_POOL *pool);
68size_t rand_pool_entropy_needed(RAND_POOL *pool);
69/* |entropy_factor| expresses how many bits of data contain 1 bit of entropy */
70size_t rand_pool_bytes_needed(RAND_POOL *pool, unsigned int entropy_factor);
71size_t rand_pool_bytes_remaining(RAND_POOL *pool);
72
73int rand_pool_add(RAND_POOL *pool,
74 const unsigned char *buffer, size_t len, size_t entropy);
75unsigned char *rand_pool_add_begin(RAND_POOL *pool, size_t len);
76int rand_pool_add_end(RAND_POOL *pool, size_t len, size_t entropy);
77
78
79/*
80 * Add random bytes to the pool to acquire requested amount of entropy
81 *
82 * This function is platform specific and tries to acquire the requested
83 * amount of entropy by polling platform specific entropy sources.
84 *
85 * If the function succeeds in acquiring at least |entropy_requested| bits
86 * of entropy, the total entropy count is returned. If it fails, it returns
87 * an entropy count of 0.
88 */
89size_t rand_pool_acquire_entropy(RAND_POOL *pool);
90
91/*
92 * Add some application specific nonce data
93 *
94 * This function is platform specific and adds some application specific
95 * data to the nonce used for instantiating the drbg.
96 *
97 * This data currently consists of the process and thread id, and a high
98 * resolution timestamp. The data does not include an atomic counter,
99 * because that is added by the calling function rand_drbg_get_nonce().
100 *
101 * Returns 1 on success and 0 on failure.
102 */
103int rand_pool_add_nonce_data(RAND_POOL *pool);
104
105
106/*
107 * Add some platform specific additional data
108 *
109 * This function is platform specific and adds some random noise to the
110 * additional data used for generating random bytes and for reseeding
111 * the drbg.
112 *
113 * Returns 1 on success and 0 on failure.
114 */
115int rand_pool_add_additional_data(RAND_POOL *pool);
116
117/*
118 * Initialise the random pool reseeding sources.
119 *
120 * Returns 1 on success and 0 on failure.
121 */
122int rand_pool_init(void);
123
124/*
125 * Finalise the random pool reseeding sources.
126 */
127void rand_pool_cleanup(void);
128
129/*
130 * Control the random pool use of open file descriptors.
131 */
132void rand_pool_keep_random_devices_open(int keep);
133
134#endif
注意: 瀏覽 TracBrowser 來幫助您使用儲存庫瀏覽器

© 2025 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette