Blame SOURCES/nss-3.66-no-small-primes.patch

b31f4f
diff -up ./gtests/softoken_gtest/softoken_dh_vectors.h.orig ./gtests/softoken_gtest/softoken_dh_vectors.h
b31f4f
--- ./gtests/softoken_gtest/softoken_dh_vectors.h.orig	2021-06-02 16:57:50.557008790 -0700
b31f4f
+++ ./gtests/softoken_gtest/softoken_dh_vectors.h	2021-06-02 16:59:52.781735096 -0700
b31f4f
@@ -2872,7 +2872,7 @@ static const DhTestVector DH_TEST_VECTOR
b31f4f
      {siBuffer, (unsigned char *)g2, sizeof(g2)},
b31f4f
      {siBuffer, NULL, 0},
b31f4f
      {siBuffer, NULL, 0},
b31f4f
-     IKE_APPROVED,
b31f4f
+     SAFE_PRIME,
b31f4f
      CLASS_1536},
b31f4f
     {"IKE 2048",
b31f4f
      {siBuffer, (unsigned char *)prime_ike_2048, sizeof(prime_ike_2048)},
b31f4f
@@ -2952,7 +2952,7 @@ static const DhTestVector DH_TEST_VECTOR
b31f4f
      {siBuffer, (unsigned char *)sub2_prime_ike_1536,
b31f4f
       sizeof(sub2_prime_ike_1536)},
b31f4f
      {siBuffer, NULL, 0},
b31f4f
-     IKE_APPROVED,
b31f4f
+     SAFE_PRIME,
b31f4f
      CLASS_1536},
b31f4f
     {"IKE 2048 with subprime",
b31f4f
      {siBuffer, (unsigned char *)prime_ike_2048, sizeof(prime_ike_2048)},
b31f4f
diff -up ./lib/softoken/pkcs11c.c.orig ./lib/softoken/pkcs11c.c
b31f4f
--- ./lib/softoken/pkcs11c.c.orig	2021-05-28 02:50:43.000000000 -0700
b31f4f
+++ ./lib/softoken/pkcs11c.c	2021-06-02 16:52:01.196932757 -0700
b31f4f
@@ -5193,7 +5193,7 @@ sftk_PairwiseConsistencyCheck(CK_SESSION
b31f4f
                 /* subprime not supplied, In this case look it up.
b31f4f
                  * This only works with approved primes, but in FIPS mode
b31f4f
                  * that's the only kine of prime that will get here */
b31f4f
-                subPrimePtr = sftk_VerifyDH_Prime(&prime);
b31f4f
+                subPrimePtr = sftk_VerifyDH_Prime(&prime,isFIPS);
b31f4f
                 if (subPrimePtr == NULL) {
b31f4f
                     crv = CKR_GENERAL_ERROR;
b31f4f
                     goto done;
b31f4f
@@ -8351,7 +8351,7 @@ NSC_DeriveKey(CK_SESSION_HANDLE hSession
b31f4f
 
b31f4f
             /* if the prime is an approved prime, we can skip all the other
b31f4f
              * checks. */
b31f4f
-            subPrime = sftk_VerifyDH_Prime(&dhPrime);
b31f4f
+            subPrime = sftk_VerifyDH_Prime(&dhPrime,isFIPS);
b31f4f
             if (subPrime == NULL) {
b31f4f
                 SECItem dhSubPrime;
b31f4f
                 /* If the caller set the subprime value, it means that
b31f4f
diff -up ./lib/softoken/pkcs11i.h.orig ./lib/softoken/pkcs11i.h
b31f4f
--- ./lib/softoken/pkcs11i.h.orig	2021-06-02 16:52:01.196932757 -0700
b31f4f
+++ ./lib/softoken/pkcs11i.h	2021-06-02 16:52:54.281248207 -0700
b31f4f
@@ -946,7 +946,7 @@ char **NSC_ModuleDBFunc(unsigned long fu
b31f4f
 /* dh verify functions */
b31f4f
 /* verify that dhPrime matches one of our known primes, and if so return
b31f4f
  * it's subprime value */
b31f4f
-const SECItem *sftk_VerifyDH_Prime(SECItem *dhPrime);
b31f4f
+const SECItem *sftk_VerifyDH_Prime(SECItem *dhPrime, PRBool isFIPS);
b31f4f
 /* check if dhSubPrime claims dhPrime is a safe prime. */
b31f4f
 SECStatus sftk_IsSafePrime(SECItem *dhPrime, SECItem *dhSubPrime, PRBool *isSafe);
b31f4f
 /* map an operation Attribute to a Mechanism flag */
b31f4f
diff -up ./lib/softoken/pkcs11u.c.orig ./lib/softoken/pkcs11u.c
b31f4f
--- ./lib/softoken/pkcs11u.c.orig	2021-06-02 16:54:23.387777705 -0700
b31f4f
+++ ./lib/softoken/pkcs11u.c	2021-06-02 16:54:51.012941866 -0700
b31f4f
@@ -2312,7 +2312,7 @@ sftk_handleSpecial(SFTKSlot *slot, CK_ME
b31f4f
             if (crv != CKR_OK) {
b31f4f
                 return PR_FALSE;
b31f4f
             }
b31f4f
-            dhSubPrime = sftk_VerifyDH_Prime(&dhPrime);
b31f4f
+            dhSubPrime = sftk_VerifyDH_Prime(&dhPrime, PR_TRUE);
b31f4f
             SECITEM_ZfreeItem(&dhPrime, PR_FALSE);
b31f4f
             return (dhSubPrime) ? PR_TRUE : PR_FALSE;
b31f4f
         }
b31f4f
diff -up ./lib/softoken/sftkdhverify.c.orig ./lib/softoken/sftkdhverify.c
b31f4f
--- ./lib/softoken/sftkdhverify.c.orig	2021-05-28 02:50:43.000000000 -0700
b31f4f
+++ ./lib/softoken/sftkdhverify.c	2021-06-02 16:52:01.196932757 -0700
b31f4f
@@ -1171,11 +1171,15 @@ static const SECItem subprime_tls_8192 =
b31f4f
  * verify that dhPrime matches one of our known primes
b31f4f
  */
b31f4f
 const SECItem *
b31f4f
-sftk_VerifyDH_Prime(SECItem *dhPrime)
b31f4f
+sftk_VerifyDH_Prime(SECItem *dhPrime, PRBool isFIPS)
b31f4f
 {
b31f4f
     /* use the length to decide which primes to check */
b31f4f
     switch (dhPrime->len) {
b31f4f
         case 1536 / PR_BITS_PER_BYTE:
b31f4f
+            /* don't accept 1536 bit primes in FIPS mode */
b31f4f
+            if (isFIPS) {
b31f4f
+                break;
b31f4f
+            }
b31f4f
             if (PORT_Memcmp(dhPrime->data, prime_ike_1536,
b31f4f
                             sizeof(prime_ike_1536)) == 0) {
b31f4f
                 return &subprime_ike_1536;