mirror of
https://repo.dactyloidae.xyz/Dactyloidae/UXP.git
synced 2026-09-25 09:57:32 +09:00
Replace NSS with Pale Moon's
This commit is contained in:
parent
ff1e5e48bf
commit
8c2e376f94
2870 changed files with 1762232 additions and 1374220 deletions
|
|
@ -129,20 +129,27 @@ CLEANUP:
|
|||
}
|
||||
#endif
|
||||
|
||||
STATIC
|
||||
mp_err
|
||||
s_mp_to_mont(const mp_int *x, mp_mont_modulus *mmm, mp_int *xMont)
|
||||
mp_to_mont(const mp_int *x, const mp_int *N, mp_int *xMont)
|
||||
{
|
||||
mp_err res;
|
||||
|
||||
/* xMont = x * R mod N where N is modulus */
|
||||
MP_CHECKOK(mp_copy(x, xMont));
|
||||
MP_CHECKOK(s_mp_lshd(xMont, MP_USED(&mmm->N))); /* xMont = x << b */
|
||||
MP_CHECKOK(mp_div(xMont, &mmm->N, 0, xMont)); /* mod N */
|
||||
if (x != xMont) {
|
||||
MP_CHECKOK(mp_copy(x, xMont));
|
||||
}
|
||||
MP_CHECKOK(s_mp_lshd(xMont, MP_USED(N))); /* xMont = x << b */
|
||||
MP_CHECKOK(mp_div(xMont, N, 0, xMont)); /* mod N */
|
||||
CLEANUP:
|
||||
return res;
|
||||
}
|
||||
|
||||
mp_digit
|
||||
mp_calculate_mont_n0i(const mp_int *N)
|
||||
{
|
||||
return 0 - s_mp_invmod_radix(MP_DIGIT(N, 0));
|
||||
}
|
||||
|
||||
#ifdef MP_USING_MONT_MULF
|
||||
|
||||
/* the floating point multiply is already cache safe,
|
||||
|
|
@ -198,7 +205,7 @@ mp_exptmod_f(const mp_int *montBase,
|
|||
MP_CHECKOK(mp_init_size(&accum1, 3 * nLen + 2));
|
||||
|
||||
mp_set(&accum1, 1);
|
||||
MP_CHECKOK(s_mp_to_mont(&accum1, mmm, &accum1));
|
||||
MP_CHECKOK(mp_to_mont(&accum1, &(mmm->N), &accum1));
|
||||
MP_CHECKOK(s_mp_pad(&accum1, nLen));
|
||||
|
||||
oddPowSize = 2 * nLen + 1;
|
||||
|
|
@ -478,7 +485,7 @@ mp_exptmod_i(const mp_int *montBase,
|
|||
|
||||
/* set accumulator to montgomery residue of 1 */
|
||||
mp_set(&accum1, 1);
|
||||
MP_CHECKOK(s_mp_to_mont(&accum1, mmm, &accum1));
|
||||
MP_CHECKOK(mp_to_mont(&accum1, &(mmm->N), &accum1));
|
||||
pa1 = &accum1;
|
||||
pa2 = &accum2;
|
||||
|
||||
|
|
@ -723,10 +730,11 @@ mp_set_safe_modexp(int value)
|
|||
* mp_ints that use less than nDigits digits are logically padded with zeros
|
||||
* while being stored in the weaved array.
|
||||
*/
|
||||
mp_err mpi_to_weave(const mp_int *bignums,
|
||||
mp_digit *weaved,
|
||||
mp_size nDigits, /* in each mp_int of input */
|
||||
mp_size nBignums) /* in the entire source array */
|
||||
mp_err
|
||||
mpi_to_weave(const mp_int *bignums,
|
||||
mp_digit *weaved,
|
||||
mp_size nDigits, /* in each mp_int of input */
|
||||
mp_size nBignums) /* in the entire source array */
|
||||
{
|
||||
mp_size i;
|
||||
mp_digit *endDest = weaved + (nDigits * nBignums);
|
||||
|
|
@ -765,11 +773,12 @@ mp_err mpi_to_weave(const mp_int *bignums,
|
|||
* Every read accesses every element of the weaved array, in order to
|
||||
* avoid timing attacks based on patterns of memory accesses.
|
||||
*/
|
||||
mp_err weave_to_mpi(mp_int *a, /* out, result */
|
||||
const mp_digit *weaved, /* in, byte matrix */
|
||||
mp_size index, /* which column to read */
|
||||
mp_size nDigits, /* number of mp_digits in each bignum */
|
||||
mp_size nBignums) /* width of the matrix */
|
||||
mp_err
|
||||
weave_to_mpi(mp_int *a, /* out, result */
|
||||
const mp_digit *weaved, /* in, byte matrix */
|
||||
mp_size index, /* which column to read */
|
||||
mp_size nDigits, /* number of mp_digits in each bignum */
|
||||
mp_size nBignums) /* width of the matrix */
|
||||
{
|
||||
/* these are indices, but need to be the same size as mp_digit
|
||||
* because of the CONST_TIME operations */
|
||||
|
|
@ -865,7 +874,7 @@ mp_exptmod_safe_i(const mp_int *montBase,
|
|||
MP_CHECKOK(mp_init_size(&accum[2], 3 * nLen + 2));
|
||||
MP_CHECKOK(mp_init_size(&accum[3], 3 * nLen + 2));
|
||||
mp_set(&accum[0], 1);
|
||||
MP_CHECKOK(s_mp_to_mont(&accum[0], mmm, &accum[0]));
|
||||
MP_CHECKOK(mp_to_mont(&accum[0], &(mmm->N), &accum[0]));
|
||||
MP_CHECKOK(mp_copy(montBase, &accum[1]));
|
||||
SQR(montBase, &accum[2]);
|
||||
MUL_NOWEAVE(montBase, &accum[2], &accum[3]);
|
||||
|
|
@ -884,7 +893,7 @@ mp_exptmod_safe_i(const mp_int *montBase,
|
|||
} else {
|
||||
if (first_window == 0) {
|
||||
mp_set(&accum1, 1);
|
||||
MP_CHECKOK(s_mp_to_mont(&accum1, mmm, &accum1));
|
||||
MP_CHECKOK(mp_to_mont(&accum1, &(mmm->N), &accum1));
|
||||
} else {
|
||||
/* assert first_window == 1? */
|
||||
MP_CHECKOK(mp_copy(montBase, &accum1));
|
||||
|
|
@ -1006,7 +1015,11 @@ CLEANUP:
|
|||
mp_clear(&accum[2]);
|
||||
mp_clear(&accum[3]);
|
||||
mp_clear(&tmp);
|
||||
/* PORT_Memset(powers,0,num_powers*nLen*sizeof(mp_digit)); */
|
||||
/* zero required by FIPS here, can't use PORT_ZFree
|
||||
* because mpi doesn't link with util */
|
||||
if (powers) {
|
||||
PORT_Memset(powers, 0, num_powers * sizeof(mp_digit));
|
||||
}
|
||||
free(powersArray);
|
||||
return res;
|
||||
}
|
||||
|
|
@ -1051,9 +1064,9 @@ mp_exptmod(const mp_int *inBase, const mp_int *exponent,
|
|||
/* compute n0', given n0, n0' = -(n0 ** -1) mod MP_RADIX
|
||||
** where n0 = least significant mp_digit of N, the modulus.
|
||||
*/
|
||||
mmm.n0prime = 0 - s_mp_invmod_radix(MP_DIGIT(modulus, 0));
|
||||
mmm.n0prime = mp_calculate_mont_n0i(modulus);
|
||||
|
||||
MP_CHECKOK(s_mp_to_mont(base, &mmm, &montBase));
|
||||
MP_CHECKOK(mp_to_mont(base, modulus, &montBase));
|
||||
|
||||
bits_in_exponent = mpl_significant_bits(exponent);
|
||||
#ifdef MP_USING_CACHE_SAFE_MOD_EXP
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue