From 92265d56a363a605b8a68d54cf49aa9a11448a1f Mon Sep 17 00:00:00 2001 From: "jan.nijtmans" Date: Tue, 29 Aug 2017 19:52:35 +0000 Subject: libtommath 1.0.1 rc 2 --- libtommath/bn_error.c | 6 ++-- libtommath/bn_fast_mp_invmod.c | 6 ++-- libtommath/bn_fast_mp_montgomery_reduce.c | 6 ++-- libtommath/bn_fast_s_mp_mul_digs.c | 6 ++-- libtommath/bn_fast_s_mp_mul_high_digs.c | 6 ++-- libtommath/bn_fast_s_mp_sqr.c | 6 ++-- libtommath/bn_mp_2expt.c | 6 ++-- libtommath/bn_mp_abs.c | 6 ++-- libtommath/bn_mp_add.c | 6 ++-- libtommath/bn_mp_add_d.c | 12 +++---- libtommath/bn_mp_addmod.c | 6 ++-- libtommath/bn_mp_and.c | 6 ++-- libtommath/bn_mp_clamp.c | 6 ++-- libtommath/bn_mp_clear.c | 6 ++-- libtommath/bn_mp_clear_multi.c | 6 ++-- libtommath/bn_mp_cmp.c | 6 ++-- libtommath/bn_mp_cmp_d.c | 6 ++-- libtommath/bn_mp_cmp_mag.c | 6 ++-- libtommath/bn_mp_cnt_lsb.c | 6 ++-- libtommath/bn_mp_copy.c | 6 ++-- libtommath/bn_mp_count_bits.c | 6 ++-- libtommath/bn_mp_div.c | 6 ++-- libtommath/bn_mp_div_2.c | 6 ++-- libtommath/bn_mp_div_2d.c | 25 ++++--------- libtommath/bn_mp_div_3.c | 6 ++-- libtommath/bn_mp_div_d.c | 6 ++-- libtommath/bn_mp_dr_is_modulus.c | 6 ++-- libtommath/bn_mp_dr_reduce.c | 6 ++-- libtommath/bn_mp_dr_setup.c | 6 ++-- libtommath/bn_mp_exch.c | 6 ++-- libtommath/bn_mp_export.c | 16 ++++----- libtommath/bn_mp_expt_d.c | 6 ++-- libtommath/bn_mp_expt_d_ex.c | 6 ++-- libtommath/bn_mp_exptmod.c | 6 ++-- libtommath/bn_mp_exptmod_fast.c | 20 +++++------ libtommath/bn_mp_exteuclid.c | 45 ++++++++++++------------ libtommath/bn_mp_fread.c | 8 +++-- libtommath/bn_mp_fwrite.c | 8 +++-- libtommath/bn_mp_gcd.c | 6 ++-- libtommath/bn_mp_get_int.c | 6 ++-- libtommath/bn_mp_grow.c | 6 ++-- libtommath/bn_mp_import.c | 16 ++++----- libtommath/bn_mp_init.c | 6 ++-- libtommath/bn_mp_init_copy.c | 13 ++++--- libtommath/bn_mp_init_multi.c | 9 ++--- libtommath/bn_mp_init_set.c | 6 ++-- libtommath/bn_mp_init_set_int.c | 6 ++-- libtommath/bn_mp_init_size.c | 6 ++-- libtommath/bn_mp_invmod.c | 8 ++--- libtommath/bn_mp_invmod_slow.c | 6 ++-- libtommath/bn_mp_is_square.c | 6 ++-- libtommath/bn_mp_jacobi.c | 6 ++-- libtommath/bn_mp_karatsuba_mul.c | 6 ++-- libtommath/bn_mp_karatsuba_sqr.c | 6 ++-- libtommath/bn_mp_lcm.c | 6 ++-- libtommath/bn_mp_lshd.c | 6 ++-- libtommath/bn_mp_mod.c | 8 ++--- libtommath/bn_mp_mod_2d.c | 6 ++-- libtommath/bn_mp_mod_d.c | 6 ++-- libtommath/bn_mp_montgomery_calc_normalization.c | 6 ++-- libtommath/bn_mp_montgomery_reduce.c | 6 ++-- libtommath/bn_mp_montgomery_setup.c | 6 ++-- libtommath/bn_mp_mul.c | 6 ++-- libtommath/bn_mp_mul_2.c | 6 ++-- libtommath/bn_mp_mul_2d.c | 6 ++-- libtommath/bn_mp_mul_d.c | 6 ++-- libtommath/bn_mp_mulmod.c | 8 ++--- libtommath/bn_mp_n_root.c | 6 ++-- libtommath/bn_mp_n_root_ex.c | 6 ++-- libtommath/bn_mp_neg.c | 6 ++-- libtommath/bn_mp_or.c | 6 ++-- libtommath/bn_mp_prime_fermat.c | 6 ++-- libtommath/bn_mp_prime_is_divisible.c | 6 ++-- libtommath/bn_mp_prime_is_prime.c | 6 ++-- libtommath/bn_mp_prime_miller_rabin.c | 6 ++-- libtommath/bn_mp_prime_next_prime.c | 6 ++-- libtommath/bn_mp_prime_rabin_miller_trials.c | 6 ++-- libtommath/bn_mp_prime_random_ex.c | 6 ++-- libtommath/bn_mp_radix_size.c | 6 ++-- libtommath/bn_mp_radix_smap.c | 6 ++-- libtommath/bn_mp_rand.c | 35 +++++++++++++++--- libtommath/bn_mp_read_radix.c | 6 ++-- libtommath/bn_mp_read_signed_bin.c | 6 ++-- libtommath/bn_mp_read_unsigned_bin.c | 6 ++-- libtommath/bn_mp_reduce.c | 6 ++-- libtommath/bn_mp_reduce_2k.c | 6 ++-- libtommath/bn_mp_reduce_2k_l.c | 6 ++-- libtommath/bn_mp_reduce_2k_setup.c | 6 ++-- libtommath/bn_mp_reduce_2k_setup_l.c | 6 ++-- libtommath/bn_mp_reduce_is_2k.c | 6 ++-- libtommath/bn_mp_reduce_is_2k_l.c | 6 ++-- libtommath/bn_mp_reduce_setup.c | 6 ++-- libtommath/bn_mp_rshd.c | 6 ++-- libtommath/bn_mp_set.c | 6 ++-- libtommath/bn_mp_set_int.c | 6 ++-- libtommath/bn_mp_set_long.c | 6 ++-- libtommath/bn_mp_set_long_long.c | 6 ++-- libtommath/bn_mp_shrink.c | 6 ++-- libtommath/bn_mp_signed_bin_size.c | 6 ++-- libtommath/bn_mp_sqr.c | 6 ++-- libtommath/bn_mp_sqrmod.c | 6 ++-- libtommath/bn_mp_sqrt.c | 6 ++-- libtommath/bn_mp_sub.c | 6 ++-- libtommath/bn_mp_sub_d.c | 6 ++-- libtommath/bn_mp_submod.c | 6 ++-- libtommath/bn_mp_to_signed_bin.c | 6 ++-- libtommath/bn_mp_to_signed_bin_n.c | 6 ++-- libtommath/bn_mp_to_unsigned_bin.c | 6 ++-- libtommath/bn_mp_to_unsigned_bin_n.c | 6 ++-- libtommath/bn_mp_toom_mul.c | 6 ++-- libtommath/bn_mp_toom_sqr.c | 6 ++-- libtommath/bn_mp_toradix.c | 6 ++-- libtommath/bn_mp_toradix_n.c | 6 ++-- libtommath/bn_mp_unsigned_bin_size.c | 6 ++-- libtommath/bn_mp_xor.c | 6 ++-- libtommath/bn_mp_zero.c | 6 ++-- libtommath/bn_prime_tab.c | 6 ++-- libtommath/bn_reverse.c | 6 ++-- libtommath/bn_s_mp_add.c | 6 ++-- libtommath/bn_s_mp_exptmod.c | 6 ++-- libtommath/bn_s_mp_mul_digs.c | 6 ++-- libtommath/bn_s_mp_mul_high_digs.c | 6 ++-- libtommath/bn_s_mp_sqr.c | 6 ++-- libtommath/bn_s_mp_sub.c | 6 ++-- libtommath/bncore.c | 6 ++-- libtommath/tommath.h | 35 ++++++++---------- libtommath/tommath_class.h | 12 +++---- libtommath/tommath_private.h | 14 +++++--- libtommath/tommath_superclass.h | 6 ++-- 129 files changed, 492 insertions(+), 472 deletions(-) diff --git a/libtommath/bn_error.c b/libtommath/bn_error.c index 3abf1a7..397f834 100644 --- a/libtommath/bn_error.c +++ b/libtommath/bn_error.c @@ -42,6 +42,6 @@ const char *mp_error_to_string(int code) #endif -/* $Source$ */ -/* $Revision$ */ -/* $Date$ */ +/* ref: HEAD -> release/1.0.1, tag: v1.0.1-rc2 */ +/* git commit: e8c27ba7df0efb90708029115c94d681dfa7812f */ +/* commit time: 2017-08-29 10:48:46 +0200 */ diff --git a/libtommath/bn_fast_mp_invmod.c b/libtommath/bn_fast_mp_invmod.c index aa41098..fa31853 100644 --- a/libtommath/bn_fast_mp_invmod.c +++ b/libtommath/bn_fast_mp_invmod.c @@ -143,6 +143,6 @@ LBL_ERR:mp_clear_multi (&x, &y, &u, &v, &B, &D, NULL); } #endif -/* $Source$ */ -/* $Revision$ */ -/* $Date$ */ +/* ref: HEAD -> release/1.0.1, tag: v1.0.1-rc2 */ +/* git commit: e8c27ba7df0efb90708029115c94d681dfa7812f */ +/* commit time: 2017-08-29 10:48:46 +0200 */ diff --git a/libtommath/bn_fast_mp_montgomery_reduce.c b/libtommath/bn_fast_mp_montgomery_reduce.c index a63839d..d13452d 100644 --- a/libtommath/bn_fast_mp_montgomery_reduce.c +++ b/libtommath/bn_fast_mp_montgomery_reduce.c @@ -167,6 +167,6 @@ int fast_mp_montgomery_reduce (mp_int * x, mp_int * n, mp_digit rho) } #endif -/* $Source$ */ -/* $Revision$ */ -/* $Date$ */ +/* ref: HEAD -> release/1.0.1, tag: v1.0.1-rc2 */ +/* git commit: e8c27ba7df0efb90708029115c94d681dfa7812f */ +/* commit time: 2017-08-29 10:48:46 +0200 */ diff --git a/libtommath/bn_fast_s_mp_mul_digs.c b/libtommath/bn_fast_s_mp_mul_digs.c index acd13b4..18bea3f 100644 --- a/libtommath/bn_fast_s_mp_mul_digs.c +++ b/libtommath/bn_fast_s_mp_mul_digs.c @@ -102,6 +102,6 @@ int fast_s_mp_mul_digs (mp_int * a, mp_int * b, mp_int * c, int digs) } #endif -/* $Source$ */ -/* $Revision$ */ -/* $Date$ */ +/* ref: HEAD -> release/1.0.1, tag: v1.0.1-rc2 */ +/* git commit: e8c27ba7df0efb90708029115c94d681dfa7812f */ +/* commit time: 2017-08-29 10:48:46 +0200 */ diff --git a/libtommath/bn_fast_s_mp_mul_high_digs.c b/libtommath/bn_fast_s_mp_mul_high_digs.c index b96cf60..8fd5117 100644 --- a/libtommath/bn_fast_s_mp_mul_high_digs.c +++ b/libtommath/bn_fast_s_mp_mul_high_digs.c @@ -93,6 +93,6 @@ int fast_s_mp_mul_high_digs (mp_int * a, mp_int * b, mp_int * c, int digs) } #endif -/* $Source$ */ -/* $Revision$ */ -/* $Date$ */ +/* ref: HEAD -> release/1.0.1, tag: v1.0.1-rc2 */ +/* git commit: e8c27ba7df0efb90708029115c94d681dfa7812f */ +/* commit time: 2017-08-29 10:48:46 +0200 */ diff --git a/libtommath/bn_fast_s_mp_sqr.c b/libtommath/bn_fast_s_mp_sqr.c index 775c76f..293c54a 100644 --- a/libtommath/bn_fast_s_mp_sqr.c +++ b/libtommath/bn_fast_s_mp_sqr.c @@ -109,6 +109,6 @@ int fast_s_mp_sqr (mp_int * a, mp_int * b) } #endif -/* $Source$ */ -/* $Revision$ */ -/* $Date$ */ +/* ref: HEAD -> release/1.0.1, tag: v1.0.1-rc2 */ +/* git commit: e8c27ba7df0efb90708029115c94d681dfa7812f */ +/* commit time: 2017-08-29 10:48:46 +0200 */ diff --git a/libtommath/bn_mp_2expt.c b/libtommath/bn_mp_2expt.c index 2845814..eb5e664 100644 --- a/libtommath/bn_mp_2expt.c +++ b/libtommath/bn_mp_2expt.c @@ -43,6 +43,6 @@ mp_2expt (mp_int * a, int b) } #endif -/* $Source$ */ -/* $Revision$ */ -/* $Date$ */ +/* ref: HEAD -> release/1.0.1, tag: v1.0.1-rc2 */ +/* git commit: e8c27ba7df0efb90708029115c94d681dfa7812f */ +/* commit time: 2017-08-29 10:48:46 +0200 */ diff --git a/libtommath/bn_mp_abs.c b/libtommath/bn_mp_abs.c index cc9c3db..16662c0 100644 --- a/libtommath/bn_mp_abs.c +++ b/libtommath/bn_mp_abs.c @@ -38,6 +38,6 @@ mp_abs (mp_int * a, mp_int * b) } #endif -/* $Source$ */ -/* $Revision$ */ -/* $Date$ */ +/* ref: HEAD -> release/1.0.1, tag: v1.0.1-rc2 */ +/* git commit: e8c27ba7df0efb90708029115c94d681dfa7812f */ +/* commit time: 2017-08-29 10:48:46 +0200 */ diff --git a/libtommath/bn_mp_add.c b/libtommath/bn_mp_add.c index 236fc75..0d91d24 100644 --- a/libtommath/bn_mp_add.c +++ b/libtommath/bn_mp_add.c @@ -48,6 +48,6 @@ int mp_add (mp_int * a, mp_int * b, mp_int * c) #endif -/* $Source$ */ -/* $Revision$ */ -/* $Date$ */ +/* ref: HEAD -> release/1.0.1, tag: v1.0.1-rc2 */ +/* git commit: e8c27ba7df0efb90708029115c94d681dfa7812f */ +/* commit time: 2017-08-29 10:48:46 +0200 */ diff --git a/libtommath/bn_mp_add_d.c b/libtommath/bn_mp_add_d.c index 4d4e1df..6b9dbef 100644 --- a/libtommath/bn_mp_add_d.c +++ b/libtommath/bn_mp_add_d.c @@ -49,9 +49,6 @@ mp_add_d (mp_int * a, mp_digit b, mp_int * c) /* old number of used digits in c */ oldused = c->used; - /* sign always positive */ - c->sign = MP_ZPOS; - /* source alias */ tmpa = a->dp; @@ -96,6 +93,9 @@ mp_add_d (mp_int * a, mp_digit b, mp_int * c) ix = 1; } + /* sign always positive */ + c->sign = MP_ZPOS; + /* now zero to oldused */ while (ix++ < oldused) { *tmpc++ = 0; @@ -107,6 +107,6 @@ mp_add_d (mp_int * a, mp_digit b, mp_int * c) #endif -/* $Source$ */ -/* $Revision$ */ -/* $Date$ */ +/* ref: HEAD -> release/1.0.1, tag: v1.0.1-rc2 */ +/* git commit: e8c27ba7df0efb90708029115c94d681dfa7812f */ +/* commit time: 2017-08-29 10:48:46 +0200 */ diff --git a/libtommath/bn_mp_addmod.c b/libtommath/bn_mp_addmod.c index 825c928..800e10a 100644 --- a/libtommath/bn_mp_addmod.c +++ b/libtommath/bn_mp_addmod.c @@ -36,6 +36,6 @@ mp_addmod (mp_int * a, mp_int * b, mp_int * c, mp_int * d) } #endif -/* $Source$ */ -/* $Revision$ */ -/* $Date$ */ +/* ref: HEAD -> release/1.0.1, tag: v1.0.1-rc2 */ +/* git commit: e8c27ba7df0efb90708029115c94d681dfa7812f */ +/* commit time: 2017-08-29 10:48:46 +0200 */ diff --git a/libtommath/bn_mp_and.c b/libtommath/bn_mp_and.c index 3b6b03e..6a18639 100644 --- a/libtommath/bn_mp_and.c +++ b/libtommath/bn_mp_and.c @@ -52,6 +52,6 @@ mp_and (mp_int * a, mp_int * b, mp_int * c) } #endif -/* $Source$ */ -/* $Revision$ */ -/* $Date$ */ +/* ref: HEAD -> release/1.0.1, tag: v1.0.1-rc2 */ +/* git commit: e8c27ba7df0efb90708029115c94d681dfa7812f */ +/* commit time: 2017-08-29 10:48:46 +0200 */ diff --git a/libtommath/bn_mp_clamp.c b/libtommath/bn_mp_clamp.c index d4fb70d..b392c10 100644 --- a/libtommath/bn_mp_clamp.c +++ b/libtommath/bn_mp_clamp.c @@ -39,6 +39,6 @@ mp_clamp (mp_int * a) } #endif -/* $Source$ */ -/* $Revision$ */ -/* $Date$ */ +/* ref: HEAD -> release/1.0.1, tag: v1.0.1-rc2 */ +/* git commit: e8c27ba7df0efb90708029115c94d681dfa7812f */ +/* commit time: 2017-08-29 10:48:46 +0200 */ diff --git a/libtommath/bn_mp_clear.c b/libtommath/bn_mp_clear.c index 17ef9d5..bf0873a 100644 --- a/libtommath/bn_mp_clear.c +++ b/libtommath/bn_mp_clear.c @@ -39,6 +39,6 @@ mp_clear (mp_int * a) } #endif -/* $Source$ */ -/* $Revision$ */ -/* $Date$ */ +/* ref: HEAD -> release/1.0.1, tag: v1.0.1-rc2 */ +/* git commit: e8c27ba7df0efb90708029115c94d681dfa7812f */ +/* commit time: 2017-08-29 10:48:46 +0200 */ diff --git a/libtommath/bn_mp_clear_multi.c b/libtommath/bn_mp_clear_multi.c index 441a200..e659cf8 100644 --- a/libtommath/bn_mp_clear_multi.c +++ b/libtommath/bn_mp_clear_multi.c @@ -29,6 +29,6 @@ void mp_clear_multi(mp_int *mp, ...) } #endif -/* $Source$ */ -/* $Revision$ */ -/* $Date$ */ +/* ref: HEAD -> release/1.0.1, tag: v1.0.1-rc2 */ +/* git commit: e8c27ba7df0efb90708029115c94d681dfa7812f */ +/* commit time: 2017-08-29 10:48:46 +0200 */ diff --git a/libtommath/bn_mp_cmp.c b/libtommath/bn_mp_cmp.c index 74a98fe..6266a7e 100644 --- a/libtommath/bn_mp_cmp.c +++ b/libtommath/bn_mp_cmp.c @@ -38,6 +38,6 @@ mp_cmp (mp_int * a, mp_int * b) } #endif -/* $Source$ */ -/* $Revision$ */ -/* $Date$ */ +/* ref: HEAD -> release/1.0.1, tag: v1.0.1-rc2 */ +/* git commit: e8c27ba7df0efb90708029115c94d681dfa7812f */ +/* commit time: 2017-08-29 10:48:46 +0200 */ diff --git a/libtommath/bn_mp_cmp_d.c b/libtommath/bn_mp_cmp_d.c index 28a53ce..a1cdaa1 100644 --- a/libtommath/bn_mp_cmp_d.c +++ b/libtommath/bn_mp_cmp_d.c @@ -39,6 +39,6 @@ int mp_cmp_d(mp_int * a, mp_digit b) } #endif -/* $Source$ */ -/* $Revision$ */ -/* $Date$ */ +/* ref: HEAD -> release/1.0.1, tag: v1.0.1-rc2 */ +/* git commit: e8c27ba7df0efb90708029115c94d681dfa7812f */ +/* commit time: 2017-08-29 10:48:46 +0200 */ diff --git a/libtommath/bn_mp_cmp_mag.c b/libtommath/bn_mp_cmp_mag.c index f72830f..b3839f0 100644 --- a/libtommath/bn_mp_cmp_mag.c +++ b/libtommath/bn_mp_cmp_mag.c @@ -50,6 +50,6 @@ int mp_cmp_mag (mp_int * a, mp_int * b) } #endif -/* $Source$ */ -/* $Revision$ */ -/* $Date$ */ +/* ref: HEAD -> release/1.0.1, tag: v1.0.1-rc2 */ +/* git commit: e8c27ba7df0efb90708029115c94d681dfa7812f */ +/* commit time: 2017-08-29 10:48:46 +0200 */ diff --git a/libtommath/bn_mp_cnt_lsb.c b/libtommath/bn_mp_cnt_lsb.c index 9d7eef8..42d2219 100644 --- a/libtommath/bn_mp_cnt_lsb.c +++ b/libtommath/bn_mp_cnt_lsb.c @@ -48,6 +48,6 @@ int mp_cnt_lsb(mp_int *a) #endif -/* $Source$ */ -/* $Revision$ */ -/* $Date$ */ +/* ref: HEAD -> release/1.0.1, tag: v1.0.1-rc2 */ +/* git commit: e8c27ba7df0efb90708029115c94d681dfa7812f */ +/* commit time: 2017-08-29 10:48:46 +0200 */ diff --git a/libtommath/bn_mp_copy.c b/libtommath/bn_mp_copy.c index 69e9464..6f2ee59 100644 --- a/libtommath/bn_mp_copy.c +++ b/libtommath/bn_mp_copy.c @@ -63,6 +63,6 @@ mp_copy (mp_int * a, mp_int * b) } #endif -/* $Source$ */ -/* $Revision$ */ -/* $Date$ */ +/* ref: HEAD -> release/1.0.1, tag: v1.0.1-rc2 */ +/* git commit: e8c27ba7df0efb90708029115c94d681dfa7812f */ +/* commit time: 2017-08-29 10:48:46 +0200 */ diff --git a/libtommath/bn_mp_count_bits.c b/libtommath/bn_mp_count_bits.c index 74b59b6..e2db126 100644 --- a/libtommath/bn_mp_count_bits.c +++ b/libtommath/bn_mp_count_bits.c @@ -40,6 +40,6 @@ mp_count_bits (mp_int * a) } #endif -/* $Source$ */ -/* $Revision$ */ -/* $Date$ */ +/* ref: HEAD -> release/1.0.1, tag: v1.0.1-rc2 */ +/* git commit: e8c27ba7df0efb90708029115c94d681dfa7812f */ +/* commit time: 2017-08-29 10:48:46 +0200 */ diff --git a/libtommath/bn_mp_div.c b/libtommath/bn_mp_div.c index 3ca5d7f..81d30eb 100644 --- a/libtommath/bn_mp_div.c +++ b/libtommath/bn_mp_div.c @@ -290,6 +290,6 @@ LBL_Q:mp_clear (&q); #endif -/* $Source$ */ -/* $Revision$ */ -/* $Date$ */ +/* ref: HEAD -> release/1.0.1, tag: v1.0.1-rc2 */ +/* git commit: e8c27ba7df0efb90708029115c94d681dfa7812f */ +/* commit time: 2017-08-29 10:48:46 +0200 */ diff --git a/libtommath/bn_mp_div_2.c b/libtommath/bn_mp_div_2.c index d2a213f..2004da7 100644 --- a/libtommath/bn_mp_div_2.c +++ b/libtommath/bn_mp_div_2.c @@ -63,6 +63,6 @@ int mp_div_2(mp_int * a, mp_int * b) } #endif -/* $Source$ */ -/* $Revision$ */ -/* $Date$ */ +/* ref: HEAD -> release/1.0.1, tag: v1.0.1-rc2 */ +/* git commit: e8c27ba7df0efb90708029115c94d681dfa7812f */ +/* commit time: 2017-08-29 10:48:46 +0200 */ diff --git a/libtommath/bn_mp_div_2d.c b/libtommath/bn_mp_div_2d.c index 5b9fb48..a5b8494 100644 --- a/libtommath/bn_mp_div_2d.c +++ b/libtommath/bn_mp_div_2d.c @@ -20,8 +20,6 @@ int mp_div_2d (mp_int * a, int b, mp_int * c, mp_int * d) { mp_digit D, r, rr; int x, res; - mp_int t; - /* if the shift count is <= 0 then we do no work */ if (b <= 0) { @@ -32,24 +30,19 @@ int mp_div_2d (mp_int * a, int b, mp_int * c, mp_int * d) return res; } - if ((res = mp_init (&t)) != MP_OKAY) { + /* copy */ + if ((res = mp_copy (a, c)) != MP_OKAY) { return res; } + /* 'a' should not be used after here - it might be the same as d */ /* get the remainder */ if (d != NULL) { - if ((res = mp_mod_2d (a, b, &t)) != MP_OKAY) { - mp_clear (&t); + if ((res = mp_mod_2d (a, b, d)) != MP_OKAY) { return res; } } - /* copy */ - if ((res = mp_copy (a, c)) != MP_OKAY) { - mp_clear (&t); - return res; - } - /* shift by as many digits in the bit count */ if (b >= (int)DIGIT_BIT) { mp_rshd (c, b / DIGIT_BIT); @@ -84,14 +77,10 @@ int mp_div_2d (mp_int * a, int b, mp_int * c, mp_int * d) } } mp_clamp (c); - if (d != NULL) { - mp_exch (&t, d); - } - mp_clear (&t); return MP_OKAY; } #endif -/* $Source$ */ -/* $Revision$ */ -/* $Date$ */ +/* ref: HEAD -> release/1.0.1, tag: v1.0.1-rc2 */ +/* git commit: e8c27ba7df0efb90708029115c94d681dfa7812f */ +/* commit time: 2017-08-29 10:48:46 +0200 */ diff --git a/libtommath/bn_mp_div_3.c b/libtommath/bn_mp_div_3.c index c2b76fb..6c79332 100644 --- a/libtommath/bn_mp_div_3.c +++ b/libtommath/bn_mp_div_3.c @@ -74,6 +74,6 @@ mp_div_3 (mp_int * a, mp_int *c, mp_digit * d) #endif -/* $Source$ */ -/* $Revision$ */ -/* $Date$ */ +/* ref: HEAD -> release/1.0.1, tag: v1.0.1-rc2 */ +/* git commit: e8c27ba7df0efb90708029115c94d681dfa7812f */ +/* commit time: 2017-08-29 10:48:46 +0200 */ diff --git a/libtommath/bn_mp_div_d.c b/libtommath/bn_mp_div_d.c index 4df1d36..aab298a 100644 --- a/libtommath/bn_mp_div_d.c +++ b/libtommath/bn_mp_div_d.c @@ -110,6 +110,6 @@ int mp_div_d (mp_int * a, mp_digit b, mp_int * c, mp_digit * d) #endif -/* $Source$ */ -/* $Revision$ */ -/* $Date$ */ +/* ref: HEAD -> release/1.0.1, tag: v1.0.1-rc2 */ +/* git commit: e8c27ba7df0efb90708029115c94d681dfa7812f */ +/* commit time: 2017-08-29 10:48:46 +0200 */ diff --git a/libtommath/bn_mp_dr_is_modulus.c b/libtommath/bn_mp_dr_is_modulus.c index 599d929..d4dbec6 100644 --- a/libtommath/bn_mp_dr_is_modulus.c +++ b/libtommath/bn_mp_dr_is_modulus.c @@ -38,6 +38,6 @@ int mp_dr_is_modulus(mp_int *a) #endif -/* $Source$ */ -/* $Revision$ */ -/* $Date$ */ +/* ref: HEAD -> release/1.0.1, tag: v1.0.1-rc2 */ +/* git commit: e8c27ba7df0efb90708029115c94d681dfa7812f */ +/* commit time: 2017-08-29 10:48:46 +0200 */ diff --git a/libtommath/bn_mp_dr_reduce.c b/libtommath/bn_mp_dr_reduce.c index 2273c79..2005f3c 100644 --- a/libtommath/bn_mp_dr_reduce.c +++ b/libtommath/bn_mp_dr_reduce.c @@ -91,6 +91,6 @@ top: } #endif -/* $Source$ */ -/* $Revision$ */ -/* $Date$ */ +/* ref: HEAD -> release/1.0.1, tag: v1.0.1-rc2 */ +/* git commit: e8c27ba7df0efb90708029115c94d681dfa7812f */ +/* commit time: 2017-08-29 10:48:46 +0200 */ diff --git a/libtommath/bn_mp_dr_setup.c b/libtommath/bn_mp_dr_setup.c index 1bccb2b..7f60c67 100644 --- a/libtommath/bn_mp_dr_setup.c +++ b/libtommath/bn_mp_dr_setup.c @@ -27,6 +27,6 @@ void mp_dr_setup(mp_int *a, mp_digit *d) #endif -/* $Source$ */ -/* $Revision$ */ -/* $Date$ */ +/* ref: HEAD -> release/1.0.1, tag: v1.0.1-rc2 */ +/* git commit: e8c27ba7df0efb90708029115c94d681dfa7812f */ +/* commit time: 2017-08-29 10:48:46 +0200 */ diff --git a/libtommath/bn_mp_exch.c b/libtommath/bn_mp_exch.c index 634193b..8dd5180 100644 --- a/libtommath/bn_mp_exch.c +++ b/libtommath/bn_mp_exch.c @@ -29,6 +29,6 @@ mp_exch (mp_int * a, mp_int * b) } #endif -/* $Source$ */ -/* $Revision$ */ -/* $Date$ */ +/* ref: HEAD -> release/1.0.1, tag: v1.0.1-rc2 */ +/* git commit: e8c27ba7df0efb90708029115c94d681dfa7812f */ +/* commit time: 2017-08-29 10:48:46 +0200 */ diff --git a/libtommath/bn_mp_export.c b/libtommath/bn_mp_export.c index ac4c2f9..6477dd9 100644 --- a/libtommath/bn_mp_export.c +++ b/libtommath/bn_mp_export.c @@ -31,12 +31,12 @@ int mp_export(void* rop, size_t* countp, int order, size_t size, } if (endian == 0) { - union { - unsigned int i; - char c[4]; + union { + unsigned int i; + char c[4]; } lint; - lint.i = 0x01020304; - + lint.i = 0x01020304; + endian = (lint.c[0] == 4) ? -1 : 1; } @@ -83,6 +83,6 @@ int mp_export(void* rop, size_t* countp, int order, size_t size, #endif -/* $Source$ */ -/* $Revision$ */ -/* $Date$ */ +/* ref: HEAD -> release/1.0.1, tag: v1.0.1-rc2 */ +/* git commit: e8c27ba7df0efb90708029115c94d681dfa7812f */ +/* commit time: 2017-08-29 10:48:46 +0200 */ diff --git a/libtommath/bn_mp_expt_d.c b/libtommath/bn_mp_expt_d.c index 61c5a1d..0a4b90b 100644 --- a/libtommath/bn_mp_expt_d.c +++ b/libtommath/bn_mp_expt_d.c @@ -23,6 +23,6 @@ int mp_expt_d (mp_int * a, mp_digit b, mp_int * c) #endif -/* $Source$ */ -/* $Revision$ */ -/* $Date$ */ +/* ref: HEAD -> release/1.0.1, tag: v1.0.1-rc2 */ +/* git commit: e8c27ba7df0efb90708029115c94d681dfa7812f */ +/* commit time: 2017-08-29 10:48:46 +0200 */ diff --git a/libtommath/bn_mp_expt_d_ex.c b/libtommath/bn_mp_expt_d_ex.c index 649d224..3bef24a 100644 --- a/libtommath/bn_mp_expt_d_ex.c +++ b/libtommath/bn_mp_expt_d_ex.c @@ -78,6 +78,6 @@ int mp_expt_d_ex (mp_int * a, mp_digit b, mp_int * c, int fast) } #endif -/* $Source$ */ -/* $Revision$ */ -/* $Date$ */ +/* ref: HEAD -> release/1.0.1, tag: v1.0.1-rc2 */ +/* git commit: e8c27ba7df0efb90708029115c94d681dfa7812f */ +/* commit time: 2017-08-29 10:48:46 +0200 */ diff --git a/libtommath/bn_mp_exptmod.c b/libtommath/bn_mp_exptmod.c index 0973e44..697ef52 100644 --- a/libtommath/bn_mp_exptmod.c +++ b/libtommath/bn_mp_exptmod.c @@ -107,6 +107,6 @@ int mp_exptmod (mp_int * G, mp_int * X, mp_int * P, mp_int * Y) #endif -/* $Source$ */ -/* $Revision$ */ -/* $Date$ */ +/* ref: HEAD -> release/1.0.1, tag: v1.0.1-rc2 */ +/* git commit: e8c27ba7df0efb90708029115c94d681dfa7812f */ +/* commit time: 2017-08-29 10:48:46 +0200 */ diff --git a/libtommath/bn_mp_exptmod_fast.c b/libtommath/bn_mp_exptmod_fast.c index 8d280bd..312305e 100644 --- a/libtommath/bn_mp_exptmod_fast.c +++ b/libtommath/bn_mp_exptmod_fast.c @@ -67,13 +67,13 @@ int mp_exptmod_fast (mp_int * G, mp_int * X, mp_int * P, mp_int * Y, int redmode /* init M array */ /* init first cell */ - if ((err = mp_init(&M[1])) != MP_OKAY) { + if ((err = mp_init_size(&M[1], P->alloc)) != MP_OKAY) { return err; } /* now init the second half of the array */ for (x = 1<<(winsize-1); x < (1 << winsize); x++) { - if ((err = mp_init(&M[x])) != MP_OKAY) { + if ((err = mp_init_size(&M[x], P->alloc)) != MP_OKAY) { for (y = 1<<(winsize-1); y < x; y++) { mp_clear (&M[y]); } @@ -133,7 +133,7 @@ int mp_exptmod_fast (mp_int * G, mp_int * X, mp_int * P, mp_int * Y, int redmode } /* setup result */ - if ((err = mp_init (&res)) != MP_OKAY) { + if ((err = mp_init_size (&res, P->alloc)) != MP_OKAY) { goto LBL_M; } @@ -150,15 +150,15 @@ int mp_exptmod_fast (mp_int * G, mp_int * X, mp_int * P, mp_int * Y, int redmode if ((err = mp_montgomery_calc_normalization (&res, P)) != MP_OKAY) { goto LBL_RES; } -#else - err = MP_VAL; - goto LBL_RES; -#endif /* now set M[1] to G * R mod m */ if ((err = mp_mulmod (G, &res, P, &M[1])) != MP_OKAY) { goto LBL_RES; } +#else + err = MP_VAL; + goto LBL_RES; +#endif } else { mp_set(&res, 1); if ((err = mp_mod(G, P, &M[1])) != MP_OKAY) { @@ -316,6 +316,6 @@ LBL_M: #endif -/* $Source$ */ -/* $Revision$ */ -/* $Date$ */ +/* ref: HEAD -> release/1.0.1, tag: v1.0.1-rc2 */ +/* git commit: e8c27ba7df0efb90708029115c94d681dfa7812f */ +/* commit time: 2017-08-29 10:48:46 +0200 */ diff --git a/libtommath/bn_mp_exteuclid.c b/libtommath/bn_mp_exteuclid.c index fbbd92c..f941385 100644 --- a/libtommath/bn_mp_exteuclid.c +++ b/libtommath/bn_mp_exteuclid.c @@ -29,41 +29,41 @@ int mp_exteuclid(mp_int *a, mp_int *b, mp_int *U1, mp_int *U2, mp_int *U3) /* initialize, (u1,u2,u3) = (1,0,a) */ mp_set(&u1, 1); - if ((err = mp_copy(a, &u3)) != MP_OKAY) { goto _ERR; } + if ((err = mp_copy(a, &u3)) != MP_OKAY) { goto LBL_ERR; } /* initialize, (v1,v2,v3) = (0,1,b) */ mp_set(&v2, 1); - if ((err = mp_copy(b, &v3)) != MP_OKAY) { goto _ERR; } + if ((err = mp_copy(b, &v3)) != MP_OKAY) { goto LBL_ERR; } /* loop while v3 != 0 */ while (mp_iszero(&v3) == MP_NO) { /* q = u3/v3 */ - if ((err = mp_div(&u3, &v3, &q, NULL)) != MP_OKAY) { goto _ERR; } + if ((err = mp_div(&u3, &v3, &q, NULL)) != MP_OKAY) { goto LBL_ERR; } /* (t1,t2,t3) = (u1,u2,u3) - (v1,v2,v3)q */ - if ((err = mp_mul(&v1, &q, &tmp)) != MP_OKAY) { goto _ERR; } - if ((err = mp_sub(&u1, &tmp, &t1)) != MP_OKAY) { goto _ERR; } - if ((err = mp_mul(&v2, &q, &tmp)) != MP_OKAY) { goto _ERR; } - if ((err = mp_sub(&u2, &tmp, &t2)) != MP_OKAY) { goto _ERR; } - if ((err = mp_mul(&v3, &q, &tmp)) != MP_OKAY) { goto _ERR; } - if ((err = mp_sub(&u3, &tmp, &t3)) != MP_OKAY) { goto _ERR; } + if ((err = mp_mul(&v1, &q, &tmp)) != MP_OKAY) { goto LBL_ERR; } + if ((err = mp_sub(&u1, &tmp, &t1)) != MP_OKAY) { goto LBL_ERR; } + if ((err = mp_mul(&v2, &q, &tmp)) != MP_OKAY) { goto LBL_ERR; } + if ((err = mp_sub(&u2, &tmp, &t2)) != MP_OKAY) { goto LBL_ERR; } + if ((err = mp_mul(&v3, &q, &tmp)) != MP_OKAY) { goto LBL_ERR; } + if ((err = mp_sub(&u3, &tmp, &t3)) != MP_OKAY) { goto LBL_ERR; } /* (u1,u2,u3) = (v1,v2,v3) */ - if ((err = mp_copy(&v1, &u1)) != MP_OKAY) { goto _ERR; } - if ((err = mp_copy(&v2, &u2)) != MP_OKAY) { goto _ERR; } - if ((err = mp_copy(&v3, &u3)) != MP_OKAY) { goto _ERR; } + if ((err = mp_copy(&v1, &u1)) != MP_OKAY) { goto LBL_ERR; } + if ((err = mp_copy(&v2, &u2)) != MP_OKAY) { goto LBL_ERR; } + if ((err = mp_copy(&v3, &u3)) != MP_OKAY) { goto LBL_ERR; } /* (v1,v2,v3) = (t1,t2,t3) */ - if ((err = mp_copy(&t1, &v1)) != MP_OKAY) { goto _ERR; } - if ((err = mp_copy(&t2, &v2)) != MP_OKAY) { goto _ERR; } - if ((err = mp_copy(&t3, &v3)) != MP_OKAY) { goto _ERR; } + if ((err = mp_copy(&t1, &v1)) != MP_OKAY) { goto LBL_ERR; } + if ((err = mp_copy(&t2, &v2)) != MP_OKAY) { goto LBL_ERR; } + if ((err = mp_copy(&t3, &v3)) != MP_OKAY) { goto LBL_ERR; } } /* make sure U3 >= 0 */ if (u3.sign == MP_NEG) { - if ((err = mp_neg(&u1, &u1)) != MP_OKAY) { goto _ERR; } - if ((err = mp_neg(&u2, &u2)) != MP_OKAY) { goto _ERR; } - if ((err = mp_neg(&u3, &u3)) != MP_OKAY) { goto _ERR; } + if ((err = mp_neg(&u1, &u1)) != MP_OKAY) { goto LBL_ERR; } + if ((err = mp_neg(&u2, &u2)) != MP_OKAY) { goto LBL_ERR; } + if ((err = mp_neg(&u3, &u3)) != MP_OKAY) { goto LBL_ERR; } } /* copy result out */ @@ -72,11 +72,12 @@ int mp_exteuclid(mp_int *a, mp_int *b, mp_int *U1, mp_int *U2, mp_int *U3) if (U3 != NULL) { mp_exch(U3, &u3); } err = MP_OKAY; -_ERR: mp_clear_multi(&u1, &u2, &u3, &v1, &v2, &v3, &t1, &t2, &t3, &q, &tmp, NULL); +LBL_ERR: + mp_clear_multi(&u1, &u2, &u3, &v1, &v2, &v3, &t1, &t2, &t3, &q, &tmp, NULL); return err; } #endif -/* $Source$ */ -/* $Revision$ */ -/* $Date$ */ +/* ref: HEAD -> release/1.0.1, tag: v1.0.1-rc2 */ +/* git commit: e8c27ba7df0efb90708029115c94d681dfa7812f */ +/* commit time: 2017-08-29 10:48:46 +0200 */ diff --git a/libtommath/bn_mp_fread.c b/libtommath/bn_mp_fread.c index a4fa8c9..6792437 100644 --- a/libtommath/bn_mp_fread.c +++ b/libtommath/bn_mp_fread.c @@ -15,6 +15,7 @@ * Tom St Denis, tstdenis82@gmail.com, http://libtom.org */ +#ifndef LTM_NO_FILE /* read a bigint from a file stream in ASCII */ int mp_fread(mp_int *a, int radix, FILE *stream) { @@ -59,9 +60,10 @@ int mp_fread(mp_int *a, int radix, FILE *stream) return MP_OKAY; } +#endif #endif -/* $Source$ */ -/* $Revision$ */ -/* $Date$ */ +/* ref: HEAD -> release/1.0.1, tag: v1.0.1-rc2 */ +/* git commit: e8c27ba7df0efb90708029115c94d681dfa7812f */ +/* commit time: 2017-08-29 10:48:46 +0200 */ diff --git a/libtommath/bn_mp_fwrite.c b/libtommath/bn_mp_fwrite.c index 90f1fc5..44812d5 100644 --- a/libtommath/bn_mp_fwrite.c +++ b/libtommath/bn_mp_fwrite.c @@ -15,6 +15,7 @@ * Tom St Denis, tstdenis82@gmail.com, http://libtom.org */ +#ifndef LTM_NO_FILE int mp_fwrite(mp_int *a, int radix, FILE *stream) { char *buf; @@ -44,9 +45,10 @@ int mp_fwrite(mp_int *a, int radix, FILE *stream) XFREE (buf); return MP_OKAY; } +#endif #endif -/* $Source$ */ -/* $Revision$ */ -/* $Date$ */ +/* ref: HEAD -> release/1.0.1, tag: v1.0.1-rc2 */ +/* git commit: e8c27ba7df0efb90708029115c94d681dfa7812f */ +/* commit time: 2017-08-29 10:48:46 +0200 */ diff --git a/libtommath/bn_mp_gcd.c b/libtommath/bn_mp_gcd.c index 16acfd9..fdefc1b 100644 --- a/libtommath/bn_mp_gcd.c +++ b/libtommath/bn_mp_gcd.c @@ -100,6 +100,6 @@ LBL_U:mp_clear (&v); } #endif -/* $Source$ */ -/* $Revision$ */ -/* $Date$ */ +/* ref: HEAD -> release/1.0.1, tag: v1.0.1-rc2 */ +/* git commit: e8c27ba7df0efb90708029115c94d681dfa7812f */ +/* commit time: 2017-08-29 10:48:46 +0200 */ diff --git a/libtommath/bn_mp_get_int.c b/libtommath/bn_mp_get_int.c index 99fb850..4d8ecd2 100644 --- a/libtommath/bn_mp_get_int.c +++ b/libtommath/bn_mp_get_int.c @@ -40,6 +40,6 @@ unsigned long mp_get_int(mp_int * a) } #endif -/* $Source$ */ -/* $Revision$ */ -/* $Date$ */ +/* ref: HEAD -> release/1.0.1, tag: v1.0.1-rc2 */ +/* git commit: e8c27ba7df0efb90708029115c94d681dfa7812f */ +/* commit time: 2017-08-29 10:48:46 +0200 */ diff --git a/libtommath/bn_mp_grow.c b/libtommath/bn_mp_grow.c index cbdcfed..7fbc5a2 100644 --- a/libtommath/bn_mp_grow.c +++ b/libtommath/bn_mp_grow.c @@ -52,6 +52,6 @@ int mp_grow (mp_int * a, int size) } #endif -/* $Source$ */ -/* $Revision$ */ -/* $Date$ */ +/* ref: HEAD -> release/1.0.1, tag: v1.0.1-rc2 */ +/* git commit: e8c27ba7df0efb90708029115c94d681dfa7812f */ +/* commit time: 2017-08-29 10:48:46 +0200 */ diff --git a/libtommath/bn_mp_import.c b/libtommath/bn_mp_import.c index dd4b8e6..c615a84 100644 --- a/libtommath/bn_mp_import.c +++ b/libtommath/bn_mp_import.c @@ -27,12 +27,12 @@ int mp_import(mp_int* rop, size_t count, int order, size_t size, mp_zero(rop); if (endian == 0) { - union { - unsigned int i; - char c[4]; + union { + unsigned int i; + char c[4]; } lint; - lint.i = 0x01020304; - + lint.i = 0x01020304; + endian = (lint.c[0] == 4) ? -1 : 1; } @@ -68,6 +68,6 @@ int mp_import(mp_int* rop, size_t count, int order, size_t size, #endif -/* $Source$ */ -/* $Revision$ */ -/* $Date$ */ +/* ref: HEAD -> release/1.0.1, tag: v1.0.1-rc2 */ +/* git commit: e8c27ba7df0efb90708029115c94d681dfa7812f */ +/* commit time: 2017-08-29 10:48:46 +0200 */ diff --git a/libtommath/bn_mp_init.c b/libtommath/bn_mp_init.c index 7a57730..8a26f09 100644 --- a/libtommath/bn_mp_init.c +++ b/libtommath/bn_mp_init.c @@ -41,6 +41,6 @@ int mp_init (mp_int * a) } #endif -/* $Source$ */ -/* $Revision$ */ -/* $Date$ */ +/* ref: HEAD -> release/1.0.1, tag: v1.0.1-rc2 */ +/* git commit: e8c27ba7df0efb90708029115c94d681dfa7812f */ +/* commit time: 2017-08-29 10:48:46 +0200 */ diff --git a/libtommath/bn_mp_init_copy.c b/libtommath/bn_mp_init_copy.c index 9e15f36..ab0e130 100644 --- a/libtommath/bn_mp_init_copy.c +++ b/libtommath/bn_mp_init_copy.c @@ -23,10 +23,15 @@ int mp_init_copy (mp_int * a, mp_int * b) if ((res = mp_init_size (a, b->used)) != MP_OKAY) { return res; } - return mp_copy (b, a); + + if((res = mp_copy (b, a)) != MP_OKAY) { + mp_clear(a); + } + + return res; } #endif -/* $Source$ */ -/* $Revision$ */ -/* $Date$ */ +/* ref: HEAD -> release/1.0.1, tag: v1.0.1-rc2 */ +/* git commit: e8c27ba7df0efb90708029115c94d681dfa7812f */ +/* commit time: 2017-08-29 10:48:46 +0200 */ diff --git a/libtommath/bn_mp_init_multi.c b/libtommath/bn_mp_init_multi.c index 52220a3..78ed62d 100644 --- a/libtommath/bn_mp_init_multi.c +++ b/libtommath/bn_mp_init_multi.c @@ -31,9 +31,6 @@ int mp_init_multi(mp_int *mp, ...) */ va_list clean_args; - /* end the current list */ - va_end(args); - /* now start cleaning up */ cur_arg = mp; va_start(clean_args, mp); @@ -54,6 +51,6 @@ int mp_init_multi(mp_int *mp, ...) #endif -/* $Source$ */ -/* $Revision$ */ -/* $Date$ */ +/* ref: HEAD -> release/1.0.1, tag: v1.0.1-rc2 */ +/* git commit: e8c27ba7df0efb90708029115c94d681dfa7812f */ +/* commit time: 2017-08-29 10:48:46 +0200 */ diff --git a/libtommath/bn_mp_init_set.c b/libtommath/bn_mp_init_set.c index c337e50..0b5cf36 100644 --- a/libtommath/bn_mp_init_set.c +++ b/libtommath/bn_mp_init_set.c @@ -27,6 +27,6 @@ int mp_init_set (mp_int * a, mp_digit b) } #endif -/* $Source$ */ -/* $Revision$ */ -/* $Date$ */ +/* ref: HEAD -> release/1.0.1, tag: v1.0.1-rc2 */ +/* git commit: e8c27ba7df0efb90708029115c94d681dfa7812f */ +/* commit time: 2017-08-29 10:48:46 +0200 */ diff --git a/libtommath/bn_mp_init_set_int.c b/libtommath/bn_mp_init_set_int.c index c88f14e..a9bf232 100644 --- a/libtommath/bn_mp_init_set_int.c +++ b/libtommath/bn_mp_init_set_int.c @@ -26,6 +26,6 @@ int mp_init_set_int (mp_int * a, unsigned long b) } #endif -/* $Source$ */ -/* $Revision$ */ -/* $Date$ */ +/* ref: HEAD -> release/1.0.1, tag: v1.0.1-rc2 */ +/* git commit: e8c27ba7df0efb90708029115c94d681dfa7812f */ +/* commit time: 2017-08-29 10:48:46 +0200 */ diff --git a/libtommath/bn_mp_init_size.c b/libtommath/bn_mp_init_size.c index e1d1b51..44b875f 100644 --- a/libtommath/bn_mp_init_size.c +++ b/libtommath/bn_mp_init_size.c @@ -43,6 +43,6 @@ int mp_init_size (mp_int * a, int size) } #endif -/* $Source$ */ -/* $Revision$ */ -/* $Date$ */ +/* ref: HEAD -> release/1.0.1, tag: v1.0.1-rc2 */ +/* git commit: e8c27ba7df0efb90708029115c94d681dfa7812f */ +/* commit time: 2017-08-29 10:48:46 +0200 */ diff --git a/libtommath/bn_mp_invmod.c b/libtommath/bn_mp_invmod.c index 44951e5..c374fd2 100644 --- a/libtommath/bn_mp_invmod.c +++ b/libtommath/bn_mp_invmod.c @@ -25,7 +25,7 @@ int mp_invmod (mp_int * a, mp_int * b, mp_int * c) #ifdef BN_FAST_MP_INVMOD_C /* if the modulus is odd we can use a faster routine instead */ - if (mp_isodd (b) == MP_YES) { + if ((mp_isodd(b) == MP_YES) && (mp_cmp_d(b, 1) != MP_EQ)) { return fast_mp_invmod (a, b, c); } #endif @@ -38,6 +38,6 @@ int mp_invmod (mp_int * a, mp_int * b, mp_int * c) } #endif -/* $Source$ */ -/* $Revision$ */ -/* $Date$ */ +/* ref: HEAD -> release/1.0.1, tag: v1.0.1-rc2 */ +/* git commit: e8c27ba7df0efb90708029115c94d681dfa7812f */ +/* commit time: 2017-08-29 10:48:46 +0200 */ diff --git a/libtommath/bn_mp_invmod_slow.c b/libtommath/bn_mp_invmod_slow.c index a21f947..879e971 100644 --- a/libtommath/bn_mp_invmod_slow.c +++ b/libtommath/bn_mp_invmod_slow.c @@ -170,6 +170,6 @@ LBL_ERR:mp_clear_multi (&x, &y, &u, &v, &A, &B, &C, &D, NULL); } #endif -/* $Source$ */ -/* $Revision$ */ -/* $Date$ */ +/* ref: HEAD -> release/1.0.1, tag: v1.0.1-rc2 */ +/* git commit: e8c27ba7df0efb90708029115c94d681dfa7812f */ +/* commit time: 2017-08-29 10:48:46 +0200 */ diff --git a/libtommath/bn_mp_is_square.c b/libtommath/bn_mp_is_square.c index 9f065ef..15e632e 100644 --- a/libtommath/bn_mp_is_square.c +++ b/libtommath/bn_mp_is_square.c @@ -104,6 +104,6 @@ ERR:mp_clear(&t); } #endif -/* $Source$ */ -/* $Revision$ */ -/* $Date$ */ +/* ref: HEAD -> release/1.0.1, tag: v1.0.1-rc2 */ +/* git commit: e8c27ba7df0efb90708029115c94d681dfa7812f */ +/* commit time: 2017-08-29 10:48:46 +0200 */ diff --git a/libtommath/bn_mp_jacobi.c b/libtommath/bn_mp_jacobi.c index 3c114e3..4e6c474 100644 --- a/libtommath/bn_mp_jacobi.c +++ b/libtommath/bn_mp_jacobi.c @@ -112,6 +112,6 @@ LBL_A1:mp_clear (&a1); } #endif -/* $Source$ */ -/* $Revision$ */ -/* $Date$ */ +/* ref: HEAD -> release/1.0.1, tag: v1.0.1-rc2 */ +/* git commit: e8c27ba7df0efb90708029115c94d681dfa7812f */ +/* commit time: 2017-08-29 10:48:46 +0200 */ diff --git a/libtommath/bn_mp_karatsuba_mul.c b/libtommath/bn_mp_karatsuba_mul.c index d65e37e..307a0d9 100644 --- a/libtommath/bn_mp_karatsuba_mul.c +++ b/libtommath/bn_mp_karatsuba_mul.c @@ -162,6 +162,6 @@ ERR: } #endif -/* $Source$ */ -/* $Revision$ */ -/* $Date$ */ +/* ref: HEAD -> release/1.0.1, tag: v1.0.1-rc2 */ +/* git commit: e8c27ba7df0efb90708029115c94d681dfa7812f */ +/* commit time: 2017-08-29 10:48:46 +0200 */ diff --git a/libtommath/bn_mp_karatsuba_sqr.c b/libtommath/bn_mp_karatsuba_sqr.c index 739840d..3993cd9 100644 --- a/libtommath/bn_mp_karatsuba_sqr.c +++ b/libtommath/bn_mp_karatsuba_sqr.c @@ -116,6 +116,6 @@ ERR: } #endif -/* $Source$ */ -/* $Revision$ */ -/* $Date$ */ +/* ref: HEAD -> release/1.0.1, tag: v1.0.1-rc2 */ +/* git commit: e8c27ba7df0efb90708029115c94d681dfa7812f */ +/* commit time: 2017-08-29 10:48:46 +0200 */ diff --git a/libtommath/bn_mp_lcm.c b/libtommath/bn_mp_lcm.c index 3bff571..b6a0ec1 100644 --- a/libtommath/bn_mp_lcm.c +++ b/libtommath/bn_mp_lcm.c @@ -55,6 +55,6 @@ LBL_T: } #endif -/* $Source$ */ -/* $Revision$ */ -/* $Date$ */ +/* ref: HEAD -> release/1.0.1, tag: v1.0.1-rc2 */ +/* git commit: e8c27ba7df0efb90708029115c94d681dfa7812f */ +/* commit time: 2017-08-29 10:48:46 +0200 */ diff --git a/libtommath/bn_mp_lshd.c b/libtommath/bn_mp_lshd.c index f6f800f..b6cb111 100644 --- a/libtommath/bn_mp_lshd.c +++ b/libtommath/bn_mp_lshd.c @@ -62,6 +62,6 @@ int mp_lshd (mp_int * a, int b) } #endif -/* $Source$ */ -/* $Revision$ */ -/* $Date$ */ +/* ref: HEAD -> release/1.0.1, tag: v1.0.1-rc2 */ +/* git commit: e8c27ba7df0efb90708029115c94d681dfa7812f */ +/* commit time: 2017-08-29 10:48:46 +0200 */ diff --git a/libtommath/bn_mp_mod.c b/libtommath/bn_mp_mod.c index b67467d..0c9bc3e 100644 --- a/libtommath/bn_mp_mod.c +++ b/libtommath/bn_mp_mod.c @@ -22,7 +22,7 @@ mp_mod (mp_int * a, mp_int * b, mp_int * c) mp_int t; int res; - if ((res = mp_init (&t)) != MP_OKAY) { + if ((res = mp_init_size (&t, b->used)) != MP_OKAY) { return res; } @@ -43,6 +43,6 @@ mp_mod (mp_int * a, mp_int * b, mp_int * c) } #endif -/* $Source$ */ -/* $Revision$ */ -/* $Date$ */ +/* ref: HEAD -> release/1.0.1, tag: v1.0.1-rc2 */ +/* git commit: e8c27ba7df0efb90708029115c94d681dfa7812f */ +/* commit time: 2017-08-29 10:48:46 +0200 */ diff --git a/libtommath/bn_mp_mod_2d.c b/libtommath/bn_mp_mod_2d.c index 926f810..1f2c47c 100644 --- a/libtommath/bn_mp_mod_2d.c +++ b/libtommath/bn_mp_mod_2d.c @@ -50,6 +50,6 @@ mp_mod_2d (mp_int * a, int b, mp_int * c) } #endif -/* $Source$ */ -/* $Revision$ */ -/* $Date$ */ +/* ref: HEAD -> release/1.0.1, tag: v1.0.1-rc2 */ +/* git commit: e8c27ba7df0efb90708029115c94d681dfa7812f */ +/* commit time: 2017-08-29 10:48:46 +0200 */ diff --git a/libtommath/bn_mp_mod_d.c b/libtommath/bn_mp_mod_d.c index d8722f0..4553cba 100644 --- a/libtommath/bn_mp_mod_d.c +++ b/libtommath/bn_mp_mod_d.c @@ -22,6 +22,6 @@ mp_mod_d (mp_int * a, mp_digit b, mp_digit * c) } #endif -/* $Source$ */ -/* $Revision$ */ -/* $Date$ */ +/* ref: HEAD -> release/1.0.1, tag: v1.0.1-rc2 */ +/* git commit: e8c27ba7df0efb90708029115c94d681dfa7812f */ +/* commit time: 2017-08-29 10:48:46 +0200 */ diff --git a/libtommath/bn_mp_montgomery_calc_normalization.c b/libtommath/bn_mp_montgomery_calc_normalization.c index ea87cbd..2b11749 100644 --- a/libtommath/bn_mp_montgomery_calc_normalization.c +++ b/libtommath/bn_mp_montgomery_calc_normalization.c @@ -54,6 +54,6 @@ int mp_montgomery_calc_normalization (mp_int * a, mp_int * b) } #endif -/* $Source$ */ -/* $Revision$ */ -/* $Date$ */ +/* ref: HEAD -> release/1.0.1, tag: v1.0.1-rc2 */ +/* git commit: e8c27ba7df0efb90708029115c94d681dfa7812f */ +/* commit time: 2017-08-29 10:48:46 +0200 */ diff --git a/libtommath/bn_mp_montgomery_reduce.c b/libtommath/bn_mp_montgomery_reduce.c index af2cc58..d3746a6 100644 --- a/libtommath/bn_mp_montgomery_reduce.c +++ b/libtommath/bn_mp_montgomery_reduce.c @@ -113,6 +113,6 @@ mp_montgomery_reduce (mp_int * x, mp_int * n, mp_digit rho) } #endif -/* $Source$ */ -/* $Revision$ */ -/* $Date$ */ +/* ref: HEAD -> release/1.0.1, tag: v1.0.1-rc2 */ +/* git commit: e8c27ba7df0efb90708029115c94d681dfa7812f */ +/* commit time: 2017-08-29 10:48:46 +0200 */ diff --git a/libtommath/bn_mp_montgomery_setup.c b/libtommath/bn_mp_montgomery_setup.c index 264a2bd..c71d362 100644 --- a/libtommath/bn_mp_montgomery_setup.c +++ b/libtommath/bn_mp_montgomery_setup.c @@ -54,6 +54,6 @@ mp_montgomery_setup (mp_int * n, mp_digit * rho) } #endif -/* $Source$ */ -/* $Revision$ */ -/* $Date$ */ +/* ref: HEAD -> release/1.0.1, tag: v1.0.1-rc2 */ +/* git commit: e8c27ba7df0efb90708029115c94d681dfa7812f */ +/* commit time: 2017-08-29 10:48:46 +0200 */ diff --git a/libtommath/bn_mp_mul.c b/libtommath/bn_mp_mul.c index ea53d5e..d81f68b 100644 --- a/libtommath/bn_mp_mul.c +++ b/libtommath/bn_mp_mul.c @@ -62,6 +62,6 @@ int mp_mul (mp_int * a, mp_int * b, mp_int * c) } #endif -/* $Source$ */ -/* $Revision$ */ -/* $Date$ */ +/* ref: HEAD -> release/1.0.1, tag: v1.0.1-rc2 */ +/* git commit: e8c27ba7df0efb90708029115c94d681dfa7812f */ +/* commit time: 2017-08-29 10:48:46 +0200 */ diff --git a/libtommath/bn_mp_mul_2.c b/libtommath/bn_mp_mul_2.c index 9c72c7f..20fb9d6 100644 --- a/libtommath/bn_mp_mul_2.c +++ b/libtommath/bn_mp_mul_2.c @@ -77,6 +77,6 @@ int mp_mul_2(mp_int * a, mp_int * b) } #endif -/* $Source$ */ -/* $Revision$ */ -/* $Date$ */ +/* ref: HEAD -> release/1.0.1, tag: v1.0.1-rc2 */ +/* git commit: e8c27ba7df0efb90708029115c94d681dfa7812f */ +/* commit time: 2017-08-29 10:48:46 +0200 */ diff --git a/libtommath/bn_mp_mul_2d.c b/libtommath/bn_mp_mul_2d.c index 9967e46..b5d3cae 100644 --- a/libtommath/bn_mp_mul_2d.c +++ b/libtommath/bn_mp_mul_2d.c @@ -80,6 +80,6 @@ int mp_mul_2d (mp_int * a, int b, mp_int * c) } #endif -/* $Source$ */ -/* $Revision$ */ -/* $Date$ */ +/* ref: HEAD -> release/1.0.1, tag: v1.0.1-rc2 */ +/* git commit: e8c27ba7df0efb90708029115c94d681dfa7812f */ +/* commit time: 2017-08-29 10:48:46 +0200 */ diff --git a/libtommath/bn_mp_mul_d.c b/libtommath/bn_mp_mul_d.c index e77da5d..c0c24cd 100644 --- a/libtommath/bn_mp_mul_d.c +++ b/libtommath/bn_mp_mul_d.c @@ -74,6 +74,6 @@ mp_mul_d (mp_int * a, mp_digit b, mp_int * c) } #endif -/* $Source$ */ -/* $Revision$ */ -/* $Date$ */ +/* ref: HEAD -> release/1.0.1, tag: v1.0.1-rc2 */ +/* git commit: e8c27ba7df0efb90708029115c94d681dfa7812f */ +/* commit time: 2017-08-29 10:48:46 +0200 */ diff --git a/libtommath/bn_mp_mulmod.c b/libtommath/bn_mp_mulmod.c index 5ea88ef..375674f 100644 --- a/libtommath/bn_mp_mulmod.c +++ b/libtommath/bn_mp_mulmod.c @@ -21,7 +21,7 @@ int mp_mulmod (mp_int * a, mp_int * b, mp_int * c, mp_int * d) int res; mp_int t; - if ((res = mp_init (&t)) != MP_OKAY) { + if ((res = mp_init_size (&t, c->used)) != MP_OKAY) { return res; } @@ -35,6 +35,6 @@ int mp_mulmod (mp_int * a, mp_int * b, mp_int * c, mp_int * d) } #endif -/* $Source$ */ -/* $Revision$ */ -/* $Date$ */ +/* ref: HEAD -> release/1.0.1, tag: v1.0.1-rc2 */ +/* git commit: e8c27ba7df0efb90708029115c94d681dfa7812f */ +/* commit time: 2017-08-29 10:48:46 +0200 */ diff --git a/libtommath/bn_mp_n_root.c b/libtommath/bn_mp_n_root.c index a14ee67..b7a4817 100644 --- a/libtommath/bn_mp_n_root.c +++ b/libtommath/bn_mp_n_root.c @@ -25,6 +25,6 @@ int mp_n_root (mp_int * a, mp_digit b, mp_int * c) #endif -/* $Source$ */ -/* $Revision$ */ -/* $Date$ */ +/* ref: HEAD -> release/1.0.1, tag: v1.0.1-rc2 */ +/* git commit: e8c27ba7df0efb90708029115c94d681dfa7812f */ +/* commit time: 2017-08-29 10:48:46 +0200 */ diff --git a/libtommath/bn_mp_n_root_ex.c b/libtommath/bn_mp_n_root_ex.c index 79d1dfb..c163c1d 100644 --- a/libtommath/bn_mp_n_root_ex.c +++ b/libtommath/bn_mp_n_root_ex.c @@ -127,6 +127,6 @@ LBL_T1:mp_clear (&t1); } #endif -/* $Source$ */ -/* $Revision$ */ -/* $Date$ */ +/* ref: HEAD -> release/1.0.1, tag: v1.0.1-rc2 */ +/* git commit: e8c27ba7df0efb90708029115c94d681dfa7812f */ +/* commit time: 2017-08-29 10:48:46 +0200 */ diff --git a/libtommath/bn_mp_neg.c b/libtommath/bn_mp_neg.c index ea32e46..b8a014a 100644 --- a/libtommath/bn_mp_neg.c +++ b/libtommath/bn_mp_neg.c @@ -35,6 +35,6 @@ int mp_neg (mp_int * a, mp_int * b) } #endif -/* $Source$ */ -/* $Revision$ */ -/* $Date$ */ +/* ref: HEAD -> release/1.0.1, tag: v1.0.1-rc2 */ +/* git commit: e8c27ba7df0efb90708029115c94d681dfa7812f */ +/* commit time: 2017-08-29 10:48:46 +0200 */ diff --git a/libtommath/bn_mp_or.c b/libtommath/bn_mp_or.c index b7f2e4f..fc303d2 100644 --- a/libtommath/bn_mp_or.c +++ b/libtommath/bn_mp_or.c @@ -45,6 +45,6 @@ int mp_or (mp_int * a, mp_int * b, mp_int * c) } #endif -/* $Source$ */ -/* $Revision$ */ -/* $Date$ */ +/* ref: HEAD -> release/1.0.1, tag: v1.0.1-rc2 */ +/* git commit: e8c27ba7df0efb90708029115c94d681dfa7812f */ +/* commit time: 2017-08-29 10:48:46 +0200 */ diff --git a/libtommath/bn_mp_prime_fermat.c b/libtommath/bn_mp_prime_fermat.c index 9dc9e85..1b1300c 100644 --- a/libtommath/bn_mp_prime_fermat.c +++ b/libtommath/bn_mp_prime_fermat.c @@ -57,6 +57,6 @@ LBL_T:mp_clear (&t); } #endif -/* $Source$ */ -/* $Revision$ */ -/* $Date$ */ +/* ref: HEAD -> release/1.0.1, tag: v1.0.1-rc2 */ +/* git commit: e8c27ba7df0efb90708029115c94d681dfa7812f */ +/* commit time: 2017-08-29 10:48:46 +0200 */ diff --git a/libtommath/bn_mp_prime_is_divisible.c b/libtommath/bn_mp_prime_is_divisible.c index 5854f08..b97390e 100644 --- a/libtommath/bn_mp_prime_is_divisible.c +++ b/libtommath/bn_mp_prime_is_divisible.c @@ -45,6 +45,6 @@ int mp_prime_is_divisible (mp_int * a, int *result) } #endif -/* $Source$ */ -/* $Revision$ */ -/* $Date$ */ +/* ref: HEAD -> release/1.0.1, tag: v1.0.1-rc2 */ +/* git commit: e8c27ba7df0efb90708029115c94d681dfa7812f */ +/* commit time: 2017-08-29 10:48:46 +0200 */ diff --git a/libtommath/bn_mp_prime_is_prime.c b/libtommath/bn_mp_prime_is_prime.c index be5ebe4..4a36047 100644 --- a/libtommath/bn_mp_prime_is_prime.c +++ b/libtommath/bn_mp_prime_is_prime.c @@ -78,6 +78,6 @@ LBL_B:mp_clear (&b); } #endif -/* $Source$ */ -/* $Revision$ */ -/* $Date$ */ +/* ref: HEAD -> release/1.0.1, tag: v1.0.1-rc2 */ +/* git commit: e8c27ba7df0efb90708029115c94d681dfa7812f */ +/* commit time: 2017-08-29 10:48:46 +0200 */ diff --git a/libtommath/bn_mp_prime_miller_rabin.c b/libtommath/bn_mp_prime_miller_rabin.c index 7b5c8d2..569d78a 100644 --- a/libtommath/bn_mp_prime_miller_rabin.c +++ b/libtommath/bn_mp_prime_miller_rabin.c @@ -98,6 +98,6 @@ LBL_N1:mp_clear (&n1); } #endif -/* $Source$ */ -/* $Revision$ */ -/* $Date$ */ +/* ref: HEAD -> release/1.0.1, tag: v1.0.1-rc2 */ +/* git commit: e8c27ba7df0efb90708029115c94d681dfa7812f */ +/* commit time: 2017-08-29 10:48:46 +0200 */ diff --git a/libtommath/bn_mp_prime_next_prime.c b/libtommath/bn_mp_prime_next_prime.c index 9951dc3..c0b7895 100644 --- a/libtommath/bn_mp_prime_next_prime.c +++ b/libtommath/bn_mp_prime_next_prime.c @@ -165,6 +165,6 @@ LBL_ERR: #endif -/* $Source$ */ -/* $Revision$ */ -/* $Date$ */ +/* ref: HEAD -> release/1.0.1, tag: v1.0.1-rc2 */ +/* git commit: e8c27ba7df0efb90708029115c94d681dfa7812f */ +/* commit time: 2017-08-29 10:48:46 +0200 */ diff --git a/libtommath/bn_mp_prime_rabin_miller_trials.c b/libtommath/bn_mp_prime_rabin_miller_trials.c index bca4229..ad954cc 100644 --- a/libtommath/bn_mp_prime_rabin_miller_trials.c +++ b/libtommath/bn_mp_prime_rabin_miller_trials.c @@ -47,6 +47,6 @@ int mp_prime_rabin_miller_trials(int size) #endif -/* $Source$ */ -/* $Revision$ */ -/* $Date$ */ +/* ref: HEAD -> release/1.0.1, tag: v1.0.1-rc2 */ +/* git commit: e8c27ba7df0efb90708029115c94d681dfa7812f */ +/* commit time: 2017-08-29 10:48:46 +0200 */ diff --git a/libtommath/bn_mp_prime_random_ex.c b/libtommath/bn_mp_prime_random_ex.c index 1efc4fc..655e8ae 100644 --- a/libtommath/bn_mp_prime_random_ex.c +++ b/libtommath/bn_mp_prime_random_ex.c @@ -119,6 +119,6 @@ error: #endif -/* $Source$ */ -/* $Revision$ */ -/* $Date$ */ +/* ref: HEAD -> release/1.0.1, tag: v1.0.1-rc2 */ +/* git commit: e8c27ba7df0efb90708029115c94d681dfa7812f */ +/* commit time: 2017-08-29 10:48:46 +0200 */ diff --git a/libtommath/bn_mp_radix_size.c b/libtommath/bn_mp_radix_size.c index e5d7772..e9cb55a 100644 --- a/libtommath/bn_mp_radix_size.c +++ b/libtommath/bn_mp_radix_size.c @@ -73,6 +73,6 @@ int mp_radix_size (mp_int * a, int radix, int *size) #endif -/* $Source$ */ -/* $Revision$ */ -/* $Date$ */ +/* ref: HEAD -> release/1.0.1, tag: v1.0.1-rc2 */ +/* git commit: e8c27ba7df0efb90708029115c94d681dfa7812f */ +/* commit time: 2017-08-29 10:48:46 +0200 */ diff --git a/libtommath/bn_mp_radix_smap.c b/libtommath/bn_mp_radix_smap.c index d1c75ad..425e0e6 100644 --- a/libtommath/bn_mp_radix_smap.c +++ b/libtommath/bn_mp_radix_smap.c @@ -19,6 +19,6 @@ const char *mp_s_rmap = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz+/"; #endif -/* $Source$ */ -/* $Revision$ */ -/* $Date$ */ +/* ref: HEAD -> release/1.0.1, tag: v1.0.1-rc2 */ +/* git commit: e8c27ba7df0efb90708029115c94d681dfa7812f */ +/* commit time: 2017-08-29 10:48:46 +0200 */ diff --git a/libtommath/bn_mp_rand.c b/libtommath/bn_mp_rand.c index 4c9610d..7c8f106 100644 --- a/libtommath/bn_mp_rand.c +++ b/libtommath/bn_mp_rand.c @@ -15,7 +15,32 @@ * Tom St Denis, tstdenis82@gmail.com, http://libtom.org */ +#if MP_GEN_RANDOM_MAX == 0xffffffff + #define MP_GEN_RANDOM_SHIFT 32 +#elif MP_GEN_RANDOM_MAX == 32767 + /* SHRT_MAX */ + #define MP_GEN_RANDOM_SHIFT 15 +#elif MP_GEN_RANDOM_MAX == 2147483647 + /* INT_MAX */ + #define MP_GEN_RANDOM_SHIFT 31 +#elif !defined(MP_GEN_RANDOM_SHIFT) +#error Thou shalt define their own valid MP_GEN_RANDOM_SHIFT +#endif + /* makes a pseudo-random int of a given size */ +static mp_digit s_gen_random(void) +{ + mp_digit d = 0, msk = 0; + do { + d <<= MP_GEN_RANDOM_SHIFT; + d |= ((mp_digit) MP_GEN_RANDOM()); + msk <<= MP_GEN_RANDOM_SHIFT; + msk |= (MP_MASK & MP_GEN_RANDOM_MAX); + } while ((MP_MASK & msk) != MP_MASK); + d &= MP_MASK; + return d; +} + int mp_rand (mp_int * a, int digits) { @@ -29,7 +54,7 @@ mp_rand (mp_int * a, int digits) /* first place a random non-zero digit */ do { - d = ((mp_digit) abs (MP_GEN_RANDOM())) & MP_MASK; + d = s_gen_random(); } while (d == 0); if ((res = mp_add_d (a, d, a)) != MP_OKAY) { @@ -41,7 +66,7 @@ mp_rand (mp_int * a, int digits) return res; } - if ((res = mp_add_d (a, ((mp_digit) abs (MP_GEN_RANDOM())), a)) != MP_OKAY) { + if ((res = mp_add_d (a, s_gen_random(), a)) != MP_OKAY) { return res; } } @@ -50,6 +75,6 @@ mp_rand (mp_int * a, int digits) } #endif -/* $Source$ */ -/* $Revision$ */ -/* $Date$ */ +/* ref: HEAD -> release/1.0.1, tag: v1.0.1-rc2 */ +/* git commit: e8c27ba7df0efb90708029115c94d681dfa7812f */ +/* commit time: 2017-08-29 10:48:46 +0200 */ diff --git a/libtommath/bn_mp_read_radix.c b/libtommath/bn_mp_read_radix.c index 5c9eb5e..6f2cc04 100644 --- a/libtommath/bn_mp_read_radix.c +++ b/libtommath/bn_mp_read_radix.c @@ -80,6 +80,6 @@ int mp_read_radix (mp_int * a, const char *str, int radix) } #endif -/* $Source$ */ -/* $Revision$ */ -/* $Date$ */ +/* ref: HEAD -> release/1.0.1, tag: v1.0.1-rc2 */ +/* git commit: e8c27ba7df0efb90708029115c94d681dfa7812f */ +/* commit time: 2017-08-29 10:48:46 +0200 */ diff --git a/libtommath/bn_mp_read_signed_bin.c b/libtommath/bn_mp_read_signed_bin.c index a4d4760..1448d21 100644 --- a/libtommath/bn_mp_read_signed_bin.c +++ b/libtommath/bn_mp_read_signed_bin.c @@ -36,6 +36,6 @@ int mp_read_signed_bin (mp_int * a, const unsigned char *b, int c) } #endif -/* $Source$ */ -/* $Revision$ */ -/* $Date$ */ +/* ref: HEAD -> release/1.0.1, tag: v1.0.1-rc2 */ +/* git commit: e8c27ba7df0efb90708029115c94d681dfa7812f */ +/* commit time: 2017-08-29 10:48:46 +0200 */ diff --git a/libtommath/bn_mp_read_unsigned_bin.c b/libtommath/bn_mp_read_unsigned_bin.c index e8e5df8..b2e399d 100644 --- a/libtommath/bn_mp_read_unsigned_bin.c +++ b/libtommath/bn_mp_read_unsigned_bin.c @@ -50,6 +50,6 @@ int mp_read_unsigned_bin (mp_int * a, const unsigned char *b, int c) } #endif -/* $Source$ */ -/* $Revision$ */ -/* $Date$ */ +/* ref: HEAD -> release/1.0.1, tag: v1.0.1-rc2 */ +/* git commit: e8c27ba7df0efb90708029115c94d681dfa7812f */ +/* commit time: 2017-08-29 10:48:46 +0200 */ diff --git a/libtommath/bn_mp_reduce.c b/libtommath/bn_mp_reduce.c index e2c3a58..c15b54e 100644 --- a/libtommath/bn_mp_reduce.c +++ b/libtommath/bn_mp_reduce.c @@ -95,6 +95,6 @@ CLEANUP: } #endif -/* $Source$ */ -/* $Revision$ */ -/* $Date$ */ +/* ref: HEAD -> release/1.0.1, tag: v1.0.1-rc2 */ +/* git commit: e8c27ba7df0efb90708029115c94d681dfa7812f */ +/* commit time: 2017-08-29 10:48:46 +0200 */ diff --git a/libtommath/bn_mp_reduce_2k.c b/libtommath/bn_mp_reduce_2k.c index 2876a75..daea5e7 100644 --- a/libtommath/bn_mp_reduce_2k.c +++ b/libtommath/bn_mp_reduce_2k.c @@ -58,6 +58,6 @@ ERR: #endif -/* $Source$ */ -/* $Revision$ */ -/* $Date$ */ +/* ref: HEAD -> release/1.0.1, tag: v1.0.1-rc2 */ +/* git commit: e8c27ba7df0efb90708029115c94d681dfa7812f */ +/* commit time: 2017-08-29 10:48:46 +0200 */ diff --git a/libtommath/bn_mp_reduce_2k_l.c b/libtommath/bn_mp_reduce_2k_l.c index 3225214..d6c2aa4 100644 --- a/libtommath/bn_mp_reduce_2k_l.c +++ b/libtommath/bn_mp_reduce_2k_l.c @@ -59,6 +59,6 @@ ERR: #endif -/* $Source$ */ -/* $Revision$ */ -/* $Date$ */ +/* ref: HEAD -> release/1.0.1, tag: v1.0.1-rc2 */ +/* git commit: e8c27ba7df0efb90708029115c94d681dfa7812f */ +/* commit time: 2017-08-29 10:48:46 +0200 */ diff --git a/libtommath/bn_mp_reduce_2k_setup.c b/libtommath/bn_mp_reduce_2k_setup.c index 545051e..f4650b4 100644 --- a/libtommath/bn_mp_reduce_2k_setup.c +++ b/libtommath/bn_mp_reduce_2k_setup.c @@ -42,6 +42,6 @@ int mp_reduce_2k_setup(mp_int *a, mp_digit *d) } #endif -/* $Source$ */ -/* $Revision$ */ -/* $Date$ */ +/* ref: HEAD -> release/1.0.1, tag: v1.0.1-rc2 */ +/* git commit: e8c27ba7df0efb90708029115c94d681dfa7812f */ +/* commit time: 2017-08-29 10:48:46 +0200 */ diff --git a/libtommath/bn_mp_reduce_2k_setup_l.c b/libtommath/bn_mp_reduce_2k_setup_l.c index 59132dd..7945d6a 100644 --- a/libtommath/bn_mp_reduce_2k_setup_l.c +++ b/libtommath/bn_mp_reduce_2k_setup_l.c @@ -39,6 +39,6 @@ ERR: } #endif -/* $Source$ */ -/* $Revision$ */ -/* $Date$ */ +/* ref: HEAD -> release/1.0.1, tag: v1.0.1-rc2 */ +/* git commit: e8c27ba7df0efb90708029115c94d681dfa7812f */ +/* commit time: 2017-08-29 10:48:46 +0200 */ diff --git a/libtommath/bn_mp_reduce_is_2k.c b/libtommath/bn_mp_reduce_is_2k.c index 784947b..e68d704 100644 --- a/libtommath/bn_mp_reduce_is_2k.c +++ b/libtommath/bn_mp_reduce_is_2k.c @@ -47,6 +47,6 @@ int mp_reduce_is_2k(mp_int *a) #endif -/* $Source$ */ -/* $Revision$ */ -/* $Date$ */ +/* ref: HEAD -> release/1.0.1, tag: v1.0.1-rc2 */ +/* git commit: e8c27ba7df0efb90708029115c94d681dfa7812f */ +/* commit time: 2017-08-29 10:48:46 +0200 */ diff --git a/libtommath/bn_mp_reduce_is_2k_l.c b/libtommath/bn_mp_reduce_is_2k_l.c index c193f39..5426352 100644 --- a/libtommath/bn_mp_reduce_is_2k_l.c +++ b/libtommath/bn_mp_reduce_is_2k_l.c @@ -39,6 +39,6 @@ int mp_reduce_is_2k_l(mp_int *a) #endif -/* $Source$ */ -/* $Revision$ */ -/* $Date$ */ +/* ref: HEAD -> release/1.0.1, tag: v1.0.1-rc2 */ +/* git commit: e8c27ba7df0efb90708029115c94d681dfa7812f */ +/* commit time: 2017-08-29 10:48:46 +0200 */ diff --git a/libtommath/bn_mp_reduce_setup.c b/libtommath/bn_mp_reduce_setup.c index f97eed5..d3ed42f 100644 --- a/libtommath/bn_mp_reduce_setup.c +++ b/libtommath/bn_mp_reduce_setup.c @@ -29,6 +29,6 @@ int mp_reduce_setup (mp_int * a, mp_int * b) } #endif -/* $Source$ */ -/* $Revision$ */ -/* $Date$ */ +/* ref: HEAD -> release/1.0.1, tag: v1.0.1-rc2 */ +/* git commit: e8c27ba7df0efb90708029115c94d681dfa7812f */ +/* commit time: 2017-08-29 10:48:46 +0200 */ diff --git a/libtommath/bn_mp_rshd.c b/libtommath/bn_mp_rshd.c index 77b0f6c..6ea4f2f 100644 --- a/libtommath/bn_mp_rshd.c +++ b/libtommath/bn_mp_rshd.c @@ -67,6 +67,6 @@ void mp_rshd (mp_int * a, int b) } #endif -/* $Source$ */ -/* $Revision$ */ -/* $Date$ */ +/* ref: HEAD -> release/1.0.1, tag: v1.0.1-rc2 */ +/* git commit: e8c27ba7df0efb90708029115c94d681dfa7812f */ +/* commit time: 2017-08-29 10:48:46 +0200 */ diff --git a/libtommath/bn_mp_set.c b/libtommath/bn_mp_set.c index cac48ea..c10850d 100644 --- a/libtommath/bn_mp_set.c +++ b/libtommath/bn_mp_set.c @@ -24,6 +24,6 @@ void mp_set (mp_int * a, mp_digit b) } #endif -/* $Source$ */ -/* $Revision$ */ -/* $Date$ */ +/* ref: HEAD -> release/1.0.1, tag: v1.0.1-rc2 */ +/* git commit: e8c27ba7df0efb90708029115c94d681dfa7812f */ +/* commit time: 2017-08-29 10:48:46 +0200 */ diff --git a/libtommath/bn_mp_set_int.c b/libtommath/bn_mp_set_int.c index 5aa59d5..3e9ae87 100644 --- a/libtommath/bn_mp_set_int.c +++ b/libtommath/bn_mp_set_int.c @@ -43,6 +43,6 @@ int mp_set_int (mp_int * a, unsigned long b) } #endif -/* $Source$ */ -/* $Revision$ */ -/* $Date$ */ +/* ref: HEAD -> release/1.0.1, tag: v1.0.1-rc2 */ +/* git commit: e8c27ba7df0efb90708029115c94d681dfa7812f */ +/* commit time: 2017-08-29 10:48:46 +0200 */ diff --git a/libtommath/bn_mp_set_long.c b/libtommath/bn_mp_set_long.c index 281fce7..680781b 100644 --- a/libtommath/bn_mp_set_long.c +++ b/libtommath/bn_mp_set_long.c @@ -19,6 +19,6 @@ MP_SET_XLONG(mp_set_long, unsigned long) #endif -/* $Source$ */ -/* $Revision$ */ -/* $Date$ */ +/* ref: HEAD -> release/1.0.1, tag: v1.0.1-rc2 */ +/* git commit: e8c27ba7df0efb90708029115c94d681dfa7812f */ +/* commit time: 2017-08-29 10:48:46 +0200 */ diff --git a/libtommath/bn_mp_set_long_long.c b/libtommath/bn_mp_set_long_long.c index 3c4b01a..7fde01a 100644 --- a/libtommath/bn_mp_set_long_long.c +++ b/libtommath/bn_mp_set_long_long.c @@ -19,6 +19,6 @@ MP_SET_XLONG(mp_set_long_long, unsigned long long) #endif -/* $Source$ */ -/* $Revision$ */ -/* $Date$ */ +/* ref: HEAD -> release/1.0.1, tag: v1.0.1-rc2 */ +/* git commit: e8c27ba7df0efb90708029115c94d681dfa7812f */ +/* commit time: 2017-08-29 10:48:46 +0200 */ diff --git a/libtommath/bn_mp_shrink.c b/libtommath/bn_mp_shrink.c index 1ad2ede..ef71874 100644 --- a/libtommath/bn_mp_shrink.c +++ b/libtommath/bn_mp_shrink.c @@ -36,6 +36,6 @@ int mp_shrink (mp_int * a) } #endif -/* $Source$ */ -/* $Revision$ */ -/* $Date$ */ +/* ref: HEAD -> release/1.0.1, tag: v1.0.1-rc2 */ +/* git commit: e8c27ba7df0efb90708029115c94d681dfa7812f */ +/* commit time: 2017-08-29 10:48:46 +0200 */ diff --git a/libtommath/bn_mp_signed_bin_size.c b/libtommath/bn_mp_signed_bin_size.c index 0e760a6..261f036 100644 --- a/libtommath/bn_mp_signed_bin_size.c +++ b/libtommath/bn_mp_signed_bin_size.c @@ -22,6 +22,6 @@ int mp_signed_bin_size (mp_int * a) } #endif -/* $Source$ */ -/* $Revision$ */ -/* $Date$ */ +/* ref: HEAD -> release/1.0.1, tag: v1.0.1-rc2 */ +/* git commit: e8c27ba7df0efb90708029115c94d681dfa7812f */ +/* commit time: 2017-08-29 10:48:46 +0200 */ diff --git a/libtommath/bn_mp_sqr.c b/libtommath/bn_mp_sqr.c index ad2099b..e0c2e85 100644 --- a/libtommath/bn_mp_sqr.c +++ b/libtommath/bn_mp_sqr.c @@ -55,6 +55,6 @@ mp_sqr (mp_int * a, mp_int * b) } #endif -/* $Source$ */ -/* $Revision$ */ -/* $Date$ */ +/* ref: HEAD -> release/1.0.1, tag: v1.0.1-rc2 */ +/* git commit: e8c27ba7df0efb90708029115c94d681dfa7812f */ +/* commit time: 2017-08-29 10:48:46 +0200 */ diff --git a/libtommath/bn_mp_sqrmod.c b/libtommath/bn_mp_sqrmod.c index 2f9463d..25ca55e 100644 --- a/libtommath/bn_mp_sqrmod.c +++ b/libtommath/bn_mp_sqrmod.c @@ -36,6 +36,6 @@ mp_sqrmod (mp_int * a, mp_int * b, mp_int * c) } #endif -/* $Source$ */ -/* $Revision$ */ -/* $Date$ */ +/* ref: HEAD -> release/1.0.1, tag: v1.0.1-rc2 */ +/* git commit: e8c27ba7df0efb90708029115c94d681dfa7812f */ +/* commit time: 2017-08-29 10:48:46 +0200 */ diff --git a/libtommath/bn_mp_sqrt.c b/libtommath/bn_mp_sqrt.c index 4a52f5e..77078e8 100644 --- a/libtommath/bn_mp_sqrt.c +++ b/libtommath/bn_mp_sqrt.c @@ -76,6 +76,6 @@ E2: mp_clear(&t1); #endif -/* $Source$ */ -/* $Revision$ */ -/* $Date$ */ +/* ref: HEAD -> release/1.0.1, tag: v1.0.1-rc2 */ +/* git commit: e8c27ba7df0efb90708029115c94d681dfa7812f */ +/* commit time: 2017-08-29 10:48:46 +0200 */ diff --git a/libtommath/bn_mp_sub.c b/libtommath/bn_mp_sub.c index 0d616c2..cf7d58e 100644 --- a/libtommath/bn_mp_sub.c +++ b/libtommath/bn_mp_sub.c @@ -54,6 +54,6 @@ mp_sub (mp_int * a, mp_int * b, mp_int * c) #endif -/* $Source$ */ -/* $Revision$ */ -/* $Date$ */ +/* ref: HEAD -> release/1.0.1, tag: v1.0.1-rc2 */ +/* git commit: e8c27ba7df0efb90708029115c94d681dfa7812f */ +/* commit time: 2017-08-29 10:48:46 +0200 */ diff --git a/libtommath/bn_mp_sub_d.c b/libtommath/bn_mp_sub_d.c index f5a932f..482de39 100644 --- a/libtommath/bn_mp_sub_d.c +++ b/libtommath/bn_mp_sub_d.c @@ -88,6 +88,6 @@ mp_sub_d (mp_int * a, mp_digit b, mp_int * c) #endif -/* $Source$ */ -/* $Revision$ */ -/* $Date$ */ +/* ref: HEAD -> release/1.0.1, tag: v1.0.1-rc2 */ +/* git commit: e8c27ba7df0efb90708029115c94d681dfa7812f */ +/* commit time: 2017-08-29 10:48:46 +0200 */ diff --git a/libtommath/bn_mp_submod.c b/libtommath/bn_mp_submod.c index 87e0889..f6098b3 100644 --- a/libtommath/bn_mp_submod.c +++ b/libtommath/bn_mp_submod.c @@ -37,6 +37,6 @@ mp_submod (mp_int * a, mp_int * b, mp_int * c, mp_int * d) } #endif -/* $Source$ */ -/* $Revision$ */ -/* $Date$ */ +/* ref: HEAD -> release/1.0.1, tag: v1.0.1-rc2 */ +/* git commit: e8c27ba7df0efb90708029115c94d681dfa7812f */ +/* commit time: 2017-08-29 10:48:46 +0200 */ diff --git a/libtommath/bn_mp_to_signed_bin.c b/libtommath/bn_mp_to_signed_bin.c index e9289ea..077b0bf 100644 --- a/libtommath/bn_mp_to_signed_bin.c +++ b/libtommath/bn_mp_to_signed_bin.c @@ -28,6 +28,6 @@ int mp_to_signed_bin (mp_int * a, unsigned char *b) } #endif -/* $Source$ */ -/* $Revision$ */ -/* $Date$ */ +/* ref: HEAD -> release/1.0.1, tag: v1.0.1-rc2 */ +/* git commit: e8c27ba7df0efb90708029115c94d681dfa7812f */ +/* commit time: 2017-08-29 10:48:46 +0200 */ diff --git a/libtommath/bn_mp_to_signed_bin_n.c b/libtommath/bn_mp_to_signed_bin_n.c index d4fe6e6..2edb8e0 100644 --- a/libtommath/bn_mp_to_signed_bin_n.c +++ b/libtommath/bn_mp_to_signed_bin_n.c @@ -26,6 +26,6 @@ int mp_to_signed_bin_n (mp_int * a, unsigned char *b, unsigned long *outlen) } #endif -/* $Source$ */ -/* $Revision$ */ -/* $Date$ */ +/* ref: HEAD -> release/1.0.1, tag: v1.0.1-rc2 */ +/* git commit: e8c27ba7df0efb90708029115c94d681dfa7812f */ +/* commit time: 2017-08-29 10:48:46 +0200 */ diff --git a/libtommath/bn_mp_to_unsigned_bin.c b/libtommath/bn_mp_to_unsigned_bin.c index d3ef46f..203bf75 100644 --- a/libtommath/bn_mp_to_unsigned_bin.c +++ b/libtommath/bn_mp_to_unsigned_bin.c @@ -43,6 +43,6 @@ int mp_to_unsigned_bin (mp_int * a, unsigned char *b) } #endif -/* $Source$ */ -/* $Revision$ */ -/* $Date$ */ +/* ref: HEAD -> release/1.0.1, tag: v1.0.1-rc2 */ +/* git commit: e8c27ba7df0efb90708029115c94d681dfa7812f */ +/* commit time: 2017-08-29 10:48:46 +0200 */ diff --git a/libtommath/bn_mp_to_unsigned_bin_n.c b/libtommath/bn_mp_to_unsigned_bin_n.c index 2da13cc..d28d7f4 100644 --- a/libtommath/bn_mp_to_unsigned_bin_n.c +++ b/libtommath/bn_mp_to_unsigned_bin_n.c @@ -26,6 +26,6 @@ int mp_to_unsigned_bin_n (mp_int * a, unsigned char *b, unsigned long *outlen) } #endif -/* $Source$ */ -/* $Revision$ */ -/* $Date$ */ +/* ref: HEAD -> release/1.0.1, tag: v1.0.1-rc2 */ +/* git commit: e8c27ba7df0efb90708029115c94d681dfa7812f */ +/* commit time: 2017-08-29 10:48:46 +0200 */ diff --git a/libtommath/bn_mp_toom_mul.c b/libtommath/bn_mp_toom_mul.c index 4731f8f..dc4f0a9 100644 --- a/libtommath/bn_mp_toom_mul.c +++ b/libtommath/bn_mp_toom_mul.c @@ -281,6 +281,6 @@ ERR: #endif -/* $Source$ */ -/* $Revision$ */ -/* $Date$ */ +/* ref: HEAD -> release/1.0.1, tag: v1.0.1-rc2 */ +/* git commit: e8c27ba7df0efb90708029115c94d681dfa7812f */ +/* commit time: 2017-08-29 10:48:46 +0200 */ diff --git a/libtommath/bn_mp_toom_sqr.c b/libtommath/bn_mp_toom_sqr.c index 69b69d4..06a568e 100644 --- a/libtommath/bn_mp_toom_sqr.c +++ b/libtommath/bn_mp_toom_sqr.c @@ -223,6 +223,6 @@ ERR: #endif -/* $Source$ */ -/* $Revision$ */ -/* $Date$ */ +/* ref: HEAD -> release/1.0.1, tag: v1.0.1-rc2 */ +/* git commit: e8c27ba7df0efb90708029115c94d681dfa7812f */ +/* commit time: 2017-08-29 10:48:46 +0200 */ diff --git a/libtommath/bn_mp_toradix.c b/libtommath/bn_mp_toradix.c index f04352d..5bd9165 100644 --- a/libtommath/bn_mp_toradix.c +++ b/libtommath/bn_mp_toradix.c @@ -70,6 +70,6 @@ int mp_toradix (mp_int * a, char *str, int radix) #endif -/* $Source$ */ -/* $Revision$ */ -/* $Date$ */ +/* ref: HEAD -> release/1.0.1, tag: v1.0.1-rc2 */ +/* git commit: e8c27ba7df0efb90708029115c94d681dfa7812f */ +/* commit time: 2017-08-29 10:48:46 +0200 */ diff --git a/libtommath/bn_mp_toradix_n.c b/libtommath/bn_mp_toradix_n.c index 19b61d7..d1587a3 100644 --- a/libtommath/bn_mp_toradix_n.c +++ b/libtommath/bn_mp_toradix_n.c @@ -83,6 +83,6 @@ int mp_toradix_n(mp_int * a, char *str, int radix, int maxlen) #endif -/* $Source$ */ -/* $Revision$ */ -/* $Date$ */ +/* ref: HEAD -> release/1.0.1, tag: v1.0.1-rc2 */ +/* git commit: e8c27ba7df0efb90708029115c94d681dfa7812f */ +/* commit time: 2017-08-29 10:48:46 +0200 */ diff --git a/libtommath/bn_mp_unsigned_bin_size.c b/libtommath/bn_mp_unsigned_bin_size.c index 0312625..e81cd82 100644 --- a/libtommath/bn_mp_unsigned_bin_size.c +++ b/libtommath/bn_mp_unsigned_bin_size.c @@ -23,6 +23,6 @@ int mp_unsigned_bin_size (mp_int * a) } #endif -/* $Source$ */ -/* $Revision$ */ -/* $Date$ */ +/* ref: HEAD -> release/1.0.1, tag: v1.0.1-rc2 */ +/* git commit: e8c27ba7df0efb90708029115c94d681dfa7812f */ +/* commit time: 2017-08-29 10:48:46 +0200 */ diff --git a/libtommath/bn_mp_xor.c b/libtommath/bn_mp_xor.c index 3c2ba9e..1fc8bdf 100644 --- a/libtommath/bn_mp_xor.c +++ b/libtommath/bn_mp_xor.c @@ -46,6 +46,6 @@ mp_xor (mp_int * a, mp_int * b, mp_int * c) } #endif -/* $Source$ */ -/* $Revision$ */ -/* $Date$ */ +/* ref: HEAD -> release/1.0.1, tag: v1.0.1-rc2 */ +/* git commit: e8c27ba7df0efb90708029115c94d681dfa7812f */ +/* commit time: 2017-08-29 10:48:46 +0200 */ diff --git a/libtommath/bn_mp_zero.c b/libtommath/bn_mp_zero.c index 21365ed..f607ce6 100644 --- a/libtommath/bn_mp_zero.c +++ b/libtommath/bn_mp_zero.c @@ -31,6 +31,6 @@ void mp_zero (mp_int * a) } #endif -/* $Source$ */ -/* $Revision$ */ -/* $Date$ */ +/* ref: HEAD -> release/1.0.1, tag: v1.0.1-rc2 */ +/* git commit: e8c27ba7df0efb90708029115c94d681dfa7812f */ +/* commit time: 2017-08-29 10:48:46 +0200 */ diff --git a/libtommath/bn_prime_tab.c b/libtommath/bn_prime_tab.c index ae727a4..4354a48 100644 --- a/libtommath/bn_prime_tab.c +++ b/libtommath/bn_prime_tab.c @@ -56,6 +56,6 @@ const mp_digit ltm_prime_tab[] = { }; #endif -/* $Source$ */ -/* $Revision$ */ -/* $Date$ */ +/* ref: HEAD -> release/1.0.1, tag: v1.0.1-rc2 */ +/* git commit: e8c27ba7df0efb90708029115c94d681dfa7812f */ +/* commit time: 2017-08-29 10:48:46 +0200 */ diff --git a/libtommath/bn_reverse.c b/libtommath/bn_reverse.c index fc6eb2d..9811a81 100644 --- a/libtommath/bn_reverse.c +++ b/libtommath/bn_reverse.c @@ -34,6 +34,6 @@ bn_reverse (unsigned char *s, int len) } #endif -/* $Source$ */ -/* $Revision$ */ -/* $Date$ */ +/* ref: HEAD -> release/1.0.1, tag: v1.0.1-rc2 */ +/* git commit: e8c27ba7df0efb90708029115c94d681dfa7812f */ +/* commit time: 2017-08-29 10:48:46 +0200 */ diff --git a/libtommath/bn_s_mp_add.c b/libtommath/bn_s_mp_add.c index c2ad649..5d886e7 100644 --- a/libtommath/bn_s_mp_add.c +++ b/libtommath/bn_s_mp_add.c @@ -104,6 +104,6 @@ s_mp_add (mp_int * a, mp_int * b, mp_int * c) } #endif -/* $Source$ */ -/* $Revision$ */ -/* $Date$ */ +/* ref: HEAD -> release/1.0.1, tag: v1.0.1-rc2 */ +/* git commit: e8c27ba7df0efb90708029115c94d681dfa7812f */ +/* commit time: 2017-08-29 10:48:46 +0200 */ diff --git a/libtommath/bn_s_mp_exptmod.c b/libtommath/bn_s_mp_exptmod.c index 63e1b1e..617b56c 100644 --- a/libtommath/bn_s_mp_exptmod.c +++ b/libtommath/bn_s_mp_exptmod.c @@ -247,6 +247,6 @@ LBL_M: } #endif -/* $Source$ */ -/* $Revision$ */ -/* $Date$ */ +/* ref: HEAD -> release/1.0.1, tag: v1.0.1-rc2 */ +/* git commit: e8c27ba7df0efb90708029115c94d681dfa7812f */ +/* commit time: 2017-08-29 10:48:46 +0200 */ diff --git a/libtommath/bn_s_mp_mul_digs.c b/libtommath/bn_s_mp_mul_digs.c index bd8553d..cf2f50c 100644 --- a/libtommath/bn_s_mp_mul_digs.c +++ b/libtommath/bn_s_mp_mul_digs.c @@ -85,6 +85,6 @@ int s_mp_mul_digs (mp_int * a, mp_int * b, mp_int * c, int digs) } #endif -/* $Source$ */ -/* $Revision$ */ -/* $Date$ */ +/* ref: HEAD -> release/1.0.1, tag: v1.0.1-rc2 */ +/* git commit: e8c27ba7df0efb90708029115c94d681dfa7812f */ +/* commit time: 2017-08-29 10:48:46 +0200 */ diff --git a/libtommath/bn_s_mp_mul_high_digs.c b/libtommath/bn_s_mp_mul_high_digs.c index 153cea44..1d5b2f0 100644 --- a/libtommath/bn_s_mp_mul_high_digs.c +++ b/libtommath/bn_s_mp_mul_high_digs.c @@ -76,6 +76,6 @@ s_mp_mul_high_digs (mp_int * a, mp_int * b, mp_int * c, int digs) } #endif -/* $Source$ */ -/* $Revision$ */ -/* $Date$ */ +/* ref: HEAD -> release/1.0.1, tag: v1.0.1-rc2 */ +/* git commit: e8c27ba7df0efb90708029115c94d681dfa7812f */ +/* commit time: 2017-08-29 10:48:46 +0200 */ diff --git a/libtommath/bn_s_mp_sqr.c b/libtommath/bn_s_mp_sqr.c index 68c95bc..b85f1b8 100644 --- a/libtommath/bn_s_mp_sqr.c +++ b/libtommath/bn_s_mp_sqr.c @@ -79,6 +79,6 @@ int s_mp_sqr (mp_int * a, mp_int * b) } #endif -/* $Source$ */ -/* $Revision$ */ -/* $Date$ */ +/* ref: HEAD -> release/1.0.1, tag: v1.0.1-rc2 */ +/* git commit: e8c27ba7df0efb90708029115c94d681dfa7812f */ +/* commit time: 2017-08-29 10:48:46 +0200 */ diff --git a/libtommath/bn_s_mp_sub.c b/libtommath/bn_s_mp_sub.c index c0ea556..ac3f785 100644 --- a/libtommath/bn_s_mp_sub.c +++ b/libtommath/bn_s_mp_sub.c @@ -84,6 +84,6 @@ s_mp_sub (mp_int * a, mp_int * b, mp_int * c) #endif -/* $Source$ */ -/* $Revision$ */ -/* $Date$ */ +/* ref: HEAD -> release/1.0.1, tag: v1.0.1-rc2 */ +/* git commit: e8c27ba7df0efb90708029115c94d681dfa7812f */ +/* commit time: 2017-08-29 10:48:46 +0200 */ diff --git a/libtommath/bncore.c b/libtommath/bncore.c index 9552714..8bd4681 100644 --- a/libtommath/bncore.c +++ b/libtommath/bncore.c @@ -31,6 +31,6 @@ int KARATSUBA_MUL_CUTOFF = 80, /* Min. number of digits before Karatsub TOOM_SQR_CUTOFF = 400; #endif -/* $Source$ */ -/* $Revision$ */ -/* $Date$ */ +/* ref: HEAD -> release/1.0.1, tag: v1.0.1-rc2 */ +/* git commit: e8c27ba7df0efb90708029115c94d681dfa7812f */ +/* commit time: 2017-08-29 10:48:46 +0200 */ diff --git a/libtommath/tommath.h b/libtommath/tommath.h index 4c66e15..0a065f6 100644 --- a/libtommath/tommath.h +++ b/libtommath/tommath.h @@ -27,7 +27,12 @@ extern "C" { #endif /* detect 64-bit mode if possible */ -#if defined(__x86_64__) +#if defined(__x86_64__) || defined(_M_X64) || defined(_M_AMD64) || \ + defined(__powerpc64__) || defined(__ppc64__) || defined(__PPC64__) || \ + defined(__s390x__) || defined(__arch64__) || defined(__aarch64__) || \ + defined(__sparcv9) || defined(__sparc_v9__) || defined(__sparc64__) || \ + defined(__ia64) || defined(__ia64__) || defined(__itanium__) || defined(_M_IA64) || \ + defined(__LP64__) || defined(_LP64) || defined(__64BIT__) #if !(defined(MP_32BIT) || defined(MP_16BIT) || defined(MP_8BIT)) #define MP_64BIT #endif @@ -57,11 +62,6 @@ extern "C" { #endif #elif defined(MP_64BIT) /* for GCC only on supported platforms */ -#ifndef CRYPT - typedef unsigned long long ulong64; - typedef signed long long long64; -#endif - typedef uint64_t mp_digit; #if defined(_WIN32) typedef unsigned __int128 mp_word; @@ -78,11 +78,6 @@ extern "C" { /* this is the default case, 28-bit digits */ /* this is to make porting into LibTomCrypt easier :-) */ -#ifndef CRYPT - typedef unsigned long long ulong64; - typedef signed long long long64; -#endif - typedef uint32_t mp_digit; typedef uint64_t mp_word; @@ -104,16 +99,16 @@ extern "C" { typedef mp_digit mp_min_u32; #endif -/* platforms that can use a better rand function */ +/* use arc4random on platforms that support it */ #if defined(__FreeBSD__) || defined(__OpenBSD__) || defined(__NetBSD__) || defined(__DragonFly__) - #define MP_USE_ALT_RAND 1 + #define MP_GEN_RANDOM() arc4random() + #define MP_GEN_RANDOM_MAX 0xffffffff #endif -/* use arc4random on platforms that support it */ -#ifdef MP_USE_ALT_RAND - #define MP_GEN_RANDOM() arc4random() -#else +/* use rand() as fall-back if there's no better rand function */ +#ifndef MP_GEN_RANDOM #define MP_GEN_RANDOM() rand() + #define MP_GEN_RANDOM_MAX RAND_MAX #endif #define MP_DIGIT_BIT DIGIT_BIT @@ -570,6 +565,6 @@ int mp_fwrite(mp_int *a, int radix, FILE *stream); #endif -/* $Source$ */ -/* $Revision$ */ -/* $Date$ */ +/* ref: HEAD -> release/1.0.1, tag: v1.0.1-rc2 */ +/* git commit: e8c27ba7df0efb90708029115c94d681dfa7812f */ +/* commit time: 2017-08-29 10:48:46 +0200 */ diff --git a/libtommath/tommath_class.h b/libtommath/tommath_class.h index 2085521..e860613 100644 --- a/libtommath/tommath_class.h +++ b/libtommath/tommath_class.h @@ -282,12 +282,9 @@ #if defined(BN_MP_DIV_2D_C) #define BN_MP_COPY_C #define BN_MP_ZERO_C - #define BN_MP_INIT_C #define BN_MP_MOD_2D_C - #define BN_MP_CLEAR_C #define BN_MP_RSHD_C #define BN_MP_CLAMP_C - #define BN_MP_EXCH_C #endif #if defined(BN_MP_DIV_3_C) @@ -359,7 +356,7 @@ #if defined(BN_MP_EXPTMOD_FAST_C) #define BN_MP_COUNT_BITS_C - #define BN_MP_INIT_C + #define BN_MP_INIT_SIZE_C #define BN_MP_CLEAR_C #define BN_MP_MONTGOMERY_SETUP_C #define BN_FAST_MP_MONTGOMERY_REDUCE_C @@ -441,6 +438,7 @@ #if defined(BN_MP_INIT_COPY_C) #define BN_MP_INIT_SIZE_C #define BN_MP_COPY_C + #define BN_MP_CLEAR_C #endif #if defined(BN_MP_INIT_MULTI_C) @@ -466,6 +464,7 @@ #if defined(BN_MP_INVMOD_C) #define BN_MP_ISZERO_C #define BN_MP_ISODD_C + #define BN_MP_CMP_D_C #define BN_FAST_MP_INVMOD_C #define BN_MP_INVMOD_SLOW_C #endif @@ -500,6 +499,7 @@ #endif #if defined(BN_MP_JACOBI_C) + #define BN_MP_ISNEG_C #define BN_MP_CMP_D_C #define BN_MP_ISZERO_C #define BN_MP_INIT_COPY_C @@ -546,7 +546,7 @@ #endif #if defined(BN_MP_MOD_C) - #define BN_MP_INIT_C + #define BN_MP_INIT_SIZE_C #define BN_MP_DIV_C #define BN_MP_CLEAR_C #define BN_MP_ISZERO_C @@ -610,7 +610,7 @@ #endif #if defined(BN_MP_MULMOD_C) - #define BN_MP_INIT_C + #define BN_MP_INIT_SIZE_C #define BN_MP_MUL_C #define BN_MP_CLEAR_C #define BN_MP_MOD_C diff --git a/libtommath/tommath_private.h b/libtommath/tommath_private.h index bc7cd35..407ebd5 100644 --- a/libtommath/tommath_private.h +++ b/libtommath/tommath_private.h @@ -18,9 +18,13 @@ #include #include -#define MIN(x,y) (((x) < (y)) ? (x) : (y)) +#ifndef MIN + #define MIN(x,y) (((x) < (y)) ? (x) : (y)) +#endif -#define MAX(x,y) (((x) > (y)) ? (x) : (y)) +#ifndef MAX + #define MAX(x,y) (((x) > (y)) ? (x) : (y)) +#endif #ifdef __cplusplus extern "C" { @@ -114,6 +118,6 @@ int func_name (mp_int * a, type b) \ #endif -/* $Source$ */ -/* $Revision$ */ -/* $Date$ */ +/* ref: HEAD -> release/1.0.1, tag: v1.0.1-rc2 */ +/* git commit: e8c27ba7df0efb90708029115c94d681dfa7812f */ +/* commit time: 2017-08-29 10:48:46 +0200 */ diff --git a/libtommath/tommath_superclass.h b/libtommath/tommath_superclass.h index 1b26841..8f6ef03 100644 --- a/libtommath/tommath_superclass.h +++ b/libtommath/tommath_superclass.h @@ -71,6 +71,6 @@ #endif -/* $Source$ */ -/* $Revision$ */ -/* $Date$ */ +/* ref: HEAD -> release/1.0.1, tag: v1.0.1-rc2 */ +/* git commit: e8c27ba7df0efb90708029115c94d681dfa7812f */ +/* commit time: 2017-08-29 10:48:46 +0200 */ -- cgit v0.12