1 #include "tommath_private.h"
2 #ifdef MP_REDUCE_IS_2K_C
3 /* LibTomMath, multiple-precision integer library -- Tom St Denis */
4 /* SPDX-License-Identifier: Unlicense */
6 /* determines if mp_reduce_2k can be used */
7 bool mp_reduce_is_2k(const mp_int
*a
)
11 } else if (a
->used
== 1) {
13 } else if (a
->used
> 1) {
16 /* Algorithm as implemented does not work if the least significant digit is zero */
17 iz
= a
->dp
[0] & MP_MASK
;
22 iy
= mp_count_bits(a
);
24 /* Test every bit from the second digit up, must be 1 */
25 for (ix
= MP_DIGIT_BIT
; ix
< iy
; ix
++) {
26 if ((a
->dp
[iw
] & iz
) == 0u) {
30 if (iz
> MP_DIGIT_MAX
) {