From: Shane Lontis Date: Tue, 22 Sep 2020 05:57:19 +0000 (+1000) Subject: Fix propq in x942kdf X-Git-Tag: openssl-3.0.0-alpha7~138 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=e771249c4f6bfb5b49d2c018447bcaa0039fd862;p=thirdparty%2Fopenssl.git Fix propq in x942kdf Reviewed-by: Matt Caswell (Merged from https://github.com/openssl/openssl/pull/12944) --- diff --git a/providers/implementations/kdfs/x942kdf.c b/providers/implementations/kdfs/x942kdf.c index 9dfa8693de9..4410ed8dd90 100644 --- a/providers/implementations/kdfs/x942kdf.c +++ b/providers/implementations/kdfs/x942kdf.c @@ -67,13 +67,14 @@ static const struct { #endif }; -static int find_alg_id(OPENSSL_CTX *libctx, const char *algname, size_t *id) +static int find_alg_id(OPENSSL_CTX *libctx, const char *algname, + const char *propq, size_t *id) { int ret = 1; size_t i; EVP_CIPHER *cipher; - cipher = EVP_CIPHER_fetch(libctx, algname, NULL); + cipher = EVP_CIPHER_fetch(libctx, algname, propq); if (cipher != NULL) { for (i = 0; i < OSSL_NELEM(kek_algs); i++) { if (EVP_CIPHER_is_a(cipher, kek_algs[i].name)) { @@ -381,9 +382,10 @@ static int x942kdf_derive(void *vctx, unsigned char *key, size_t keylen) static int x942kdf_set_ctx_params(void *vctx, const OSSL_PARAM params[]) { - const OSSL_PARAM *p; + const OSSL_PARAM *p, *pq; KDF_X942 *ctx = vctx; OPENSSL_CTX *provctx = PROV_LIBRARY_CONTEXT_OF(ctx->provctx); + const char *propq = NULL; size_t id; if (!ossl_prov_digest_load_from_params(&ctx->digest, params, provctx)) @@ -401,7 +403,14 @@ static int x942kdf_set_ctx_params(void *vctx, const OSSL_PARAM params[]) if ((p = OSSL_PARAM_locate_const(params, OSSL_KDF_PARAM_CEK_ALG)) != NULL) { if (p->data_type != OSSL_PARAM_UTF8_STRING) return 0; - if (find_alg_id(provctx, p->data, &id) == 0) + pq = OSSL_PARAM_locate_const(params, OSSL_ALG_PARAM_PROPERTIES); + /* + * We already grab the properties during ossl_prov_digest_load_from_params() + * so there is no need to check the validity again.. + */ + if (pq != NULL) + propq = p->data; + if (find_alg_id(provctx, p->data, propq, &id) == 0) return 0; ctx->cek_oid = kek_algs[id].oid; ctx->cek_oid_len = kek_algs[id].oid_len;