summaryrefslogtreecommitdiffstats
path: root/crypto/evp/evp_rand.c
diff options
context:
space:
mode:
authorShane Lontis <shane.lontis@oracle.com>2021-05-14 13:08:42 +1000
committerPauli <pauli@openssl.org>2021-05-24 10:12:18 +1000
commit7c14d0c1c0ece97f7406b4df466df6439146d6c6 (patch)
tree0df7120b66ec8b6cc4072492822fa071fd1288ef /crypto/evp/evp_rand.c
parentc45df3302d20291ff1125f1aeb82fae1cdceaac8 (diff)
Rename the field 'provctx and data' to 'algctx' inside some objects containing
pointers to provider size algorithm contexts. Fixes #14284 The gettable_ctx_params methods were confusingly passing a 'provctx' and a provider context which are completely different objects. Some objects such as EVP_KDF used 'data' while others such as EVP_MD used 'provctx'. For libcrypto this 'ctx' is an opaque ptr returned when a providers algorithm implementation creates an internal context using a new_ctx() method. Hence the new name 'algctx'. Reviewed-by: Tomas Mraz <tomas@openssl.org> Reviewed-by: Richard Levitte <levitte@openssl.org> Reviewed-by: Paul Dale <pauli@openssl.org> (Merged from https://github.com/openssl/openssl/pull/15275)
Diffstat (limited to 'crypto/evp/evp_rand.c')
-rw-r--r--crypto/evp/evp_rand.c38
1 files changed, 19 insertions, 19 deletions
diff --git a/crypto/evp/evp_rand.c b/crypto/evp/evp_rand.c
index 5cd6588fa8..c886d9a563 100644
--- a/crypto/evp/evp_rand.c
+++ b/crypto/evp/evp_rand.c
@@ -97,7 +97,7 @@ static void *evp_rand_new(void)
int EVP_RAND_enable_locking(EVP_RAND_CTX *rand)
{
if (rand->meth->enable_locking != NULL)
- return rand->meth->enable_locking(rand->data);
+ return rand->meth->enable_locking(rand->algctx);
ERR_raise(ERR_LIB_EVP, EVP_R_LOCKING_NOT_SUPPORTED);
return 0;
}
@@ -106,7 +106,7 @@ int EVP_RAND_enable_locking(EVP_RAND_CTX *rand)
static int evp_rand_lock(EVP_RAND_CTX *rand)
{
if (rand->meth->lock != NULL)
- return rand->meth->lock(rand->data);
+ return rand->meth->lock(rand->algctx);
return 1;
}
@@ -114,7 +114,7 @@ static int evp_rand_lock(EVP_RAND_CTX *rand)
static void evp_rand_unlock(EVP_RAND_CTX *rand)
{
if (rand->meth->unlock != NULL)
- rand->meth->unlock(rand->data);
+ rand->meth->unlock(rand->algctx);
}
static void *evp_rand_from_algorithm(int name_id,
@@ -356,14 +356,14 @@ EVP_RAND_CTX *EVP_RAND_CTX_new(EVP_RAND *rand, EVP_RAND_CTX *parent)
OPENSSL_free(ctx);
return NULL;
}
- parent_ctx = parent->data;
+ parent_ctx = parent->algctx;
parent_dispatch = parent->meth->dispatch;
}
- if ((ctx->data = rand->newctx(ossl_provider_ctx(rand->prov), parent_ctx,
- parent_dispatch)) == NULL
+ if ((ctx->algctx = rand->newctx(ossl_provider_ctx(rand->prov), parent_ctx,
+ parent_dispatch)) == NULL
|| !EVP_RAND_up_ref(rand)) {
ERR_raise(ERR_LIB_EVP, ERR_R_MALLOC_FAILURE);
- rand->freectx(ctx->data);
+ rand->freectx(ctx->algctx);
CRYPTO_THREAD_lock_free(ctx->refcnt_lock);
OPENSSL_free(ctx);
EVP_RAND_CTX_free(parent);
@@ -387,8 +387,8 @@ void EVP_RAND_CTX_free(EVP_RAND_CTX *ctx)
if (ref > 0)
return;
parent = ctx->parent;
- ctx->meth->freectx(ctx->data);
- ctx->data = NULL;
+ ctx->meth->freectx(ctx->algctx);
+ ctx->algctx = NULL;
EVP_RAND_free(ctx->meth);
CRYPTO_THREAD_lock_free(ctx->refcnt_lock);
OPENSSL_free(ctx);
@@ -403,7 +403,7 @@ EVP_RAND *EVP_RAND_CTX_rand(EVP_RAND_CTX *ctx)
static int evp_rand_get_ctx_params_locked(EVP_RAND_CTX *ctx,
OSSL_PARAM params[])
{
- return ctx->meth->get_ctx_params(ctx->data, params);
+ return ctx->meth->get_ctx_params(ctx->algctx, params);
}
int EVP_RAND_CTX_get_params(EVP_RAND_CTX *ctx, OSSL_PARAM params[])
@@ -421,7 +421,7 @@ static int evp_rand_set_ctx_params_locked(EVP_RAND_CTX *ctx,
const OSSL_PARAM params[])
{
if (ctx->meth->set_ctx_params != NULL)
- return ctx->meth->set_ctx_params(ctx->data, params);
+ return ctx->meth->set_ctx_params(ctx->algctx, params);
return 1;
}
@@ -470,7 +470,7 @@ const OSSL_PARAM *EVP_RAND_CTX_gettable_params(EVP_RAND_CTX *ctx)
if (ctx->meth->gettable_ctx_params == NULL)
return NULL;
provctx = ossl_provider_ctx(EVP_RAND_provider(ctx->meth));
- return ctx->meth->gettable_ctx_params(ctx->data, provctx);
+ return ctx->meth->gettable_ctx_params(ctx->algctx, provctx);
}
const OSSL_PARAM *EVP_RAND_CTX_settable_params(EVP_RAND_CTX *ctx)
@@ -480,7 +480,7 @@ const OSSL_PARAM *EVP_RAND_CTX_settable_params(EVP_RAND_CTX *ctx)
if (ctx->meth->settable_ctx_params == NULL)
return NULL;
provctx = ossl_provider_ctx(EVP_RAND_provider(ctx->meth));
- return ctx->meth->settable_ctx_params(ctx->data, provctx);
+ return ctx->meth->settable_ctx_params(ctx->algctx, provctx);
}
void EVP_RAND_do_all_provided(OSSL_LIB_CTX *libctx,
@@ -506,7 +506,7 @@ static int evp_rand_instantiate_locked
(EVP_RAND_CTX *ctx, unsigned int strength, int prediction_resistance,
const unsigned char *pstr, size_t pstr_len, const OSSL_PARAM params[])
{
- return ctx->meth->instantiate(ctx->data, strength, prediction_resistance,
+ return ctx->meth->instantiate(ctx->algctx, strength, prediction_resistance,
pstr, pstr_len, params);
}
@@ -527,7 +527,7 @@ int EVP_RAND_instantiate(EVP_RAND_CTX *ctx, unsigned int strength,
static int evp_rand_uninstantiate_locked(EVP_RAND_CTX *ctx)
{
- return ctx->meth->uninstantiate(ctx->data);
+ return ctx->meth->uninstantiate(ctx->algctx);
}
int EVP_RAND_uninstantiate(EVP_RAND_CTX *ctx)
@@ -559,7 +559,7 @@ static int evp_rand_generate_locked(EVP_RAND_CTX *ctx, unsigned char *out,
}
for (; outlen > 0; outlen -= chunk, out += chunk) {
chunk = outlen > max_request ? max_request : outlen;
- if (!ctx->meth->generate(ctx->data, out, chunk, strength,
+ if (!ctx->meth->generate(ctx->algctx, out, chunk, strength,
prediction_resistance, addin, addin_len)) {
ERR_raise(ERR_LIB_EVP, EVP_R_GENERATE_ERROR);
return 0;
@@ -592,7 +592,7 @@ static int evp_rand_reseed_locked(EVP_RAND_CTX *ctx, int prediction_resistance,
const unsigned char *addin, size_t addin_len)
{
if (ctx->meth->reseed != NULL)
- return ctx->meth->reseed(ctx->data, prediction_resistance,
+ return ctx->meth->reseed(ctx->algctx, prediction_resistance,
ent, ent_len, addin, addin_len);
return 1;
}
@@ -640,7 +640,7 @@ static int evp_rand_nonce_locked(EVP_RAND_CTX *ctx, unsigned char *out,
if (ctx->meth->nonce == NULL)
return 0;
- if (ctx->meth->nonce(ctx->data, out, str, outlen, outlen))
+ if (ctx->meth->nonce(ctx->algctx, out, str, outlen, outlen))
return 1;
return evp_rand_generate_locked(ctx, out, outlen, str, 0, NULL, 0);
}
@@ -670,7 +670,7 @@ int EVP_RAND_state(EVP_RAND_CTX *ctx)
static int evp_rand_verify_zeroization_locked(EVP_RAND_CTX *ctx)
{
if (ctx->meth->verify_zeroization != NULL)
- return ctx->meth->verify_zeroization(ctx->data);
+ return ctx->meth->verify_zeroization(ctx->algctx);
return 0;
}