mirror of
https://github.com/openssl/openssl.git
synced 2025-04-12 20:30:52 +08:00
Rename internal drbg_ functions so they have an ossl_ prefix.
These functions are: drbg_enable_locking(), drbg_get_ctx_params(), drbg_lock(), drbg_set_ctx_params() and drbg_unlock(). Reviewed-by: Tim Hudson <tjh@openssl.org> (Merged from https://github.com/openssl/openssl/pull/13417)
This commit is contained in:
parent
b68a947fd2
commit
b24d6c335d
@ -43,7 +43,7 @@ static const OSSL_DISPATCH *find_call(const OSSL_DISPATCH *dispatch,
|
||||
|
||||
static int rand_drbg_restart(PROV_DRBG *drbg);
|
||||
|
||||
int drbg_lock(void *vctx)
|
||||
int ossl_drbg_lock(void *vctx)
|
||||
{
|
||||
PROV_DRBG *drbg = vctx;
|
||||
|
||||
@ -52,7 +52,7 @@ int drbg_lock(void *vctx)
|
||||
return CRYPTO_THREAD_write_lock(drbg->lock);
|
||||
}
|
||||
|
||||
void drbg_unlock(void *vctx)
|
||||
void ossl_drbg_unlock(void *vctx)
|
||||
{
|
||||
PROV_DRBG *drbg = vctx;
|
||||
|
||||
@ -60,7 +60,7 @@ void drbg_unlock(void *vctx)
|
||||
CRYPTO_THREAD_unlock(drbg->lock);
|
||||
}
|
||||
|
||||
static int drbg_lock_parent(PROV_DRBG *drbg)
|
||||
static int ossl_drbg_lock_parent(PROV_DRBG *drbg)
|
||||
{
|
||||
void *parent = drbg->parent;
|
||||
|
||||
@ -73,7 +73,7 @@ static int drbg_lock_parent(PROV_DRBG *drbg)
|
||||
return 1;
|
||||
}
|
||||
|
||||
static void drbg_unlock_parent(PROV_DRBG *drbg)
|
||||
static void ossl_drbg_unlock_parent(PROV_DRBG *drbg)
|
||||
{
|
||||
void *parent = drbg->parent;
|
||||
|
||||
@ -93,12 +93,12 @@ static int get_parent_strength(PROV_DRBG *drbg, unsigned int *str)
|
||||
}
|
||||
|
||||
*params = OSSL_PARAM_construct_uint(OSSL_RAND_PARAM_STRENGTH, str);
|
||||
if (!drbg_lock_parent(drbg)) {
|
||||
if (!ossl_drbg_lock_parent(drbg)) {
|
||||
ERR_raise(ERR_LIB_PROV, PROV_R_UNABLE_TO_LOCK_PARENT);
|
||||
return 0;
|
||||
}
|
||||
res = drbg->parent_get_ctx_params(parent, params);
|
||||
drbg_unlock_parent(drbg);
|
||||
ossl_drbg_unlock_parent(drbg);
|
||||
if (!res) {
|
||||
ERR_raise(ERR_LIB_PROV, PROV_R_UNABLE_TO_GET_PARENT_STRENGTH);
|
||||
return 0;
|
||||
@ -113,16 +113,16 @@ static unsigned int get_parent_reseed_count(PROV_DRBG *drbg)
|
||||
unsigned int r;
|
||||
|
||||
*params = OSSL_PARAM_construct_uint(OSSL_DRBG_PARAM_RESEED_COUNTER, &r);
|
||||
if (!drbg_lock_parent(drbg)) {
|
||||
if (!ossl_drbg_lock_parent(drbg)) {
|
||||
ERR_raise(ERR_LIB_PROV, PROV_R_UNABLE_TO_LOCK_PARENT);
|
||||
goto err;
|
||||
}
|
||||
if (!drbg->parent_get_ctx_params(parent, params)) {
|
||||
drbg_unlock_parent(drbg);
|
||||
ossl_drbg_unlock_parent(drbg);
|
||||
ERR_raise(ERR_LIB_PROV, PROV_R_UNABLE_TO_GET_RESEED_PROP_CTR);
|
||||
goto err;
|
||||
}
|
||||
drbg_unlock_parent(drbg);
|
||||
ossl_drbg_unlock_parent(drbg);
|
||||
return r;
|
||||
|
||||
err:
|
||||
@ -191,7 +191,7 @@ static size_t prov_drbg_get_entropy(PROV_DRBG *drbg, unsigned char **pout,
|
||||
* generating bits from it. (Note: taking the lock will be a no-op
|
||||
* if locking if drbg->parent->lock == NULL.)
|
||||
*/
|
||||
drbg_lock_parent(drbg);
|
||||
ossl_drbg_lock_parent(drbg);
|
||||
/*
|
||||
* Get random data from parent. Include our DRBG address as
|
||||
* additional input, in order to provide a distinction between
|
||||
@ -206,7 +206,7 @@ static size_t prov_drbg_get_entropy(PROV_DRBG *drbg, unsigned char **pout,
|
||||
(unsigned char *)&drbg,
|
||||
sizeof(drbg)) != 0)
|
||||
bytes = bytes_needed;
|
||||
drbg_unlock_parent(drbg);
|
||||
ossl_drbg_unlock_parent(drbg);
|
||||
drbg->parent_reseed_counter = get_parent_reseed_count(drbg);
|
||||
|
||||
rand_pool_add_end(pool, bytes, 8 * bytes);
|
||||
@ -780,7 +780,7 @@ static const OSSL_DISPATCH *find_call(const OSSL_DISPATCH *dispatch,
|
||||
return NULL;
|
||||
}
|
||||
|
||||
int drbg_enable_locking(void *vctx)
|
||||
int ossl_drbg_enable_locking(void *vctx)
|
||||
{
|
||||
PROV_DRBG *drbg = vctx;
|
||||
|
||||
@ -897,7 +897,7 @@ void ossl_rand_drbg_free(PROV_DRBG *drbg)
|
||||
OPENSSL_free(drbg);
|
||||
}
|
||||
|
||||
int drbg_get_ctx_params(PROV_DRBG *drbg, OSSL_PARAM params[])
|
||||
int ossl_drbg_get_ctx_params(PROV_DRBG *drbg, OSSL_PARAM params[])
|
||||
{
|
||||
OSSL_PARAM *p;
|
||||
|
||||
@ -956,7 +956,7 @@ int drbg_get_ctx_params(PROV_DRBG *drbg, OSSL_PARAM params[])
|
||||
return 1;
|
||||
}
|
||||
|
||||
int drbg_set_ctx_params(PROV_DRBG *drbg, const OSSL_PARAM params[])
|
||||
int ossl_drbg_set_ctx_params(PROV_DRBG *drbg, const OSSL_PARAM params[])
|
||||
{
|
||||
const OSSL_PARAM *p;
|
||||
|
||||
|
@ -645,7 +645,7 @@ static int drbg_ctr_get_ctx_params(void *vdrbg, OSSL_PARAM params[])
|
||||
return 0;
|
||||
}
|
||||
|
||||
return drbg_get_ctx_params(drbg, params);
|
||||
return ossl_drbg_get_ctx_params(drbg, params);
|
||||
}
|
||||
|
||||
static const OSSL_PARAM *drbg_ctr_gettable_ctx_params(ossl_unused void *provctx)
|
||||
@ -713,7 +713,7 @@ static int drbg_ctr_set_ctx_params(void *vctx, const OSSL_PARAM params[])
|
||||
if (cipher_init && !drbg_ctr_init(ctx))
|
||||
return 0;
|
||||
|
||||
return drbg_set_ctx_params(ctx, params);
|
||||
return ossl_drbg_set_ctx_params(ctx, params);
|
||||
}
|
||||
|
||||
static const OSSL_PARAM *drbg_ctr_settable_ctx_params(ossl_unused void *provctx)
|
||||
@ -744,9 +744,9 @@ const OSSL_DISPATCH ossl_drbg_ctr_functions[] = {
|
||||
(void(*)(void))drbg_ctr_uninstantiate_wrapper },
|
||||
{ OSSL_FUNC_RAND_GENERATE, (void(*)(void))drbg_ctr_generate_wrapper },
|
||||
{ OSSL_FUNC_RAND_RESEED, (void(*)(void))drbg_ctr_reseed_wrapper },
|
||||
{ OSSL_FUNC_RAND_ENABLE_LOCKING, (void(*)(void))drbg_enable_locking },
|
||||
{ OSSL_FUNC_RAND_LOCK, (void(*)(void))drbg_lock },
|
||||
{ OSSL_FUNC_RAND_UNLOCK, (void(*)(void))drbg_unlock },
|
||||
{ OSSL_FUNC_RAND_ENABLE_LOCKING, (void(*)(void))ossl_drbg_enable_locking },
|
||||
{ OSSL_FUNC_RAND_LOCK, (void(*)(void))ossl_drbg_lock },
|
||||
{ OSSL_FUNC_RAND_UNLOCK, (void(*)(void))ossl_drbg_unlock },
|
||||
{ OSSL_FUNC_RAND_SETTABLE_CTX_PARAMS,
|
||||
(void(*)(void))drbg_ctr_settable_ctx_params },
|
||||
{ OSSL_FUNC_RAND_SET_CTX_PARAMS, (void(*)(void))drbg_ctr_set_ctx_params },
|
||||
|
@ -439,7 +439,7 @@ static int drbg_hash_get_ctx_params(void *vdrbg, OSSL_PARAM params[])
|
||||
return 0;
|
||||
}
|
||||
|
||||
return drbg_get_ctx_params(drbg, params);
|
||||
return ossl_drbg_get_ctx_params(drbg, params);
|
||||
}
|
||||
|
||||
static const OSSL_PARAM *drbg_hash_gettable_ctx_params(ossl_unused void *p_ctx)
|
||||
@ -484,7 +484,7 @@ static int drbg_hash_set_ctx_params(void *vctx, const OSSL_PARAM params[])
|
||||
ctx->min_noncelen = ctx->min_entropylen / 2;
|
||||
}
|
||||
|
||||
return drbg_set_ctx_params(ctx, params);
|
||||
return ossl_drbg_set_ctx_params(ctx, params);
|
||||
}
|
||||
|
||||
static const OSSL_PARAM *drbg_hash_settable_ctx_params(ossl_unused void *p_ctx)
|
||||
@ -507,9 +507,9 @@ const OSSL_DISPATCH ossl_drbg_hash_functions[] = {
|
||||
(void(*)(void))drbg_hash_uninstantiate_wrapper },
|
||||
{ OSSL_FUNC_RAND_GENERATE, (void(*)(void))drbg_hash_generate_wrapper },
|
||||
{ OSSL_FUNC_RAND_RESEED, (void(*)(void))drbg_hash_reseed_wrapper },
|
||||
{ OSSL_FUNC_RAND_ENABLE_LOCKING, (void(*)(void))drbg_enable_locking },
|
||||
{ OSSL_FUNC_RAND_LOCK, (void(*)(void))drbg_lock },
|
||||
{ OSSL_FUNC_RAND_UNLOCK, (void(*)(void))drbg_unlock },
|
||||
{ OSSL_FUNC_RAND_ENABLE_LOCKING, (void(*)(void))ossl_drbg_enable_locking },
|
||||
{ OSSL_FUNC_RAND_LOCK, (void(*)(void))ossl_drbg_lock },
|
||||
{ OSSL_FUNC_RAND_UNLOCK, (void(*)(void))ossl_drbg_unlock },
|
||||
{ OSSL_FUNC_RAND_SETTABLE_CTX_PARAMS,
|
||||
(void(*)(void))drbg_hash_settable_ctx_params },
|
||||
{ OSSL_FUNC_RAND_SET_CTX_PARAMS, (void(*)(void))drbg_hash_set_ctx_params },
|
||||
|
@ -346,7 +346,7 @@ static int drbg_hmac_get_ctx_params(void *vdrbg, OSSL_PARAM params[])
|
||||
return 0;
|
||||
}
|
||||
|
||||
return drbg_get_ctx_params(drbg, params);
|
||||
return ossl_drbg_get_ctx_params(drbg, params);
|
||||
}
|
||||
|
||||
static const OSSL_PARAM *drbg_hmac_gettable_ctx_params(ossl_unused void *p_ctx)
|
||||
@ -397,7 +397,7 @@ static int drbg_hmac_set_ctx_params(void *vctx, const OSSL_PARAM params[])
|
||||
ctx->min_noncelen = ctx->min_entropylen / 2;
|
||||
}
|
||||
|
||||
return drbg_set_ctx_params(ctx, params);
|
||||
return ossl_drbg_set_ctx_params(ctx, params);
|
||||
}
|
||||
|
||||
static const OSSL_PARAM *drbg_hmac_settable_ctx_params(ossl_unused void *p_ctx)
|
||||
@ -421,9 +421,9 @@ const OSSL_DISPATCH ossl_drbg_ossl_hmac_functions[] = {
|
||||
(void(*)(void))drbg_hmac_uninstantiate_wrapper },
|
||||
{ OSSL_FUNC_RAND_GENERATE, (void(*)(void))drbg_hmac_generate_wrapper },
|
||||
{ OSSL_FUNC_RAND_RESEED, (void(*)(void))drbg_hmac_reseed_wrapper },
|
||||
{ OSSL_FUNC_RAND_ENABLE_LOCKING, (void(*)(void))drbg_enable_locking },
|
||||
{ OSSL_FUNC_RAND_LOCK, (void(*)(void))drbg_lock },
|
||||
{ OSSL_FUNC_RAND_UNLOCK, (void(*)(void))drbg_unlock },
|
||||
{ OSSL_FUNC_RAND_ENABLE_LOCKING, (void(*)(void))ossl_drbg_enable_locking },
|
||||
{ OSSL_FUNC_RAND_LOCK, (void(*)(void))ossl_drbg_lock },
|
||||
{ OSSL_FUNC_RAND_UNLOCK, (void(*)(void))ossl_drbg_unlock },
|
||||
{ OSSL_FUNC_RAND_SETTABLE_CTX_PARAMS,
|
||||
(void(*)(void))drbg_hmac_settable_ctx_params },
|
||||
{ OSSL_FUNC_RAND_SET_CTX_PARAMS, (void(*)(void))drbg_hmac_set_ctx_params },
|
||||
|
@ -230,13 +230,13 @@ int ossl_prov_drbg_generate(PROV_DRBG *drbg, unsigned char *out, size_t outlen,
|
||||
}
|
||||
|
||||
/* locking api */
|
||||
OSSL_FUNC_rand_enable_locking_fn drbg_enable_locking;
|
||||
OSSL_FUNC_rand_lock_fn drbg_lock;
|
||||
OSSL_FUNC_rand_unlock_fn drbg_unlock;
|
||||
OSSL_FUNC_rand_enable_locking_fn ossl_drbg_enable_locking;
|
||||
OSSL_FUNC_rand_lock_fn ossl_drbg_lock;
|
||||
OSSL_FUNC_rand_unlock_fn ossl_drbg_unlock;
|
||||
|
||||
/* Common parameters for all of our DRBGs */
|
||||
int drbg_get_ctx_params(PROV_DRBG *drbg, OSSL_PARAM params[]);
|
||||
int drbg_set_ctx_params(PROV_DRBG *drbg, const OSSL_PARAM params[]);
|
||||
int ossl_drbg_get_ctx_params(PROV_DRBG *drbg, OSSL_PARAM params[]);
|
||||
int ossl_drbg_set_ctx_params(PROV_DRBG *drbg, const OSSL_PARAM params[]);
|
||||
|
||||
#define OSSL_PARAM_DRBG_SETTABLE_CTX_COMMON \
|
||||
OSSL_PARAM_uint(OSSL_DRBG_PARAM_RESEED_REQUESTS, NULL), \
|
||||
|
@ -183,7 +183,7 @@ static int test_rng_get_ctx_params(void *vdrbg, OSSL_PARAM params[])
|
||||
{
|
||||
PROV_DRBG *drbg = (PROV_DRBG *)vdrbg;
|
||||
|
||||
return drbg_get_ctx_params(drbg, params);
|
||||
return ossl_drbg_get_ctx_params(drbg, params);
|
||||
}
|
||||
|
||||
static const OSSL_PARAM *test_rng_gettable_ctx_params(ossl_unused void *provctx)
|
||||
@ -261,7 +261,7 @@ static int test_rng_set_ctx_params(void *vdrbg, const OSSL_PARAM params[])
|
||||
|| !set_size_t(params, OSSL_DRBG_PARAM_MAX_ADINLEN,
|
||||
&drbg->max_adinlen))
|
||||
return 0;
|
||||
return drbg_set_ctx_params(drbg, params);
|
||||
return ossl_drbg_set_ctx_params(drbg, params);
|
||||
}
|
||||
|
||||
static const OSSL_PARAM *test_rng_settable_ctx_params(ossl_unused void *provctx)
|
||||
@ -309,9 +309,9 @@ const OSSL_DISPATCH ossl_test_rng_functions[] = {
|
||||
{ OSSL_FUNC_RAND_GENERATE, (void(*)(void))test_rng_generate_wrapper },
|
||||
{ OSSL_FUNC_RAND_RESEED, (void(*)(void))test_rng_reseed_wrapper },
|
||||
{ OSSL_FUNC_RAND_NONCE, (void(*)(void))test_rng_nonce },
|
||||
{ OSSL_FUNC_RAND_ENABLE_LOCKING, (void(*)(void))drbg_enable_locking },
|
||||
{ OSSL_FUNC_RAND_LOCK, (void(*)(void))drbg_lock },
|
||||
{ OSSL_FUNC_RAND_UNLOCK, (void(*)(void))drbg_unlock },
|
||||
{ OSSL_FUNC_RAND_ENABLE_LOCKING, (void(*)(void))ossl_drbg_enable_locking },
|
||||
{ OSSL_FUNC_RAND_LOCK, (void(*)(void))ossl_drbg_lock },
|
||||
{ OSSL_FUNC_RAND_UNLOCK, (void(*)(void))ossl_drbg_unlock },
|
||||
{ OSSL_FUNC_RAND_SETTABLE_CTX_PARAMS,
|
||||
(void(*)(void))test_rng_settable_ctx_params },
|
||||
{ OSSL_FUNC_RAND_SET_CTX_PARAMS, (void(*)(void))test_rng_set_ctx_params },
|
||||
|
Loading…
x
Reference in New Issue
Block a user