Latest update.
This commit is contained in:
+24
-4
@@ -175,6 +175,12 @@ int EVP_PKEY_derive_init(EVP_PKEY_CTX *ctx)
|
||||
evp_pkey_ctx_free_old_ops(ctx);
|
||||
ctx->operation = EVP_PKEY_OP_DERIVE;
|
||||
|
||||
/*
|
||||
* TODO when we stop falling back to legacy, this and the ERR_pop_to_mark()
|
||||
* calls can be removed.
|
||||
*/
|
||||
ERR_set_mark();
|
||||
|
||||
if (ctx->engine != NULL || ctx->keytype == NULL)
|
||||
goto legacy;
|
||||
|
||||
@@ -185,6 +191,7 @@ int EVP_PKEY_derive_init(EVP_PKEY_CTX *ctx)
|
||||
if (provkey == NULL)
|
||||
goto legacy;
|
||||
if (!EVP_KEYMGMT_up_ref(tmp_keymgmt)) {
|
||||
ERR_clear_last_mark();
|
||||
ERR_raise(ERR_LIB_EVP, EVP_R_INITIALIZATION_ERROR);
|
||||
goto err;
|
||||
}
|
||||
@@ -211,15 +218,21 @@ int EVP_PKEY_derive_init(EVP_PKEY_CTX *ctx)
|
||||
|| (EVP_KEYMGMT_provider(ctx->keymgmt)
|
||||
!= EVP_KEYEXCH_provider(exchange))) {
|
||||
/*
|
||||
* We don't have the full support we need with provided methods,
|
||||
* let's go see if legacy does. Also, we don't need to free
|
||||
* ctx->keymgmt here, as it's not necessarily tied to this
|
||||
* operation. It will be freed by EVP_PKEY_CTX_free().
|
||||
* We don't need to free ctx->keymgmt here, as it's not necessarily
|
||||
* tied to this operation. It will be freed by EVP_PKEY_CTX_free().
|
||||
*/
|
||||
EVP_KEYEXCH_free(exchange);
|
||||
goto legacy;
|
||||
}
|
||||
|
||||
/*
|
||||
* TODO remove this when legacy is gone
|
||||
* If we don't have the full support we need with provided methods,
|
||||
* let's go see if legacy does.
|
||||
*/
|
||||
ERR_pop_to_mark();
|
||||
|
||||
/* No more legacy from here down to legacy: */
|
||||
|
||||
ctx->op.kex.exchange = exchange;
|
||||
ctx->op.kex.exchprovctx = exchange->newctx(ossl_provider_ctx(exchange->prov));
|
||||
@@ -236,6 +249,13 @@ int EVP_PKEY_derive_init(EVP_PKEY_CTX *ctx)
|
||||
return 0;
|
||||
|
||||
legacy:
|
||||
/*
|
||||
* TODO remove this when legacy is gone
|
||||
* If we don't have the full support we need with provided methods,
|
||||
* let's go see if legacy does.
|
||||
*/
|
||||
ERR_pop_to_mark();
|
||||
|
||||
if (ctx->pmeth == NULL || ctx->pmeth->derive == NULL) {
|
||||
EVPerr(0, EVP_R_OPERATION_NOT_SUPPORTED_FOR_THIS_KEYTYPE);
|
||||
return -2;
|
||||
|
||||
Reference in New Issue
Block a user