forked from cory/tildefriends
OpenSSL 3.1.3 built for android.
git-svn-id: https://www.unprompted.com/svn/projects/tildefriends/trunk@4508 ed5197a5-7fde-0310-b194-c3ffbd925b24
This commit is contained in:
@ -1,14 +1,14 @@
|
||||
/*
|
||||
* Copyright 2016-2021 The OpenSSL Project Authors. All Rights Reserved.
|
||||
* Copyright 2016-2022 The OpenSSL Project Authors. All Rights Reserved.
|
||||
*
|
||||
* Licensed under the OpenSSL license (the "License"). You may not use
|
||||
* Licensed under the Apache License 2.0 (the "License"). You may not use
|
||||
* this file except in compliance with the License. You can obtain a copy
|
||||
* in the file LICENSE in the source distribution or at
|
||||
* https://www.openssl.org/source/license.html
|
||||
*/
|
||||
|
||||
/*
|
||||
* Licensed under the OpenSSL licenses, (the "License");
|
||||
* Licensed under the Apache License 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
* https://www.openssl.org/source/license.html
|
||||
@ -17,8 +17,10 @@
|
||||
|
||||
#ifndef OSSL_CRYPTO_RAND_H
|
||||
# define OSSL_CRYPTO_RAND_H
|
||||
# pragma once
|
||||
|
||||
# include <openssl/rand.h>
|
||||
# include "crypto/rand_pool.h"
|
||||
|
||||
# if defined(__APPLE__) && !defined(OPENSSL_NO_APPLE_CRYPTO_RANDOM)
|
||||
# include <Availability.h>
|
||||
@ -30,115 +32,97 @@
|
||||
# endif
|
||||
# endif
|
||||
|
||||
/* forward declaration */
|
||||
typedef struct rand_pool_st RAND_POOL;
|
||||
|
||||
void rand_cleanup_int(void);
|
||||
void rand_drbg_cleanup_int(void);
|
||||
void drbg_delete_thread_state(void);
|
||||
|
||||
/* Hardware-based seeding functions. */
|
||||
size_t rand_acquire_entropy_from_tsc(RAND_POOL *pool);
|
||||
size_t rand_acquire_entropy_from_cpu(RAND_POOL *pool);
|
||||
|
||||
/* DRBG entropy callbacks. */
|
||||
size_t rand_drbg_get_entropy(RAND_DRBG *drbg,
|
||||
unsigned char **pout,
|
||||
int entropy, size_t min_len, size_t max_len,
|
||||
int prediction_resistance);
|
||||
void rand_drbg_cleanup_entropy(RAND_DRBG *drbg,
|
||||
unsigned char *out, size_t outlen);
|
||||
size_t rand_drbg_get_nonce(RAND_DRBG *drbg,
|
||||
unsigned char **pout,
|
||||
int entropy, size_t min_len, size_t max_len);
|
||||
void rand_drbg_cleanup_nonce(RAND_DRBG *drbg,
|
||||
unsigned char *out, size_t outlen);
|
||||
|
||||
size_t rand_drbg_get_additional_data(RAND_POOL *pool, unsigned char **pout);
|
||||
|
||||
void rand_drbg_cleanup_additional_data(RAND_POOL *pool, unsigned char *out);
|
||||
|
||||
/*
|
||||
* RAND_POOL functions
|
||||
* Defines related to seed sources
|
||||
*/
|
||||
RAND_POOL *rand_pool_new(int entropy_requested, int secure,
|
||||
size_t min_len, size_t max_len);
|
||||
RAND_POOL *rand_pool_attach(const unsigned char *buffer, size_t len,
|
||||
size_t entropy);
|
||||
void rand_pool_free(RAND_POOL *pool);
|
||||
|
||||
const unsigned char *rand_pool_buffer(RAND_POOL *pool);
|
||||
unsigned char *rand_pool_detach(RAND_POOL *pool);
|
||||
void rand_pool_reattach(RAND_POOL *pool, unsigned char *buffer);
|
||||
|
||||
size_t rand_pool_entropy(RAND_POOL *pool);
|
||||
size_t rand_pool_length(RAND_POOL *pool);
|
||||
|
||||
size_t rand_pool_entropy_available(RAND_POOL *pool);
|
||||
size_t rand_pool_entropy_needed(RAND_POOL *pool);
|
||||
/* |entropy_factor| expresses how many bits of data contain 1 bit of entropy */
|
||||
size_t rand_pool_bytes_needed(RAND_POOL *pool, unsigned int entropy_factor);
|
||||
size_t rand_pool_bytes_remaining(RAND_POOL *pool);
|
||||
|
||||
int rand_pool_add(RAND_POOL *pool,
|
||||
const unsigned char *buffer, size_t len, size_t entropy);
|
||||
unsigned char *rand_pool_add_begin(RAND_POOL *pool, size_t len);
|
||||
int rand_pool_add_end(RAND_POOL *pool, size_t len, size_t entropy);
|
||||
|
||||
|
||||
#ifndef DEVRANDOM
|
||||
/*
|
||||
* Add random bytes to the pool to acquire requested amount of entropy
|
||||
*
|
||||
* This function is platform specific and tries to acquire the requested
|
||||
* amount of entropy by polling platform specific entropy sources.
|
||||
*
|
||||
* If the function succeeds in acquiring at least |entropy_requested| bits
|
||||
* of entropy, the total entropy count is returned. If it fails, it returns
|
||||
* an entropy count of 0.
|
||||
* set this to a comma-separated list of 'random' device files to try out. By
|
||||
* default, we will try to read at least one of these files
|
||||
*/
|
||||
size_t rand_pool_acquire_entropy(RAND_POOL *pool);
|
||||
|
||||
# define DEVRANDOM "/dev/urandom", "/dev/random", "/dev/hwrng", "/dev/srandom"
|
||||
# if defined(__linux) && !defined(__ANDROID__)
|
||||
# ifndef DEVRANDOM_WAIT
|
||||
# define DEVRANDOM_WAIT "/dev/random"
|
||||
# endif
|
||||
/*
|
||||
* Add some application specific nonce data
|
||||
*
|
||||
* This function is platform specific and adds some application specific
|
||||
* data to the nonce used for instantiating the drbg.
|
||||
*
|
||||
* This data currently consists of the process and thread id, and a high
|
||||
* resolution timestamp. The data does not include an atomic counter,
|
||||
* because that is added by the calling function rand_drbg_get_nonce().
|
||||
*
|
||||
* Returns 1 on success and 0 on failure.
|
||||
* Linux kernels 4.8 and later changes how their random device works and there
|
||||
* is no reliable way to tell that /dev/urandom has been seeded -- getentropy(2)
|
||||
* should be used instead.
|
||||
*/
|
||||
int rand_pool_add_nonce_data(RAND_POOL *pool);
|
||||
|
||||
|
||||
# ifndef DEVRANDOM_SAFE_KERNEL
|
||||
# define DEVRANDOM_SAFE_KERNEL 4, 8
|
||||
# endif
|
||||
/*
|
||||
* Add some platform specific additional data
|
||||
*
|
||||
* This function is platform specific and adds some random noise to the
|
||||
* additional data used for generating random bytes and for reseeding
|
||||
* the drbg.
|
||||
*
|
||||
* Returns 1 on success and 0 on failure.
|
||||
* Some operating systems do not permit select(2) on their random devices,
|
||||
* defining this to zero will force the use of read(2) to extract one byte
|
||||
* from /dev/random.
|
||||
*/
|
||||
int rand_pool_add_additional_data(RAND_POOL *pool);
|
||||
# ifndef DEVRANDM_WAIT_USE_SELECT
|
||||
# define DEVRANDM_WAIT_USE_SELECT 1
|
||||
# endif
|
||||
/*
|
||||
* Define the shared memory identifier used to indicate if the operating
|
||||
* system has properly seeded the DEVRANDOM source.
|
||||
*/
|
||||
# ifndef OPENSSL_RAND_SEED_DEVRANDOM_SHM_ID
|
||||
# define OPENSSL_RAND_SEED_DEVRANDOM_SHM_ID 114
|
||||
# endif
|
||||
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#if !defined(OPENSSL_NO_EGD) && !defined(DEVRANDOM_EGD)
|
||||
/*
|
||||
* set this to a comma-separated list of 'egd' sockets to try out. These
|
||||
* sockets will be tried in the order listed in case accessing the device
|
||||
* files listed in DEVRANDOM did not return enough randomness.
|
||||
*/
|
||||
# define DEVRANDOM_EGD "/var/run/egd-pool", "/dev/egd-pool", "/etc/egd-pool", "/etc/entropy"
|
||||
#endif
|
||||
|
||||
void ossl_rand_cleanup_int(void);
|
||||
|
||||
/*
|
||||
* Initialise the random pool reseeding sources.
|
||||
*
|
||||
* Returns 1 on success and 0 on failure.
|
||||
*/
|
||||
int rand_pool_init(void);
|
||||
int ossl_rand_pool_init(void);
|
||||
|
||||
/*
|
||||
* Finalise the random pool reseeding sources.
|
||||
*/
|
||||
void rand_pool_cleanup(void);
|
||||
void ossl_rand_pool_cleanup(void);
|
||||
|
||||
/*
|
||||
* Control the random pool use of open file descriptors.
|
||||
*/
|
||||
void rand_pool_keep_random_devices_open(int keep);
|
||||
void ossl_rand_pool_keep_random_devices_open(int keep);
|
||||
|
||||
/*
|
||||
* Configuration
|
||||
*/
|
||||
void ossl_random_add_conf_module(void);
|
||||
|
||||
/*
|
||||
* Get and cleanup random seed material.
|
||||
*/
|
||||
size_t ossl_rand_get_entropy(ossl_unused const OSSL_CORE_HANDLE *handle,
|
||||
unsigned char **pout, int entropy,
|
||||
size_t min_len, size_t max_len);
|
||||
void ossl_rand_cleanup_entropy(ossl_unused const OSSL_CORE_HANDLE *handle,
|
||||
unsigned char *buf, size_t len);
|
||||
size_t ossl_rand_get_nonce(ossl_unused const OSSL_CORE_HANDLE *handle,
|
||||
unsigned char **pout, size_t min_len, size_t max_len,
|
||||
const void *salt, size_t salt_len);
|
||||
void ossl_rand_cleanup_nonce(ossl_unused const OSSL_CORE_HANDLE *handle,
|
||||
unsigned char *buf, size_t len);
|
||||
|
||||
/*
|
||||
* Get seeding material from the operating system sources.
|
||||
*/
|
||||
size_t ossl_pool_acquire_entropy(RAND_POOL *pool);
|
||||
int ossl_pool_add_nonce_data(RAND_POOL *pool);
|
||||
|
||||
#endif
|
||||
|
Reference in New Issue
Block a user