diff options
author | Dr. Matthias St. Pierre <Matthias.St.Pierre@ncp-e.com> | 2018-03-05 23:45:44 +0100 |
---|---|---|
committer | Dr. Matthias St. Pierre <Matthias.St.Pierre@ncp-e.com> | 2018-03-15 18:58:38 +0100 |
commit | 6decf9436f77ff65ed8ed773268663a9273cfbc8 (patch) | |
tree | d22016d214eff4f34e7ffa34f754cf0d25552379 /crypto/include | |
parent | Add code to run test, get malloc counts (diff) | |
download | openssl-6decf9436f77ff65ed8ed773268663a9273cfbc8.tar.xz openssl-6decf9436f77ff65ed8ed773268663a9273cfbc8.zip |
Publish the RAND_DRBG API
Fixes #4403
This commit moves the internal header file "internal/rand.h" to
<openssl/rand_drbg.h>, making the RAND_DRBG API public.
The RAND_POOL API remains private, its function prototypes were
moved to "internal/rand_int.h" and converted to lowercase.
Documentation for the new API is work in progress on GitHub #5461.
Reviewed-by: Richard Levitte <levitte@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/5462)
Diffstat (limited to 'crypto/include')
-rw-r--r-- | crypto/include/internal/rand_int.h | 58 |
1 files changed, 57 insertions, 1 deletions
diff --git a/crypto/include/internal/rand_int.h b/crypto/include/internal/rand_int.h index fc1abd97bc..d90d9c5f63 100644 --- a/crypto/include/internal/rand_int.h +++ b/crypto/include/internal/rand_int.h @@ -15,8 +15,64 @@ * or in the file LICENSE in the source distribution. */ -#include <openssl/rand.h> +#ifndef HEADER_RAND_INT_H +# define HEADER_RAND_INT_H + +# include <openssl/rand.h> + +/* forward declaration */ +typedef struct rand_pool_st RAND_POOL; void rand_cleanup_int(void); void rand_drbg_cleanup_int(void); void rand_fork(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); +void rand_drbg_cleanup_entropy(RAND_DRBG *drbg, + unsigned char *out, size_t outlen); +size_t rand_drbg_get_additional_data(unsigned char **pout, size_t max_len); + + +/* + * RAND_POOL functions + */ +RAND_POOL *rand_pool_new(int entropy_requested, size_t min_len, size_t max_len); +void rand_pool_free(RAND_POOL *pool); + +const unsigned char *rand_pool_buffer(RAND_POOL *pool); +unsigned char *rand_pool_detach(RAND_POOL *pool); + +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); +size_t rand_pool_bytes_needed(RAND_POOL *pool, unsigned int entropy_per_byte); +size_t rand_pool_bytes_remaining(RAND_POOL *pool); + +size_t 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); +size_t rand_pool_add_end(RAND_POOL *pool, size_t len, size_t entropy); + + +/* + * 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. + */ +size_t rand_pool_acquire_entropy(RAND_POOL *pool); + +#endif |