|
6 | 6 |
|
7 | 7 | /* SPDX-License-Identifier: Unlicense */
|
8 | 8 | #include <tommath_private.h>
|
| 9 | +#ifdef BN_MP_GET_BIT_C |
| 10 | +/* Checks the bit at position b and returns MP_YES |
| 11 | + if the bit is 1, MP_NO if it is 0 and MP_VAL |
| 12 | + in case of error */ |
| 13 | +int mp_get_bit(const mp_int *a, int b) |
| 14 | +{ |
| 15 | + if (b < 0) { |
| 16 | + return MP_VAL; |
| 17 | + } |
| 18 | + return s_mp_get_bit(a, (unsigned int)b) == MP_YES ? MP_YES : MP_NO; |
| 19 | +} |
| 20 | +#endif |
| 21 | +#ifdef BN_MP_JACOBI_C |
| 22 | +mp_err s_mp_jacobi(const mp_int *a, const mp_int *n, int *c) |
| 23 | +{ |
| 24 | + if (a->sign == MP_NEG) { |
| 25 | + return MP_VAL; |
| 26 | + } |
| 27 | + if (mp_cmp_d(n, 0uL) != MP_GT) { |
| 28 | + return MP_VAL; |
| 29 | + } |
| 30 | + return mp_kronecker(a, n, c); |
| 31 | +} |
| 32 | +mp_err mp_jacobi(const mp_int *a, const mp_int *n, int *c) |
| 33 | +{ |
| 34 | + return s_mp_jacobi(a, n, c); |
| 35 | +} |
| 36 | +#endif |
| 37 | +#ifdef BN_MP_PRIME_RANDOM_EX_C |
| 38 | +mp_err mp_prime_random_ex(mp_int *a, int t, int size, int flags, private_mp_prime_callback cb, void *dat) |
| 39 | +{ |
| 40 | + return s_mp_prime_random_ex(a, t, size, flags, cb, dat); |
| 41 | +} |
| 42 | +#endif |
| 43 | +#ifdef BN_MP_RAND_DIGIT_C |
| 44 | +mp_err mp_rand_digit(mp_digit *r) |
| 45 | +{ |
| 46 | + mp_err ret = s_mp_rand_source(r, sizeof(mp_digit)); |
| 47 | + *r &= MP_MASK; |
| 48 | + return ret; |
| 49 | +} |
| 50 | +#endif |
9 | 51 | #ifdef BN_FAST_MP_INVMOD_C
|
10 | 52 | mp_err fast_mp_invmod(const mp_int *a, const mp_int *b, mp_int *c)
|
11 | 53 | {
|
|
0 commit comments