Skip to content

Commit af09617

Browse files
committed
corrected preprocessor branch in bn_mp_montgomery_setup.c
1 parent d7359c6 commit af09617

File tree

3 files changed

+7
-4
lines changed

3 files changed

+7
-4
lines changed

bn_mp_montgomery_setup.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ mp_err mp_montgomery_setup(const mp_int *n, mp_digit *rho)
2525
x = (((b + 2u) & 4u) << 1) + b; /* here x*a==1 mod 2**4 */
2626
x *= 2u - (b * x); /* here x*a==1 mod 2**8 */
2727
x *= 2u - (b * x); /* here x*a==1 mod 2**16 */
28-
#if (defined(MP_64BIT) || defined(MP_16BIT))
28+
#if defined(MP_64BIT) || !(defined(MP_16BIT))
2929
x *= 2u - (b * x); /* here x*a==1 mod 2**32 */
3030
#endif
3131
#ifdef MP_64BIT

bn_mp_prime_is_prime.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,12 @@ mp_err mp_prime_is_prime(const mp_int *a, int t, mp_bool *result)
100100
*/
101101
#ifndef LTM_USE_FIPS_ONLY
102102
if (t >= 0) {
103-
#ifdef LTM_USE_FROBENIUS_TEST
103+
/*
104+
* Use a Frobenius-Underwood test instead of the Lucas-Selfridge test for
105+
* MP_8BIT (It is unknown if the Lucas-Selfridge test works with 16-bit
106+
* integers but the necesssary analysis is on the todo-list).
107+
*/
108+
#ifdef (LTM_USE_FROBENIUS_TEST)
104109
err = mp_prime_frobenius_underwood(a, &res);
105110
if ((err != MP_OKAY) && (err != MP_ITER)) {
106111
goto LBL_B;
@@ -228,7 +233,6 @@ mp_err mp_prime_is_prime(const mp_int *a, int t, mp_bool *result)
228233
* an unsigned int and "mask" on the other side is most probably not.
229234
*/
230235
fips_rand = (unsigned int)(b.dp[0] & (mp_digit) mask);
231-
232236
if (fips_rand > (unsigned int)(INT_MAX - MP_DIGIT_BIT)) {
233237
len = INT_MAX / MP_DIGIT_BIT;
234238
} else {

bn_mp_prime_strong_lucas_selfridge.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -278,6 +278,5 @@ mp_err mp_prime_strong_lucas_selfridge(const mp_int *a, mp_bool *result)
278278
mp_clear_multi(&Q2kdz, &T4z, &T3z, &T2z, &T1z, &Qkdz, &Q2mz, &Qmz, &V2mz, &U2mz, &Vz, &Uz, &Np1, &gcd, &Dz, NULL);
279279
return err;
280280
}
281-
282281
#endif
283282
#endif

0 commit comments

Comments
 (0)