Skip to content

Commit 672fd29

Browse files
committed
added some casting and c&p the table into test.c for now
1 parent ae125e9 commit 672fd29

File tree

2 files changed

+14
-3
lines changed

2 files changed

+14
-3
lines changed

demo/test.c

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1012,6 +1012,17 @@ static int test_mp_montgomery_reduce(void)
10121012

10131013
}
10141014

1015+
const uint8_t test_s_mp_radix_exponent_y[] = { 0, 0, /* 0 .. 1*/
1016+
20, 12, 10, 8, 7, 7, 6, 6, /* 2 .. 9 */
1017+
6, 5, 5, 5, 5, 5, 5, 4, /* 10 .. 17 */
1018+
4, 4, 4, 4, 4, 4, 4, 4, /* 18 .. 25 */
1019+
4, 4, 4, 4, 4, 4, 4, 3, /* 26 .. 33 */
1020+
3, 3, 3, 3, 3, 3, 3, 3, /* 34 .. 41 */
1021+
3, 3, 3, 3, 3, 3, 3, 3, /* 42 .. 49 */
1022+
3, 3, 3, 3, 3, 3, 3, 3, /* 51 .. 57 */
1023+
3, 3, 3, 3, 3, 3, 3 /* 58 .. 64 */
1024+
};
1025+
10151026
static int test_mp_read_radix(void)
10161027
{
10171028
char buf[4096];
@@ -1048,7 +1059,7 @@ static int test_mp_read_radix(void)
10481059
/* Test the fast method with a slightly larger number */
10491060

10501061
/* Must be bigger than the cut-off value, of course */
1051-
bignum = 2* (2 * s_mp_radix_exponent_y[2] * MP_RADIX_BARRETT_START_MULTIPLICATOR);
1062+
bignum = 2* (2 * test_s_mp_radix_exponent_y[2] * MP_RADIX_BARRETT_START_MULTIPLICATOR);
10521063
printf("Size of bignum_size = %d\n", bignum);
10531064
/* Check if "bignum" is small enough for the result to fit into "buf"
10541065
otherwise lead tester to this function */

s_mp_faster_read_radix.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ mp_err s_mp_faster_read_radix(mp_int *a, const char *str, int start, int end, in
4343

4444
mid = len / 2;
4545

46-
if ((err = mp_init_set(&m, radix)) != MP_OKAY) {
46+
if ((err = mp_init_set(&m, (mp_digit)radix)) != MP_OKAY) {
4747
return err;
4848
}
4949
if ((err = mp_init_multi(&A, &B, NULL)) != MP_OKAY) {
@@ -54,7 +54,7 @@ mp_err s_mp_faster_read_radix(mp_int *a, const char *str, int start, int end, in
5454
if ((err = s_mp_slower_read_radix(&A, str, start, start + mid + 1, radix)) != MP_OKAY) goto LTM_ERR;
5555
if ((err = s_mp_slower_read_radix(&B, str, start + mid + 1, end, radix)) != MP_OKAY) goto LTM_ERR;
5656

57-
if (MP_IS_2EXPT(radix)) {
57+
if (MP_IS_2EXPT((unsigned int)radix)) {
5858
if ((err = mp_mul_2d(&A, ((len - mid) -1) * s_floor_ilog2(radix), &A)) != MP_OKAY) goto LTM_ERR;
5959
} else {
6060
if ((err = mp_expt_n(&m, (len - mid) - 1, &m)) != MP_OKAY) goto LTM_ERR;

0 commit comments

Comments
 (0)