Skip to content

Commit 6494ca3

Browse files
committed
move mp_prime_random_ex to bn_deprecated.c
1 parent a3b2236 commit 6494ca3

File tree

4 files changed

+13
-9
lines changed

4 files changed

+13
-9
lines changed

bn_deprecated.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,12 @@
66

77
/* SPDX-License-Identifier: Unlicense */
88
#include <tommath_private.h>
9+
#ifdef BN_MP_PRIME_RANDOM_EX_C
10+
mp_err mp_prime_random_ex(mp_int *a, int t, int size, int flags, private_mp_prime_callback cb, void *dat)
11+
{
12+
return s_mp_prime_random_ex(a, t, size, flags, cb, dat);
13+
}
14+
#endif
915
#ifdef BN_MP_RAND_DIGIT_C
1016
mp_err mp_rand_digit(mp_digit *r)
1117
{

bn_mp_prime_rand.c

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
*/
1919

2020
/* This is possibly the mother of all prime generation functions, muahahahahaha! */
21-
static mp_err s_mp_prime_random_ex(mp_int *a, int t, int size, int flags, private_mp_prime_callback cb, void *dat)
21+
mp_err s_mp_prime_random_ex(mp_int *a, int t, int size, int flags, private_mp_prime_callback cb, void *dat)
2222
{
2323
unsigned char *tmp, maskAND, maskOR_msb, maskOR_lsb;
2424
int bsize, maskOR_msb_offset;
@@ -132,11 +132,6 @@ static int s_mp_rand_cb(unsigned char *dst, int len, void *dat)
132132
return len;
133133
}
134134

135-
mp_err mp_prime_random_ex(mp_int *a, int t, int size, int flags, private_mp_prime_callback cb, void *dat)
136-
{
137-
return s_mp_prime_random_ex(a, t, size, flags, cb, dat);
138-
}
139-
140135
mp_err mp_prime_rand(mp_int *a, int t, int size, int flags)
141136
{
142137
return s_mp_prime_random_ex(a, t, size, flags, s_mp_rand_cb, NULL);

tommath_class.h

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,10 @@
163163
#endif
164164

165165
#if defined(BN_DEPRECATED_C)
166+
# define BN_MP_PRIME_RANDOM_EX_C
167+
# define BN_S_MP_PRIME_RANDOM_EX_C
168+
# define BN_MP_RAND_DIGIT_C
169+
# define BN_S_MP_RAND_SOURCE_C
166170
# define BN_FAST_MP_INVMOD_C
167171
# define BN_S_MP_INVMOD_FAST_C
168172
# define BN_FAST_MP_MONTGOMERY_REDUCE_C
@@ -724,7 +728,6 @@
724728
# define BN_MP_ADD_D_C
725729
# define BN_S_MP_RAND_CB_C
726730
# define BN_S_MP_RAND_SOURCE_C
727-
# define BN_MP_PRIME_RANDOM_EX_C
728731
#endif
729732

730733
#if defined(BN_MP_PRIME_STRONG_LUCAS_SELFRIDGE_C)
@@ -766,10 +769,9 @@
766769

767770
#if defined(BN_MP_RAND_C)
768771
# define BN_MP_RAND_SOURCE_C
769-
# define BN_MP_RAND_DIGIT_C
770-
# define BN_S_MP_RAND_SOURCE_C
771772
# define BN_MP_ZERO_C
772773
# define BN_MP_GROW_C
774+
# define BN_S_MP_RAND_SOURCE_C
773775
#endif
774776

775777
#if defined(BN_MP_READ_RADIX_C)

tommath_private.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,7 @@ mp_err s_mp_montgomery_reduce_fast(mp_int *x, const mp_int *n, mp_digit rho) MP_
168168
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;
169169
mp_err s_mp_exptmod(const mp_int *G, const mp_int *X, const mp_int *P, mp_int *Y, int redmode) MP_WUR;
170170
mp_err s_mp_rand_platform(void *p, size_t n) MP_WUR;
171+
mp_err s_mp_prime_random_ex(mp_int *a, int t, int size, int flags, private_mp_prime_callback cb, void *dat);
171172
void s_mp_reverse(unsigned char *s, int len);
172173

173174
/* TODO: jenkins prng is not thread safe as of now */

0 commit comments

Comments
 (0)