Bump actions/upload-artifacts version
[libtommath.git] / s_mp_prime_is_divisible.c
blob63b2405ab3d6d874320925757466c1d91474ea95
1 #include "tommath_private.h"
2 #ifdef S_MP_PRIME_IS_DIVISIBLE_C
3 /* LibTomMath, multiple-precision integer library -- Tom St Denis */
4 /* SPDX-License-Identifier: Unlicense */
6 /* determines if an integers is divisible by one
7 * of the first PRIME_SIZE primes or not
9 * sets result to 0 if not, 1 if yes
11 mp_err s_mp_prime_is_divisible(const mp_int *a, bool *result)
13 int i;
14 for (i = 0; i < MP_PRIME_TAB_SIZE; i++) {
15 /* what is a mod LBL_prime_tab[i] */
16 mp_err err;
17 mp_digit res;
18 if ((err = mp_mod_d(a, s_mp_prime_tab[i], &res)) != MP_OKAY) {
19 return err;
22 /* is the residue zero? */
23 if (res == 0u) {
24 *result = true;
25 return MP_OKAY;
29 /* default to not */
30 *result = false;
31 return MP_OKAY;
33 #endif