Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 1 addition & 4 deletions providers/common/include/prov/provider_util.h
Original file line number Diff line number Diff line change
Expand Up @@ -71,13 +71,10 @@ const EVP_MD *ossl_prov_digest_fetch(PROV_DIGEST *pd, OSSL_LIB_CTX *libctx,

/*
* Load a digest from the specified parameters with the specified context.
* The params "properties", "engine" and "digest" are used to determine the
* The params "propq", "engine" and "digest" are used to determine the
* implementation used. If a provider cannot be found, it falls back to trying
* non-provider based implementations.
*/
int ossl_prov_digest_load_from_params(PROV_DIGEST *pd,
const OSSL_PARAM params[],
OSSL_LIB_CTX *ctx);
int ossl_prov_digest_load(PROV_DIGEST *pd,const OSSL_PARAM *digest,
const OSSL_PARAM *propq, const OSSL_PARAM *engine,
OSSL_LIB_CTX *ctx);
Expand Down
11 changes: 0 additions & 11 deletions providers/common/provider_util.c
Original file line number Diff line number Diff line change
Expand Up @@ -212,17 +212,6 @@ int ossl_prov_digest_load(PROV_DIGEST *pd, const OSSL_PARAM *digest,
return pd->md != NULL;
}

int ossl_prov_digest_load_from_params(PROV_DIGEST *pd,
const OSSL_PARAM params[],
OSSL_LIB_CTX *ctx)
{
return ossl_prov_digest_load(pd,
OSSL_PARAM_locate_const(params, OSSL_ALG_PARAM_DIGEST),
OSSL_PARAM_locate_const(params, OSSL_ALG_PARAM_PROPERTIES),
OSSL_PARAM_locate_const(params, OSSL_ALG_PARAM_ENGINE),
ctx);
}

void ossl_prov_digest_set_md(PROV_DIGEST *pd, EVP_MD *md)
{
ossl_prov_digest_reset(pd);
Expand Down
9 changes: 4 additions & 5 deletions providers/implementations/kdfs/hkdf.c.in
Original file line number Diff line number Diff line change
Expand Up @@ -501,16 +501,15 @@ static void *kdf_hkdf_fixed_digest_new(void *provctx, const char *digest)
{
OSSL_LIB_CTX *libctx = PROV_LIBCTX_OF(provctx);
KDF_HKDF *ctx;
OSSL_PARAM params[2];
OSSL_PARAM param;

ctx = kdf_hkdf_new(provctx);
if (ctx == NULL)
return NULL;

params[0] = OSSL_PARAM_construct_utf8_string(OSSL_ALG_PARAM_DIGEST,
(char *)digest, 0);
params[1] = OSSL_PARAM_construct_end();
if (!ossl_prov_digest_load_from_params(&ctx->digest, params, libctx)) {
param = OSSL_PARAM_construct_utf8_string(OSSL_ALG_PARAM_DIGEST,
(char *)digest, 0);
if (!ossl_prov_digest_load(&ctx->digest, &param, NULL, NULL, libctx)) {
kdf_hkdf_free(ctx);
return NULL;
}
Expand Down
8 changes: 4 additions & 4 deletions providers/implementations/kdfs/pbkdf2.c.in
Original file line number Diff line number Diff line change
Expand Up @@ -151,12 +151,12 @@ static void *kdf_pbkdf2_dup(void *vctx)

static void kdf_pbkdf2_init(KDF_PBKDF2 *ctx)
{
OSSL_PARAM params[2] = { OSSL_PARAM_END, OSSL_PARAM_END };
OSSL_PARAM param;
OSSL_LIB_CTX *provctx = PROV_LIBCTX_OF(ctx->provctx);

params[0] = OSSL_PARAM_construct_utf8_string(OSSL_KDF_PARAM_DIGEST,
SN_sha1, 0);
if (!ossl_prov_digest_load_from_params(&ctx->digest, params, provctx))
param = OSSL_PARAM_construct_utf8_string(OSSL_KDF_PARAM_DIGEST,
SN_sha1, 0);
if (!ossl_prov_digest_load(&ctx->digest, &param, NULL, NULL, provctx))
/* This is an error, but there is no way to indicate such directly */
ossl_prov_digest_reset(&ctx->digest);
ctx->iter = PKCS5_DEFAULT_ITER;
Expand Down
8 changes: 4 additions & 4 deletions providers/implementations/kdfs/pvkkdf.c.in
Original file line number Diff line number Diff line change
Expand Up @@ -108,12 +108,12 @@ static void kdf_pvk_reset(void *vctx)

static void kdf_pvk_init(KDF_PVK *ctx)
{
OSSL_PARAM params[2] = { OSSL_PARAM_END, OSSL_PARAM_END };
OSSL_PARAM param;
OSSL_LIB_CTX *provctx = PROV_LIBCTX_OF(ctx->provctx);

params[0] = OSSL_PARAM_construct_utf8_string(OSSL_KDF_PARAM_DIGEST,
SN_sha1, 0);
if (!ossl_prov_digest_load_from_params(&ctx->digest, params, provctx))
param = OSSL_PARAM_construct_utf8_string(OSSL_KDF_PARAM_DIGEST,
SN_sha1, 0);
if (!ossl_prov_digest_load(&ctx->digest, &param, NULL, NULL, provctx))
/* This is an error, but there is no way to indicate such directly */
ossl_prov_digest_reset(&ctx->digest);
}
Expand Down
15 changes: 12 additions & 3 deletions providers/implementations/macs/kmac_prov.c.in
Original file line number Diff line number Diff line change
Expand Up @@ -189,15 +189,24 @@ static struct kmac_data_st *kmac_new(void *provctx)
return kctx;
}

#define kmac_new_list

{- produce_param_decoder('kmac_new',
(['MAC_PARAM_DIGEST', 'digest', 'utf8_string'],
['MAC_PARAM_PROPERTIES', 'propq', 'utf8_string'],
['ALG_PARAM_ENGINE', 'engine', 'utf8_string', 'hidden'],
)); -}

static void *kmac_fetch_new(void *provctx, const OSSL_PARAM *params)
{
struct kmac_data_st *kctx = kmac_new(provctx);
struct kmac_new_st p;
int md_size;

if (kctx == NULL)
if (kctx == NULL || !kmac_new_decoder(params, &p))
return 0;
if (!ossl_prov_digest_load_from_params(&kctx->digest, params,
PROV_LIBCTX_OF(provctx))) {
if (!ossl_prov_digest_load(&kctx->digest, p.digest, p.propq, p.engine,
PROV_LIBCTX_OF(provctx))) {
kmac_free(kctx);
return 0;
}
Expand Down
Loading