Provide side RNG functions renamed to have an ossl_ prefix.

These are: prov_crngt_cleanup_entropy(), prov_crngt_get_entropy(),
prov_pool_acquire_entropy(), prov_pool_add_nonce_data(),
prov_rand_drbg_free() and prov_rand_drbg_new().

Reviewed-by: Tim Hudson <tjh@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/13417)
This commit is contained in:
Pauli 2020-11-16 12:04:56 +10:00
parent 893d3df972
commit 1dc188ba0e
13 changed files with 35 additions and 35 deletions

View File

@ -125,7 +125,7 @@ int RAND_poll(void)
if (pool == NULL)
return 0;
if (prov_pool_acquire_entropy(pool) == 0)
if (ossl_pool_acquire_entropy(pool) == 0)
goto err;
if (meth->add == NULL

View File

@ -18,8 +18,8 @@ size_t prov_drbg_get_additional_data(RAND_POOL *pool, unsigned char **pout);
void prov_drbg_cleanup_additional_data(RAND_POOL *pool, unsigned char *out);
size_t prov_pool_acquire_entropy(RAND_POOL *pool);
int prov_pool_add_nonce_data(RAND_POOL *pool);
size_t ossl_pool_acquire_entropy(RAND_POOL *pool);
int ossl_pool_add_nonce_data(RAND_POOL *pool);
/*
* Add some platform specific additional data

View File

@ -41,7 +41,7 @@ static int crngt_get_entropy(OSSL_LIB_CTX *ctx, RAND_POOL *pool,
if (pool == NULL)
return 0;
n = prov_pool_acquire_entropy(pool);
n = ossl_pool_acquire_entropy(pool);
if (n >= CRNGT_BUFSIZ) {
fmd = EVP_MD_fetch(ctx, "SHA256", "");
if (fmd == NULL)
@ -104,7 +104,7 @@ static int prov_crngt_compare_previous(const unsigned char *prev,
return res;
}
size_t prov_crngt_get_entropy(PROV_DRBG *drbg,
size_t ossl_crngt_get_entropy(PROV_DRBG *drbg,
unsigned char **pout,
int entropy, size_t min_len, size_t max_len,
int prediction_resistance)
@ -164,7 +164,7 @@ err:
return r;
}
void prov_crngt_cleanup_entropy(PROV_DRBG *drbg,
void ossl_crngt_cleanup_entropy(PROV_DRBG *drbg,
unsigned char *out, size_t outlen)
{
OPENSSL_secure_clear_free(out, outlen);

View File

@ -139,7 +139,7 @@ static unsigned int get_parent_reseed_count(PROV_DRBG *drbg)
* is fetched using the parent's ossl_prov_drbg_generate().
*
* Otherwise, the entropy is polled from the system entropy sources
* using prov_pool_acquire_entropy().
* using ossl_pool_acquire_entropy().
*
* If a random pool has been added to the DRBG using RAND_add(), then
* its entropy will be used up first.
@ -214,7 +214,7 @@ static size_t prov_drbg_get_entropy(PROV_DRBG *drbg, unsigned char **pout,
}
} else {
/* Get entropy by polling system entropy sources. */
entropy_available = prov_pool_acquire_entropy(pool);
entropy_available = ossl_pool_acquire_entropy(pool);
}
if (entropy_available > 0) {
@ -246,7 +246,7 @@ static size_t get_entropy(PROV_DRBG *drbg, unsigned char **pout, int entropy,
{
#ifdef FIPS_MODULE
if (drbg->parent == NULL)
return prov_crngt_get_entropy(drbg, pout, entropy, min_len, max_len,
return ossl_crngt_get_entropy(drbg, pout, entropy, min_len, max_len,
prediction_resistance);
#endif
@ -258,7 +258,7 @@ static void cleanup_entropy(PROV_DRBG *drbg, unsigned char *out, size_t outlen)
{
#ifdef FIPS_MODULE
if (drbg->parent == NULL)
prov_crngt_cleanup_entropy(drbg, out, outlen);
ossl_crngt_cleanup_entropy(drbg, out, outlen);
else
#endif
prov_drbg_cleanup_entropy(drbg, out, outlen);
@ -353,7 +353,7 @@ static size_t prov_drbg_get_nonce(PROV_DRBG *drbg,
if (pool == NULL)
return 0;
if (prov_pool_add_nonce_data(pool) == 0)
if (ossl_pool_add_nonce_data(pool) == 0)
goto err;
data.instance = drbg;
@ -807,7 +807,7 @@ int drbg_enable_locking(void *vctx)
*
* Returns a pointer to the new DRBG instance on success, NULL on failure.
*/
PROV_DRBG *prov_rand_drbg_new
PROV_DRBG *ossl_rand_drbg_new
(void *provctx, void *parent, const OSSL_DISPATCH *p_dispatch,
int (*dnew)(PROV_DRBG *ctx),
int (*instantiate)(PROV_DRBG *drbg,
@ -883,11 +883,11 @@ PROV_DRBG *prov_rand_drbg_new
return drbg;
err:
prov_rand_drbg_free(drbg);
ossl_rand_drbg_free(drbg);
return NULL;
}
void prov_rand_drbg_free(PROV_DRBG *drbg)
void ossl_rand_drbg_free(PROV_DRBG *drbg)
{
if (drbg == NULL)
return;

View File

@ -606,7 +606,7 @@ static int drbg_ctr_new(PROV_DRBG *drbg)
static void *drbg_ctr_new_wrapper(void *provctx, void *parent,
const OSSL_DISPATCH *parent_dispatch)
{
return prov_rand_drbg_new(provctx, parent, parent_dispatch, &drbg_ctr_new,
return ossl_rand_drbg_new(provctx, parent, parent_dispatch, &drbg_ctr_new,
&drbg_ctr_instantiate, &drbg_ctr_uninstantiate,
&drbg_ctr_reseed, &drbg_ctr_generate);
}
@ -625,7 +625,7 @@ static void drbg_ctr_free(void *vdrbg)
OPENSSL_secure_clear_free(ctr, sizeof(*ctr));
}
prov_rand_drbg_free(drbg);
ossl_rand_drbg_free(drbg);
}
static int drbg_ctr_get_ctx_params(void *vdrbg, OSSL_PARAM params[])

View File

@ -407,7 +407,7 @@ static int drbg_hash_new(PROV_DRBG *ctx)
static void *drbg_hash_new_wrapper(void *provctx, void *parent,
const OSSL_DISPATCH *parent_dispatch)
{
return prov_rand_drbg_new(provctx, parent, parent_dispatch, &drbg_hash_new,
return ossl_rand_drbg_new(provctx, parent, parent_dispatch, &drbg_hash_new,
&drbg_hash_instantiate, &drbg_hash_uninstantiate,
&drbg_hash_reseed, &drbg_hash_generate);
}
@ -422,7 +422,7 @@ static void drbg_hash_free(void *vdrbg)
ossl_prov_digest_reset(&hash->digest);
OPENSSL_secure_clear_free(hash, sizeof(*hash));
}
prov_rand_drbg_free(drbg);
ossl_rand_drbg_free(drbg);
}
static int drbg_hash_get_ctx_params(void *vdrbg, OSSL_PARAM params[])

View File

@ -304,7 +304,7 @@ static int drbg_hmac_new(PROV_DRBG *drbg)
static void *drbg_hmac_new_wrapper(void *provctx, void *parent,
const OSSL_DISPATCH *parent_dispatch)
{
return prov_rand_drbg_new(provctx, parent, parent_dispatch, &drbg_hmac_new,
return ossl_rand_drbg_new(provctx, parent, parent_dispatch, &drbg_hmac_new,
&drbg_hmac_instantiate, &drbg_hmac_uninstantiate,
&drbg_hmac_reseed, &drbg_hmac_generate);
}
@ -319,7 +319,7 @@ static void drbg_hmac_free(void *vdrbg)
ossl_prov_digest_reset(&hmac->digest);
OPENSSL_secure_clear_free(hmac, sizeof(*hmac));
}
prov_rand_drbg_free(drbg);
ossl_rand_drbg_free(drbg);
}
static int drbg_hmac_get_ctx_params(void *vdrbg, OSSL_PARAM params[])

View File

@ -191,7 +191,7 @@ struct prov_drbg_st {
OSSL_CALLBACK *cleanup_nonce_fn;
};
PROV_DRBG *prov_rand_drbg_new
PROV_DRBG *ossl_rand_drbg_new
(void *provctx, void *parent, const OSSL_DISPATCH *parent_dispatch,
int (*dnew)(PROV_DRBG *ctx),
int (*instantiate)(PROV_DRBG *drbg,
@ -203,7 +203,7 @@ PROV_DRBG *prov_rand_drbg_new
const unsigned char *adin, size_t adin_len),
int (*generate)(PROV_DRBG *, unsigned char *out, size_t outlen,
const unsigned char *adin, size_t adin_len));
void prov_rand_drbg_free(PROV_DRBG *drbg);
void ossl_rand_drbg_free(PROV_DRBG *drbg);
int ossl_prov_drbg_instantiate(PROV_DRBG *drbg, unsigned int strength,
int prediction_resistance,
@ -258,11 +258,11 @@ int drbg_set_ctx_params(PROV_DRBG *drbg, const OSSL_PARAM params[]);
OSSL_PARAM_uint64(OSSL_DRBG_PARAM_RESEED_TIME_INTERVAL, NULL)
/* Continuous test "entropy" calls */
size_t prov_crngt_get_entropy(PROV_DRBG *drbg,
size_t ossl_crngt_get_entropy(PROV_DRBG *drbg,
unsigned char **pout,
int entropy, size_t min_len, size_t max_len,
int prediction_resistance);
void prov_crngt_cleanup_entropy(PROV_DRBG *drbg,
void ossl_crngt_cleanup_entropy(PROV_DRBG *drbg,
unsigned char *out, size_t outlen);
#endif

View File

@ -165,7 +165,7 @@ static uint64_t get_timer_bits(void);
*
* As a precaution, we assume only 2 bits of entropy per byte.
*/
size_t prov_pool_acquire_entropy(RAND_POOL *pool)
size_t ossl_pool_acquire_entropy(RAND_POOL *pool)
{
short int code;
int i, k;
@ -649,7 +649,7 @@ void rand_pool_keep_random_devices_open(int keep)
* of input from the different entropy sources (trust, quality,
* possibility of blocking).
*/
size_t prov_pool_acquire_entropy(RAND_POOL *pool)
size_t ossl_pool_acquire_entropy(RAND_POOL *pool)
{
# if defined(OPENSSL_RAND_SEED_NONE)
return rand_pool_entropy_available(pool);
@ -777,7 +777,7 @@ size_t prov_pool_acquire_entropy(RAND_POOL *pool)
#if (defined(OPENSSL_SYS_UNIX) && !defined(OPENSSL_SYS_VXWORKS)) \
|| defined(__DJGPP__)
int prov_pool_add_nonce_data(RAND_POOL *pool)
int ossl_pool_add_nonce_data(RAND_POOL *pool)
{
struct {
pid_t pid;

View File

@ -474,7 +474,7 @@ size_t data_collect_method(RAND_POOL *pool)
return rand_pool_entropy_available(pool);
}
int prov_pool_add_nonce_data(RAND_POOL *pool)
int ossl_pool_add_nonce_data(RAND_POOL *pool)
{
struct {
pid_t pid;
@ -568,7 +568,7 @@ size_t get_entropy_method(RAND_POOL *pool)
* These functions are called by the RAND / DRBG functions
*/
size_t prov_pool_acquire_entropy(RAND_POOL *pool)
size_t ossl_pool_acquire_entropy(RAND_POOL *pool)
{
if (init_get_entropy_address())
return get_entropy_method(pool);

View File

@ -96,7 +96,7 @@ int rand_pool_add_additional_data(RAND_POOL *pool)
return rand_pool_add(pool, (unsigned char *)&data, sizeof(data), 0);
}
int prov_pool_add_nonce_data(RAND_POOL *pool)
int ossl_pool_add_nonce_data(RAND_POOL *pool)
{
struct {
pid_t pid;
@ -118,7 +118,7 @@ int prov_pool_add_nonce_data(RAND_POOL *pool)
return rand_pool_add(pool, (unsigned char *)&data, sizeof(data), 0);
}
size_t prov_pool_acquire_entropy(RAND_POOL *pool)
size_t ossl_pool_acquire_entropy(RAND_POOL *pool)
{
#if defined(RAND_SEED_VXRANDLIB)
/* vxRandLib based entropy method */

View File

@ -42,7 +42,7 @@
# define INTEL_DEF_PROV L"Intel Hardware Cryptographic Service Provider"
# endif
size_t prov_pool_acquire_entropy(RAND_POOL *pool)
size_t ossl_pool_acquire_entropy(RAND_POOL *pool)
{
# ifndef USE_BCRYPTGENRANDOM
HCRYPTPROV hProvider;
@ -122,7 +122,7 @@ size_t prov_pool_acquire_entropy(RAND_POOL *pool)
}
int prov_pool_add_nonce_data(RAND_POOL *pool)
int ossl_pool_add_nonce_data(RAND_POOL *pool)
{
struct {
DWORD pid;

View File

@ -61,7 +61,7 @@ static void test_rng_free(void *vdrbg)
OPENSSL_free(t->entropy);
OPENSSL_free(t->nonce);
OPENSSL_free(drbg->data);
prov_rand_drbg_free(drbg);
ossl_rand_drbg_free(drbg);
}
static int test_rng_instantiate(PROV_DRBG *drbg,
@ -293,7 +293,7 @@ static int test_rng_verify_zeroization(void *vdrbg)
static void *test_rng_new_wrapper(void *provctx, void *parent,
const OSSL_DISPATCH *parent_dispatch)
{
return prov_rand_drbg_new(provctx, parent, parent_dispatch,
return ossl_rand_drbg_new(provctx, parent, parent_dispatch,
&test_rng_new, &test_rng_instantiate,
&test_rng_uninstantiate, &test_rng_reseed,
&test_rng_generate);