locpctx = ctx->pctx;
evp_pkey_ctx_free_old_ops(locpctx);
+ if (props == NULL)
+ props = locpctx->propquery;
+
/*
* TODO when we stop falling back to legacy, this and the ERR_pop_to_mark()
* calls can be removed.
locpctx->operation = ver ? EVP_PKEY_OP_VERIFYCTX
: EVP_PKEY_OP_SIGNCTX;
locpctx->op.sig.sigprovctx
- = signature->newctx(ossl_provider_ctx(signature->prov));
+ = signature->newctx(ossl_provider_ctx(signature->prov), props);
if (locpctx->op.sig.sigprovctx == NULL) {
ERR_raise(ERR_LIB_EVP, EVP_R_INITIALIZATION_ERROR);
goto err;
goto err;
}
ret = signature->digest_verify_init(locpctx->op.sig.sigprovctx,
- mdname, props, provkey);
+ mdname, provkey);
} else {
if (signature->digest_sign_init == NULL) {
ERR_raise(ERR_LIB_EVP, EVP_R_INITIALIZATION_ERROR);
goto err;
}
ret = signature->digest_sign_init(locpctx->op.sig.sigprovctx,
- mdname, props, provkey);
+ mdname, provkey);
}
return ret ? 1 : 0;
/* No more legacy from here down to legacy: */
ctx->op.sig.signature = signature;
- ctx->op.sig.sigprovctx = signature->newctx(ossl_provider_ctx(signature->prov));
+ ctx->op.sig.sigprovctx =
+ signature->newctx(ossl_provider_ctx(signature->prov), ctx->propquery);
if (ctx->op.sig.sigprovctx == NULL) {
/* The provider key can stay in the cache */
EVPerr(0, EVP_R_INITIALIZATION_ERROR);
# define OSSL_FUNC_SIGNATURE_SET_CTX_MD_PARAMS 24
# define OSSL_FUNC_SIGNATURE_SETTABLE_CTX_MD_PARAMS 25
-OSSL_CORE_MAKE_FUNC(void *, OP_signature_newctx, (void *provctx))
+OSSL_CORE_MAKE_FUNC(void *, OP_signature_newctx, (void *provctx,
+ const char *propq))
OSSL_CORE_MAKE_FUNC(int, OP_signature_sign_init, (void *ctx, void *provkey))
OSSL_CORE_MAKE_FUNC(int, OP_signature_sign, (void *ctx, unsigned char *sig,
size_t *siglen, size_t sigsize,
const unsigned char *sig,
size_t siglen))
OSSL_CORE_MAKE_FUNC(int, OP_signature_digest_sign_init,
- (void *ctx, const char *mdname, const char *props,
- void *provkey))
+ (void *ctx, const char *mdname, void *provkey))
OSSL_CORE_MAKE_FUNC(int, OP_signature_digest_sign_update,
(void *ctx, const unsigned char *data, size_t datalen))
OSSL_CORE_MAKE_FUNC(int, OP_signature_digest_sign_final,
(void *ctx, unsigned char *sigret, size_t *siglen,
size_t sigsize, const unsigned char *tbs, size_t tbslen))
OSSL_CORE_MAKE_FUNC(int, OP_signature_digest_verify_init,
- (void *ctx, const char *mdname, const char *props,
- void *provkey))
+ (void *ctx, const char *mdname, void *provkey))
OSSL_CORE_MAKE_FUNC(int, OP_signature_digest_verify_update,
(void *ctx, const unsigned char *data, size_t datalen))
OSSL_CORE_MAKE_FUNC(int, OP_signature_digest_verify_final,
typedef struct {
OPENSSL_CTX *libctx;
+ char *propq;
DSA *dsa;
/*
return mdnid;
}
-static void *dsa_newctx(void *provctx)
+static void *dsa_newctx(void *provctx, const char *propq)
{
PROV_DSA_CTX *pdsactx = OPENSSL_zalloc(sizeof(PROV_DSA_CTX));
pdsactx->libctx = PROV_LIBRARY_CONTEXT_OF(provctx);
pdsactx->flag_allow_md = 1;
+ if (propq != NULL && (pdsactx->propq = OPENSSL_strdup(propq)) == NULL) {
+ OPENSSL_free(pdsactx);
+ pdsactx = NULL;
+ ERR_raise(ERR_LIB_PROV, ERR_R_MALLOC_FAILURE);
+ }
return pdsactx;
}
static int dsa_setup_md(PROV_DSA_CTX *ctx,
const char *mdname, const char *mdprops)
{
+ if (mdprops == NULL)
+ mdprops = ctx->propq;
+
if (mdname != NULL) {
EVP_MD *md = EVP_MD_fetch(ctx->libctx, mdname, mdprops);
int md_nid = dsa_get_md_nid(md);
}
static int dsa_digest_signverify_init(void *vpdsactx, const char *mdname,
- const char *props, void *vdsa)
+ void *vdsa)
{
PROV_DSA_CTX *pdsactx = (PROV_DSA_CTX *)vpdsactx;
if (!dsa_signature_init(vpdsactx, vdsa))
return 0;
- if (!dsa_setup_md(pdsactx, mdname, props))
+ if (!dsa_setup_md(pdsactx, mdname, NULL))
return 0;
pdsactx->mdctx = EVP_MD_CTX_new();
typedef struct {
OPENSSL_CTX *libctx;
+ char *propq;
EC_KEY *ec;
char mdname[OSSL_MAX_NAME_SIZE];
BIGNUM *r;
} PROV_ECDSA_CTX;
-static void *ecdsa_newctx(void *provctx)
+static void *ecdsa_newctx(void *provctx, const char *propq)
{
PROV_ECDSA_CTX *ctx = OPENSSL_zalloc(sizeof(PROV_ECDSA_CTX));
return NULL;
ctx->libctx = PROV_LIBRARY_CONTEXT_OF(provctx);
+ if (propq != NULL && (ctx->propq = OPENSSL_strdup(propq)) == NULL) {
+ OPENSSL_free(ctx);
+ ctx = NULL;
+ ERR_raise(ERR_LIB_PROV, ERR_R_MALLOC_FAILURE);
+ }
return ctx;
}
}
static int ecdsa_digest_signverify_init(void *vctx, const char *mdname,
- const char *props, void *ec)
+ void *ec)
{
PROV_ECDSA_CTX *ctx = (PROV_ECDSA_CTX *)vctx;
int md_nid = NID_undef;
if (!ecdsa_signature_init(vctx, ec))
return 0;
- ctx->md = EVP_MD_fetch(ctx->libctx, mdname, props);
+ ctx->md = EVP_MD_fetch(ctx->libctx, mdname, ctx->propq);
if ((md_nid = get_md_nid(ctx->md)) == NID_undef)
goto error;
ECX_KEY *key;
} PROV_EDDSA_CTX;
-static void *eddsa_newctx(void *provctx)
+static void *eddsa_newctx(void *provctx, const char *propq_unused)
{
PROV_EDDSA_CTX *peddsactx = OPENSSL_zalloc(sizeof(PROV_EDDSA_CTX));
}
static int eddsa_digest_signverify_init(void *vpeddsactx, const char *mdname,
- const char *props, void *vedkey)
+ void *vedkey)
{
PROV_EDDSA_CTX *peddsactx = (PROV_EDDSA_CTX *)vpeddsactx;
ECX_KEY *edkey = (ECX_KEY *)vedkey;
typedef struct {
OPENSSL_CTX *libctx;
+ char *propq;
RSA *rsa;
int operation;
return 1;
}
-static void *rsa_newctx(void *provctx)
+static void *rsa_newctx(void *provctx, const char *propq)
{
PROV_RSA_CTX *prsactx = OPENSSL_zalloc(sizeof(PROV_RSA_CTX));
prsactx->libctx = PROV_LIBRARY_CONTEXT_OF(provctx);
prsactx->flag_allow_md = 1;
+ if (propq != NULL && (prsactx->propq = OPENSSL_strdup(propq)) == NULL) {
+ OPENSSL_free(prsactx);
+ prsactx = NULL;
+ ERR_raise(ERR_LIB_PROV, ERR_R_MALLOC_FAILURE);
+ }
return prsactx;
}
static int rsa_setup_md(PROV_RSA_CTX *ctx, const char *mdname,
const char *mdprops)
{
+ if (mdprops == NULL)
+ mdprops = ctx->propq;
+
if (mdname != NULL) {
EVP_MD *md = EVP_MD_fetch(ctx->libctx, mdname, mdprops);
int md_nid = rsa_get_md_nid(md);
}
static int rsa_setup_mgf1_md(PROV_RSA_CTX *ctx, const char *mdname,
- const char *props)
+ const char *mdprops)
{
+ if (mdprops == NULL)
+ mdprops = ctx->propq;
+
if (ctx->mgf1_mdname[0] != '\0')
EVP_MD_free(ctx->mgf1_md);
- if ((ctx->mgf1_md = EVP_MD_fetch(ctx->libctx, mdname, props)) == NULL)
+ if ((ctx->mgf1_md = EVP_MD_fetch(ctx->libctx, mdname, mdprops)) == NULL)
return 0;
OPENSSL_strlcpy(ctx->mgf1_mdname, mdname, sizeof(ctx->mgf1_mdname));
}
static int rsa_digest_signverify_init(void *vprsactx, const char *mdname,
- const char *props, void *vrsa,
- int operation)
+ void *vrsa, int operation)
{
PROV_RSA_CTX *prsactx = (PROV_RSA_CTX *)vprsactx;
prsactx->flag_allow_md = 0;
if (!rsa_signature_init(vprsactx, vrsa, operation)
- || !rsa_setup_md(prsactx, mdname, props))
+ || !rsa_setup_md(prsactx, mdname, NULL))
return 0;
prsactx->mdctx = EVP_MD_CTX_new();
EVP_MD_CTX_free(prsactx->mdctx);
EVP_MD_free(prsactx->md);
EVP_MD_free(prsactx->mgf1_md);
+ OPENSSL_free(prsactx->propq);
free_tbuf(prsactx);
OPENSSL_clear_free(prsactx, sizeof(prsactx));
if (!OSSL_PARAM_get_utf8_string(p, &pmdname, sizeof(mdname)))
return 0;
- if (propsp != NULL
- && !OSSL_PARAM_get_utf8_string(propsp, &pmdprops, sizeof(mdprops)))
+
+ if (propsp == NULL)
+ pmdprops = NULL;
+ else if (!OSSL_PARAM_get_utf8_string(propsp,
+ &pmdprops, sizeof(mdprops)))
return 0;
/* TODO(3.0) PSS check needs more work */
}
/* non-PSS code follows */
- if (!rsa_setup_md(prsactx, mdname, mdprops))
+ if (!rsa_setup_md(prsactx, mdname, pmdprops))
return 0;
}
if (!OSSL_PARAM_get_utf8_string(p, &pmdname, sizeof(mdname)))
return 0;
- if (propsp != NULL
- && !OSSL_PARAM_get_utf8_string(propsp, &pmdprops, sizeof(mdprops)))
+
+ if (propsp == NULL)
+ pmdprops = NULL;
+ else if (!OSSL_PARAM_get_utf8_string(propsp,
+ &pmdprops, sizeof(mdprops)))
return 0;
if (prsactx->pad_mode != RSA_PKCS1_PSS_PADDING) {
}
/* non-PSS code follows */
- if (!rsa_setup_mgf1_md(prsactx, mdname, mdprops))
+ if (!rsa_setup_mgf1_md(prsactx, mdname, pmdprops))
return 0;
}