]> git.ipfire.org Git - thirdparty/openssl.git/commitdiff
CRYPTO: Remove the check for built-in methods in the export_to function
authorRichard Levitte <levitte@openssl.org>
Tue, 6 Jul 2021 06:44:37 +0000 (08:44 +0200)
committerRichard Levitte <levitte@openssl.org>
Wed, 7 Jul 2021 13:38:21 +0000 (15:38 +0200)
That check was seen as necessary at the time, but other changes have
been made since, so we now have better control on when we're handling
legacy structures and methods, making it safe to run the export_to
function on keys with foreign methods.

The basic message is that foreign methods must set key structure
values according to our standards no matter what, or not set them at
all.  This has really always been the case, but was harder to see at
the time because of interaction with other bugs.

Fixes #15927

Reviewed-by: Tim Hudson <tjh@openssl.org>
Reviewed-by: Paul Dale <pauli@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/15996)

crypto/dh/dh_ameth.c
crypto/dsa/dsa_ameth.c
crypto/ec/ec_ameth.c
crypto/rsa/rsa_ameth.c

index 3d23321b59df09a1cc6b9a379c1d0a44cd94a5d6..0e577177ec4a81567e93f9a719eaa5ad2b61b8bc 100644 (file)
@@ -453,13 +453,6 @@ static int dh_pkey_export_to(const EVP_PKEY *from, void *to_keydata,
     int selection = 0;
     int rv = 0;
 
-    /*
-     * If the DH method is foreign, then we can't be sure of anything, and
-     * can therefore not export or pretend to export.
-     */
-    if (ossl_dh_get_method(dh) != DH_OpenSSL())
-        return 0;
-
     if (p == NULL || g == NULL)
         return 0;
 
index ea9f83995509d52345c1f2034ce5e46d973f9c73..53417bff6a47169be95116a550c963728f5a7a8f 100644 (file)
@@ -436,13 +436,6 @@ static int dsa_pkey_export_to(const EVP_PKEY *from, void *to_keydata,
     int selection = 0;
     int rv = 0;
 
-    /*
-     * If the DSA method is foreign, then we can't be sure of anything, and
-     * can therefore not export or pretend to export.
-     */
-    if (DSA_get_method(dsa) != DSA_OpenSSL())
-        return 0;
-
     if (p == NULL || q == NULL || g == NULL)
         return 0;
 
index c7fbaeab5e9ee216ca073c8b3affe408c3770b22..9ca023bbe3afd7e2835b5b5dc4c9d264a93f7ca4 100644 (file)
@@ -498,13 +498,6 @@ int ec_pkey_export_to(const EVP_PKEY *from, void *to_keydata,
             || (ecg = EC_KEY_get0_group(eckey)) == NULL)
         return 0;
 
-    /*
-     * If the EC_KEY method is foreign, then we can't be sure of anything,
-     * and can therefore not export or pretend to export.
-     */
-    if (EC_KEY_get_method(eckey) != EC_KEY_OpenSSL())
-        return 0;
-
     tmpl = OSSL_PARAM_BLD_new();
     if (tmpl == NULL)
         return 0;
index 1d3b8685bd2897cf76024afce2717d4dc038cdf5..b1580ca48cf2e9081223a761f380c09a4357fb8d 100644 (file)
@@ -738,13 +738,6 @@ static int rsa_int_export_to(const EVP_PKEY *from, int rsa_type,
 
     if (tmpl == NULL)
         return 0;
-    /*
-     * If the RSA method is foreign, then we can't be sure of anything, and
-     * can therefore not export or pretend to export.
-     */
-    if (RSA_get_method(rsa) != RSA_PKCS1_OpenSSL())
-        goto err;
-
     /* Public parameters must always be present */
     if (RSA_get0_n(rsa) == NULL || RSA_get0_e(rsa) == NULL)
         goto err;