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;
|
||||
|
||||
+23
-4
@@ -54,6 +54,12 @@ static int do_sigver_init(EVP_MD_CTX *ctx, EVP_PKEY_CTX **pctx,
|
||||
locpctx = ctx->pctx;
|
||||
evp_pkey_ctx_free_old_ops(locpctx);
|
||||
|
||||
/*
|
||||
* TODO when we stop falling back to legacy, this and the ERR_pop_to_mark()
|
||||
* calls can be removed.
|
||||
*/
|
||||
ERR_set_mark();
|
||||
|
||||
if (locpctx->keytype == NULL)
|
||||
goto legacy;
|
||||
|
||||
@@ -80,6 +86,7 @@ static int do_sigver_init(EVP_MD_CTX *ctx, EVP_PKEY_CTX **pctx,
|
||||
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;
|
||||
}
|
||||
@@ -108,15 +115,20 @@ static int do_sigver_init(EVP_MD_CTX *ctx, EVP_PKEY_CTX **pctx,
|
||||
|| (EVP_KEYMGMT_provider(locpctx->keymgmt)
|
||||
!= EVP_SIGNATURE_provider(signature))) {
|
||||
/*
|
||||
* 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_SIGNATURE_free(signature);
|
||||
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: */
|
||||
|
||||
locpctx->op.sig.signature = signature;
|
||||
@@ -164,6 +176,13 @@ static int do_sigver_init(EVP_MD_CTX *ctx, EVP_PKEY_CTX **pctx,
|
||||
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->pctx->pmeth == NULL) {
|
||||
EVPerr(0, EVP_R_OPERATION_NOT_SUPPORTED_FOR_THIS_KEYTYPE);
|
||||
return 0;
|
||||
|
||||
+29
-5
@@ -32,6 +32,12 @@ static int evp_pkey_asym_cipher_init(EVP_PKEY_CTX *ctx, int operation)
|
||||
evp_pkey_ctx_free_old_ops(ctx);
|
||||
ctx->operation = operation;
|
||||
|
||||
/*
|
||||
* TODO when we stop falling back to legacy, this and the ERR_pop_to_mark()
|
||||
* calls can be removed.
|
||||
*/
|
||||
ERR_set_mark();
|
||||
|
||||
if (ctx->keytype == NULL || ctx->engine != NULL)
|
||||
goto legacy;
|
||||
|
||||
@@ -41,7 +47,11 @@ static int evp_pkey_asym_cipher_init(EVP_PKEY_CTX *ctx, int operation)
|
||||
&tmp_keymgmt, ctx->propquery, 0);
|
||||
if (provkey == NULL)
|
||||
goto legacy;
|
||||
EVP_KEYMGMT_up_ref(tmp_keymgmt);
|
||||
if (!EVP_KEYMGMT_up_ref(tmp_keymgmt)) {
|
||||
ERR_clear_last_mark();
|
||||
ERR_raise(ERR_LIB_EVP, EVP_R_INITIALIZATION_ERROR);
|
||||
goto err;
|
||||
}
|
||||
EVP_KEYMGMT_free(ctx->keymgmt);
|
||||
ctx->keymgmt = tmp_keymgmt;
|
||||
|
||||
@@ -67,15 +77,22 @@ static int evp_pkey_asym_cipher_init(EVP_PKEY_CTX *ctx, int operation)
|
||||
|| (EVP_KEYMGMT_provider(ctx->keymgmt)
|
||||
!= EVP_ASYM_CIPHER_provider(cipher))) {
|
||||
/*
|
||||
* 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_ASYM_CIPHER_free(cipher);
|
||||
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.ciph.cipher = cipher;
|
||||
ctx->op.ciph.ciphprovctx = cipher->newctx(ossl_provider_ctx(cipher->prov));
|
||||
if (ctx->op.ciph.ciphprovctx == NULL) {
|
||||
@@ -114,6 +131,13 @@ static int evp_pkey_asym_cipher_init(EVP_PKEY_CTX *ctx, int operation)
|
||||
return 1;
|
||||
|
||||
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->encrypt == NULL) {
|
||||
EVPerr(0, EVP_R_OPERATION_NOT_SUPPORTED_FOR_THIS_KEYTYPE);
|
||||
return -2;
|
||||
|
||||
+25
-4
@@ -333,6 +333,12 @@ static int evp_pkey_signature_init(EVP_PKEY_CTX *ctx, int operation)
|
||||
evp_pkey_ctx_free_old_ops(ctx);
|
||||
ctx->operation = operation;
|
||||
|
||||
/*
|
||||
* TODO when we stop falling back to legacy, this and the ERR_pop_to_mark()
|
||||
* calls can be removed.
|
||||
*/
|
||||
ERR_set_mark();
|
||||
|
||||
if (ctx->keytype == NULL)
|
||||
goto legacy;
|
||||
|
||||
@@ -343,6 +349,7 @@ static int evp_pkey_signature_init(EVP_PKEY_CTX *ctx, int operation)
|
||||
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;
|
||||
}
|
||||
@@ -370,15 +377,22 @@ static int evp_pkey_signature_init(EVP_PKEY_CTX *ctx, int operation)
|
||||
|| (EVP_KEYMGMT_provider(ctx->keymgmt)
|
||||
!= EVP_SIGNATURE_provider(signature))) {
|
||||
/*
|
||||
* 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_SIGNATURE_free(signature);
|
||||
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.sig.signature = signature;
|
||||
ctx->op.sig.sigprovctx = signature->newctx(ossl_provider_ctx(signature->prov));
|
||||
if (ctx->op.sig.sigprovctx == NULL) {
|
||||
@@ -425,6 +439,13 @@ static int evp_pkey_signature_init(EVP_PKEY_CTX *ctx, int operation)
|
||||
return 1;
|
||||
|
||||
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
|
||||
|| (operation == EVP_PKEY_OP_SIGN && ctx->pmeth->sign == NULL)
|
||||
|| (operation == EVP_PKEY_OP_VERIFY && ctx->pmeth->verify == NULL)
|
||||
|
||||
@@ -774,6 +774,9 @@ static OSSL_core_get_library_context_fn core_get_libctx;
|
||||
static OSSL_core_new_error_fn core_new_error;
|
||||
static OSSL_core_set_error_debug_fn core_set_error_debug;
|
||||
static OSSL_core_vset_error_fn core_vset_error;
|
||||
static OSSL_core_set_error_mark_fn core_set_error_mark;
|
||||
static OSSL_core_clear_last_error_mark_fn core_clear_last_error_mark;
|
||||
static OSSL_core_pop_error_to_mark_fn core_pop_error_to_mark;
|
||||
#endif
|
||||
|
||||
static const OSSL_PARAM *core_gettable_params(const OSSL_PROVIDER *prov)
|
||||
@@ -857,6 +860,21 @@ static void core_vset_error(const OSSL_PROVIDER *prov,
|
||||
ERR_vset_error(prov->error_lib, (int)reason, fmt, args);
|
||||
}
|
||||
}
|
||||
|
||||
static int core_set_error_mark(const OSSL_PROVIDER *prov)
|
||||
{
|
||||
return ERR_set_mark();
|
||||
}
|
||||
|
||||
static int core_clear_last_error_mark(const OSSL_PROVIDER *prov)
|
||||
{
|
||||
return ERR_clear_last_mark();
|
||||
}
|
||||
|
||||
static int core_pop_error_to_mark(const OSSL_PROVIDER *prov)
|
||||
{
|
||||
return ERR_pop_to_mark();
|
||||
}
|
||||
#endif
|
||||
|
||||
/*
|
||||
@@ -872,6 +890,11 @@ static const OSSL_DISPATCH core_dispatch_[] = {
|
||||
{ OSSL_FUNC_CORE_NEW_ERROR, (void (*)(void))core_new_error },
|
||||
{ OSSL_FUNC_CORE_SET_ERROR_DEBUG, (void (*)(void))core_set_error_debug },
|
||||
{ OSSL_FUNC_CORE_VSET_ERROR, (void (*)(void))core_vset_error },
|
||||
{ OSSL_FUNC_CORE_SET_ERROR_MARK, (void (*)(void))core_set_error_mark },
|
||||
{ OSSL_FUNC_CORE_CLEAR_LAST_ERROR_MARK,
|
||||
(void (*)(void))core_clear_last_error_mark },
|
||||
{ OSSL_FUNC_CORE_POP_ERROR_TO_MARK,
|
||||
(void (*)(void))core_pop_error_to_mark },
|
||||
{ OSSL_FUNC_BIO_NEW_FILE, (void (*)(void))BIO_new_file },
|
||||
{ OSSL_FUNC_BIO_NEW_MEMBUF, (void (*)(void))BIO_new_mem_buf },
|
||||
{ OSSL_FUNC_BIO_READ_EX, (void (*)(void))BIO_read_ex },
|
||||
|
||||
Reference in New Issue
Block a user