diff --git a/bn_mp_tc_and.c b/bn_mp_tc_and.c index 9a6f5281e..833878b1c 100644 --- a/bn_mp_tc_and.c +++ b/bn_mp_tc_and.c @@ -53,7 +53,7 @@ int mp_tc_and(const mp_int *a, const mp_int *b, mp_int *c) } } - res = mp_and(a, b, c); + res = s_mp_and(a, b, c); if ((sa == MP_NEG) && (sb == MP_NEG) && (res == MP_OKAY)) { res = mp_sub(c, mx, c); diff --git a/bn_mp_tc_or.c b/bn_mp_tc_or.c index 93cb520db..9441c8991 100644 --- a/bn_mp_tc_or.c +++ b/bn_mp_tc_or.c @@ -53,7 +53,7 @@ int mp_tc_or(const mp_int *a, const mp_int *b, mp_int *c) } } - res = mp_or(a, b, c); + res = s_mp_or(a, b, c); if (((sa == MP_NEG) || (sb == MP_NEG)) && (res == MP_OKAY)) { res = mp_sub(c, mx, c); diff --git a/bn_mp_tc_xor.c b/bn_mp_tc_xor.c index ff4189c34..a0fe4c40b 100644 --- a/bn_mp_tc_xor.c +++ b/bn_mp_tc_xor.c @@ -53,7 +53,7 @@ int mp_tc_xor(const mp_int *a, const mp_int *b, mp_int *c) } } - res = mp_xor(a, b, c); + res = s_mp_xor(a, b, c); if ((((sa == MP_NEG) && (sb != MP_NEG)) || ((sa != MP_NEG) && (sb == MP_NEG))) && (res == MP_OKAY)) { res = mp_sub(c, mx, c); diff --git a/bn_mp_and.c b/bn_s_mp_and.c similarity index 87% rename from bn_mp_and.c rename to bn_s_mp_and.c index 7f94d354e..b2ed60c95 100644 --- a/bn_mp_and.c +++ b/bn_s_mp_and.c @@ -1,10 +1,10 @@ #include "tommath_private.h" -#ifdef BN_MP_AND_C +#ifdef BN_S_MP_AND_C /* LibTomMath, multiple-precision integer library -- Tom St Denis */ /* SPDX-License-Identifier: Unlicense */ /* AND two ints together */ -int mp_and(const mp_int *a, const mp_int *b, mp_int *c) +int s_mp_and(const mp_int *a, const mp_int *b, mp_int *c) { int res, ix, px; mp_int t; @@ -38,4 +38,9 @@ int mp_and(const mp_int *a, const mp_int *b, mp_int *c) mp_clear(&t); return MP_OKAY; } + +int mp_and(const mp_int *a, const mp_int *b, mp_int *c) +{ + return s_mp_and(a, b, c); +} #endif diff --git a/bn_mp_or.c b/bn_s_mp_or.c similarity index 86% rename from bn_mp_or.c rename to bn_s_mp_or.c index f3704f7ed..947afe534 100644 --- a/bn_mp_or.c +++ b/bn_s_mp_or.c @@ -1,10 +1,10 @@ #include "tommath_private.h" -#ifdef BN_MP_OR_C +#ifdef BN_S_MP_OR_C /* LibTomMath, multiple-precision integer library -- Tom St Denis */ /* SPDX-License-Identifier: Unlicense */ /* OR two ints together */ -int mp_or(const mp_int *a, const mp_int *b, mp_int *c) +int s_mp_or(const mp_int *a, const mp_int *b, mp_int *c) { int res, ix, px; mp_int t; @@ -32,4 +32,9 @@ int mp_or(const mp_int *a, const mp_int *b, mp_int *c) mp_clear(&t); return MP_OKAY; } + +int mp_or(const mp_int *a, const mp_int *b, mp_int *c) +{ + return s_mp_or(a, b, c); +} #endif diff --git a/bn_mp_xor.c b/bn_s_mp_xor.c similarity index 86% rename from bn_mp_xor.c rename to bn_s_mp_xor.c index a61c8fe0d..967b63540 100644 --- a/bn_mp_xor.c +++ b/bn_s_mp_xor.c @@ -1,10 +1,10 @@ #include "tommath_private.h" -#ifdef BN_MP_XOR_C +#ifdef BN_S_MP_XOR_C /* LibTomMath, multiple-precision integer library -- Tom St Denis */ /* SPDX-License-Identifier: Unlicense */ /* XOR two ints together */ -int mp_xor(const mp_int *a, const mp_int *b, mp_int *c) +int s_mp_xor(const mp_int *a, const mp_int *b, mp_int *c) { int res, ix, px; mp_int t; @@ -32,4 +32,9 @@ int mp_xor(const mp_int *a, const mp_int *b, mp_int *c) mp_clear(&t); return MP_OKAY; } + +int mp_xor(const mp_int *a, const mp_int *b, mp_int *c) +{ + return s_mp_xor(a, b, c); +} #endif diff --git a/callgraph.txt b/callgraph.txt index 000409afc..4820f4175 100644 --- a/callgraph.txt +++ b/callgraph.txt @@ -899,17 +899,6 @@ BN_MP_ADD_D_C +--->BN_MP_CLAMP_C -BN_MP_AND_C -+--->BN_MP_INIT_COPY_C -| +--->BN_MP_INIT_SIZE_C -| +--->BN_MP_COPY_C -| | +--->BN_MP_GROW_C -| +--->BN_MP_CLEAR_C -+--->BN_MP_CLAMP_C -+--->BN_MP_EXCH_C -+--->BN_MP_CLEAR_C - - BN_MP_CLAMP_C @@ -4497,17 +4486,6 @@ BN_MP_N_ROOT_EX_C +--->BN_MP_CLEAR_C -BN_MP_OR_C -+--->BN_MP_INIT_COPY_C -| +--->BN_MP_INIT_SIZE_C -| +--->BN_MP_COPY_C -| | +--->BN_MP_GROW_C -| +--->BN_MP_CLEAR_C -+--->BN_MP_CLAMP_C -+--->BN_MP_EXCH_C -+--->BN_MP_CLEAR_C - - BN_MP_PRIME_FERMAT_C +--->BN_MP_CMP_D_C +--->BN_MP_INIT_C @@ -14027,7 +14005,7 @@ BN_MP_TC_AND_C | | +--->BN_MP_GROW_C | | +--->BN_MP_CLAMP_C +--->BN_MP_CLEAR_C -+--->BN_MP_AND_C ++--->BN_S_MP_AND_C | +--->BN_MP_INIT_COPY_C | | +--->BN_MP_INIT_SIZE_C | | +--->BN_MP_COPY_C @@ -14085,7 +14063,7 @@ BN_MP_TC_OR_C | | +--->BN_MP_GROW_C | | +--->BN_MP_CLAMP_C +--->BN_MP_CLEAR_C -+--->BN_MP_OR_C ++--->BN_S_MP_OR_C | +--->BN_MP_INIT_COPY_C | | +--->BN_MP_INIT_SIZE_C | | +--->BN_MP_COPY_C @@ -14124,7 +14102,7 @@ BN_MP_TC_XOR_C | | +--->BN_MP_GROW_C | | +--->BN_MP_CLAMP_C +--->BN_MP_CLEAR_C -+--->BN_MP_XOR_C ++--->BN_S_MP_XOR_C | +--->BN_MP_INIT_COPY_C | | +--->BN_MP_INIT_SIZE_C | | +--->BN_MP_COPY_C @@ -14282,17 +14260,6 @@ BN_MP_UNSIGNED_BIN_SIZE_C +--->BN_MP_COUNT_BITS_C -BN_MP_XOR_C -+--->BN_MP_INIT_COPY_C -| +--->BN_MP_INIT_SIZE_C -| +--->BN_MP_COPY_C -| | +--->BN_MP_GROW_C -| +--->BN_MP_CLEAR_C -+--->BN_MP_CLAMP_C -+--->BN_MP_EXCH_C -+--->BN_MP_CLEAR_C - - BN_MP_ZERO_C @@ -14304,6 +14271,17 @@ BN_S_MP_ADD_C +--->BN_MP_CLAMP_C +BN_S_MP_AND_C ++--->BN_MP_INIT_COPY_C +| +--->BN_MP_INIT_SIZE_C +| +--->BN_MP_COPY_C +| | +--->BN_MP_GROW_C +| +--->BN_MP_CLEAR_C ++--->BN_MP_CLAMP_C ++--->BN_MP_EXCH_C ++--->BN_MP_CLEAR_C + + BN_S_MP_BALANCE_MUL_C +--->BN_MP_INIT_SIZE_C +--->BN_MP_INIT_MULTI_C @@ -15360,6 +15338,17 @@ BN_S_MP_MUL_HIGH_DIGS_FAST_C +--->BN_MP_CLAMP_C +BN_S_MP_OR_C ++--->BN_MP_INIT_COPY_C +| +--->BN_MP_INIT_SIZE_C +| +--->BN_MP_COPY_C +| | +--->BN_MP_GROW_C +| +--->BN_MP_CLEAR_C ++--->BN_MP_CLAMP_C ++--->BN_MP_EXCH_C ++--->BN_MP_CLEAR_C + + BN_S_MP_REVERSE_C @@ -15543,3 +15532,14 @@ BN_S_MP_TOOM_SQR_C | +--->BN_MP_CLEAR_C +BN_S_MP_XOR_C ++--->BN_MP_INIT_COPY_C +| +--->BN_MP_INIT_SIZE_C +| +--->BN_MP_COPY_C +| | +--->BN_MP_GROW_C +| +--->BN_MP_CLEAR_C ++--->BN_MP_CLAMP_C ++--->BN_MP_EXCH_C ++--->BN_MP_CLEAR_C + + diff --git a/libtommath_VS2008.vcproj b/libtommath_VS2008.vcproj index db7a18561..93157000c 100644 --- a/libtommath_VS2008.vcproj +++ b/libtommath_VS2008.vcproj @@ -340,10 +340,6 @@ RelativePath="bn_mp_addmod.c" > - - @@ -608,10 +604,6 @@ RelativePath="bn_mp_neg.c" > - - @@ -808,10 +800,6 @@ RelativePath="bn_mp_unsigned_bin_size.c" > - - @@ -824,6 +812,10 @@ RelativePath="bn_s_mp_add.c" > + + @@ -872,6 +864,10 @@ RelativePath="bn_s_mp_mul_high_digs_fast.c" > + + @@ -896,6 +892,10 @@ RelativePath="bn_s_mp_toom_sqr.c" > + + diff --git a/makefile b/makefile index 223b4dfd6..196a8da05 100644 --- a/makefile +++ b/makefile @@ -27,9 +27,9 @@ LCOV_ARGS=--directory . #START_INS OBJECTS=bn_cutoffs.o bn_deprecated.o bn_mp_2expt.o bn_mp_abs.o bn_mp_add.o bn_mp_add_d.o bn_mp_addmod.o \ -bn_mp_and.o bn_mp_clamp.o bn_mp_clear.o bn_mp_clear_multi.o bn_mp_cmp.o bn_mp_cmp_d.o bn_mp_cmp_mag.o \ -bn_mp_cnt_lsb.o bn_mp_complement.o bn_mp_copy.o bn_mp_count_bits.o bn_mp_decr.o bn_mp_div.o bn_mp_div_2.o \ -bn_mp_div_2d.o bn_mp_div_3.o bn_mp_div_d.o bn_mp_dr_is_modulus.o bn_mp_dr_reduce.o bn_mp_dr_setup.o \ +bn_mp_clamp.o bn_mp_clear.o bn_mp_clear_multi.o bn_mp_cmp.o bn_mp_cmp_d.o bn_mp_cmp_mag.o bn_mp_cnt_lsb.o \ +bn_mp_complement.o bn_mp_copy.o bn_mp_count_bits.o bn_mp_decr.o bn_mp_div.o bn_mp_div_2.o bn_mp_div_2d.o \ +bn_mp_div_3.o bn_mp_div_d.o bn_mp_dr_is_modulus.o bn_mp_dr_reduce.o bn_mp_dr_setup.o \ bn_mp_error_to_string.o bn_mp_exch.o bn_mp_export.o bn_mp_expt_d.o bn_mp_expt_d_ex.o bn_mp_exptmod.o \ bn_mp_exteuclid.o bn_mp_fread.o bn_mp_fwrite.o bn_mp_gcd.o bn_mp_get_bit.o bn_mp_get_double.o \ bn_mp_get_int.o bn_mp_get_long.o bn_mp_get_long_long.o bn_mp_grow.o bn_mp_ilogb.o bn_mp_import.o \ @@ -38,7 +38,7 @@ bn_mp_init_size.o bn_mp_invmod.o bn_mp_is_square.o bn_mp_iseven.o bn_mp_isodd.o bn_mp_kronecker.o bn_mp_lcm.o bn_mp_lshd.o bn_mp_mod.o bn_mp_mod_2d.o bn_mp_mod_d.o \ bn_mp_montgomery_calc_normalization.o bn_mp_montgomery_reduce.o bn_mp_montgomery_setup.o bn_mp_mul.o \ bn_mp_mul_2.o bn_mp_mul_2d.o bn_mp_mul_d.o bn_mp_mulmod.o bn_mp_n_root.o bn_mp_n_root_ex.o bn_mp_neg.o \ -bn_mp_or.o bn_mp_prime_fermat.o bn_mp_prime_frobenius_underwood.o bn_mp_prime_is_divisible.o \ +bn_mp_prime_fermat.o bn_mp_prime_frobenius_underwood.o bn_mp_prime_is_divisible.o \ bn_mp_prime_is_prime.o bn_mp_prime_miller_rabin.o bn_mp_prime_next_prime.o \ bn_mp_prime_rabin_miller_trials.o bn_mp_prime_random_ex.o bn_mp_prime_strong_lucas_selfridge.o \ bn_mp_radix_size.o bn_mp_radix_smap.o bn_mp_rand.o bn_mp_read_radix.o bn_mp_read_signed_bin.o \ @@ -48,11 +48,12 @@ bn_mp_set.o bn_mp_set_double.o bn_mp_set_int.o bn_mp_set_long.o bn_mp_set_long_l bn_mp_signed_bin_size.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_tc_and.o bn_mp_tc_div_2d.o bn_mp_tc_or.o bn_mp_tc_xor.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_invmod_fast.o \ +bn_mp_toradix.o bn_mp_toradix_n.o bn_mp_unsigned_bin_size.o bn_mp_zero.o bn_prime_tab.o bn_s_mp_add.o \ +bn_s_mp_and.o bn_s_mp_balance_mul.o bn_s_mp_exptmod.o bn_s_mp_exptmod_fast.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_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_s_mp_or.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_s_mp_xor.o #END_INS diff --git a/makefile.mingw b/makefile.mingw index 48d11c933..11154e144 100644 --- a/makefile.mingw +++ b/makefile.mingw @@ -30,9 +30,9 @@ LIBMAIN_D =libtommath.dll #List of objects to compile (all goes to libtommath.a) OBJECTS=bn_cutoffs.o bn_deprecated.o bn_mp_2expt.o bn_mp_abs.o bn_mp_add.o bn_mp_add_d.o bn_mp_addmod.o \ -bn_mp_and.o bn_mp_clamp.o bn_mp_clear.o bn_mp_clear_multi.o bn_mp_cmp.o bn_mp_cmp_d.o bn_mp_cmp_mag.o \ -bn_mp_cnt_lsb.o bn_mp_complement.o bn_mp_copy.o bn_mp_count_bits.o bn_mp_decr.o bn_mp_div.o bn_mp_div_2.o \ -bn_mp_div_2d.o bn_mp_div_3.o bn_mp_div_d.o bn_mp_dr_is_modulus.o bn_mp_dr_reduce.o bn_mp_dr_setup.o \ +bn_mp_clamp.o bn_mp_clear.o bn_mp_clear_multi.o bn_mp_cmp.o bn_mp_cmp_d.o bn_mp_cmp_mag.o bn_mp_cnt_lsb.o \ +bn_mp_complement.o bn_mp_copy.o bn_mp_count_bits.o bn_mp_decr.o bn_mp_div.o bn_mp_div_2.o bn_mp_div_2d.o \ +bn_mp_div_3.o bn_mp_div_d.o bn_mp_dr_is_modulus.o bn_mp_dr_reduce.o bn_mp_dr_setup.o \ bn_mp_error_to_string.o bn_mp_exch.o bn_mp_export.o bn_mp_expt_d.o bn_mp_expt_d_ex.o bn_mp_exptmod.o \ bn_mp_exteuclid.o bn_mp_fread.o bn_mp_fwrite.o bn_mp_gcd.o bn_mp_get_bit.o bn_mp_get_double.o \ bn_mp_get_int.o bn_mp_get_long.o bn_mp_get_long_long.o bn_mp_grow.o bn_mp_ilogb.o bn_mp_import.o \ @@ -41,7 +41,7 @@ bn_mp_init_size.o bn_mp_invmod.o bn_mp_is_square.o bn_mp_iseven.o bn_mp_isodd.o bn_mp_kronecker.o bn_mp_lcm.o bn_mp_lshd.o bn_mp_mod.o bn_mp_mod_2d.o bn_mp_mod_d.o \ bn_mp_montgomery_calc_normalization.o bn_mp_montgomery_reduce.o bn_mp_montgomery_setup.o bn_mp_mul.o \ bn_mp_mul_2.o bn_mp_mul_2d.o bn_mp_mul_d.o bn_mp_mulmod.o bn_mp_n_root.o bn_mp_n_root_ex.o bn_mp_neg.o \ -bn_mp_or.o bn_mp_prime_fermat.o bn_mp_prime_frobenius_underwood.o bn_mp_prime_is_divisible.o \ +bn_mp_prime_fermat.o bn_mp_prime_frobenius_underwood.o bn_mp_prime_is_divisible.o \ bn_mp_prime_is_prime.o bn_mp_prime_miller_rabin.o bn_mp_prime_next_prime.o \ bn_mp_prime_rabin_miller_trials.o bn_mp_prime_random_ex.o bn_mp_prime_strong_lucas_selfridge.o \ bn_mp_radix_size.o bn_mp_radix_smap.o bn_mp_rand.o bn_mp_read_radix.o bn_mp_read_signed_bin.o \ @@ -51,11 +51,12 @@ bn_mp_set.o bn_mp_set_double.o bn_mp_set_int.o bn_mp_set_long.o bn_mp_set_long_l bn_mp_signed_bin_size.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_tc_and.o bn_mp_tc_div_2d.o bn_mp_tc_or.o bn_mp_tc_xor.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_invmod_fast.o \ +bn_mp_toradix.o bn_mp_toradix_n.o bn_mp_unsigned_bin_size.o bn_mp_zero.o bn_prime_tab.o bn_s_mp_add.o \ +bn_s_mp_and.o bn_s_mp_balance_mul.o bn_s_mp_exptmod.o bn_s_mp_exptmod_fast.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_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_s_mp_or.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_s_mp_xor.o HEADERS_PUB=tommath.h tommath_class.h tommath_superclass.h diff --git a/makefile.msvc b/makefile.msvc index 6d96ad1bf..65f9dfcee 100644 --- a/makefile.msvc +++ b/makefile.msvc @@ -22,9 +22,9 @@ LIBMAIN_S =tommath.lib #List of objects to compile (all goes to tommath.lib) OBJECTS=bn_cutoffs.obj bn_deprecated.obj bn_mp_2expt.obj bn_mp_abs.obj bn_mp_add.obj bn_mp_add_d.obj bn_mp_addmod.obj \ -bn_mp_and.obj bn_mp_clamp.obj bn_mp_clear.obj bn_mp_clear_multi.obj bn_mp_cmp.obj bn_mp_cmp_d.obj bn_mp_cmp_mag.obj \ -bn_mp_cnt_lsb.obj bn_mp_complement.obj bn_mp_copy.obj bn_mp_count_bits.obj bn_mp_decr.obj bn_mp_div.obj bn_mp_div_2.obj \ -bn_mp_div_2d.obj bn_mp_div_3.obj bn_mp_div_d.obj bn_mp_dr_is_modulus.obj bn_mp_dr_reduce.obj bn_mp_dr_setup.obj \ +bn_mp_clamp.obj bn_mp_clear.obj bn_mp_clear_multi.obj bn_mp_cmp.obj bn_mp_cmp_d.obj bn_mp_cmp_mag.obj bn_mp_cnt_lsb.obj \ +bn_mp_complement.obj bn_mp_copy.obj bn_mp_count_bits.obj bn_mp_decr.obj bn_mp_div.obj bn_mp_div_2.obj bn_mp_div_2d.obj \ +bn_mp_div_3.obj bn_mp_div_d.obj bn_mp_dr_is_modulus.obj bn_mp_dr_reduce.obj bn_mp_dr_setup.obj \ bn_mp_error_to_string.obj bn_mp_exch.obj bn_mp_export.obj bn_mp_expt_d.obj bn_mp_expt_d_ex.obj bn_mp_exptmod.obj \ bn_mp_exteuclid.obj bn_mp_fread.obj bn_mp_fwrite.obj bn_mp_gcd.obj bn_mp_get_bit.obj bn_mp_get_double.obj \ bn_mp_get_int.obj bn_mp_get_long.obj bn_mp_get_long_long.obj bn_mp_grow.obj bn_mp_ilogb.obj bn_mp_import.obj \ @@ -33,7 +33,7 @@ bn_mp_init_size.obj bn_mp_invmod.obj bn_mp_is_square.obj bn_mp_iseven.obj bn_mp_ bn_mp_kronecker.obj bn_mp_lcm.obj bn_mp_lshd.obj bn_mp_mod.obj bn_mp_mod_2d.obj bn_mp_mod_d.obj \ bn_mp_montgomery_calc_normalization.obj bn_mp_montgomery_reduce.obj bn_mp_montgomery_setup.obj bn_mp_mul.obj \ bn_mp_mul_2.obj bn_mp_mul_2d.obj bn_mp_mul_d.obj bn_mp_mulmod.obj bn_mp_n_root.obj bn_mp_n_root_ex.obj bn_mp_neg.obj \ -bn_mp_or.obj bn_mp_prime_fermat.obj bn_mp_prime_frobenius_underwood.obj bn_mp_prime_is_divisible.obj \ +bn_mp_prime_fermat.obj bn_mp_prime_frobenius_underwood.obj bn_mp_prime_is_divisible.obj \ bn_mp_prime_is_prime.obj bn_mp_prime_miller_rabin.obj bn_mp_prime_next_prime.obj \ bn_mp_prime_rabin_miller_trials.obj bn_mp_prime_random_ex.obj bn_mp_prime_strong_lucas_selfridge.obj \ bn_mp_radix_size.obj bn_mp_radix_smap.obj bn_mp_rand.obj bn_mp_read_radix.obj bn_mp_read_signed_bin.obj \ @@ -43,11 +43,12 @@ bn_mp_set.obj bn_mp_set_double.obj bn_mp_set_int.obj bn_mp_set_long.obj bn_mp_se bn_mp_signed_bin_size.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_tc_and.obj bn_mp_tc_div_2d.obj bn_mp_tc_or.obj bn_mp_tc_xor.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_invmod_fast.obj \ +bn_mp_toradix.obj bn_mp_toradix_n.obj bn_mp_unsigned_bin_size.obj bn_mp_zero.obj bn_prime_tab.obj bn_s_mp_add.obj \ +bn_s_mp_and.obj bn_s_mp_balance_mul.obj bn_s_mp_exptmod.obj bn_s_mp_exptmod_fast.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_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_s_mp_or.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_s_mp_xor.obj HEADERS_PUB=tommath.h tommath_class.h tommath_superclass.h diff --git a/makefile.shared b/makefile.shared index e816fc783..0a3ec404e 100644 --- a/makefile.shared +++ b/makefile.shared @@ -24,9 +24,9 @@ LCOV_ARGS=--directory .libs --directory . #START_INS OBJECTS=bn_cutoffs.o bn_deprecated.o bn_mp_2expt.o bn_mp_abs.o bn_mp_add.o bn_mp_add_d.o bn_mp_addmod.o \ -bn_mp_and.o bn_mp_clamp.o bn_mp_clear.o bn_mp_clear_multi.o bn_mp_cmp.o bn_mp_cmp_d.o bn_mp_cmp_mag.o \ -bn_mp_cnt_lsb.o bn_mp_complement.o bn_mp_copy.o bn_mp_count_bits.o bn_mp_decr.o bn_mp_div.o bn_mp_div_2.o \ -bn_mp_div_2d.o bn_mp_div_3.o bn_mp_div_d.o bn_mp_dr_is_modulus.o bn_mp_dr_reduce.o bn_mp_dr_setup.o \ +bn_mp_clamp.o bn_mp_clear.o bn_mp_clear_multi.o bn_mp_cmp.o bn_mp_cmp_d.o bn_mp_cmp_mag.o bn_mp_cnt_lsb.o \ +bn_mp_complement.o bn_mp_copy.o bn_mp_count_bits.o bn_mp_decr.o bn_mp_div.o bn_mp_div_2.o bn_mp_div_2d.o \ +bn_mp_div_3.o bn_mp_div_d.o bn_mp_dr_is_modulus.o bn_mp_dr_reduce.o bn_mp_dr_setup.o \ bn_mp_error_to_string.o bn_mp_exch.o bn_mp_export.o bn_mp_expt_d.o bn_mp_expt_d_ex.o bn_mp_exptmod.o \ bn_mp_exteuclid.o bn_mp_fread.o bn_mp_fwrite.o bn_mp_gcd.o bn_mp_get_bit.o bn_mp_get_double.o \ bn_mp_get_int.o bn_mp_get_long.o bn_mp_get_long_long.o bn_mp_grow.o bn_mp_ilogb.o bn_mp_import.o \ @@ -35,7 +35,7 @@ bn_mp_init_size.o bn_mp_invmod.o bn_mp_is_square.o bn_mp_iseven.o bn_mp_isodd.o bn_mp_kronecker.o bn_mp_lcm.o bn_mp_lshd.o bn_mp_mod.o bn_mp_mod_2d.o bn_mp_mod_d.o \ bn_mp_montgomery_calc_normalization.o bn_mp_montgomery_reduce.o bn_mp_montgomery_setup.o bn_mp_mul.o \ bn_mp_mul_2.o bn_mp_mul_2d.o bn_mp_mul_d.o bn_mp_mulmod.o bn_mp_n_root.o bn_mp_n_root_ex.o bn_mp_neg.o \ -bn_mp_or.o bn_mp_prime_fermat.o bn_mp_prime_frobenius_underwood.o bn_mp_prime_is_divisible.o \ +bn_mp_prime_fermat.o bn_mp_prime_frobenius_underwood.o bn_mp_prime_is_divisible.o \ bn_mp_prime_is_prime.o bn_mp_prime_miller_rabin.o bn_mp_prime_next_prime.o \ bn_mp_prime_rabin_miller_trials.o bn_mp_prime_random_ex.o bn_mp_prime_strong_lucas_selfridge.o \ bn_mp_radix_size.o bn_mp_radix_smap.o bn_mp_rand.o bn_mp_read_radix.o bn_mp_read_signed_bin.o \ @@ -45,11 +45,12 @@ bn_mp_set.o bn_mp_set_double.o bn_mp_set_int.o bn_mp_set_long.o bn_mp_set_long_l bn_mp_signed_bin_size.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_tc_and.o bn_mp_tc_div_2d.o bn_mp_tc_or.o bn_mp_tc_xor.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_invmod_fast.o \ +bn_mp_toradix.o bn_mp_toradix_n.o bn_mp_unsigned_bin_size.o bn_mp_zero.o bn_prime_tab.o bn_s_mp_add.o \ +bn_s_mp_and.o bn_s_mp_balance_mul.o bn_s_mp_exptmod.o bn_s_mp_exptmod_fast.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_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_s_mp_or.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_s_mp_xor.o #END_INS diff --git a/makefile.unix b/makefile.unix index 42dfcf948..f5260260a 100644 --- a/makefile.unix +++ b/makefile.unix @@ -31,9 +31,9 @@ LTM_LDFLAGS = $(LDFLAGS) LIBMAIN_S = libtommath.a OBJECTS=bn_cutoffs.o bn_deprecated.o bn_mp_2expt.o bn_mp_abs.o bn_mp_add.o bn_mp_add_d.o bn_mp_addmod.o \ -bn_mp_and.o bn_mp_clamp.o bn_mp_clear.o bn_mp_clear_multi.o bn_mp_cmp.o bn_mp_cmp_d.o bn_mp_cmp_mag.o \ -bn_mp_cnt_lsb.o bn_mp_complement.o bn_mp_copy.o bn_mp_count_bits.o bn_mp_decr.o bn_mp_div.o bn_mp_div_2.o \ -bn_mp_div_2d.o bn_mp_div_3.o bn_mp_div_d.o bn_mp_dr_is_modulus.o bn_mp_dr_reduce.o bn_mp_dr_setup.o \ +bn_mp_clamp.o bn_mp_clear.o bn_mp_clear_multi.o bn_mp_cmp.o bn_mp_cmp_d.o bn_mp_cmp_mag.o bn_mp_cnt_lsb.o \ +bn_mp_complement.o bn_mp_copy.o bn_mp_count_bits.o bn_mp_decr.o bn_mp_div.o bn_mp_div_2.o bn_mp_div_2d.o \ +bn_mp_div_3.o bn_mp_div_d.o bn_mp_dr_is_modulus.o bn_mp_dr_reduce.o bn_mp_dr_setup.o \ bn_mp_error_to_string.o bn_mp_exch.o bn_mp_export.o bn_mp_expt_d.o bn_mp_expt_d_ex.o bn_mp_exptmod.o \ bn_mp_exteuclid.o bn_mp_fread.o bn_mp_fwrite.o bn_mp_gcd.o bn_mp_get_bit.o bn_mp_get_double.o \ bn_mp_get_int.o bn_mp_get_long.o bn_mp_get_long_long.o bn_mp_grow.o bn_mp_ilogb.o bn_mp_import.o \ @@ -42,7 +42,7 @@ bn_mp_init_size.o bn_mp_invmod.o bn_mp_is_square.o bn_mp_iseven.o bn_mp_isodd.o bn_mp_kronecker.o bn_mp_lcm.o bn_mp_lshd.o bn_mp_mod.o bn_mp_mod_2d.o bn_mp_mod_d.o \ bn_mp_montgomery_calc_normalization.o bn_mp_montgomery_reduce.o bn_mp_montgomery_setup.o bn_mp_mul.o \ bn_mp_mul_2.o bn_mp_mul_2d.o bn_mp_mul_d.o bn_mp_mulmod.o bn_mp_n_root.o bn_mp_n_root_ex.o bn_mp_neg.o \ -bn_mp_or.o bn_mp_prime_fermat.o bn_mp_prime_frobenius_underwood.o bn_mp_prime_is_divisible.o \ +bn_mp_prime_fermat.o bn_mp_prime_frobenius_underwood.o bn_mp_prime_is_divisible.o \ bn_mp_prime_is_prime.o bn_mp_prime_miller_rabin.o bn_mp_prime_next_prime.o \ bn_mp_prime_rabin_miller_trials.o bn_mp_prime_random_ex.o bn_mp_prime_strong_lucas_selfridge.o \ bn_mp_radix_size.o bn_mp_radix_smap.o bn_mp_rand.o bn_mp_read_radix.o bn_mp_read_signed_bin.o \ @@ -52,11 +52,12 @@ bn_mp_set.o bn_mp_set_double.o bn_mp_set_int.o bn_mp_set_long.o bn_mp_set_long_l bn_mp_signed_bin_size.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_tc_and.o bn_mp_tc_div_2d.o bn_mp_tc_or.o bn_mp_tc_xor.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_invmod_fast.o \ +bn_mp_toradix.o bn_mp_toradix_n.o bn_mp_unsigned_bin_size.o bn_mp_zero.o bn_prime_tab.o bn_s_mp_add.o \ +bn_s_mp_and.o bn_s_mp_balance_mul.o bn_s_mp_exptmod.o bn_s_mp_exptmod_fast.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_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_s_mp_or.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_s_mp_xor.o HEADERS_PUB=tommath.h tommath_class.h tommath_superclass.h diff --git a/tommath.h b/tommath.h index 5d8961b4c..fa489a734 100644 --- a/tommath.h +++ b/tommath.h @@ -318,28 +318,32 @@ extern unsigned long (*ltm_rng)(unsigned char *out, unsigned long outlen, void ( extern void (*ltm_rng_callback)(void); #endif -/* ---> binary operations <--- */ +/* ---> bitwise operations <--- */ + +/* Checks the bit at position b and returns MP_YES + if the bit is 1, MP_NO if it is 0 and MP_VAL + in case of error */ +int mp_get_bit(const mp_int *a, int b); + /* c = a XOR b */ -int mp_xor(const mp_int *a, const mp_int *b, mp_int *c); +MP_DEPRECATED(mp_tc_xor) int mp_xor(const mp_int *a, const mp_int *b, mp_int *c); /* c = a OR b */ -int mp_or(const mp_int *a, const mp_int *b, mp_int *c); +MP_DEPRECATED(mp_tc_or) int mp_or(const mp_int *a, const mp_int *b, mp_int *c); /* c = a AND b */ -int mp_and(const mp_int *a, const mp_int *b, mp_int *c); +MP_DEPRECATED(mp_tc_and) int mp_and(const mp_int *a, const mp_int *b, mp_int *c); -/* Checks the bit at position b and returns MP_YES - if the bit is 1, MP_NO if it is 0 and MP_VAL - in case of error */ -int mp_get_bit(const mp_int *a, int b); +/* b = ~a */ +int mp_complement(const mp_int *a, mp_int *b); -/* c = a XOR b (two complement) */ +/* c = a XOR b (two complement, generalised mp_xor) */ int mp_tc_xor(const mp_int *a, const mp_int *b, mp_int *c); -/* c = a OR b (two complement) */ +/* c = a OR b (two complement, generalised mp_or) */ int mp_tc_or(const mp_int *a, const mp_int *b, mp_int *c); -/* c = a AND b (two complement) */ +/* c = a AND b (two complement, generalised mp_and) */ int mp_tc_and(const mp_int *a, const mp_int *b, mp_int *c); /* right shift (two complement) */ @@ -347,9 +351,6 @@ int mp_tc_div_2d(const mp_int *a, int b, mp_int *c); /* ---> Basic arithmetic <--- */ -/* b = ~a */ -int mp_complement(const mp_int *a, mp_int *b); - /* b = -a */ int mp_neg(const mp_int *a, mp_int *b); diff --git a/tommath_class.h b/tommath_class.h index e96ff6fd3..a2c2c150b 100644 --- a/tommath_class.h +++ b/tommath_class.h @@ -17,7 +17,6 @@ # define BN_MP_ADD_C # define BN_MP_ADD_D_C # define BN_MP_ADDMOD_C -# define BN_MP_AND_C # define BN_MP_CLAMP_C # define BN_MP_CLEAR_C # define BN_MP_CLEAR_MULTI_C @@ -84,7 +83,6 @@ # define BN_MP_N_ROOT_C # define BN_MP_N_ROOT_EX_C # define BN_MP_NEG_C -# define BN_MP_OR_C # define BN_MP_PRIME_FERMAT_C # define BN_MP_PRIME_FROBENIUS_UNDERWOOD_C # define BN_MP_PRIME_IS_DIVISIBLE_C @@ -134,10 +132,10 @@ # define BN_MP_TORADIX_C # define BN_MP_TORADIX_N_C # define BN_MP_UNSIGNED_BIN_SIZE_C -# define BN_MP_XOR_C # define BN_MP_ZERO_C # define BN_PRIME_TAB_C # define BN_S_MP_ADD_C +# define BN_S_MP_AND_C # define BN_S_MP_BALANCE_MUL_C # define BN_S_MP_EXPTMOD_C # define BN_S_MP_EXPTMOD_FAST_C @@ -150,12 +148,14 @@ # define BN_S_MP_MUL_DIGS_FAST_C # define BN_S_MP_MUL_HIGH_DIGS_C # define BN_S_MP_MUL_HIGH_DIGS_FAST_C +# define BN_S_MP_OR_C # define BN_S_MP_REVERSE_C # define BN_S_MP_SQR_C # define BN_S_MP_SQR_FAST_C # define BN_S_MP_SUB_C # define BN_S_MP_TOOM_MUL_C # define BN_S_MP_TOOM_SQR_C +# define BN_S_MP_XOR_C #endif #if defined(BN_CUTOFFS_C) #endif @@ -216,13 +216,6 @@ # define BN_MP_MOD_C #endif -#if defined(BN_MP_AND_C) -# define BN_MP_INIT_COPY_C -# define BN_MP_CLAMP_C -# define BN_MP_EXCH_C -# define BN_MP_CLEAR_C -#endif - #if defined(BN_MP_CLAMP_C) #endif @@ -628,13 +621,6 @@ # define BN_MP_COPY_C #endif -#if defined(BN_MP_OR_C) -# define BN_MP_INIT_COPY_C -# define BN_MP_CLAMP_C -# define BN_MP_EXCH_C -# define BN_MP_CLEAR_C -#endif - #if defined(BN_MP_PRIME_FERMAT_C) # define BN_MP_CMP_D_C # define BN_MP_INIT_C @@ -952,7 +938,7 @@ # define BN_MP_INIT_C # define BN_MP_ADD_C # define BN_MP_CLEAR_C -# define BN_MP_AND_C +# define BN_S_MP_AND_C # define BN_MP_SUB_C #endif @@ -969,7 +955,7 @@ # define BN_MP_INIT_C # define BN_MP_ADD_C # define BN_MP_CLEAR_C -# define BN_MP_OR_C +# define BN_S_MP_OR_C # define BN_MP_SUB_C #endif @@ -980,7 +966,7 @@ # define BN_MP_INIT_C # define BN_MP_ADD_C # define BN_MP_CLEAR_C -# define BN_MP_XOR_C +# define BN_S_MP_XOR_C # define BN_MP_SUB_C #endif @@ -1023,13 +1009,6 @@ # define BN_MP_COUNT_BITS_C #endif -#if defined(BN_MP_XOR_C) -# define BN_MP_INIT_COPY_C -# define BN_MP_CLAMP_C -# define BN_MP_EXCH_C -# define BN_MP_CLEAR_C -#endif - #if defined(BN_MP_ZERO_C) #endif @@ -1041,6 +1020,14 @@ # define BN_MP_CLAMP_C #endif +#if defined(BN_S_MP_AND_C) +# define BN_MP_INIT_COPY_C +# define BN_MP_CLAMP_C +# define BN_MP_EXCH_C +# define BN_MP_CLEAR_C +# define BN_MP_AND_C +#endif + #if defined(BN_S_MP_BALANCE_MUL_C) # define BN_MP_INIT_SIZE_C # define BN_MP_INIT_MULTI_C @@ -1168,6 +1155,14 @@ # define BN_MP_CLAMP_C #endif +#if defined(BN_S_MP_OR_C) +# define BN_MP_INIT_COPY_C +# define BN_MP_CLAMP_C +# define BN_MP_EXCH_C +# define BN_MP_CLEAR_C +# define BN_MP_OR_C +#endif + #if defined(BN_S_MP_REVERSE_C) #endif @@ -1222,6 +1217,14 @@ # define BN_MP_CLEAR_MULTI_C #endif +#if defined(BN_S_MP_XOR_C) +# define BN_MP_INIT_COPY_C +# define BN_MP_CLAMP_C +# define BN_MP_EXCH_C +# define BN_MP_CLEAR_C +# define BN_MP_XOR_C +#endif + #ifdef LTM3 # define LTM_LAST #endif diff --git a/tommath_private.h b/tommath_private.h index c4004543c..82e5cf12a 100644 --- a/tommath_private.h +++ b/tommath_private.h @@ -86,6 +86,9 @@ int s_mp_montgomery_reduce_fast(mp_int *x, const mp_int *n, mp_digit rho); int s_mp_exptmod_fast(const mp_int *G, const mp_int *X, const mp_int *P, mp_int *Y, int redmode); int s_mp_exptmod(const mp_int *G, const mp_int *X, const mp_int *P, mp_int *Y, int redmode); void s_mp_reverse(unsigned char *s, int len); +int s_mp_xor(const mp_int *a, const mp_int *b, mp_int *c); +int s_mp_or(const mp_int *a, const mp_int *b, mp_int *c); +int s_mp_and(const mp_int *a, const mp_int *b, mp_int *c); extern const char *const mp_s_rmap; extern const uint8_t mp_s_rmap_reverse[];