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

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