]> git.ipfire.org Git - thirdparty/openssl.git/commitdiff
import pct: remove import PCTs for most algorithms
authorPauli <ppzgs1@gmail.com>
Thu, 4 Sep 2025 21:23:28 +0000 (07:23 +1000)
committerNeil Horman <nhorman@openssl.org>
Sat, 6 Sep 2025 13:28:22 +0000 (09:28 -0400)
This coveres DH, EC, RSA and SLH-DSA.

Reviewed-by: Neil Horman <nhorman@openssl.org>
Reviewed-by: Tim Hudson <tjh@openssl.org>
Reviewed-by: Shane Lontis <shane.lontis@oracle.com>
(Merged from https://github.com/openssl/openssl/pull/28447)

(cherry picked from commit 7f7f75816f2643daa9c1ba986aa17d50ae72dce7)

providers/implementations/keymgmt/dh_kmgmt.c
providers/implementations/keymgmt/ec_kmgmt.c
providers/implementations/keymgmt/rsa_kmgmt.c
providers/implementations/keymgmt/slh_dsa_kmgmt.c.in

index 431d649eb0afb1e808c68c337c7aedfdcaf9ddb0..4cc0920fac11b26396b885f3d91b3ba92afa04c8 100644 (file)
@@ -209,18 +209,6 @@ static int dh_import(void *keydata, int selection, const OSSL_PARAM params[])
             selection & OSSL_KEYMGMT_SELECT_PRIVATE_KEY ? 1 : 0;
 
         ok = ok && ossl_dh_key_fromdata(dh, params, include_private);
-#ifdef FIPS_MODULE
-        /*
-         * FIPS 140-3 IG 10.3.A additional comment 1 mandates that a pairwise
-         * consistency check be undertaken on key import.  The required test
-         * is described in SP 800-56Ar3 5.6.2.1.4.
-         */
-        if (ok > 0 && !ossl_fips_self_testing()) {
-            ok = ossl_dh_check_pairwise(dh, 1);
-            if (ok <= 0)
-                ossl_set_error_state(OSSL_SELF_TEST_TYPE_PCT_IMPORT);
-        }
-#endif  /* FIPS_MODULE */
     }
 
     return ok;
index f4d8ba7254c0d51dfdf71063855522ed12e176b4..5b7cca59c56a4375af42dc4ae6d98f5e46e892d6 100644 (file)
@@ -431,21 +431,6 @@ int common_import(void *keydata, int selection, const OSSL_PARAM params[],
     if ((selection & OSSL_KEYMGMT_SELECT_OTHER_PARAMETERS) != 0)
         ok = ok && ossl_ec_key_otherparams_fromdata(ec, params);
 
-#ifdef FIPS_MODULE
-    if (ok > 0
-            && !ossl_fips_self_testing()
-            && EC_KEY_get0_public_key(ec) != NULL
-            && EC_KEY_get0_private_key(ec) != NULL
-            && EC_KEY_get0_group(ec) != NULL) {
-        BN_CTX *bnctx = BN_CTX_new_ex(ossl_ec_key_get_libctx(ec));
-
-        ok = bnctx != NULL && ossl_ec_key_pairwise_check(ec, bnctx);
-        BN_CTX_free(bnctx);
-        if (ok <= 0)
-            ossl_set_error_state(OSSL_SELF_TEST_TYPE_PCT_IMPORT);
-    }
-#endif  /* FIPS_MODULE */
-
     return ok;
 }
 
index 38ca5e77f906fd839710d365e3dd7c12d0e465e1..68691280cdf6024598c6c1a2e4f78d838c1bfc44 100644 (file)
@@ -197,23 +197,6 @@ static int rsa_import(void *keydata, int selection, const OSSL_PARAM params[])
         ok = ok && ossl_rsa_fromdata(rsa, params, include_private);
     }
 
-#ifdef FIPS_MODULE
-    if (ok > 0 && !ossl_fips_self_testing()) {
-        const BIGNUM *n, *e, *d, *dp, *dq, *iq, *p, *q;
-
-        RSA_get0_key(rsa, &n, &e, &d);
-        RSA_get0_crt_params(rsa, &dp, &dq, &iq);
-        p = RSA_get0_p(rsa);
-        q = RSA_get0_q(rsa);
-
-        /* Check for the public key */
-        if (n != NULL && e != NULL)
-            /* Check for private key in straightforward or CRT form */
-            if (d != NULL || (p != NULL && q != NULL && dp != NULL
-                              && dq != NULL && iq != NULL))
-                ok = ossl_rsa_key_pairwise_test(rsa);
-    }
-#endif  /* FIPS_MODULE */
     return ok;
 }
 
index aa62efe718cfafeace143c227206acfab6eb7283..e2690731efaebc6fdcc2acdf898b707100561c40 100644 (file)
@@ -119,7 +119,7 @@ static int slh_dsa_validate(const void *key_data, int selection, int check_type)
 static int slh_dsa_import(void *keydata, int selection, const OSSL_PARAM params[])
 {
     SLH_DSA_KEY *key = keydata;
-    int include_priv, res;
+    int include_priv;
     struct slh_dsa_import_st p;
 
     if (!ossl_prov_is_running()
@@ -131,21 +131,7 @@ static int slh_dsa_import(void *keydata, int selection, const OSSL_PARAM params[
         return 0;
 
     include_priv = ((selection & OSSL_KEYMGMT_SELECT_PRIVATE_KEY) != 0);
-    res = ossl_slh_dsa_key_fromdata(key, p.pub, p.priv, include_priv);
-#ifdef FIPS_MODULE
-    /*
-     * FIPS 140-3 IG 10.3.A additional comment 1 mandates that a pairwise
-     * consistency check be undertaken on key import.  The required test
-     * is described in SP 800-56Ar3 5.6.2.1.4.
-     */
-    if (res > 0 && ossl_slh_dsa_key_has(key, OSSL_KEYMGMT_SELECT_KEYPAIR) > 0)
-        if (!slh_dsa_fips140_pairwise_test(key, NULL)) {
-            ossl_set_error_state(OSSL_SELF_TEST_TYPE_PCT_IMPORT);
-            ossl_slh_dsa_key_reset(key);
-            res = 0;
-        }
-#endif  /* FIPS_MODULE */
-    return res;
+    return ossl_slh_dsa_key_fromdata(key, p.pub, p.priv, include_priv);
 }
 
 static const OSSL_PARAM *slh_dsa_imexport_types(int selection)