Replace NSS with Pale Moon's

This commit is contained in:
wuggy 2026-06-29 21:29:25 +01:00
commit 8c2e376f94
2870 changed files with 1762232 additions and 1374220 deletions

View file

@ -78,7 +78,7 @@ DH_GenParam(int primeLen, DHParams **params)
CHECK_MPI_OK(mp_init(&h));
CHECK_MPI_OK(mp_init(&psub1));
CHECK_MPI_OK(mp_init(&test));
/* generate prime with MPI, uses Miller-Rabin to generate strong prime. */
/* generate prime with MPI, uses Miller-Rabin to generate safe prime. */
CHECK_SEC_OK(generate_prime(&p, primeLen));
/* construct Sophie-Germain prime q = (p-1)/2. */
CHECK_MPI_OK(mp_sub_d(&p, 1, &psub1));
@ -257,17 +257,17 @@ DH_Derive(SECItem *publicValue,
}
/*
* We check to make sure that ZZ is not equal to 1 or -1 mod p.
* We check to make sure that ZZ is not equal to 0, 1 or -1 mod p.
* This helps guard against small subgroup attacks, since an attacker
* using a subgroup of size N will produce 1 or -1 with probability 1/N.
* using a subgroup of size N will produce 0, 1 or -1 with probability 1/N.
* When the protocol is executed within a properly large subgroup, the
* probability of this result will be negligibly small. For example,
* with a strong prime of the form 2p+1, the probability will be 1/p.
* with a safe prime of the form 2q+1, the probability will be 1/q.
*
* We return MP_BADARG because this is probably the result of a bad
* public value or a bad prime having been provided.
*/
if (mp_cmp_d(&ZZ, 1) == 0 ||
if (mp_cmp_d(&ZZ, 0) == 0 || mp_cmp_d(&ZZ, 1) == 0 ||
mp_cmp(&ZZ, &psub1) == 0) {
err = MP_BADARG;
goto cleanup;
@ -413,6 +413,35 @@ cleanup:
return SECSuccess;
}
/* Test counts based on the fact the prime and subprime
* were given to us */
static int
dh_prime_testcount(int prime_length)
{
if (prime_length < 1024) {
return 50;
} else if (prime_length < 2048) {
return 40;
} else if (prime_length < 3072) {
return 56;
}
return 64;
}
PRBool
KEA_PrimeCheck(SECItem *prime)
{
mp_int p;
mp_err err = 0;
MP_DIGITS(&p) = 0;
CHECK_MPI_OK(mp_init(&p));
SECITEM_TO_MPINT(*prime, &p);
CHECK_MPI_OK(mpp_pprime_secure(&p, dh_prime_testcount(prime->len)));
cleanup:
mp_clear(&p);
return err ? PR_FALSE : PR_TRUE;
}
PRBool
KEA_Verify(SECItem *Y, SECItem *prime, SECItem *subPrime)
{