Merge pull request #578 from PX4/fix_mp_prime_strong_lucas_lefridge_compilation
[libtommath.git] / mp_dr_is_modulus.c
blob72b3c968148dd731c1ce19f509e3b03107ac73c2
1 #include "tommath_private.h"
2 #ifdef MP_DR_IS_MODULUS_C
3 /* LibTomMath, multiple-precision integer library -- Tom St Denis */
4 /* SPDX-License-Identifier: Unlicense */
6 /* determines if a number is a valid DR modulus */
7 bool mp_dr_is_modulus(const mp_int *a)
9 int ix;
11 /* must be at least two digits */
12 if (a->used < 2) {
13 return false;
16 /* must be of the form b**k - a [a <= b] so all
17 * but the first digit must be equal to -1 (mod b).
19 for (ix = 1; ix < a->used; ix++) {
20 if (a->dp[ix] != MP_MASK) {
21 return false;
24 return true;
27 #endif