replace mp_bool by stdbool

* This gives the advantage that static analysis **understands** bool,
  but complains about using an enum type instead of bool.

* If stdbool.h is not desired, true/false/bool can be replaced using sed
  as in the no-stdint-h branch.

* We already include stdint.h and stdbool.h is not more harmful than
  this header
This commit is contained in:
Daniel Mendler 2019-10-24 22:02:29 +02:00
parent c91c1ba2b1
commit bf9507a9d4
No known key found for this signature in database
GPG Key ID: D88ADB2A2693CA43
19 changed files with 78 additions and 83 deletions

View File

@ -823,7 +823,7 @@ static int test_mp_is_square(void)
int i, n;
mp_int a, b;
mp_bool res;
bool res;
if (mp_init_multi(&a, &b, NULL)!= MP_OKAY) {
return EXIT_FAILURE;
@ -945,7 +945,7 @@ static int test_mp_prime_is_prime(void)
{
int ix;
mp_err err;
mp_bool cnt, fu;
bool cnt, fu;
mp_int a, b;
if (mp_init_multi(&a, &b, NULL)!= MP_OKAY) {
@ -1061,7 +1061,7 @@ static int test_mp_prime_next_prime(void)
/* edge cases */
mp_set(&a, 0u);
if ((err = mp_prime_next_prime(&a, 5, MP_NO)) != MP_OKAY) {
if ((err = mp_prime_next_prime(&a, 5, false)) != MP_OKAY) {
goto LBL_ERR;
}
if (mp_cmp_d(&a, 2u) != MP_EQ) {
@ -1072,7 +1072,7 @@ static int test_mp_prime_next_prime(void)
}
mp_set(&a, 0u);
if ((err = mp_prime_next_prime(&a, 5, MP_YES)) != MP_OKAY) {
if ((err = mp_prime_next_prime(&a, 5, true)) != MP_OKAY) {
goto LBL_ERR;
}
if (mp_cmp_d(&a, 3u) != MP_EQ) {
@ -1083,7 +1083,7 @@ static int test_mp_prime_next_prime(void)
}
mp_set(&a, 2u);
if ((err = mp_prime_next_prime(&a, 5, MP_NO)) != MP_OKAY) {
if ((err = mp_prime_next_prime(&a, 5, false)) != MP_OKAY) {
goto LBL_ERR;
}
if (mp_cmp_d(&a, 3u) != MP_EQ) {
@ -1094,7 +1094,7 @@ static int test_mp_prime_next_prime(void)
}
mp_set(&a, 2u);
if ((err = mp_prime_next_prime(&a, 5, MP_YES)) != MP_OKAY) {
if ((err = mp_prime_next_prime(&a, 5, true)) != MP_OKAY) {
goto LBL_ERR;
}
if (mp_cmp_d(&a, 3u) != MP_EQ) {
@ -1104,7 +1104,7 @@ static int test_mp_prime_next_prime(void)
goto LBL_ERR;
}
mp_set(&a, 8);
if ((err = mp_prime_next_prime(&a, 5, MP_YES)) != MP_OKAY) {
if ((err = mp_prime_next_prime(&a, 5, true)) != MP_OKAY) {
goto LBL_ERR;
}
if (mp_cmp_d(&a, 11u) != MP_EQ) {
@ -1130,7 +1130,7 @@ static int test_mp_prime_next_prime(void)
if ((err = mp_add(&b, &c, &b)) != MP_OKAY) {
goto LBL_ERR;
}
if ((err = mp_prime_next_prime(&a, 5, MP_NO)) != MP_OKAY) {
if ((err = mp_prime_next_prime(&a, 5, false)) != MP_OKAY) {
goto LBL_ERR;
}
if (mp_cmp(&a, &b) != MP_EQ) {
@ -1160,7 +1160,7 @@ static int test_mp_prime_next_prime(void)
if ((err = mp_add(&b, &c, &b)) != MP_OKAY) {
goto LBL_ERR;
}
if ((err = mp_prime_next_prime(&a, 5, MP_YES)) != MP_OKAY) {
if ((err = mp_prime_next_prime(&a, 5, true)) != MP_OKAY) {
goto LBL_ERR;
}
if (mp_cmp(&a, &b) != MP_EQ) {
@ -1284,7 +1284,7 @@ static int test_mp_read_radix(void)
char *s = fgets(buf, sizeof(buf), stdin);
if (s != buf) break;
mp_read_radix(&a, buf, 10);
mp_prime_next_prime(&a, 5, MP_YES);
mp_prime_next_prime(&a, 5, true);
mp_to_radix(&a, buf, sizeof(buf), NULL, 10);
printf("%s, %lu\n", buf, (unsigned long)a.dp[0] & 3uL);
}

View File

@ -8,7 +8,7 @@ int main(void)
{
char buf[2000];
size_t x;
mp_bool y;
bool y;
mp_int q, p;
FILE *out;
clock_t t1;

View File

@ -5,7 +5,7 @@ static int sizes[] = { 1+256/MP_DIGIT_BIT, 1+512/MP_DIGIT_BIT, 1+768/MP_DIGIT_BI
int main(void)
{
mp_bool res;
bool res;
int x, y;
char buf[4096];
FILE *out;
@ -30,7 +30,7 @@ top:
a.used = sizes[x];
/* now loop */
res = MP_NO;
res = false;
for (;;) {
a.dp[0] += 4uL;
if (a.dp[0] >= MP_MASK) break;

View File

@ -5,13 +5,13 @@
#include <time.h>
#include <tommath.h>
static mp_err is_mersenne(long s, mp_bool *pp)
static mp_err is_mersenne(long s, bool *pp)
{
mp_int n, u;
mp_err res;
int k;
*pp = MP_NO;
*pp = false;
if ((res = mp_init(&n)) != MP_OKAY) {
return res;
@ -103,7 +103,7 @@ static int isprime(long k)
int main(void)
{
mp_bool pp;
bool pp;
long k;
clock_t tt;

View File

@ -4,13 +4,13 @@
/* SPDX-License-Identifier: Unlicense */
/* determines if a number is a valid DR modulus */
mp_bool mp_dr_is_modulus(const mp_int *a)
bool mp_dr_is_modulus(const mp_int *a)
{
int ix;
/* must be at least two digits */
if (a->used < 2) {
return MP_NO;
return false;
}
/* must be of the form b**k - a [a <= b] so all
@ -18,10 +18,10 @@ mp_bool mp_dr_is_modulus(const mp_int *a)
*/
for (ix = 1; ix < a->used; ix++) {
if (a->dp[ix] != MP_MASK) {
return MP_NO;
return false;
}
}
return MP_YES;
return true;
}
#endif

View File

@ -26,7 +26,7 @@ static const char rem_105[105] = {
};
/* Store non-zero to ret if arg is square, and zero if not */
mp_err mp_is_square(const mp_int *arg, mp_bool *ret)
mp_err mp_is_square(const mp_int *arg, bool *ret)
{
mp_err err;
mp_digit c;
@ -34,7 +34,7 @@ mp_err mp_is_square(const mp_int *arg, mp_bool *ret)
unsigned long r;
/* Default to Non-square :) */
*ret = MP_NO;
*ret = false;
if (arg->sign == MP_NEG) {
return MP_VAL;

View File

@ -11,13 +11,13 @@
*
* Sets result to 1 if the congruence holds, or zero otherwise.
*/
mp_err mp_prime_fermat(const mp_int *a, const mp_int *b, mp_bool *result)
mp_err mp_prime_fermat(const mp_int *a, const mp_int *b, bool *result)
{
mp_int t;
mp_err err;
/* default to composite */
*result = MP_NO;
*result = false;
/* ensure b > 1 */
if (mp_cmp_d(b, 1uL) != MP_GT) {
@ -36,7 +36,7 @@ mp_err mp_prime_fermat(const mp_int *a, const mp_int *b, mp_bool *result)
/* is it equal to b? */
if (mp_cmp(&t, b) == MP_EQ) {
*result = MP_YES;
*result = true;
}
err = MP_OKAY;

View File

@ -20,14 +20,14 @@
*/
#define LTM_FROBENIUS_UNDERWOOD_A 32764
mp_err mp_prime_frobenius_underwood(const mp_int *N, mp_bool *result)
mp_err mp_prime_frobenius_underwood(const mp_int *N, bool *result)
{
mp_int T1z, T2z, Np1z, sz, tz;
int a, ap2, length, i, j;
mp_err err;
*result = MP_NO;
*result = false;
if ((err = mp_init_multi(&T1z, &T2z, &Np1z, &sz, &tz, NULL)) != MP_OKAY) {
return err;
@ -113,7 +113,7 @@ mp_err mp_prime_frobenius_underwood(const mp_int *N, mp_bool *result)
mp_set_u32(&T1z, (uint32_t)((2 * a) + 5));
if ((err = mp_mod(&T1z, N, &T1z)) != MP_OKAY) goto LBL_FU_ERR;
if (mp_iszero(&sz) && (mp_cmp(&tz, &T1z) == MP_EQ)) {
*result = MP_YES;
*result = true;
}
LBL_FU_ERR:

View File

@ -14,26 +14,26 @@ static unsigned int s_floor_ilog2(int value)
}
mp_err mp_prime_is_prime(const mp_int *a, int t, mp_bool *result)
mp_err mp_prime_is_prime(const mp_int *a, int t, bool *result)
{
mp_int b;
int ix, p_max = 0, size_a, len;
mp_bool res;
bool res;
mp_err err;
unsigned int fips_rand, mask;
/* default to no */
*result = MP_NO;
*result = false;
/* Some shortcuts */
/* N > 3 */
if (a->used == 1) {
if ((a->dp[0] == 0u) || (a->dp[0] == 1u)) {
*result = MP_NO;
*result = false;
return MP_OKAY;
}
if (a->dp[0] == 2u) {
*result = MP_YES;
*result = true;
return MP_OKAY;
}
}
@ -53,7 +53,7 @@ mp_err mp_prime_is_prime(const mp_int *a, int t, mp_bool *result)
/* is the input equal to one of the primes in the table? */
for (ix = 0; ix < MP_PRIME_TAB_SIZE; ix++) {
if (mp_cmp_d(a, s_mp_prime_tab[ix]) == MP_EQ) {
*result = MP_YES;
*result = true;
return MP_OKAY;
}
}
@ -267,7 +267,7 @@ mp_err mp_prime_is_prime(const mp_int *a, int t, mp_bool *result)
}
/* passed the test */
*result = MP_YES;
*result = true;
LBL_B:
mp_clear(&b);
return err;

View File

@ -10,14 +10,14 @@
* Randomly the chance of error is no more than 1/4 and often
* very much lower.
*/
mp_err mp_prime_miller_rabin(const mp_int *a, const mp_int *b, mp_bool *result)
mp_err mp_prime_miller_rabin(const mp_int *a, const mp_int *b, bool *result)
{
mp_int n1, y, r;
mp_err err;
int s, j;
/* default */
*result = MP_NO;
*result = false;
/* ensure b > 1 */
if (mp_cmp_d(b, 1uL) != MP_GT) {
@ -79,7 +79,7 @@ mp_err mp_prime_miller_rabin(const mp_int *a, const mp_int *b, mp_bool *result)
}
/* probably prime now */
*result = MP_YES;
*result = true;
LBL_Y:
mp_clear(&y);
LBL_R:

View File

@ -6,14 +6,14 @@
/* finds the next prime after the number "a" using "t" trials
* of Miller-Rabin.
*
* bbs_style = MP_YES means the prime must be congruent to 3 mod 4
* bbs_style = true means the prime must be congruent to 3 mod 4
*/
mp_err mp_prime_next_prime(mp_int *a, int t, mp_bool bbs_style)
mp_err mp_prime_next_prime(mp_int *a, int t, bool bbs_style)
{
int x, y;
mp_ord cmp;
mp_err err;
mp_bool res = MP_NO;
bool res = false;
mp_digit res_tab[MP_PRIME_TAB_SIZE], step, kstep;
mp_int b;

View File

@ -22,7 +22,7 @@ mp_err mp_prime_rand(mp_int *a, int t, int size, int flags)
{
unsigned char *tmp, maskAND, maskOR_msb, maskOR_lsb;
int bsize, maskOR_msb_offset;
mp_bool res;
bool res;
mp_err err;
/* sanity check the input */

View File

@ -33,7 +33,7 @@ static mp_err s_mp_mul_si(const mp_int *a, int32_t d, mp_int *c)
}
/*
Strong Lucas-Selfridge test.
returns MP_YES if it is a strong L-S prime, MP_NO if it is composite
returns true if it is a strong L-S prime, false if it is composite
Code ported from Thomas Ray Nicely's implementation of the BPSW test
at http://www.trnicely.net/misc/bpsw.html
@ -48,15 +48,15 @@ static mp_err s_mp_mul_si(const mp_int *a, int32_t d, mp_int *c)
(If that name sounds familiar, he is the guy who found the fdiv bug in the
Pentium (P5x, I think) Intel processor)
*/
mp_err mp_prime_strong_lucas_selfridge(const mp_int *a, mp_bool *result)
mp_err mp_prime_strong_lucas_selfridge(const mp_int *a, bool *result)
{
/* CZ TODO: choose better variable names! */
mp_int Dz, gcd, Np1, Uz, Vz, U2mz, V2mz, Qmz, Q2mz, Qkdz, T1z, T2z, T3z, T4z, Q2kdz;
int32_t D, Ds, J, sign, P, Q, r, s, u, Nbits;
mp_err err;
mp_bool oddness;
bool oddness;
*result = MP_NO;
*result = false;
/*
Find the first element D in the sequence {5, -7, 9, -11, 13, ...}
such that Jacobi(D,N) = -1 (Selfridge's algorithm). Theory
@ -240,7 +240,7 @@ mp_err mp_prime_strong_lucas_selfridge(const mp_int *a, mp_bool *result)
/* If U_d or V_d is congruent to 0 mod N, then N is a prime or a
strong Lucas pseudoprime. */
if (mp_iszero(&Uz) || mp_iszero(&Vz)) {
*result = MP_YES;
*result = true;
goto LBL_LS_ERR;
}
@ -263,7 +263,7 @@ mp_err mp_prime_strong_lucas_selfridge(const mp_int *a, mp_bool *result)
if ((err = mp_sub(&Vz, &Q2kdz, &Vz)) != MP_OKAY) goto LBL_LS_ERR;
if ((err = mp_mod(&Vz, a, &Vz)) != MP_OKAY) goto LBL_LS_ERR;
if (mp_iszero(&Vz)) {
*result = MP_YES;
*result = true;
goto LBL_LS_ERR;
}
/* Calculate Q^{d*2^r} for next r (final iteration irrelevant). */

View File

@ -4,15 +4,15 @@
/* SPDX-License-Identifier: Unlicense */
/* determines if mp_reduce_2k can be used */
mp_bool mp_reduce_is_2k(const mp_int *a)
bool mp_reduce_is_2k(const mp_int *a)
{
int ix, iy, iw;
mp_digit iz;
if (a->used == 0) {
return MP_NO;
return false;
} else if (a->used == 1) {
return MP_YES;
return true;
} else if (a->used > 1) {
iy = mp_count_bits(a);
iz = 1;
@ -21,7 +21,7 @@ mp_bool mp_reduce_is_2k(const mp_int *a)
/* Test every bit from the second digit up, must be 1 */
for (ix = MP_DIGIT_BIT; ix < iy; ix++) {
if ((a->dp[iw] & iz) == 0u) {
return MP_NO;
return false;
}
iz <<= 1;
if (iz > MP_DIGIT_MAX) {
@ -29,9 +29,9 @@ mp_bool mp_reduce_is_2k(const mp_int *a)
iz = 1;
}
}
return MP_YES;
return true;
} else {
return MP_YES;
return true;
}
}

View File

@ -4,14 +4,14 @@
/* SPDX-License-Identifier: Unlicense */
/* determines if reduce_2k_l can be used */
mp_bool mp_reduce_is_2k_l(const mp_int *a)
bool mp_reduce_is_2k_l(const mp_int *a)
{
int ix, iy;
if (a->used == 0) {
return MP_NO;
return false;
} else if (a->used == 1) {
return MP_YES;
return true;
} else if (a->used > 1) {
/* if more than half of the digits are -1 we're sold */
for (iy = ix = 0; ix < a->used; ix++) {
@ -21,7 +21,7 @@ mp_bool mp_reduce_is_2k_l(const mp_int *a)
}
return (iy >= (a->used/2));
} else {
return MP_NO;
return false;
}
}

View File

@ -4,14 +4,14 @@
/* LibTomMath, multiple-precision integer library -- Tom St Denis */
/* SPDX-License-Identifier: Unlicense */
/* Get bit at position b and return MP_YES if the bit is 1, MP_NO if it is 0 */
mp_bool s_mp_get_bit(const mp_int *a, unsigned int b)
/* Get bit at position b and return true if the bit is 1, false if it is 0 */
bool s_mp_get_bit(const mp_int *a, unsigned int b)
{
mp_digit bit;
int limb = (int)(b / MP_DIGIT_BIT);
if (limb >= a->used) {
return MP_NO;
return false;
}
bit = (mp_digit)1 << (b % MP_DIGIT_BIT);

View File

@ -8,14 +8,14 @@
*
* sets result to 0 if not, 1 if yes
*/
mp_err s_mp_prime_is_divisible(const mp_int *a, mp_bool *result)
mp_err s_mp_prime_is_divisible(const mp_int *a, bool *result)
{
int ix;
mp_err err;
mp_digit res;
/* default to not */
*result = MP_NO;
*result = false;
for (ix = 0; ix < MP_PRIME_TAB_SIZE; ix++) {
/* what is a mod LBL_prime_tab[ix] */
@ -25,7 +25,7 @@ mp_err s_mp_prime_is_divisible(const mp_int *a, mp_bool *result)
/* is the residue zero? */
if (res == 0u) {
*result = MP_YES;
*result = true;
return MP_OKAY;
}
}

View File

@ -6,6 +6,7 @@
#include <stdint.h>
#include <stddef.h>
#include <stdbool.h>
#ifndef MP_NO_FILE
# include <stdio.h>
@ -93,11 +94,6 @@ typedef enum {
MP_GT = 1 /* greater than */
} mp_ord;
typedef enum {
MP_NO = 0,
MP_YES = 1
} mp_bool;
typedef enum {
MP_OKAY = 0, /* no error */
MP_ERR = -1, /* unknown error */
@ -119,7 +115,6 @@ typedef enum {
} mp_endian;
/* tunable cutoffs */
#ifndef MP_FIXED_CUTOFFS
extern int
MP_KARATSUBA_MUL_CUTOFF,
@ -441,7 +436,7 @@ mp_err mp_sqrt(const mp_int *arg, mp_int *ret) MP_WUR;
mp_err mp_sqrtmod_prime(const mp_int *n, const mp_int *prime, mp_int *ret) MP_WUR;
/* is number a square? */
mp_err mp_is_square(const mp_int *arg, mp_bool *ret) MP_WUR;
mp_err mp_is_square(const mp_int *arg, bool *ret) MP_WUR;
/* computes the Kronecker symbol c = (a | p) (like jacobi() but with {a,p} in Z */
mp_err mp_kronecker(const mp_int *a, const mp_int *p, int *c) MP_WUR;
@ -468,7 +463,7 @@ mp_err mp_montgomery_calc_normalization(mp_int *a, const mp_int *b) MP_WUR;
mp_err mp_montgomery_reduce(mp_int *x, const mp_int *n, mp_digit rho) MP_WUR;
/* returns 1 if a is a valid DR modulus */
mp_bool mp_dr_is_modulus(const mp_int *a) MP_WUR;
bool mp_dr_is_modulus(const mp_int *a) MP_WUR;
/* sets the value of "d" required for mp_dr_reduce */
void mp_dr_setup(const mp_int *a, mp_digit *d);
@ -477,7 +472,7 @@ void mp_dr_setup(const mp_int *a, mp_digit *d);
mp_err mp_dr_reduce(mp_int *x, const mp_int *n, mp_digit k) MP_WUR;
/* returns true if a can be reduced with mp_reduce_2k */
mp_bool mp_reduce_is_2k(const mp_int *a) MP_WUR;
bool mp_reduce_is_2k(const mp_int *a) MP_WUR;
/* determines k value for 2k reduction */
mp_err mp_reduce_2k_setup(const mp_int *a, mp_digit *d) MP_WUR;
@ -486,7 +481,7 @@ mp_err mp_reduce_2k_setup(const mp_int *a, mp_digit *d) MP_WUR;
mp_err mp_reduce_2k(mp_int *a, const mp_int *n, mp_digit d) MP_WUR;
/* returns true if a can be reduced with mp_reduce_2k_l */
mp_bool mp_reduce_is_2k_l(const mp_int *a) MP_WUR;
bool mp_reduce_is_2k_l(const mp_int *a) MP_WUR;
/* determines k value for 2k reduction */
mp_err mp_reduce_2k_setup_l(const mp_int *a, mp_int *d) MP_WUR;
@ -502,12 +497,12 @@ mp_err mp_exptmod(const mp_int *G, const mp_int *X, const mp_int *P, mp_int *Y)
/* performs one Fermat test of "a" using base "b".
* Sets result to 0 if composite or 1 if probable prime
*/
mp_err mp_prime_fermat(const mp_int *a, const mp_int *b, mp_bool *result) MP_WUR;
mp_err mp_prime_fermat(const mp_int *a, const mp_int *b, bool *result) MP_WUR;
/* performs one Miller-Rabin test of "a" using base "b".
* Sets result to 0 if composite or 1 if probable prime
*/
mp_err mp_prime_miller_rabin(const mp_int *a, const mp_int *b, mp_bool *result) MP_WUR;
mp_err mp_prime_miller_rabin(const mp_int *a, const mp_int *b, bool *result) MP_WUR;
/* This gives [for a given bit size] the number of trials required
* such that Miller-Rabin gives a prob of failure lower than 2^-96
@ -517,12 +512,12 @@ int mp_prime_rabin_miller_trials(int size) MP_WUR;
/* performs one strong Lucas-Selfridge test of "a".
* Sets result to 0 if composite or 1 if probable prime
*/
mp_err mp_prime_strong_lucas_selfridge(const mp_int *a, mp_bool *result) MP_WUR;
mp_err mp_prime_strong_lucas_selfridge(const mp_int *a, bool *result) MP_WUR;
/* performs one Frobenius test of "a" as described by Paul Underwood.
* Sets result to 0 if composite or 1 if probable prime
*/
mp_err mp_prime_frobenius_underwood(const mp_int *N, mp_bool *result) MP_WUR;
mp_err mp_prime_frobenius_underwood(const mp_int *N, bool *result) MP_WUR;
/* performs t random rounds of Miller-Rabin on "a" additional to
* bases 2 and 3. Also performs an initial sieve of trial
@ -538,14 +533,14 @@ mp_err mp_prime_frobenius_underwood(const mp_int *N, mp_bool *result) MP_WUR;
*
* Sets result to 1 if probably prime, 0 otherwise
*/
mp_err mp_prime_is_prime(const mp_int *a, int t, mp_bool *result) MP_WUR;
mp_err mp_prime_is_prime(const mp_int *a, int t, bool *result) MP_WUR;
/* finds the next prime after the number "a" using "t" trials
* of Miller-Rabin.
*
* bbs_style = MP_YES means the prime must be congruent to 3 mod 4
* bbs_style = true means the prime must be congruent to 3 mod 4
*/
mp_err mp_prime_next_prime(mp_int *a, int t, mp_bool bbs_style) MP_WUR;
mp_err mp_prime_next_prime(mp_int *a, int t, bool bbs_style) MP_WUR;
/* makes a truly random prime of a given size (bits),
*

View File

@ -182,7 +182,7 @@ MP_STATIC_ASSERT(prec_geq_min_prec, MP_PREC >= MP_MIN_PREC)
extern MP_PRIVATE mp_err(*s_mp_rand_source)(void *out, size_t size);
/* lowlevel functions, do not call! */
MP_PRIVATE mp_bool s_mp_get_bit(const mp_int *a, unsigned int b);
MP_PRIVATE bool s_mp_get_bit(const mp_int *a, unsigned int b);
MP_PRIVATE mp_err s_mp_add(const mp_int *a, const mp_int *b, mp_int *c) MP_WUR;
MP_PRIVATE mp_err s_mp_sub(const mp_int *a, const mp_int *b, mp_int *c) MP_WUR;
MP_PRIVATE mp_err s_mp_mul_digs_fast(const mp_int *a, const mp_int *b, mp_int *c, int digs) MP_WUR;
@ -202,7 +202,7 @@ MP_PRIVATE mp_err s_mp_montgomery_reduce_fast(mp_int *x, const mp_int *n, mp_dig
MP_PRIVATE mp_err s_mp_exptmod_fast(const mp_int *G, const mp_int *X, const mp_int *P, mp_int *Y, int redmode) MP_WUR;
MP_PRIVATE mp_err s_mp_exptmod(const mp_int *G, const mp_int *X, const mp_int *P, mp_int *Y, int redmode) MP_WUR;
MP_PRIVATE mp_err s_mp_rand_platform(void *p, size_t n) MP_WUR;
MP_PRIVATE mp_err s_mp_prime_is_divisible(const mp_int *a, mp_bool *result);
MP_PRIVATE mp_err s_mp_prime_is_divisible(const mp_int *a, bool *result);
MP_PRIVATE mp_digit s_mp_log_d(mp_digit base, mp_digit n);
MP_PRIVATE mp_err s_mp_log(const mp_int *a, uint32_t base, uint32_t *c);
MP_PRIVATE uint32_t s_mp_log_pow2(const mp_int *a, uint32_t base);