Skip to content

Barrett todecimal #331

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions bn_mp_todecimal.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#include "tommath_private.h"
#ifdef BN_MP_TODECIMAL_C
/* LibTomMath, multiple-precision integer library -- Tom St Denis */
/* SPDX-License-Identifier: Unlicense */

/* stores a bignum as a decimal ASCII string, using Barrett
* reduction if available.
*/

mp_err mp_todecimal(const mp_int *a, char *str)
{
mp_err err;

if (MP_HAS(S_MP_TODECIMAL_FAST)) {
err = s_mp_todecimal_fast(a, str);
} else {
err = mp_toradix(a, str, 10);
}

return err;
}

#endif
205 changes: 205 additions & 0 deletions bn_s_mp_todecimal_fast.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,205 @@
#include "tommath_private.h"
#include <string.h>
#ifdef BN_S_MP_TODECIMAL_FAST_C
/* LibTomMath, multiple-precision integer library -- Tom St Denis */
/* SPDX-License-Identifier: Unlicense */

/* store a bignum as a decimal ASCII string */
mp_err s_mp_todecimal_fast_rec(const mp_int *number, mp_int *nL, mp_int *shiftL, mp_int *mL, int precalc_array_index,
int left,
char **result)
{
mp_int q, nLq, r;
mp_err err;

if (precalc_array_index < 0) {
int new_pos = left ? snprintf(*result, 4, "%u", mp_get_i32(number)) : snprintf(*result, 4, "%03u",
mp_get_i32(number));
*result += new_pos;
return MP_OKAY;
}

if ((err = mp_init_multi(&q, &nLq, &r, NULL)) != MP_OKAY) {
goto LBL_ERR;
}
if ((err = mp_mul(number, &mL[precalc_array_index], &q)) != MP_OKAY) {
goto LBL_ERR;
}
if ((err = mp_div_2d(&q, mp_get_i32(&shiftL[precalc_array_index]), &q, NULL)) != MP_OKAY) {
goto LBL_ERR;
}

if ((err = mp_mul(&nL[precalc_array_index], &q, &nLq)) != MP_OKAY) {
goto LBL_ERR;
}

if ((err = mp_sub(number, &nLq, &r)) != MP_OKAY) {
goto LBL_ERR;
}

if (mp_isneg(&r)) {
if ((err = mp_sub_d(&q, 1, &q)) != MP_OKAY) {
goto LBL_ERR;
}
if ((err = mp_add(&r, &nL[precalc_array_index], &r)) != MP_OKAY) {
goto LBL_ERR;
}
}

--precalc_array_index;
if (left && mp_iszero(&q)) {
if ((err = s_mp_todecimal_fast_rec(&r, nL, shiftL, mL, precalc_array_index, 1, result)) != MP_OKAY) {
goto LBL_ERR;
}
} else {
if ((err = s_mp_todecimal_fast_rec(&q, nL, shiftL, mL, precalc_array_index, left, result)) != MP_OKAY) {
goto LBL_ERR;
}
if ((err = s_mp_todecimal_fast_rec(&r, nL, shiftL, mL, precalc_array_index, 0, result)) != MP_OKAY) {
goto LBL_ERR;
}
}

err = MP_OKAY;

LBL_ERR:
mp_clear_multi(&q, &nLq, &r, NULL);
return err;
}

mp_err s_mp_todecimal_fast(const mp_int *a, char *result)
{
mp_int number, n, shift, M, M2, M22, M4, M44;
mp_int nL[20], shiftL[20], mL[20];
mp_err err;
char **result_addr = &result;
int precalc_array_index = 1;

if ((err = mp_init_multi(&M2, &M22, &M4, &M44, NULL)) != MP_OKAY) {
goto LBL_ERR;
}

if ((err = mp_init_copy(&number, a)) != MP_OKAY) {
goto LBL_ERR;
}
if (mp_isneg(&number)) {
if ((err = mp_neg(&number, &number)) != MP_OKAY) {
goto LBL_ERR;
}
result[0] = '-';
result_addr += 1;
}
if ((err = mp_init_set(&n, (mp_digit)1000)) != MP_OKAY) {
goto LBL_ERR;
}

if ((err = mp_init_copy(&nL[0], &n)) != MP_OKAY) {
goto LBL_ERR;
}

if ((err = mp_init_set(&shift, (mp_digit)20)) != MP_OKAY) {
goto LBL_ERR;
}

if ((err = mp_init_copy(&shiftL[0], &shift)) != MP_OKAY) {
goto LBL_ERR;
}

/* (8 * 2**$shift) / $n rounded up */
if ((err = mp_init_set(&M, (mp_digit)8389)) != MP_OKAY) {
goto LBL_ERR;
}

/* $M / 8, rounded up */
if ((err = mp_init_set(&mL[0], (mp_digit)1049)) != MP_OKAY) {
goto LBL_ERR;
}

while (1) {
if ((err = mp_sqr(&n, &n)) != MP_OKAY) {
goto LBL_ERR;
}
if (mp_cmp(&n, &number) == MP_GT) {
break;
}

if ((err = mp_mul_2(&shift, &shift)) != MP_OKAY) {
goto LBL_ERR;
}

/* The following is a Newton-Raphson step, to restore the invariant
* that $M is (8 * 2**$shift) / $n, rounded up. */
{
if ((err = mp_sqr(&M, &M2)) != MP_OKAY) {
goto LBL_ERR;
}
if ((err = mp_sqr(&M2, &M4)) != MP_OKAY) {
goto LBL_ERR;
}

if ((err = mp_mul(&M4, &n, &M4)) != MP_OKAY) {
goto LBL_ERR;
}
if ((err = mp_div_2d(&M4, mp_get_i32(&shift) + 6, &M4, NULL)) != MP_OKAY) {
goto LBL_ERR;
}
if ((err = mp_mul_2(&M2, &M2)) != MP_OKAY) {
goto LBL_ERR;
}
if ((err = mp_sub(&M4, &M2, &M4)) != MP_OKAY) {
goto LBL_ERR;
}
if ((err = mp_add_d(&M4, 1, &M4)) != MP_OKAY) {
goto LBL_ERR;
}
if ((err = mp_div_2d(&M4, 3, &M4, NULL)) != MP_OKAY) {
goto LBL_ERR;
}
if ((err = mp_sub_d(&M4, 1, &M4)) != MP_OKAY) {
goto LBL_ERR;
}
if ((err = mp_neg(&M4, &M)) != MP_OKAY) {
goto LBL_ERR;
}
}

if ((err = mp_init_copy(&nL[precalc_array_index], &n)) != MP_OKAY) {
goto LBL_ERR;
}
if ((err = mp_init_copy(&shiftL[precalc_array_index], &shift)) != MP_OKAY) {
goto LBL_ERR;
}

/* Divide by 8, round up */
{
if ((err = mp_add_d(&M4, 1, &M4)) != MP_OKAY) {
goto LBL_ERR;
}
if ((err = mp_div_2d(&M4, 3, &M4, NULL)) != MP_OKAY) {
goto LBL_ERR;
}
if ((err = mp_sub_d(&M4, 1, &M4)) != MP_OKAY) {
goto LBL_ERR;
}
if ((err = mp_neg(&M4, &M4)) != MP_OKAY) {
goto LBL_ERR;
}
}
if ((err = mp_init_copy(&mL[precalc_array_index], &M4)) != MP_OKAY) {
goto LBL_ERR;
}
precalc_array_index++;
}

if ((err = s_mp_todecimal_fast_rec(&number, nL, shiftL, mL, precalc_array_index - 1, 1, result_addr)) != MP_OKAY) {
goto LBL_ERR;
}

err = MP_OKAY;

LBL_ERR:
mp_clear_multi(&n, &shift, &M, &M2, &M22, &M4, &M44, NULL);
return err;
}

#endif
8 changes: 8 additions & 0 deletions libtommath_VS2008.vcproj
Original file line number Diff line number Diff line change
Expand Up @@ -832,6 +832,10 @@
RelativePath="bn_mp_to_unsigned_bin_n.c"
>
</File>
<File
RelativePath="bn_mp_todecimal.c"
>
</File>
<File
RelativePath="bn_mp_toradix.c"
>
Expand Down Expand Up @@ -940,6 +944,10 @@
RelativePath="bn_s_mp_sub.c"
>
</File>
<File
RelativePath="bn_s_mp_todecimal_fast.c"
>
</File>
<File
RelativePath="bn_s_mp_toom_mul.c"
>
Expand Down
15 changes: 8 additions & 7 deletions makefile
Original file line number Diff line number Diff line change
Expand Up @@ -49,13 +49,14 @@ bn_mp_set.o bn_mp_set_double.o bn_mp_set_i32.o bn_mp_set_i64.o bn_mp_set_l.o bn_
bn_mp_set_u32.o bn_mp_set_u64.o bn_mp_set_ul.o bn_mp_set_ull.o bn_mp_shrink.o bn_mp_signed_bin_size.o \
bn_mp_signed_rsh.o bn_mp_sqr.o bn_mp_sqrmod.o bn_mp_sqrt.o bn_mp_sqrtmod_prime.o bn_mp_sub.o bn_mp_sub_d.o \
bn_mp_submod.o bn_mp_to_signed_bin.o bn_mp_to_signed_bin_n.o bn_mp_to_unsigned_bin.o \
bn_mp_to_unsigned_bin_n.o bn_mp_toradix.o bn_mp_toradix_n.o bn_mp_unsigned_bin_size.o bn_mp_xor.o \
bn_mp_zero.o bn_prime_tab.o bn_s_mp_add.o bn_s_mp_balance_mul.o bn_s_mp_exptmod.o bn_s_mp_exptmod_fast.o \
bn_s_mp_get_bit.o bn_s_mp_invmod_fast.o bn_s_mp_invmod_slow.o bn_s_mp_karatsuba_mul.o \
bn_s_mp_karatsuba_sqr.o bn_s_mp_montgomery_reduce_fast.o bn_s_mp_mul_digs.o bn_s_mp_mul_digs_fast.o \
bn_s_mp_mul_high_digs.o bn_s_mp_mul_high_digs_fast.o bn_s_mp_prime_is_divisible.o \
bn_s_mp_rand_jenkins.o bn_s_mp_rand_platform.o bn_s_mp_reverse.o bn_s_mp_sqr.o bn_s_mp_sqr_fast.o \
bn_s_mp_sub.o bn_s_mp_toom_mul.o bn_s_mp_toom_sqr.o
bn_mp_to_unsigned_bin_n.o bn_mp_todecimal.o bn_mp_toradix.o bn_mp_toradix_n.o bn_mp_unsigned_bin_size.o \
bn_mp_xor.o bn_mp_zero.o bn_prime_tab.o bn_s_mp_add.o bn_s_mp_balance_mul.o bn_s_mp_exptmod.o \
bn_s_mp_exptmod_fast.o bn_s_mp_get_bit.o bn_s_mp_invmod_fast.o bn_s_mp_invmod_slow.o \
bn_s_mp_karatsuba_mul.o bn_s_mp_karatsuba_sqr.o bn_s_mp_montgomery_reduce_fast.o bn_s_mp_mul_digs.o \
bn_s_mp_mul_digs_fast.o bn_s_mp_mul_high_digs.o bn_s_mp_mul_high_digs_fast.o \
bn_s_mp_prime_is_divisible.o bn_s_mp_rand_jenkins.o bn_s_mp_rand_platform.o bn_s_mp_reverse.o \
bn_s_mp_sqr.o bn_s_mp_sqr_fast.o bn_s_mp_sub.o bn_s_mp_todecimal_fast.o bn_s_mp_toom_mul.o \
bn_s_mp_toom_sqr.o

#END_INS

Expand Down
15 changes: 8 additions & 7 deletions makefile.mingw
Original file line number Diff line number Diff line change
Expand Up @@ -52,13 +52,14 @@ bn_mp_set.o bn_mp_set_double.o bn_mp_set_i32.o bn_mp_set_i64.o bn_mp_set_l.o bn_
bn_mp_set_u32.o bn_mp_set_u64.o bn_mp_set_ul.o bn_mp_set_ull.o bn_mp_shrink.o bn_mp_signed_bin_size.o \
bn_mp_signed_rsh.o bn_mp_sqr.o bn_mp_sqrmod.o bn_mp_sqrt.o bn_mp_sqrtmod_prime.o bn_mp_sub.o bn_mp_sub_d.o \
bn_mp_submod.o bn_mp_to_signed_bin.o bn_mp_to_signed_bin_n.o bn_mp_to_unsigned_bin.o \
bn_mp_to_unsigned_bin_n.o bn_mp_toradix.o bn_mp_toradix_n.o bn_mp_unsigned_bin_size.o bn_mp_xor.o \
bn_mp_zero.o bn_prime_tab.o bn_s_mp_add.o bn_s_mp_balance_mul.o bn_s_mp_exptmod.o bn_s_mp_exptmod_fast.o \
bn_s_mp_get_bit.o bn_s_mp_invmod_fast.o bn_s_mp_invmod_slow.o bn_s_mp_karatsuba_mul.o \
bn_s_mp_karatsuba_sqr.o bn_s_mp_montgomery_reduce_fast.o bn_s_mp_mul_digs.o bn_s_mp_mul_digs_fast.o \
bn_s_mp_mul_high_digs.o bn_s_mp_mul_high_digs_fast.o bn_s_mp_prime_is_divisible.o \
bn_s_mp_rand_jenkins.o bn_s_mp_rand_platform.o bn_s_mp_reverse.o bn_s_mp_sqr.o bn_s_mp_sqr_fast.o \
bn_s_mp_sub.o bn_s_mp_toom_mul.o bn_s_mp_toom_sqr.o
bn_mp_to_unsigned_bin_n.o bn_mp_todecimal.o bn_mp_toradix.o bn_mp_toradix_n.o bn_mp_unsigned_bin_size.o \
bn_mp_xor.o bn_mp_zero.o bn_prime_tab.o bn_s_mp_add.o bn_s_mp_balance_mul.o bn_s_mp_exptmod.o \
bn_s_mp_exptmod_fast.o bn_s_mp_get_bit.o bn_s_mp_invmod_fast.o bn_s_mp_invmod_slow.o \
bn_s_mp_karatsuba_mul.o bn_s_mp_karatsuba_sqr.o bn_s_mp_montgomery_reduce_fast.o bn_s_mp_mul_digs.o \
bn_s_mp_mul_digs_fast.o bn_s_mp_mul_high_digs.o bn_s_mp_mul_high_digs_fast.o \
bn_s_mp_prime_is_divisible.o bn_s_mp_rand_jenkins.o bn_s_mp_rand_platform.o bn_s_mp_reverse.o \
bn_s_mp_sqr.o bn_s_mp_sqr_fast.o bn_s_mp_sub.o bn_s_mp_todecimal_fast.o bn_s_mp_toom_mul.o \
bn_s_mp_toom_sqr.o

HEADERS_PUB=tommath.h
HEADERS=tommath_private.h tommath_class.h tommath_superclass.h $(HEADERS_PUB)
Expand Down
15 changes: 8 additions & 7 deletions makefile.msvc
Original file line number Diff line number Diff line change
Expand Up @@ -44,13 +44,14 @@ bn_mp_set.obj bn_mp_set_double.obj bn_mp_set_i32.obj bn_mp_set_i64.obj bn_mp_set
bn_mp_set_u32.obj bn_mp_set_u64.obj bn_mp_set_ul.obj bn_mp_set_ull.obj bn_mp_shrink.obj bn_mp_signed_bin_size.obj \
bn_mp_signed_rsh.obj bn_mp_sqr.obj bn_mp_sqrmod.obj bn_mp_sqrt.obj bn_mp_sqrtmod_prime.obj bn_mp_sub.obj bn_mp_sub_d.obj \
bn_mp_submod.obj bn_mp_to_signed_bin.obj bn_mp_to_signed_bin_n.obj bn_mp_to_unsigned_bin.obj \
bn_mp_to_unsigned_bin_n.obj bn_mp_toradix.obj bn_mp_toradix_n.obj bn_mp_unsigned_bin_size.obj bn_mp_xor.obj \
bn_mp_zero.obj bn_prime_tab.obj bn_s_mp_add.obj bn_s_mp_balance_mul.obj bn_s_mp_exptmod.obj bn_s_mp_exptmod_fast.obj \
bn_s_mp_get_bit.obj bn_s_mp_invmod_fast.obj bn_s_mp_invmod_slow.obj bn_s_mp_karatsuba_mul.obj \
bn_s_mp_karatsuba_sqr.obj bn_s_mp_montgomery_reduce_fast.obj bn_s_mp_mul_digs.obj bn_s_mp_mul_digs_fast.obj \
bn_s_mp_mul_high_digs.obj bn_s_mp_mul_high_digs_fast.obj bn_s_mp_prime_is_divisible.obj \
bn_s_mp_rand_jenkins.obj bn_s_mp_rand_platform.obj bn_s_mp_reverse.obj bn_s_mp_sqr.obj bn_s_mp_sqr_fast.obj \
bn_s_mp_sub.obj bn_s_mp_toom_mul.obj bn_s_mp_toom_sqr.obj
bn_mp_to_unsigned_bin_n.obj bn_mp_todecimal.obj bn_mp_toradix.obj bn_mp_toradix_n.obj bn_mp_unsigned_bin_size.obj \
bn_mp_xor.obj bn_mp_zero.obj bn_prime_tab.obj bn_s_mp_add.obj bn_s_mp_balance_mul.obj bn_s_mp_exptmod.obj \
bn_s_mp_exptmod_fast.obj bn_s_mp_get_bit.obj bn_s_mp_invmod_fast.obj bn_s_mp_invmod_slow.obj \
bn_s_mp_karatsuba_mul.obj bn_s_mp_karatsuba_sqr.obj bn_s_mp_montgomery_reduce_fast.obj bn_s_mp_mul_digs.obj \
bn_s_mp_mul_digs_fast.obj bn_s_mp_mul_high_digs.obj bn_s_mp_mul_high_digs_fast.obj \
bn_s_mp_prime_is_divisible.obj bn_s_mp_rand_jenkins.obj bn_s_mp_rand_platform.obj bn_s_mp_reverse.obj \
bn_s_mp_sqr.obj bn_s_mp_sqr_fast.obj bn_s_mp_sub.obj bn_s_mp_todecimal_fast.obj bn_s_mp_toom_mul.obj \
bn_s_mp_toom_sqr.obj

HEADERS_PUB=tommath.h
HEADERS=tommath_private.h tommath_class.h tommath_superclass.h $(HEADERS_PUB)
Expand Down
15 changes: 8 additions & 7 deletions makefile.shared
Original file line number Diff line number Diff line change
Expand Up @@ -46,13 +46,14 @@ bn_mp_set.o bn_mp_set_double.o bn_mp_set_i32.o bn_mp_set_i64.o bn_mp_set_l.o bn_
bn_mp_set_u32.o bn_mp_set_u64.o bn_mp_set_ul.o bn_mp_set_ull.o bn_mp_shrink.o bn_mp_signed_bin_size.o \
bn_mp_signed_rsh.o bn_mp_sqr.o bn_mp_sqrmod.o bn_mp_sqrt.o bn_mp_sqrtmod_prime.o bn_mp_sub.o bn_mp_sub_d.o \
bn_mp_submod.o bn_mp_to_signed_bin.o bn_mp_to_signed_bin_n.o bn_mp_to_unsigned_bin.o \
bn_mp_to_unsigned_bin_n.o bn_mp_toradix.o bn_mp_toradix_n.o bn_mp_unsigned_bin_size.o bn_mp_xor.o \
bn_mp_zero.o bn_prime_tab.o bn_s_mp_add.o bn_s_mp_balance_mul.o bn_s_mp_exptmod.o bn_s_mp_exptmod_fast.o \
bn_s_mp_get_bit.o bn_s_mp_invmod_fast.o bn_s_mp_invmod_slow.o bn_s_mp_karatsuba_mul.o \
bn_s_mp_karatsuba_sqr.o bn_s_mp_montgomery_reduce_fast.o bn_s_mp_mul_digs.o bn_s_mp_mul_digs_fast.o \
bn_s_mp_mul_high_digs.o bn_s_mp_mul_high_digs_fast.o bn_s_mp_prime_is_divisible.o \
bn_s_mp_rand_jenkins.o bn_s_mp_rand_platform.o bn_s_mp_reverse.o bn_s_mp_sqr.o bn_s_mp_sqr_fast.o \
bn_s_mp_sub.o bn_s_mp_toom_mul.o bn_s_mp_toom_sqr.o
bn_mp_to_unsigned_bin_n.o bn_mp_todecimal.o bn_mp_toradix.o bn_mp_toradix_n.o bn_mp_unsigned_bin_size.o \
bn_mp_xor.o bn_mp_zero.o bn_prime_tab.o bn_s_mp_add.o bn_s_mp_balance_mul.o bn_s_mp_exptmod.o \
bn_s_mp_exptmod_fast.o bn_s_mp_get_bit.o bn_s_mp_invmod_fast.o bn_s_mp_invmod_slow.o \
bn_s_mp_karatsuba_mul.o bn_s_mp_karatsuba_sqr.o bn_s_mp_montgomery_reduce_fast.o bn_s_mp_mul_digs.o \
bn_s_mp_mul_digs_fast.o bn_s_mp_mul_high_digs.o bn_s_mp_mul_high_digs_fast.o \
bn_s_mp_prime_is_divisible.o bn_s_mp_rand_jenkins.o bn_s_mp_rand_platform.o bn_s_mp_reverse.o \
bn_s_mp_sqr.o bn_s_mp_sqr_fast.o bn_s_mp_sub.o bn_s_mp_todecimal_fast.o bn_s_mp_toom_mul.o \
bn_s_mp_toom_sqr.o

#END_INS

Expand Down
15 changes: 8 additions & 7 deletions makefile.unix
Original file line number Diff line number Diff line change
Expand Up @@ -53,13 +53,14 @@ bn_mp_set.o bn_mp_set_double.o bn_mp_set_i32.o bn_mp_set_i64.o bn_mp_set_l.o bn_
bn_mp_set_u32.o bn_mp_set_u64.o bn_mp_set_ul.o bn_mp_set_ull.o bn_mp_shrink.o bn_mp_signed_bin_size.o \
bn_mp_signed_rsh.o bn_mp_sqr.o bn_mp_sqrmod.o bn_mp_sqrt.o bn_mp_sqrtmod_prime.o bn_mp_sub.o bn_mp_sub_d.o \
bn_mp_submod.o bn_mp_to_signed_bin.o bn_mp_to_signed_bin_n.o bn_mp_to_unsigned_bin.o \
bn_mp_to_unsigned_bin_n.o bn_mp_toradix.o bn_mp_toradix_n.o bn_mp_unsigned_bin_size.o bn_mp_xor.o \
bn_mp_zero.o bn_prime_tab.o bn_s_mp_add.o bn_s_mp_balance_mul.o bn_s_mp_exptmod.o bn_s_mp_exptmod_fast.o \
bn_s_mp_get_bit.o bn_s_mp_invmod_fast.o bn_s_mp_invmod_slow.o bn_s_mp_karatsuba_mul.o \
bn_s_mp_karatsuba_sqr.o bn_s_mp_montgomery_reduce_fast.o bn_s_mp_mul_digs.o bn_s_mp_mul_digs_fast.o \
bn_s_mp_mul_high_digs.o bn_s_mp_mul_high_digs_fast.o bn_s_mp_prime_is_divisible.o \
bn_s_mp_rand_jenkins.o bn_s_mp_rand_platform.o bn_s_mp_reverse.o bn_s_mp_sqr.o bn_s_mp_sqr_fast.o \
bn_s_mp_sub.o bn_s_mp_toom_mul.o bn_s_mp_toom_sqr.o
bn_mp_to_unsigned_bin_n.o bn_mp_todecimal.o bn_mp_toradix.o bn_mp_toradix_n.o bn_mp_unsigned_bin_size.o \
bn_mp_xor.o bn_mp_zero.o bn_prime_tab.o bn_s_mp_add.o bn_s_mp_balance_mul.o bn_s_mp_exptmod.o \
bn_s_mp_exptmod_fast.o bn_s_mp_get_bit.o bn_s_mp_invmod_fast.o bn_s_mp_invmod_slow.o \
bn_s_mp_karatsuba_mul.o bn_s_mp_karatsuba_sqr.o bn_s_mp_montgomery_reduce_fast.o bn_s_mp_mul_digs.o \
bn_s_mp_mul_digs_fast.o bn_s_mp_mul_high_digs.o bn_s_mp_mul_high_digs_fast.o \
bn_s_mp_prime_is_divisible.o bn_s_mp_rand_jenkins.o bn_s_mp_rand_platform.o bn_s_mp_reverse.o \
bn_s_mp_sqr.o bn_s_mp_sqr_fast.o bn_s_mp_sub.o bn_s_mp_todecimal_fast.o bn_s_mp_toom_mul.o \
bn_s_mp_toom_sqr.o

HEADERS_PUB=tommath.h
HEADERS=tommath_private.h tommath_class.h tommath_superclass.h $(HEADERS_PUB)
Expand Down
1 change: 1 addition & 0 deletions tommath.def
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,7 @@ EXPORTS
mp_to_signed_bin_n
mp_to_unsigned_bin
mp_to_unsigned_bin_n
mp_todecimal
mp_toradix
mp_toradix_n
mp_unsigned_bin_size
Expand Down
2 changes: 1 addition & 1 deletion tommath.h
Original file line number Diff line number Diff line change
Expand Up @@ -702,6 +702,7 @@ mp_err mp_read_radix(mp_int *a, const char *str, int radix) MP_WUR;
mp_err mp_toradix(const mp_int *a, char *str, int radix) MP_WUR;
mp_err mp_toradix_n(const mp_int *a, char *str, int radix, int maxlen) MP_WUR;
mp_err mp_radix_size(const mp_int *a, int radix, int *size) MP_WUR;
mp_err mp_todecimal(const mp_int *a, char *str) MP_WUR;

#ifndef MP_NO_FILE
mp_err mp_fread(mp_int *a, int radix, FILE *stream) MP_WUR;
Expand All @@ -717,7 +718,6 @@ mp_err mp_fwrite(const mp_int *a, int radix, FILE *stream) MP_WUR;

#define mp_tobinary(M, S) mp_toradix((M), (S), 2)
#define mp_tooctal(M, S) mp_toradix((M), (S), 8)
#define mp_todecimal(M, S) mp_toradix((M), (S), 10)
#define mp_tohex(M, S) mp_toradix((M), (S), 16)

#ifdef __cplusplus
Expand Down
Loading