Latest update.
This commit is contained in:
+23
-25
@@ -33,6 +33,7 @@ static int do_sigver_init(EVP_MD_CTX *ctx, EVP_PKEY_CTX **pctx,
|
||||
EVP_SIGNATURE *signature = NULL;
|
||||
EVP_KEYMGMT *tmp_keymgmt = NULL;
|
||||
const char *supported_sig = NULL;
|
||||
char locmdname[80] = ""; /* 80 chars should be enough */
|
||||
void *provkey = NULL;
|
||||
int ret;
|
||||
|
||||
@@ -63,26 +64,10 @@ static int do_sigver_init(EVP_MD_CTX *ctx, EVP_PKEY_CTX **pctx,
|
||||
if (locpctx->keytype == NULL)
|
||||
goto legacy;
|
||||
|
||||
if (mdname == NULL) {
|
||||
if (type != NULL) {
|
||||
mdname = EVP_MD_name(type);
|
||||
} else if (pkey != NULL) {
|
||||
/*
|
||||
* TODO(v3.0) work out a better way for EVP_PKEYs with no legacy
|
||||
* component.
|
||||
*/
|
||||
if (pkey->pkey.ptr != NULL) {
|
||||
int def_nid;
|
||||
if (EVP_PKEY_get_default_digest_nid(pkey, &def_nid) > 0)
|
||||
mdname = OBJ_nid2sn(def_nid);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* Ensure that the key is provided. If not, go legacy */
|
||||
tmp_keymgmt = locpctx->keymgmt;
|
||||
provkey = evp_pkey_make_provided(locpctx->pkey, locpctx->libctx,
|
||||
&tmp_keymgmt, locpctx->propquery, 0);
|
||||
&tmp_keymgmt, locpctx->propquery);
|
||||
if (provkey == NULL)
|
||||
goto legacy;
|
||||
if (!EVP_KEYMGMT_up_ref(tmp_keymgmt)) {
|
||||
@@ -131,6 +116,9 @@ static int do_sigver_init(EVP_MD_CTX *ctx, EVP_PKEY_CTX **pctx,
|
||||
|
||||
/* No more legacy from here down to legacy: */
|
||||
|
||||
if (pctx != NULL)
|
||||
*pctx = locpctx;
|
||||
|
||||
locpctx->op.sig.signature = signature;
|
||||
locpctx->operation = ver ? EVP_PKEY_OP_VERIFYCTX
|
||||
: EVP_PKEY_OP_SIGNCTX;
|
||||
@@ -142,15 +130,25 @@ static int do_sigver_init(EVP_MD_CTX *ctx, EVP_PKEY_CTX **pctx,
|
||||
}
|
||||
if (type != NULL) {
|
||||
ctx->reqdigest = type;
|
||||
if (mdname == NULL)
|
||||
mdname = EVP_MD_name(type);
|
||||
} else {
|
||||
/*
|
||||
* This might be requested by a later call to EVP_MD_CTX_md(). In that
|
||||
* case the "explicit fetch" rules apply for that function (as per
|
||||
* man pages), i.e. the ref count is not updated so the EVP_MD should
|
||||
* not be used beyound the lifetime of the EVP_MD_CTX.
|
||||
*/
|
||||
ctx->reqdigest = ctx->fetched_digest =
|
||||
EVP_MD_fetch(locpctx->libctx, mdname, props);
|
||||
if (mdname == NULL
|
||||
&& EVP_PKEY_get_default_digest_name(locpctx->pkey, locmdname,
|
||||
sizeof(locmdname)))
|
||||
mdname = locmdname;
|
||||
|
||||
if (mdname != NULL) {
|
||||
/*
|
||||
* This might be requested by a later call to EVP_MD_CTX_md().
|
||||
* In that case the "explicit fetch" rules apply for that
|
||||
* function (as per man pages), i.e. the ref count is not updated
|
||||
* so the EVP_MD should not be used beyound the lifetime of the
|
||||
* EVP_MD_CTX.
|
||||
*/
|
||||
ctx->reqdigest = ctx->fetched_digest =
|
||||
EVP_MD_fetch(locpctx->libctx, mdname, props);
|
||||
}
|
||||
}
|
||||
|
||||
if (ver) {
|
||||
|
||||
Reference in New Issue
Block a user