diff options
| author | tb <> | 2023-11-19 15:43:52 +0000 |
|---|---|---|
| committer | tb <> | 2023-11-19 15:43:52 +0000 |
| commit | cde35b41c5eb9d9d0b61fe730c39e6a5c553b840 (patch) | |
| tree | f32da51e993861a652fa3e012466423087ebd181 /src | |
| parent | f06ef86abaad7907cce57f275e90632f9aba77e1 (diff) | |
| download | openbsd-cde35b41c5eb9d9d0b61fe730c39e6a5c553b840.tar.gz openbsd-cde35b41c5eb9d9d0b61fe730c39e6a5c553b840.tar.bz2 openbsd-cde35b41c5eb9d9d0b61fe730c39e6a5c553b840.zip | |
Unifdef OPENSSL_NO_ENGINE in pmeth_lib.c
This includes a manual intervention for the call to EVP_PKEY_meth_find()
which ended up in the middle of nowhere.
ok jsing
Diffstat (limited to 'src')
| -rw-r--r-- | src/lib/libcrypto/evp/pmeth_lib.c | 44 |
1 files changed, 3 insertions, 41 deletions
diff --git a/src/lib/libcrypto/evp/pmeth_lib.c b/src/lib/libcrypto/evp/pmeth_lib.c index b480a574fe..7ebf273415 100644 --- a/src/lib/libcrypto/evp/pmeth_lib.c +++ b/src/lib/libcrypto/evp/pmeth_lib.c | |||
| @@ -1,4 +1,4 @@ | |||
| 1 | /* $OpenBSD: pmeth_lib.c,v 1.33 2023/07/07 19:37:54 beck Exp $ */ | 1 | /* $OpenBSD: pmeth_lib.c,v 1.34 2023/11/19 15:43:52 tb Exp $ */ |
| 2 | /* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL | 2 | /* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL |
| 3 | * project 2006. | 3 | * project 2006. |
| 4 | */ | 4 | */ |
| @@ -68,10 +68,6 @@ | |||
| 68 | #include <openssl/objects.h> | 68 | #include <openssl/objects.h> |
| 69 | #include <openssl/x509v3.h> | 69 | #include <openssl/x509v3.h> |
| 70 | 70 | ||
| 71 | #ifndef OPENSSL_NO_ENGINE | ||
| 72 | #include <openssl/engine.h> | ||
| 73 | #endif | ||
| 74 | |||
| 75 | #include "asn1_local.h" | 71 | #include "asn1_local.h" |
| 76 | #include "evp_local.h" | 72 | #include "evp_local.h" |
| 77 | 73 | ||
| @@ -161,26 +157,8 @@ evp_pkey_ctx_new(EVP_PKEY *pkey, ENGINE *engine, int id) | |||
| 161 | return NULL; | 157 | return NULL; |
| 162 | id = pkey->ameth->pkey_id; | 158 | id = pkey->ameth->pkey_id; |
| 163 | } | 159 | } |
| 164 | #ifndef OPENSSL_NO_ENGINE | 160 | |
| 165 | if (pkey != NULL && pkey->engine != NULL) | 161 | if ((pmeth = EVP_PKEY_meth_find(id)) == NULL) { |
| 166 | engine = pkey->engine; | ||
| 167 | /* Try to find an ENGINE which implements this method. */ | ||
| 168 | if (engine != NULL) { | ||
| 169 | if (!ENGINE_init(engine)) { | ||
| 170 | EVPerror(ERR_R_ENGINE_LIB); | ||
| 171 | return NULL; | ||
| 172 | } | ||
| 173 | } else | ||
| 174 | engine = ENGINE_get_pkey_meth_engine(id); | ||
| 175 | |||
| 176 | /* Look up method handler in ENGINE or use internal tables. */ | ||
| 177 | if (engine != NULL) | ||
| 178 | pmeth = ENGINE_get_pkey_meth(engine, id); | ||
| 179 | else | ||
| 180 | #endif | ||
| 181 | pmeth = EVP_PKEY_meth_find(id); | ||
| 182 | |||
| 183 | if (pmeth == NULL) { | ||
| 184 | EVPerror(EVP_R_UNSUPPORTED_ALGORITHM); | 162 | EVPerror(EVP_R_UNSUPPORTED_ALGORITHM); |
| 185 | goto err; | 163 | goto err; |
| 186 | } | 164 | } |
| @@ -205,9 +183,6 @@ evp_pkey_ctx_new(EVP_PKEY *pkey, ENGINE *engine, int id) | |||
| 205 | 183 | ||
| 206 | err: | 184 | err: |
| 207 | EVP_PKEY_CTX_free(pkey_ctx); | 185 | EVP_PKEY_CTX_free(pkey_ctx); |
| 208 | #ifndef OPENSSL_NO_ENGINE | ||
| 209 | ENGINE_finish(engine); | ||
| 210 | #endif | ||
| 211 | 186 | ||
| 212 | return NULL; | 187 | return NULL; |
| 213 | } | 188 | } |
| @@ -275,22 +250,12 @@ EVP_PKEY_CTX_dup(EVP_PKEY_CTX *pctx) | |||
| 275 | 250 | ||
| 276 | if (pctx->pmeth == NULL || pctx->pmeth->copy == NULL) | 251 | if (pctx->pmeth == NULL || pctx->pmeth->copy == NULL) |
| 277 | goto err; | 252 | goto err; |
| 278 | #ifndef OPENSSL_NO_ENGINE | ||
| 279 | /* Make sure it's safe to copy a pkey context using an ENGINE */ | ||
| 280 | if (pctx->engine != NULL && !ENGINE_init(pctx->engine)) { | ||
| 281 | EVPerror(ERR_R_ENGINE_LIB); | ||
| 282 | goto err; | ||
| 283 | } | ||
| 284 | #endif | ||
| 285 | if ((rctx = calloc(1, sizeof(*rctx))) == NULL) { | 253 | if ((rctx = calloc(1, sizeof(*rctx))) == NULL) { |
| 286 | EVPerror(ERR_R_MALLOC_FAILURE); | 254 | EVPerror(ERR_R_MALLOC_FAILURE); |
| 287 | goto err; | 255 | goto err; |
| 288 | } | 256 | } |
| 289 | 257 | ||
| 290 | rctx->pmeth = pctx->pmeth; | 258 | rctx->pmeth = pctx->pmeth; |
| 291 | #ifndef OPENSSL_NO_ENGINE | ||
| 292 | rctx->engine = pctx->engine; | ||
| 293 | #endif | ||
| 294 | 259 | ||
| 295 | if ((rctx->pkey = pctx->pkey) != NULL) | 260 | if ((rctx->pkey = pctx->pkey) != NULL) |
| 296 | EVP_PKEY_up_ref(rctx->pkey); | 261 | EVP_PKEY_up_ref(rctx->pkey); |
| @@ -333,9 +298,6 @@ EVP_PKEY_CTX_free(EVP_PKEY_CTX *ctx) | |||
| 333 | ctx->pmeth->cleanup(ctx); | 298 | ctx->pmeth->cleanup(ctx); |
| 334 | EVP_PKEY_free(ctx->pkey); | 299 | EVP_PKEY_free(ctx->pkey); |
| 335 | EVP_PKEY_free(ctx->peerkey); | 300 | EVP_PKEY_free(ctx->peerkey); |
| 336 | #ifndef OPENSSL_NO_ENGINE | ||
| 337 | ENGINE_finish(ctx->engine); | ||
| 338 | #endif | ||
| 339 | free(ctx); | 301 | free(ctx); |
| 340 | } | 302 | } |
| 341 | 303 | ||
