move mp_prime_random_ex to bn_deprecated.c
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89
diff --git a/bn_deprecated.c b/bn_deprecated.c
index 52c17dc..7141ef9 100644
--- a/bn_deprecated.c
+++ b/bn_deprecated.c
@@ -6,6 +6,12 @@
/* SPDX-License-Identifier: Unlicense */
#include <tommath_private.h>
+#ifdef BN_MP_PRIME_RANDOM_EX_C
+mp_err mp_prime_random_ex(mp_int *a, int t, int size, int flags, private_mp_prime_callback cb, void *dat)
+{
+ return s_mp_prime_random_ex(a, t, size, flags, cb, dat);
+}
+#endif
#ifdef BN_MP_RAND_DIGIT_C
mp_err mp_rand_digit(mp_digit *r)
{
diff --git a/bn_mp_prime_rand.c b/bn_mp_prime_rand.c
index b4b08ba..dbf3975 100644
--- a/bn_mp_prime_rand.c
+++ b/bn_mp_prime_rand.c
@@ -18,7 +18,7 @@
*/
/* This is possibly the mother of all prime generation functions, muahahahahaha! */
-static mp_err s_mp_prime_random_ex(mp_int *a, int t, int size, int flags, private_mp_prime_callback cb, void *dat)
+mp_err s_mp_prime_random_ex(mp_int *a, int t, int size, int flags, private_mp_prime_callback cb, void *dat)
{
unsigned char *tmp, maskAND, maskOR_msb, maskOR_lsb;
int bsize, maskOR_msb_offset;
@@ -132,11 +132,6 @@ static int s_mp_rand_cb(unsigned char *dst, int len, void *dat)
return len;
}
-mp_err mp_prime_random_ex(mp_int *a, int t, int size, int flags, private_mp_prime_callback cb, void *dat)
-{
- return s_mp_prime_random_ex(a, t, size, flags, cb, dat);
-}
-
mp_err mp_prime_rand(mp_int *a, int t, int size, int flags)
{
return s_mp_prime_random_ex(a, t, size, flags, s_mp_rand_cb, NULL);
diff --git a/tommath_class.h b/tommath_class.h
index 2e62a64..0dc3756 100644
--- a/tommath_class.h
+++ b/tommath_class.h
@@ -163,6 +163,10 @@
#endif
#if defined(BN_DEPRECATED_C)
+# define BN_MP_PRIME_RANDOM_EX_C
+# define BN_S_MP_PRIME_RANDOM_EX_C
+# define BN_MP_RAND_DIGIT_C
+# define BN_S_MP_RAND_SOURCE_C
# define BN_FAST_MP_INVMOD_C
# define BN_S_MP_INVMOD_FAST_C
# define BN_FAST_MP_MONTGOMERY_REDUCE_C
@@ -724,7 +728,6 @@
# define BN_MP_ADD_D_C
# define BN_S_MP_RAND_CB_C
# define BN_S_MP_RAND_SOURCE_C
-# define BN_MP_PRIME_RANDOM_EX_C
#endif
#if defined(BN_MP_PRIME_STRONG_LUCAS_SELFRIDGE_C)
@@ -766,10 +769,9 @@
#if defined(BN_MP_RAND_C)
# define BN_MP_RAND_SOURCE_C
-# define BN_MP_RAND_DIGIT_C
-# define BN_S_MP_RAND_SOURCE_C
# define BN_MP_ZERO_C
# define BN_MP_GROW_C
+# define BN_S_MP_RAND_SOURCE_C
#endif
#if defined(BN_MP_READ_RADIX_C)
diff --git a/tommath_private.h b/tommath_private.h
index 0956da0..e18ea52 100644
--- a/tommath_private.h
+++ b/tommath_private.h
@@ -168,6 +168,7 @@ mp_err s_mp_montgomery_reduce_fast(mp_int *x, const mp_int *n, mp_digit rho) MP_
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_err s_mp_exptmod(const mp_int *G, const mp_int *X, const mp_int *P, mp_int *Y, int redmode) MP_WUR;
mp_err s_mp_rand_platform(void *p, size_t n) MP_WUR;
+mp_err s_mp_prime_random_ex(mp_int *a, int t, int size, int flags, private_mp_prime_callback cb, void *dat);
void s_mp_reverse(unsigned char *s, int len);
/* TODO: jenkins prng is not thread safe as of now */