]> git.ipfire.org Git - thirdparty/openssl.git/commitdiff
Remove private ENGINE references from local structs.
authorMilan Broz <gmazyland@gmail.com>
Wed, 3 Sep 2025 09:52:49 +0000 (11:52 +0200)
committerNeil Horman <nhorman@openssl.org>
Fri, 3 Oct 2025 17:00:26 +0000 (13:00 -0400)
Resolves: https://github.com/openssl/project/issues/1368

Signed-off-by: Milan Broz <gmazyland@gmail.com>
Reviewed-by: Matt Caswell <matt@openssl.org>
Reviewed-by: Saša Nedvědický <sashan@openssl.org>
Reviewed-by: Neil Horman <nhorman@openssl.org>
Reviewed-by: Dmitry Belyavskiy <beldmit@gmail.com>
(Merged from https://github.com/openssl/openssl/pull/28384)

19 files changed:
crypto/dh/dh_backend.c
crypto/dh/dh_lib.c
crypto/dh/dh_local.h
crypto/dsa/dsa_backend.c
crypto/dsa/dsa_lib.c
crypto/dsa/dsa_local.h
crypto/ec/ec_backend.c
crypto/ec/ec_key.c
crypto/ec/ec_local.h
crypto/evp/evp_enc.c
crypto/evp/evp_local.h
crypto/evp/p_lib.c
crypto/evp/pmeth_lib.c
crypto/rsa/rsa_backend.c
crypto/rsa/rsa_lib.c
crypto/rsa/rsa_local.h
crypto/store/store_local.h
crypto/store/store_register.c
include/crypto/evp.h

index b15284cfff709a3ac4d251fc83658de303054b5e..ee7a67b71bdc9bdd64a3b9c3e16b2efdc1dde638 100644 (file)
@@ -124,7 +124,7 @@ int ossl_dh_key_todata(DH *dh, OSSL_PARAM_BLD *bld, OSSL_PARAM *pubkey,
 int ossl_dh_is_foreign(const DH *dh)
 {
 #ifndef FIPS_MODULE
-    if (dh->engine != NULL || ossl_dh_get_method(dh) != DH_OpenSSL())
+    if (ossl_dh_get_method(dh) != DH_OpenSSL())
         return 1;
 #endif
     return 0;
index 7bbf987358199d4add14ddb2e96e661fa4c36abc..4787f415523287bed6c9fe6a260ef855688a831e 100644 (file)
@@ -296,7 +296,7 @@ void DH_set_flags(DH *dh, int flags)
 #ifndef FIPS_MODULE
 ENGINE *DH_get0_engine(DH *dh)
 {
-    return dh->engine;
+    return NULL;
 }
 #endif /*FIPS_MODULE */
 
index 1ff075e3dc1df55fb2e3f36564897ea4fc187b08..e4cba4c30189c777aa732da4470772196a9a4ea3 100644 (file)
@@ -30,7 +30,6 @@ struct dh_st {
     CRYPTO_REF_COUNT references;
 #ifndef FIPS_MODULE
     CRYPTO_EX_DATA ex_data;
-    ENGINE *engine;
 #endif
     OSSL_LIB_CTX *libctx;
     const DH_METHOD *meth;
index 8bd4b8ad7e0e2c6251587e54c38aa710ff8ea4b4..99f417cad740a2ffe049d9b7b081f5a21aec47e1 100644 (file)
@@ -66,7 +66,7 @@ int ossl_dsa_key_fromdata(DSA *dsa, const OSSL_PARAM params[],
 int ossl_dsa_is_foreign(const DSA *dsa)
 {
 #ifndef FIPS_MODULE
-    if (dsa->engine != NULL || DSA_get_method((DSA *)dsa) != DSA_OpenSSL())
+    if (DSA_get_method((DSA *)dsa) != DSA_OpenSSL())
         return 1;
 #endif
     return 0;
index 259d5d790c34ce4d5bdb5a1d90f0ef68f7bd345e..18b747e3613b9854cc44d9350c0b308ac898035f 100644 (file)
@@ -100,7 +100,7 @@ void DSA_set_flags(DSA *d, int flags)
 
 ENGINE *DSA_get0_engine(DSA *d)
 {
-    return d->engine;
+    return NULL;
 }
 
 int DSA_set_method(DSA *dsa, const DSA_METHOD *meth)
index 38cb64a8294142145ffa43a4627699bcc36b53e4..341f039e4f3ecd5f16da62af01f98e7bf3cbf069 100644 (file)
@@ -29,8 +29,6 @@ struct dsa_st {
     CRYPTO_EX_DATA ex_data;
 #endif
     const DSA_METHOD *meth;
-    /* functional reference if 'meth' is ENGINE-provided */
-    ENGINE *engine;
     CRYPTO_RWLOCK *lock;
     OSSL_LIB_CTX *libctx;
 
index f0191a7db3b06e2249f6a8e04b82b360f78c6e7f..1adb506279848707ec70ad583a0ac4c2dd08c74f 100644 (file)
@@ -587,7 +587,7 @@ int ossl_ec_key_otherparams_fromdata(EC_KEY *ec, const OSSL_PARAM params[])
 int ossl_ec_key_is_foreign(const EC_KEY *ec)
 {
 #ifndef FIPS_MODULE
-    if (ec->engine != NULL || EC_KEY_get_method(ec) != EC_KEY_OpenSSL())
+    if (EC_KEY_get_method(ec) != EC_KEY_OpenSSL())
         return 1;
 #endif
     return 0;
@@ -604,7 +604,7 @@ EC_KEY *ossl_ec_key_dup(const EC_KEY *src, int selection)
     }
 
     if ((ret = ossl_ec_key_new_method_int(src->libctx, src->propq,
-                                          src->engine)) == NULL)
+                                          NULL)) == NULL)
         return NULL;
 
     /* copy the parameters */
index c25761c64037bb9d2f17319b21d69c5443d94674..238bce9fbbb0b628e1cc9ec8f5f24f8c62c7c5f0 100644 (file)
@@ -190,7 +190,7 @@ int EC_KEY_up_ref(EC_KEY *r)
 
 ENGINE *EC_KEY_get0_engine(const EC_KEY *eckey)
 {
-    return eckey->engine;
+    return NULL;
 }
 
 int EC_KEY_generate_key(EC_KEY *eckey)
index 91c3a7190299f1da835e81a5403dd8346d4d9070..148bbc72523b5bd755c22083cd3300eb5ee6fd05 100644 (file)
@@ -289,7 +289,6 @@ struct ec_group_st {
 
 struct ec_key_st {
     const EC_KEY_METHOD *meth;
-    ENGINE *engine;
     int version;
     EC_GROUP *group;
     EC_POINT *pub_key;
index 17ee28fa32b8a429f0bddeaaf7ac5a0b25ab4d7f..a86f116090c4b311c93c52be92d4ffc00b7228cc 100644 (file)
@@ -440,8 +440,7 @@ static int evp_cipher_init_skey_internal(EVP_CIPHER_CTX *ctx,
     /*
      * If there are engines involved then we throw an error
      */
-    if (ctx->engine != NULL
-            || (cipher != NULL && cipher->origin == EVP_ORIG_METH)
+    if ((cipher != NULL && cipher->origin == EVP_ORIG_METH)
             || (cipher == NULL && ctx->cipher != NULL
                 && ctx->cipher->origin == EVP_ORIG_METH)) {
         ERR_raise(ERR_LIB_EVP, EVP_R_INITIALIZATION_ERROR);
index 677711ebea0decb5cab5e2a8e2ddcfd8d2bb3086..9da138ede9ea8f3ae8b7a274a3bb874f770f6e1a 100644 (file)
@@ -16,8 +16,6 @@
 struct evp_md_ctx_st {
     const EVP_MD *reqdigest;    /* The original requested digest */
     const EVP_MD *digest;
-    ENGINE *engine;             /* functional reference if 'digest' is
-                                 * ENGINE-provided */
     unsigned long flags;
     void *md_data;
     /* Public key context for sign/verify */
@@ -35,8 +33,6 @@ struct evp_md_ctx_st {
 
 struct evp_cipher_ctx_st {
     const EVP_CIPHER *cipher;
-    ENGINE *engine;             /* functional reference if 'cipher' is
-                                 * ENGINE-provided */
     int encrypt;                /* encrypt or decrypt */
     int buf_len;                /* number we have left */
     unsigned char oiv[EVP_MAX_IV_LENGTH]; /* original iv */
index 7980f220cd850f4ce32aba197f8b5517105bf2ff..715fe062bf575a5792c3edc9408e1e84ecb6689d 100644 (file)
@@ -1574,7 +1574,6 @@ static int pkey_set_type(EVP_PKEY *pkey, ENGINE *e, int type, const char *str,
         } else {
             pkey->type = EVP_PKEY_KEYMGMT;
         }
-        pkey->engine = e;
 #endif
     }
     return 1;
index fc84067af1ba8752fbef64b4fcb80a1e8ab41927..4eef8dfd659ae682eaaaa2af6aa78a284d5bba23 100644 (file)
@@ -292,7 +292,6 @@ static EVP_PKEY_CTX *int_ctx_new(OSSL_LIB_CTX *libctx,
     ret->keytype = keytype;
     ret->keymgmt = keymgmt;
     ret->legacy_keytype = id;
-    ret->engine = e;
     ret->pmeth = pmeth;
     ret->operation = EVP_PKEY_OP_UNDEFINED;
 
index d6864dc237cd190f7335c302480f2473c6f4f45f..04c4ccdf1b2f5825f261a3086b0c2b5e2ca22900 100644 (file)
@@ -455,7 +455,7 @@ int ossl_rsa_pss_params_30_fromdata(RSA_PSS_PARAMS_30 *pss_params,
 int ossl_rsa_is_foreign(const RSA *rsa)
 {
 #ifndef FIPS_MODULE
-    if (rsa->engine != NULL || RSA_get_method(rsa) != RSA_PKCS1_OpenSSL())
+    if (RSA_get_method(rsa) != RSA_PKCS1_OpenSSL())
         return 1;
 #endif
     return 0;
index a517dcdca23074707e13da52f8302092534b1c26..f1e68114fdf7115de0a7516f7af5b3ad5b284c48 100644 (file)
@@ -710,7 +710,7 @@ int RSA_get_version(RSA *r)
 #ifndef FIPS_MODULE
 ENGINE *RSA_get0_engine(const RSA *r)
 {
-    return r->engine;
+    return NULL;
 }
 
 int RSA_pkey_ctx_ctrl(EVP_PKEY_CTX *ctx, int optype, int cmd, int p1, void *p2)
index bc6bd63996c5ded4ee051a8d069896f8d8ed3e01..5c10564a83c6f7b145ffc8fe10588ecb96622e44 100644 (file)
@@ -57,8 +57,6 @@ struct rsa_st {
     OSSL_LIB_CTX *libctx;
     int32_t version;
     const RSA_METHOD *meth;
-    /* functional reference if 'meth' is ENGINE-provided */
-    ENGINE *engine;
     BIGNUM *n;
     BIGNUM *e;
     BIGNUM *d;
index 6ad79180a091f620707bf904dfa674c7d43ab71b..8c3ca54ebef9ffea382c7289fa337053bfde348b 100644 (file)
@@ -83,7 +83,6 @@ struct ossl_store_loader_st {
 #ifndef OPENSSL_NO_DEPRECATED_3_0
     /* Legacy stuff */
     const char *scheme;
-    ENGINE *engine;
     OSSL_STORE_open_fn open;
     OSSL_STORE_attach_fn attach;
     OSSL_STORE_ctrl_fn ctrl;
index 6f73e197200ddd44158a6ed24283edb1411887bc..2368021e248dba975b469750b6e0ccd67a78a244 100644 (file)
@@ -46,14 +46,13 @@ OSSL_STORE_LOADER *OSSL_STORE_LOADER_new(ENGINE *e, const char *scheme)
     if ((res = OPENSSL_zalloc(sizeof(*res))) == NULL)
         return NULL;
 
-    res->engine = e;
     res->scheme = scheme;
     return res;
 }
 
 const ENGINE *OSSL_STORE_LOADER_get0_engine(const OSSL_STORE_LOADER *loader)
 {
-    return loader->engine;
+    return NULL;
 }
 
 const char *OSSL_STORE_LOADER_get0_scheme(const OSSL_STORE_LOADER *loader)
index ed867f77fbc981d2e6af276976f5f6446378e8c3..6c729a3dca41e94080326eaf7c77f5f2250a5100 100644 (file)
@@ -121,8 +121,6 @@ struct evp_pkey_ctx_st {
     int legacy_keytype;
     /* Method associated with this operation */
     const EVP_PKEY_METHOD *pmeth;
-    /* Engine that implements this method or NULL if builtin */
-    ENGINE *engine;
     /* Key: may be NULL */
     EVP_PKEY *pkey;
     /* Peer key for key agreement, may be NULL */
@@ -678,8 +676,6 @@ struct evp_pkey_st {
      * a pointer to a low level key and possibly a pointer to an engine.
      */
     const EVP_PKEY_ASN1_METHOD *ameth;
-    ENGINE *engine;
-    ENGINE *pmeth_engine; /* If not NULL public key ENGINE to use */
 
     /* Union to store the reference to an origin legacy key */
     union legacy_pkey_st pkey;