Index: generic/tclTomMath.h ================================================================== --- generic/tclTomMath.h +++ generic/tclTomMath.h @@ -114,20 +114,20 @@ typedef uint_least32_t mp_min_u32; #else 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 -#endif - -/* use arc4random on platforms that support it */ -#ifdef MP_USE_ALT_RAND #define MP_GEN_RANDOM() arc4random() -#else + #define MP_GEN_RANDOM_MAX 0xffffffff +#endif + +/* 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 #define MP_MASK ((((mp_digit)1)<<((mp_digit)DIGIT_BIT))-((mp_digit)1)) #define MP_DIGIT_MAX MP_MASK @@ -794,9 +794,9 @@ #endif #endif -/* $Source$ */ -/* $Revision$ */ -/* $Date$ */ +/* ref: tag: v1.0.1, master */ +/* git commit: 5953f62e42b24af93748b1ee5e1d062e242c2546 */ +/* commit time: 2017-08-29 22:27:36 +0200 */ Index: libtommath/bn_error.c ================================================================== --- libtommath/bn_error.c +++ libtommath/bn_error.c @@ -40,8 +40,8 @@ return "Invalid error code"; } #endif -/* $Source$ */ -/* $Revision$ */ -/* $Date$ */ +/* ref: tag: v1.0.1, master */ +/* git commit: 5953f62e42b24af93748b1ee5e1d062e242c2546 */ +/* commit time: 2017-08-29 22:27:36 +0200 */ Index: libtommath/bn_fast_mp_invmod.c ================================================================== --- libtommath/bn_fast_mp_invmod.c +++ libtommath/bn_fast_mp_invmod.c @@ -141,8 +141,8 @@ LBL_ERR:mp_clear_multi (&x, &y, &u, &v, &B, &D, NULL); return res; } #endif -/* $Source$ */ -/* $Revision$ */ -/* $Date$ */ +/* ref: tag: v1.0.1, master */ +/* git commit: 5953f62e42b24af93748b1ee5e1d062e242c2546 */ +/* commit time: 2017-08-29 22:27:36 +0200 */ Index: libtommath/bn_fast_mp_montgomery_reduce.c ================================================================== --- libtommath/bn_fast_mp_montgomery_reduce.c +++ libtommath/bn_fast_mp_montgomery_reduce.c @@ -165,8 +165,8 @@ } return MP_OKAY; } #endif -/* $Source$ */ -/* $Revision$ */ -/* $Date$ */ +/* ref: tag: v1.0.1, master */ +/* git commit: 5953f62e42b24af93748b1ee5e1d062e242c2546 */ +/* commit time: 2017-08-29 22:27:36 +0200 */ Index: libtommath/bn_fast_s_mp_mul_digs.c ================================================================== --- libtommath/bn_fast_s_mp_mul_digs.c +++ libtommath/bn_fast_s_mp_mul_digs.c @@ -100,8 +100,8 @@ mp_clamp (c); return MP_OKAY; } #endif -/* $Source$ */ -/* $Revision$ */ -/* $Date$ */ +/* ref: tag: v1.0.1, master */ +/* git commit: 5953f62e42b24af93748b1ee5e1d062e242c2546 */ +/* commit time: 2017-08-29 22:27:36 +0200 */ Index: libtommath/bn_fast_s_mp_mul_high_digs.c ================================================================== --- libtommath/bn_fast_s_mp_mul_high_digs.c +++ libtommath/bn_fast_s_mp_mul_high_digs.c @@ -91,8 +91,8 @@ mp_clamp (c); return MP_OKAY; } #endif -/* $Source$ */ -/* $Revision$ */ -/* $Date$ */ +/* ref: tag: v1.0.1, master */ +/* git commit: 5953f62e42b24af93748b1ee5e1d062e242c2546 */ +/* commit time: 2017-08-29 22:27:36 +0200 */ Index: libtommath/bn_fast_s_mp_sqr.c ================================================================== --- libtommath/bn_fast_s_mp_sqr.c +++ libtommath/bn_fast_s_mp_sqr.c @@ -107,8 +107,8 @@ mp_clamp (b); return MP_OKAY; } #endif -/* $Source$ */ -/* $Revision$ */ -/* $Date$ */ +/* ref: tag: v1.0.1, master */ +/* git commit: 5953f62e42b24af93748b1ee5e1d062e242c2546 */ +/* commit time: 2017-08-29 22:27:36 +0200 */ Index: libtommath/bn_mp_2expt.c ================================================================== --- libtommath/bn_mp_2expt.c +++ libtommath/bn_mp_2expt.c @@ -41,8 +41,8 @@ return MP_OKAY; } #endif -/* $Source$ */ -/* $Revision$ */ -/* $Date$ */ +/* ref: tag: v1.0.1, master */ +/* git commit: 5953f62e42b24af93748b1ee5e1d062e242c2546 */ +/* commit time: 2017-08-29 22:27:36 +0200 */ Index: libtommath/bn_mp_abs.c ================================================================== --- libtommath/bn_mp_abs.c +++ libtommath/bn_mp_abs.c @@ -36,8 +36,8 @@ return MP_OKAY; } #endif -/* $Source$ */ -/* $Revision$ */ -/* $Date$ */ +/* ref: tag: v1.0.1, master */ +/* git commit: 5953f62e42b24af93748b1ee5e1d062e242c2546 */ +/* commit time: 2017-08-29 22:27:36 +0200 */ Index: libtommath/bn_mp_add.c ================================================================== --- libtommath/bn_mp_add.c +++ libtommath/bn_mp_add.c @@ -46,8 +46,8 @@ return res; } #endif -/* $Source$ */ -/* $Revision$ */ -/* $Date$ */ +/* ref: tag: v1.0.1, master */ +/* git commit: 5953f62e42b24af93748b1ee5e1d062e242c2546 */ +/* commit time: 2017-08-29 22:27:36 +0200 */ Index: libtommath/bn_mp_add_d.c ================================================================== --- libtommath/bn_mp_add_d.c +++ libtommath/bn_mp_add_d.c @@ -47,13 +47,10 @@ } /* old number of used digits in c */ oldused = c->used; - /* sign always positive */ - c->sign = MP_ZPOS; - /* source alias */ tmpa = a->dp; /* destination alias */ tmpc = c->dp; @@ -93,10 +90,13 @@ /* setup count so the clearing of oldused * can fall through correctly */ ix = 1; } + + /* sign always positive */ + c->sign = MP_ZPOS; /* now zero to oldused */ while (ix++ < oldused) { *tmpc++ = 0; } @@ -105,8 +105,8 @@ return MP_OKAY; } #endif -/* $Source$ */ -/* $Revision$ */ -/* $Date$ */ +/* ref: tag: v1.0.1, master */ +/* git commit: 5953f62e42b24af93748b1ee5e1d062e242c2546 */ +/* commit time: 2017-08-29 22:27:36 +0200 */ Index: libtommath/bn_mp_addmod.c ================================================================== --- libtommath/bn_mp_addmod.c +++ libtommath/bn_mp_addmod.c @@ -34,8 +34,8 @@ mp_clear (&t); return res; } #endif -/* $Source$ */ -/* $Revision$ */ -/* $Date$ */ +/* ref: tag: v1.0.1, master */ +/* git commit: 5953f62e42b24af93748b1ee5e1d062e242c2546 */ +/* commit time: 2017-08-29 22:27:36 +0200 */ Index: libtommath/bn_mp_and.c ================================================================== --- libtommath/bn_mp_and.c +++ libtommath/bn_mp_and.c @@ -50,8 +50,8 @@ mp_clear (&t); return MP_OKAY; } #endif -/* $Source$ */ -/* $Revision$ */ -/* $Date$ */ +/* ref: tag: v1.0.1, master */ +/* git commit: 5953f62e42b24af93748b1ee5e1d062e242c2546 */ +/* commit time: 2017-08-29 22:27:36 +0200 */ Index: libtommath/bn_mp_clamp.c ================================================================== --- libtommath/bn_mp_clamp.c +++ libtommath/bn_mp_clamp.c @@ -37,8 +37,8 @@ a->sign = MP_ZPOS; } } #endif -/* $Source$ */ -/* $Revision$ */ -/* $Date$ */ +/* ref: tag: v1.0.1, master */ +/* git commit: 5953f62e42b24af93748b1ee5e1d062e242c2546 */ +/* commit time: 2017-08-29 22:27:36 +0200 */ Index: libtommath/bn_mp_clear.c ================================================================== --- libtommath/bn_mp_clear.c +++ libtommath/bn_mp_clear.c @@ -37,8 +37,8 @@ a->sign = MP_ZPOS; } } #endif -/* $Source$ */ -/* $Revision$ */ -/* $Date$ */ +/* ref: tag: v1.0.1, master */ +/* git commit: 5953f62e42b24af93748b1ee5e1d062e242c2546 */ +/* commit time: 2017-08-29 22:27:36 +0200 */ Index: libtommath/bn_mp_clear_multi.c ================================================================== --- libtommath/bn_mp_clear_multi.c +++ libtommath/bn_mp_clear_multi.c @@ -27,8 +27,8 @@ } va_end(args); } #endif -/* $Source$ */ -/* $Revision$ */ -/* $Date$ */ +/* ref: tag: v1.0.1, master */ +/* git commit: 5953f62e42b24af93748b1ee5e1d062e242c2546 */ +/* commit time: 2017-08-29 22:27:36 +0200 */ Index: libtommath/bn_mp_cmp.c ================================================================== --- libtommath/bn_mp_cmp.c +++ libtommath/bn_mp_cmp.c @@ -36,8 +36,8 @@ return mp_cmp_mag(a, b); } } #endif -/* $Source$ */ -/* $Revision$ */ -/* $Date$ */ +/* ref: tag: v1.0.1, master */ +/* git commit: 5953f62e42b24af93748b1ee5e1d062e242c2546 */ +/* commit time: 2017-08-29 22:27:36 +0200 */ Index: libtommath/bn_mp_cmp_d.c ================================================================== --- libtommath/bn_mp_cmp_d.c +++ libtommath/bn_mp_cmp_d.c @@ -37,8 +37,8 @@ return MP_EQ; } } #endif -/* $Source$ */ -/* $Revision$ */ -/* $Date$ */ +/* ref: tag: v1.0.1, master */ +/* git commit: 5953f62e42b24af93748b1ee5e1d062e242c2546 */ +/* commit time: 2017-08-29 22:27:36 +0200 */ Index: libtommath/bn_mp_cmp_mag.c ================================================================== --- libtommath/bn_mp_cmp_mag.c +++ libtommath/bn_mp_cmp_mag.c @@ -48,8 +48,8 @@ } return MP_EQ; } #endif -/* $Source$ */ -/* $Revision$ */ -/* $Date$ */ +/* ref: tag: v1.0.1, master */ +/* git commit: 5953f62e42b24af93748b1ee5e1d062e242c2546 */ +/* commit time: 2017-08-29 22:27:36 +0200 */ Index: libtommath/bn_mp_cnt_lsb.c ================================================================== --- libtommath/bn_mp_cnt_lsb.c +++ libtommath/bn_mp_cnt_lsb.c @@ -46,8 +46,8 @@ return x; } #endif -/* $Source$ */ -/* $Revision$ */ -/* $Date$ */ +/* ref: tag: v1.0.1, master */ +/* git commit: 5953f62e42b24af93748b1ee5e1d062e242c2546 */ +/* commit time: 2017-08-29 22:27:36 +0200 */ Index: libtommath/bn_mp_copy.c ================================================================== --- libtommath/bn_mp_copy.c +++ libtommath/bn_mp_copy.c @@ -61,8 +61,8 @@ b->sign = a->sign; return MP_OKAY; } #endif -/* $Source$ */ -/* $Revision$ */ -/* $Date$ */ +/* ref: tag: v1.0.1, master */ +/* git commit: 5953f62e42b24af93748b1ee5e1d062e242c2546 */ +/* commit time: 2017-08-29 22:27:36 +0200 */ Index: libtommath/bn_mp_count_bits.c ================================================================== --- libtommath/bn_mp_count_bits.c +++ libtommath/bn_mp_count_bits.c @@ -38,8 +38,8 @@ } return r; } #endif -/* $Source$ */ -/* $Revision$ */ -/* $Date$ */ +/* ref: tag: v1.0.1, master */ +/* git commit: 5953f62e42b24af93748b1ee5e1d062e242c2546 */ +/* commit time: 2017-08-29 22:27:36 +0200 */ Index: libtommath/bn_mp_div.c ================================================================== --- libtommath/bn_mp_div.c +++ libtommath/bn_mp_div.c @@ -288,8 +288,8 @@ #endif #endif -/* $Source$ */ -/* $Revision$ */ -/* $Date$ */ +/* ref: tag: v1.0.1, master */ +/* git commit: 5953f62e42b24af93748b1ee5e1d062e242c2546 */ +/* commit time: 2017-08-29 22:27:36 +0200 */ Index: libtommath/bn_mp_div_2.c ================================================================== --- libtommath/bn_mp_div_2.c +++ libtommath/bn_mp_div_2.c @@ -61,8 +61,8 @@ mp_clamp (b); return MP_OKAY; } #endif -/* $Source$ */ -/* $Revision$ */ -/* $Date$ */ +/* ref: tag: v1.0.1, master */ +/* git commit: 5953f62e42b24af93748b1ee5e1d062e242c2546 */ +/* commit time: 2017-08-29 22:27:36 +0200 */ Index: libtommath/bn_mp_div_2d.c ================================================================== --- libtommath/bn_mp_div_2d.c +++ libtommath/bn_mp_div_2d.c @@ -18,12 +18,10 @@ /* shift right by a certain bit count (store quotient in c, optional remainder in d) */ int mp_div_2d (const 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) { res = mp_copy (a, c); if (d != NULL) { @@ -30,28 +28,23 @@ mp_zero (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); } @@ -82,16 +75,12 @@ /* set the carry to the carry bits of the current word found above */ r = rr; } } mp_clamp (c); - if (d != NULL) { - mp_exch (&t, d); - } - mp_clear (&t); return MP_OKAY; } #endif -/* $Source$ */ -/* $Revision$ */ -/* $Date$ */ +/* ref: tag: v1.0.1, master */ +/* git commit: 5953f62e42b24af93748b1ee5e1d062e242c2546 */ +/* commit time: 2017-08-29 22:27:36 +0200 */ Index: libtommath/bn_mp_div_3.c ================================================================== --- libtommath/bn_mp_div_3.c +++ libtommath/bn_mp_div_3.c @@ -72,8 +72,8 @@ return res; } #endif -/* $Source$ */ -/* $Revision$ */ -/* $Date$ */ +/* ref: tag: v1.0.1, master */ +/* git commit: 5953f62e42b24af93748b1ee5e1d062e242c2546 */ +/* commit time: 2017-08-29 22:27:36 +0200 */ Index: libtommath/bn_mp_div_d.c ================================================================== --- libtommath/bn_mp_div_d.c +++ libtommath/bn_mp_div_d.c @@ -107,8 +107,8 @@ return res; } #endif -/* $Source$ */ -/* $Revision$ */ -/* $Date$ */ +/* ref: tag: v1.0.1, master */ +/* git commit: 5953f62e42b24af93748b1ee5e1d062e242c2546 */ +/* commit time: 2017-08-29 22:27:36 +0200 */ Index: libtommath/bn_mp_dr_is_modulus.c ================================================================== --- libtommath/bn_mp_dr_is_modulus.c +++ libtommath/bn_mp_dr_is_modulus.c @@ -36,8 +36,8 @@ return 1; } #endif -/* $Source$ */ -/* $Revision$ */ -/* $Date$ */ +/* ref: tag: v1.0.1, master */ +/* git commit: 5953f62e42b24af93748b1ee5e1d062e242c2546 */ +/* commit time: 2017-08-29 22:27:36 +0200 */ Index: libtommath/bn_mp_dr_reduce.c ================================================================== --- libtommath/bn_mp_dr_reduce.c +++ libtommath/bn_mp_dr_reduce.c @@ -89,8 +89,8 @@ } return MP_OKAY; } #endif -/* $Source$ */ -/* $Revision$ */ -/* $Date$ */ +/* ref: tag: v1.0.1, master */ +/* git commit: 5953f62e42b24af93748b1ee5e1d062e242c2546 */ +/* commit time: 2017-08-29 22:27:36 +0200 */ Index: libtommath/bn_mp_dr_setup.c ================================================================== --- libtommath/bn_mp_dr_setup.c +++ libtommath/bn_mp_dr_setup.c @@ -25,8 +25,8 @@ ((mp_word)a->dp[0])); } #endif -/* $Source$ */ -/* $Revision$ */ -/* $Date$ */ +/* ref: tag: v1.0.1, master */ +/* git commit: 5953f62e42b24af93748b1ee5e1d062e242c2546 */ +/* commit time: 2017-08-29 22:27:36 +0200 */ Index: libtommath/bn_mp_exch.c ================================================================== --- libtommath/bn_mp_exch.c +++ libtommath/bn_mp_exch.c @@ -27,8 +27,8 @@ *a = *b; *b = t; } #endif -/* $Source$ */ -/* $Revision$ */ -/* $Date$ */ +/* ref: tag: v1.0.1, master */ +/* git commit: 5953f62e42b24af93748b1ee5e1d062e242c2546 */ +/* commit time: 2017-08-29 22:27:36 +0200 */ Index: libtommath/bn_mp_export.c ================================================================== --- libtommath/bn_mp_export.c +++ libtommath/bn_mp_export.c @@ -81,8 +81,8 @@ return MP_OKAY; } #endif -/* $Source$ */ -/* $Revision$ */ -/* $Date$ */ +/* ref: tag: v1.0.1, master */ +/* git commit: 5953f62e42b24af93748b1ee5e1d062e242c2546 */ +/* commit time: 2017-08-29 22:27:36 +0200 */ Index: libtommath/bn_mp_expt_d.c ================================================================== --- libtommath/bn_mp_expt_d.c +++ libtommath/bn_mp_expt_d.c @@ -21,8 +21,8 @@ return mp_expt_d_ex(a, b, c, 0); } #endif -/* $Source$ */ -/* $Revision$ */ -/* $Date$ */ +/* ref: tag: v1.0.1, master */ +/* git commit: 5953f62e42b24af93748b1ee5e1d062e242c2546 */ +/* commit time: 2017-08-29 22:27:36 +0200 */ Index: libtommath/bn_mp_expt_d_ex.c ================================================================== --- libtommath/bn_mp_expt_d_ex.c +++ libtommath/bn_mp_expt_d_ex.c @@ -76,8 +76,8 @@ mp_clear (&g); return MP_OKAY; } #endif -/* $Source$ */ -/* $Revision$ */ -/* $Date$ */ +/* ref: tag: v1.0.1, master */ +/* git commit: 5953f62e42b24af93748b1ee5e1d062e242c2546 */ +/* commit time: 2017-08-29 22:27:36 +0200 */ Index: libtommath/bn_mp_exptmod.c ================================================================== --- libtommath/bn_mp_exptmod.c +++ libtommath/bn_mp_exptmod.c @@ -105,8 +105,8 @@ #endif } #endif -/* $Source$ */ -/* $Revision$ */ -/* $Date$ */ +/* ref: tag: v1.0.1, master */ +/* git commit: 5953f62e42b24af93748b1ee5e1d062e242c2546 */ +/* commit time: 2017-08-29 22:27:36 +0200 */ Index: libtommath/bn_mp_exptmod_fast.c ================================================================== --- libtommath/bn_mp_exptmod_fast.c +++ libtommath/bn_mp_exptmod_fast.c @@ -65,17 +65,17 @@ } #endif /* 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]); } mp_clear(&M[1]); return err; @@ -131,11 +131,11 @@ goto LBL_M; #endif } /* setup result */ - if ((err = mp_init (&res)) != MP_OKAY) { + if ((err = mp_init_size (&res, P->alloc)) != MP_OKAY) { goto LBL_M; } /* create M table * @@ -148,19 +148,19 @@ #ifdef BN_MP_MONTGOMERY_CALC_NORMALIZATION_C /* now we need R mod m */ 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) { goto LBL_RES; } @@ -314,8 +314,8 @@ return err; } #endif -/* $Source$ */ -/* $Revision$ */ -/* $Date$ */ +/* ref: tag: v1.0.1, master */ +/* git commit: 5953f62e42b24af93748b1ee5e1d062e242c2546 */ +/* commit time: 2017-08-29 22:27:36 +0200 */ Index: libtommath/bn_mp_exteuclid.c ================================================================== --- libtommath/bn_mp_exteuclid.c +++ libtommath/bn_mp_exteuclid.c @@ -27,56 +27,57 @@ return err; } /* 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 */ if (U1 != NULL) { mp_exch(U1, &u1); } if (U2 != NULL) { mp_exch(U2, &u2); } 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: tag: v1.0.1, master */ +/* git commit: 5953f62e42b24af93748b1ee5e1d062e242c2546 */ +/* commit time: 2017-08-29 22:27:36 +0200 */ Index: libtommath/bn_mp_fread.c ================================================================== --- libtommath/bn_mp_fread.c +++ libtommath/bn_mp_fread.c @@ -13,10 +13,11 @@ * guarantee it works. * * 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) { int err, ch, neg, y; @@ -57,11 +58,12 @@ a->sign = neg; } return MP_OKAY; } +#endif #endif -/* $Source$ */ -/* $Revision$ */ -/* $Date$ */ +/* ref: tag: v1.0.1, master */ +/* git commit: 5953f62e42b24af93748b1ee5e1d062e242c2546 */ +/* commit time: 2017-08-29 22:27:36 +0200 */ Index: libtommath/bn_mp_fwrite.c ================================================================== --- libtommath/bn_mp_fwrite.c +++ libtommath/bn_mp_fwrite.c @@ -13,10 +13,11 @@ * guarantee it works. * * 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; int err, len, x; @@ -42,11 +43,12 @@ } XFREE (buf); return MP_OKAY; } +#endif #endif -/* $Source$ */ -/* $Revision$ */ -/* $Date$ */ +/* ref: tag: v1.0.1, master */ +/* git commit: 5953f62e42b24af93748b1ee5e1d062e242c2546 */ +/* commit time: 2017-08-29 22:27:36 +0200 */ Index: libtommath/bn_mp_gcd.c ================================================================== --- libtommath/bn_mp_gcd.c +++ libtommath/bn_mp_gcd.c @@ -98,8 +98,8 @@ LBL_U:mp_clear (&v); return res; } #endif -/* $Source$ */ -/* $Revision$ */ -/* $Date$ */ +/* ref: tag: v1.0.1, master */ +/* git commit: 5953f62e42b24af93748b1ee5e1d062e242c2546 */ +/* commit time: 2017-08-29 22:27:36 +0200 */ Index: libtommath/bn_mp_get_int.c ================================================================== --- libtommath/bn_mp_get_int.c +++ libtommath/bn_mp_get_int.c @@ -38,8 +38,8 @@ /* force result to 32-bits always so it is consistent on non 32-bit platforms */ return res & 0xFFFFFFFFUL; } #endif -/* $Source$ */ -/* $Revision$ */ -/* $Date$ */ +/* ref: tag: v1.0.1, master */ +/* git commit: 5953f62e42b24af93748b1ee5e1d062e242c2546 */ +/* commit time: 2017-08-29 22:27:36 +0200 */ Index: libtommath/bn_mp_grow.c ================================================================== --- libtommath/bn_mp_grow.c +++ libtommath/bn_mp_grow.c @@ -50,8 +50,8 @@ } return MP_OKAY; } #endif -/* $Source$ */ -/* $Revision$ */ -/* $Date$ */ +/* ref: tag: v1.0.1, master */ +/* git commit: 5953f62e42b24af93748b1ee5e1d062e242c2546 */ +/* commit time: 2017-08-29 22:27:36 +0200 */ Index: libtommath/bn_mp_import.c ================================================================== --- libtommath/bn_mp_import.c +++ libtommath/bn_mp_import.c @@ -66,8 +66,8 @@ return MP_OKAY; } #endif -/* $Source$ */ -/* $Revision$ */ -/* $Date$ */ +/* ref: tag: v1.0.1, master */ +/* git commit: 5953f62e42b24af93748b1ee5e1d062e242c2546 */ +/* commit time: 2017-08-29 22:27:36 +0200 */ Index: libtommath/bn_mp_init.c ================================================================== --- libtommath/bn_mp_init.c +++ libtommath/bn_mp_init.c @@ -39,8 +39,8 @@ return MP_OKAY; } #endif -/* $Source$ */ -/* $Revision$ */ -/* $Date$ */ +/* ref: tag: v1.0.1, master */ +/* git commit: 5953f62e42b24af93748b1ee5e1d062e242c2546 */ +/* commit time: 2017-08-29 22:27:36 +0200 */ Index: libtommath/bn_mp_init_copy.c ================================================================== --- libtommath/bn_mp_init_copy.c +++ libtommath/bn_mp_init_copy.c @@ -21,12 +21,17 @@ int res; 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: tag: v1.0.1, master */ +/* git commit: 5953f62e42b24af93748b1ee5e1d062e242c2546 */ +/* commit time: 2017-08-29 22:27:36 +0200 */ Index: libtommath/bn_mp_init_multi.c ================================================================== --- libtommath/bn_mp_init_multi.c +++ libtommath/bn_mp_init_multi.c @@ -29,13 +29,10 @@ /* Oops - error! Back-track and mp_clear what we already succeeded in init-ing, then return error. */ va_list clean_args; - /* end the current list */ - va_end(args); - /* now start cleaning up */ cur_arg = mp; va_start(clean_args, mp); while (n-- != 0) { mp_clear(cur_arg); @@ -52,8 +49,8 @@ return res; /* Assumed ok, if error flagged above. */ } #endif -/* $Source$ */ -/* $Revision$ */ -/* $Date$ */ +/* ref: tag: v1.0.1, master */ +/* git commit: 5953f62e42b24af93748b1ee5e1d062e242c2546 */ +/* commit time: 2017-08-29 22:27:36 +0200 */ Index: libtommath/bn_mp_init_set.c ================================================================== --- libtommath/bn_mp_init_set.c +++ libtommath/bn_mp_init_set.c @@ -25,8 +25,8 @@ mp_set(a, b); return err; } #endif -/* $Source$ */ -/* $Revision$ */ -/* $Date$ */ +/* ref: tag: v1.0.1, master */ +/* git commit: 5953f62e42b24af93748b1ee5e1d062e242c2546 */ +/* commit time: 2017-08-29 22:27:36 +0200 */ Index: libtommath/bn_mp_init_set_int.c ================================================================== --- libtommath/bn_mp_init_set_int.c +++ libtommath/bn_mp_init_set_int.c @@ -24,8 +24,8 @@ } return mp_set_int(a, b); } #endif -/* $Source$ */ -/* $Revision$ */ -/* $Date$ */ +/* ref: tag: v1.0.1, master */ +/* git commit: 5953f62e42b24af93748b1ee5e1d062e242c2546 */ +/* commit time: 2017-08-29 22:27:36 +0200 */ Index: libtommath/bn_mp_init_size.c ================================================================== --- libtommath/bn_mp_init_size.c +++ libtommath/bn_mp_init_size.c @@ -41,8 +41,8 @@ return MP_OKAY; } #endif -/* $Source$ */ -/* $Revision$ */ -/* $Date$ */ +/* ref: tag: v1.0.1, master */ +/* git commit: 5953f62e42b24af93748b1ee5e1d062e242c2546 */ +/* commit time: 2017-08-29 22:27:36 +0200 */ Index: libtommath/bn_mp_invmod.c ================================================================== --- libtommath/bn_mp_invmod.c +++ libtommath/bn_mp_invmod.c @@ -23,11 +23,11 @@ return MP_VAL; } #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 #ifdef BN_MP_INVMOD_SLOW_C @@ -36,8 +36,8 @@ return MP_VAL; #endif } #endif -/* $Source$ */ -/* $Revision$ */ -/* $Date$ */ +/* ref: tag: v1.0.1, master */ +/* git commit: 5953f62e42b24af93748b1ee5e1d062e242c2546 */ +/* commit time: 2017-08-29 22:27:36 +0200 */ Index: libtommath/bn_mp_invmod_slow.c ================================================================== --- libtommath/bn_mp_invmod_slow.c +++ libtommath/bn_mp_invmod_slow.c @@ -168,8 +168,8 @@ LBL_ERR:mp_clear_multi (&x, &y, &u, &v, &A, &B, &C, &D, NULL); return res; } #endif -/* $Source$ */ -/* $Revision$ */ -/* $Date$ */ +/* ref: tag: v1.0.1, master */ +/* git commit: 5953f62e42b24af93748b1ee5e1d062e242c2546 */ +/* commit time: 2017-08-29 22:27:36 +0200 */ Index: libtommath/bn_mp_is_square.c ================================================================== --- libtommath/bn_mp_is_square.c +++ libtommath/bn_mp_is_square.c @@ -102,8 +102,8 @@ ERR:mp_clear(&t); return res; } #endif -/* $Source$ */ -/* $Revision$ */ -/* $Date$ */ +/* ref: tag: v1.0.1, master */ +/* git commit: 5953f62e42b24af93748b1ee5e1d062e242c2546 */ +/* commit time: 2017-08-29 22:27:36 +0200 */ Index: libtommath/bn_mp_jacobi.c ================================================================== --- libtommath/bn_mp_jacobi.c +++ libtommath/bn_mp_jacobi.c @@ -110,8 +110,8 @@ LBL_A1:mp_clear (&a1); return res; } #endif -/* $Source$ */ -/* $Revision$ */ -/* $Date$ */ +/* ref: tag: v1.0.1, master */ +/* git commit: 5953f62e42b24af93748b1ee5e1d062e242c2546 */ +/* commit time: 2017-08-29 22:27:36 +0200 */ Index: libtommath/bn_mp_karatsuba_mul.c ================================================================== --- libtommath/bn_mp_karatsuba_mul.c +++ libtommath/bn_mp_karatsuba_mul.c @@ -160,8 +160,8 @@ ERR: return err; } #endif -/* $Source$ */ -/* $Revision$ */ -/* $Date$ */ +/* ref: tag: v1.0.1, master */ +/* git commit: 5953f62e42b24af93748b1ee5e1d062e242c2546 */ +/* commit time: 2017-08-29 22:27:36 +0200 */ Index: libtommath/bn_mp_karatsuba_sqr.c ================================================================== --- libtommath/bn_mp_karatsuba_sqr.c +++ libtommath/bn_mp_karatsuba_sqr.c @@ -114,8 +114,8 @@ ERR: return err; } #endif -/* $Source$ */ -/* $Revision$ */ -/* $Date$ */ +/* ref: tag: v1.0.1, master */ +/* git commit: 5953f62e42b24af93748b1ee5e1d062e242c2546 */ +/* commit time: 2017-08-29 22:27:36 +0200 */ Index: libtommath/bn_mp_lcm.c ================================================================== --- libtommath/bn_mp_lcm.c +++ libtommath/bn_mp_lcm.c @@ -53,8 +53,8 @@ mp_clear_multi (&t1, &t2, NULL); return res; } #endif -/* $Source$ */ -/* $Revision$ */ -/* $Date$ */ +/* ref: tag: v1.0.1, master */ +/* git commit: 5953f62e42b24af93748b1ee5e1d062e242c2546 */ +/* commit time: 2017-08-29 22:27:36 +0200 */ Index: libtommath/bn_mp_lshd.c ================================================================== --- libtommath/bn_mp_lshd.c +++ libtommath/bn_mp_lshd.c @@ -60,8 +60,8 @@ } return MP_OKAY; } #endif -/* $Source$ */ -/* $Revision$ */ -/* $Date$ */ +/* ref: tag: v1.0.1, master */ +/* git commit: 5953f62e42b24af93748b1ee5e1d062e242c2546 */ +/* commit time: 2017-08-29 22:27:36 +0200 */ Index: libtommath/bn_mp_mod.c ================================================================== --- libtommath/bn_mp_mod.c +++ libtommath/bn_mp_mod.c @@ -20,11 +20,11 @@ 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; } if ((res = mp_div (a, b, NULL, &t)) != MP_OKAY) { mp_clear (&t); @@ -41,8 +41,8 @@ mp_clear (&t); return res; } #endif -/* $Source$ */ -/* $Revision$ */ -/* $Date$ */ +/* ref: tag: v1.0.1, master */ +/* git commit: 5953f62e42b24af93748b1ee5e1d062e242c2546 */ +/* commit time: 2017-08-29 22:27:36 +0200 */ Index: libtommath/bn_mp_mod_2d.c ================================================================== --- libtommath/bn_mp_mod_2d.c +++ libtommath/bn_mp_mod_2d.c @@ -48,8 +48,8 @@ mp_clamp (c); return MP_OKAY; } #endif -/* $Source$ */ -/* $Revision$ */ -/* $Date$ */ +/* ref: tag: v1.0.1, master */ +/* git commit: 5953f62e42b24af93748b1ee5e1d062e242c2546 */ +/* commit time: 2017-08-29 22:27:36 +0200 */ Index: libtommath/bn_mp_mod_d.c ================================================================== --- libtommath/bn_mp_mod_d.c +++ libtommath/bn_mp_mod_d.c @@ -20,8 +20,8 @@ { return mp_div_d(a, b, NULL, c); } #endif -/* $Source$ */ -/* $Revision$ */ -/* $Date$ */ +/* ref: tag: v1.0.1, master */ +/* git commit: 5953f62e42b24af93748b1ee5e1d062e242c2546 */ +/* commit time: 2017-08-29 22:27:36 +0200 */ Index: libtommath/bn_mp_montgomery_calc_normalization.c ================================================================== --- libtommath/bn_mp_montgomery_calc_normalization.c +++ libtommath/bn_mp_montgomery_calc_normalization.c @@ -52,8 +52,8 @@ return MP_OKAY; } #endif -/* $Source$ */ -/* $Revision$ */ -/* $Date$ */ +/* ref: tag: v1.0.1, master */ +/* git commit: 5953f62e42b24af93748b1ee5e1d062e242c2546 */ +/* commit time: 2017-08-29 22:27:36 +0200 */ Index: libtommath/bn_mp_montgomery_reduce.c ================================================================== --- libtommath/bn_mp_montgomery_reduce.c +++ libtommath/bn_mp_montgomery_reduce.c @@ -111,8 +111,8 @@ return MP_OKAY; } #endif -/* $Source$ */ -/* $Revision$ */ -/* $Date$ */ +/* ref: tag: v1.0.1, master */ +/* git commit: 5953f62e42b24af93748b1ee5e1d062e242c2546 */ +/* commit time: 2017-08-29 22:27:36 +0200 */ Index: libtommath/bn_mp_montgomery_setup.c ================================================================== --- libtommath/bn_mp_montgomery_setup.c +++ libtommath/bn_mp_montgomery_setup.c @@ -52,8 +52,8 @@ return MP_OKAY; } #endif -/* $Source$ */ -/* $Revision$ */ -/* $Date$ */ +/* ref: tag: v1.0.1, master */ +/* git commit: 5953f62e42b24af93748b1ee5e1d062e242c2546 */ +/* commit time: 2017-08-29 22:27:36 +0200 */ Index: libtommath/bn_mp_mul.c ================================================================== --- libtommath/bn_mp_mul.c +++ libtommath/bn_mp_mul.c @@ -60,8 +60,8 @@ c->sign = (c->used > 0) ? neg : MP_ZPOS; return res; } #endif -/* $Source$ */ -/* $Revision$ */ -/* $Date$ */ +/* ref: tag: v1.0.1, master */ +/* git commit: 5953f62e42b24af93748b1ee5e1d062e242c2546 */ +/* commit time: 2017-08-29 22:27:36 +0200 */ Index: libtommath/bn_mp_mul_2.c ================================================================== --- libtommath/bn_mp_mul_2.c +++ libtommath/bn_mp_mul_2.c @@ -75,8 +75,8 @@ b->sign = a->sign; return MP_OKAY; } #endif -/* $Source$ */ -/* $Revision$ */ -/* $Date$ */ +/* ref: tag: v1.0.1, master */ +/* git commit: 5953f62e42b24af93748b1ee5e1d062e242c2546 */ +/* commit time: 2017-08-29 22:27:36 +0200 */ Index: libtommath/bn_mp_mul_2d.c ================================================================== --- libtommath/bn_mp_mul_2d.c +++ libtommath/bn_mp_mul_2d.c @@ -78,8 +78,8 @@ mp_clamp (c); return MP_OKAY; } #endif -/* $Source$ */ -/* $Revision$ */ -/* $Date$ */ +/* ref: tag: v1.0.1, master */ +/* git commit: 5953f62e42b24af93748b1ee5e1d062e242c2546 */ +/* commit time: 2017-08-29 22:27:36 +0200 */ Index: libtommath/bn_mp_mul_d.c ================================================================== --- libtommath/bn_mp_mul_d.c +++ libtommath/bn_mp_mul_d.c @@ -72,8 +72,8 @@ return MP_OKAY; } #endif -/* $Source$ */ -/* $Revision$ */ -/* $Date$ */ +/* ref: tag: v1.0.1, master */ +/* git commit: 5953f62e42b24af93748b1ee5e1d062e242c2546 */ +/* commit time: 2017-08-29 22:27:36 +0200 */ Index: libtommath/bn_mp_mulmod.c ================================================================== --- libtommath/bn_mp_mulmod.c +++ libtommath/bn_mp_mulmod.c @@ -19,11 +19,11 @@ 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; } if ((res = mp_mul (a, b, &t)) != MP_OKAY) { mp_clear (&t); @@ -33,8 +33,8 @@ mp_clear (&t); return res; } #endif -/* $Source$ */ -/* $Revision$ */ -/* $Date$ */ +/* ref: tag: v1.0.1, master */ +/* git commit: 5953f62e42b24af93748b1ee5e1d062e242c2546 */ +/* commit time: 2017-08-29 22:27:36 +0200 */ Index: libtommath/bn_mp_n_root.c ================================================================== --- libtommath/bn_mp_n_root.c +++ libtommath/bn_mp_n_root.c @@ -23,8 +23,8 @@ return mp_n_root_ex(a, b, c, 0); } #endif -/* $Source$ */ -/* $Revision$ */ -/* $Date$ */ +/* ref: tag: v1.0.1, master */ +/* git commit: 5953f62e42b24af93748b1ee5e1d062e242c2546 */ +/* commit time: 2017-08-29 22:27:36 +0200 */ Index: libtommath/bn_mp_n_root_ex.c ================================================================== --- libtommath/bn_mp_n_root_ex.c +++ libtommath/bn_mp_n_root_ex.c @@ -125,8 +125,8 @@ LBL_T1:mp_clear (&t1); return res; } #endif -/* $Source$ */ -/* $Revision$ */ -/* $Date$ */ +/* ref: tag: v1.0.1, master */ +/* git commit: 5953f62e42b24af93748b1ee5e1d062e242c2546 */ +/* commit time: 2017-08-29 22:27:36 +0200 */ Index: libtommath/bn_mp_neg.c ================================================================== --- libtommath/bn_mp_neg.c +++ libtommath/bn_mp_neg.c @@ -33,8 +33,8 @@ return MP_OKAY; } #endif -/* $Source$ */ -/* $Revision$ */ -/* $Date$ */ +/* ref: tag: v1.0.1, master */ +/* git commit: 5953f62e42b24af93748b1ee5e1d062e242c2546 */ +/* commit time: 2017-08-29 22:27:36 +0200 */ Index: libtommath/bn_mp_or.c ================================================================== --- libtommath/bn_mp_or.c +++ libtommath/bn_mp_or.c @@ -43,8 +43,8 @@ mp_clear (&t); return MP_OKAY; } #endif -/* $Source$ */ -/* $Revision$ */ -/* $Date$ */ +/* ref: tag: v1.0.1, master */ +/* git commit: 5953f62e42b24af93748b1ee5e1d062e242c2546 */ +/* commit time: 2017-08-29 22:27:36 +0200 */ Index: libtommath/bn_mp_prime_fermat.c ================================================================== --- libtommath/bn_mp_prime_fermat.c +++ libtommath/bn_mp_prime_fermat.c @@ -55,8 +55,8 @@ LBL_T:mp_clear (&t); return err; } #endif -/* $Source$ */ -/* $Revision$ */ -/* $Date$ */ +/* ref: tag: v1.0.1, master */ +/* git commit: 5953f62e42b24af93748b1ee5e1d062e242c2546 */ +/* commit time: 2017-08-29 22:27:36 +0200 */ Index: libtommath/bn_mp_prime_is_divisible.c ================================================================== --- libtommath/bn_mp_prime_is_divisible.c +++ libtommath/bn_mp_prime_is_divisible.c @@ -43,8 +43,8 @@ return MP_OKAY; } #endif -/* $Source$ */ -/* $Revision$ */ -/* $Date$ */ +/* ref: tag: v1.0.1, master */ +/* git commit: 5953f62e42b24af93748b1ee5e1d062e242c2546 */ +/* commit time: 2017-08-29 22:27:36 +0200 */ Index: libtommath/bn_mp_prime_is_prime.c ================================================================== --- libtommath/bn_mp_prime_is_prime.c +++ libtommath/bn_mp_prime_is_prime.c @@ -76,8 +76,8 @@ LBL_B:mp_clear (&b); return err; } #endif -/* $Source$ */ -/* $Revision$ */ -/* $Date$ */ +/* ref: tag: v1.0.1, master */ +/* git commit: 5953f62e42b24af93748b1ee5e1d062e242c2546 */ +/* commit time: 2017-08-29 22:27:36 +0200 */ Index: libtommath/bn_mp_prime_miller_rabin.c ================================================================== --- libtommath/bn_mp_prime_miller_rabin.c +++ libtommath/bn_mp_prime_miller_rabin.c @@ -96,8 +96,8 @@ LBL_N1:mp_clear (&n1); return err; } #endif -/* $Source$ */ -/* $Revision$ */ -/* $Date$ */ +/* ref: tag: v1.0.1, master */ +/* git commit: 5953f62e42b24af93748b1ee5e1d062e242c2546 */ +/* commit time: 2017-08-29 22:27:36 +0200 */ Index: libtommath/bn_mp_prime_next_prime.c ================================================================== --- libtommath/bn_mp_prime_next_prime.c +++ libtommath/bn_mp_prime_next_prime.c @@ -163,8 +163,8 @@ return err; } #endif -/* $Source$ */ -/* $Revision$ */ -/* $Date$ */ +/* ref: tag: v1.0.1, master */ +/* git commit: 5953f62e42b24af93748b1ee5e1d062e242c2546 */ +/* commit time: 2017-08-29 22:27:36 +0200 */ Index: libtommath/bn_mp_prime_rabin_miller_trials.c ================================================================== --- libtommath/bn_mp_prime_rabin_miller_trials.c +++ libtommath/bn_mp_prime_rabin_miller_trials.c @@ -45,8 +45,8 @@ } #endif -/* $Source$ */ -/* $Revision$ */ -/* $Date$ */ +/* ref: tag: v1.0.1, master */ +/* git commit: 5953f62e42b24af93748b1ee5e1d062e242c2546 */ +/* commit time: 2017-08-29 22:27:36 +0200 */ Index: libtommath/bn_mp_prime_random_ex.c ================================================================== --- libtommath/bn_mp_prime_random_ex.c +++ libtommath/bn_mp_prime_random_ex.c @@ -117,8 +117,8 @@ } #endif -/* $Source$ */ -/* $Revision$ */ -/* $Date$ */ +/* ref: tag: v1.0.1, master */ +/* git commit: 5953f62e42b24af93748b1ee5e1d062e242c2546 */ +/* commit time: 2017-08-29 22:27:36 +0200 */ Index: libtommath/bn_mp_radix_size.c ================================================================== --- libtommath/bn_mp_radix_size.c +++ libtommath/bn_mp_radix_size.c @@ -71,8 +71,8 @@ return MP_OKAY; } #endif -/* $Source$ */ -/* $Revision$ */ -/* $Date$ */ +/* ref: tag: v1.0.1, master */ +/* git commit: 5953f62e42b24af93748b1ee5e1d062e242c2546 */ +/* commit time: 2017-08-29 22:27:36 +0200 */ Index: libtommath/bn_mp_radix_smap.c ================================================================== --- libtommath/bn_mp_radix_smap.c +++ libtommath/bn_mp_radix_smap.c @@ -17,8 +17,8 @@ /* chars used in radix conversions */ const char *mp_s_rmap = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz+/"; #endif -/* $Source$ */ -/* $Revision$ */ -/* $Date$ */ +/* ref: tag: v1.0.1, master */ +/* git commit: 5953f62e42b24af93748b1ee5e1d062e242c2546 */ +/* commit time: 2017-08-29 22:27:36 +0200 */ Index: libtommath/bn_mp_rand.c ================================================================== --- libtommath/bn_mp_rand.c +++ libtommath/bn_mp_rand.c @@ -12,12 +12,37 @@ * The library is free for all purposes without any express * guarantee it works. * * 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) { int res; mp_digit d; @@ -27,11 +52,11 @@ return MP_OKAY; } /* 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) { return res; } @@ -39,17 +64,17 @@ while (--digits > 0) { if ((res = mp_lshd (a, 1)) != MP_OKAY) { 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; } } return MP_OKAY; } #endif -/* $Source$ */ -/* $Revision$ */ -/* $Date$ */ +/* ref: tag: v1.0.1, master */ +/* git commit: 5953f62e42b24af93748b1ee5e1d062e242c2546 */ +/* commit time: 2017-08-29 22:27:36 +0200 */ Index: libtommath/bn_mp_read_radix.c ================================================================== --- libtommath/bn_mp_read_radix.c +++ libtommath/bn_mp_read_radix.c @@ -85,8 +85,8 @@ } return MP_OKAY; } #endif -/* $Source$ */ -/* $Revision$ */ -/* $Date$ */ +/* ref: tag: v1.0.1, master */ +/* git commit: 5953f62e42b24af93748b1ee5e1d062e242c2546 */ +/* commit time: 2017-08-29 22:27:36 +0200 */ Index: libtommath/bn_mp_read_signed_bin.c ================================================================== --- libtommath/bn_mp_read_signed_bin.c +++ libtommath/bn_mp_read_signed_bin.c @@ -34,8 +34,8 @@ return MP_OKAY; } #endif -/* $Source$ */ -/* $Revision$ */ -/* $Date$ */ +/* ref: tag: v1.0.1, master */ +/* git commit: 5953f62e42b24af93748b1ee5e1d062e242c2546 */ +/* commit time: 2017-08-29 22:27:36 +0200 */ Index: libtommath/bn_mp_read_unsigned_bin.c ================================================================== --- libtommath/bn_mp_read_unsigned_bin.c +++ libtommath/bn_mp_read_unsigned_bin.c @@ -48,8 +48,8 @@ mp_clamp (a); return MP_OKAY; } #endif -/* $Source$ */ -/* $Revision$ */ -/* $Date$ */ +/* ref: tag: v1.0.1, master */ +/* git commit: 5953f62e42b24af93748b1ee5e1d062e242c2546 */ +/* commit time: 2017-08-29 22:27:36 +0200 */ Index: libtommath/bn_mp_reduce.c ================================================================== --- libtommath/bn_mp_reduce.c +++ libtommath/bn_mp_reduce.c @@ -93,8 +93,8 @@ return res; } #endif -/* $Source$ */ -/* $Revision$ */ -/* $Date$ */ +/* ref: tag: v1.0.1, master */ +/* git commit: 5953f62e42b24af93748b1ee5e1d062e242c2546 */ +/* commit time: 2017-08-29 22:27:36 +0200 */ Index: libtommath/bn_mp_reduce_2k.c ================================================================== --- libtommath/bn_mp_reduce_2k.c +++ libtommath/bn_mp_reduce_2k.c @@ -56,8 +56,8 @@ return res; } #endif -/* $Source$ */ -/* $Revision$ */ -/* $Date$ */ +/* ref: tag: v1.0.1, master */ +/* git commit: 5953f62e42b24af93748b1ee5e1d062e242c2546 */ +/* commit time: 2017-08-29 22:27:36 +0200 */ Index: libtommath/bn_mp_reduce_2k_l.c ================================================================== --- libtommath/bn_mp_reduce_2k_l.c +++ libtommath/bn_mp_reduce_2k_l.c @@ -57,8 +57,8 @@ return res; } #endif -/* $Source$ */ -/* $Revision$ */ -/* $Date$ */ +/* ref: tag: v1.0.1, master */ +/* git commit: 5953f62e42b24af93748b1ee5e1d062e242c2546 */ +/* commit time: 2017-08-29 22:27:36 +0200 */ Index: libtommath/bn_mp_reduce_2k_setup.c ================================================================== --- libtommath/bn_mp_reduce_2k_setup.c +++ libtommath/bn_mp_reduce_2k_setup.c @@ -40,8 +40,8 @@ mp_clear(&tmp); return MP_OKAY; } #endif -/* $Source$ */ -/* $Revision$ */ -/* $Date$ */ +/* ref: tag: v1.0.1, master */ +/* git commit: 5953f62e42b24af93748b1ee5e1d062e242c2546 */ +/* commit time: 2017-08-29 22:27:36 +0200 */ Index: libtommath/bn_mp_reduce_2k_setup_l.c ================================================================== --- libtommath/bn_mp_reduce_2k_setup_l.c +++ libtommath/bn_mp_reduce_2k_setup_l.c @@ -37,8 +37,8 @@ mp_clear(&tmp); return res; } #endif -/* $Source$ */ -/* $Revision$ */ -/* $Date$ */ +/* ref: tag: v1.0.1, master */ +/* git commit: 5953f62e42b24af93748b1ee5e1d062e242c2546 */ +/* commit time: 2017-08-29 22:27:36 +0200 */ Index: libtommath/bn_mp_reduce_is_2k.c ================================================================== --- libtommath/bn_mp_reduce_is_2k.c +++ libtommath/bn_mp_reduce_is_2k.c @@ -45,8 +45,8 @@ return MP_YES; } #endif -/* $Source$ */ -/* $Revision$ */ -/* $Date$ */ +/* ref: tag: v1.0.1, master */ +/* git commit: 5953f62e42b24af93748b1ee5e1d062e242c2546 */ +/* commit time: 2017-08-29 22:27:36 +0200 */ Index: libtommath/bn_mp_reduce_is_2k_l.c ================================================================== --- libtommath/bn_mp_reduce_is_2k_l.c +++ libtommath/bn_mp_reduce_is_2k_l.c @@ -37,8 +37,8 @@ return MP_NO; } #endif -/* $Source$ */ -/* $Revision$ */ -/* $Date$ */ +/* ref: tag: v1.0.1, master */ +/* git commit: 5953f62e42b24af93748b1ee5e1d062e242c2546 */ +/* commit time: 2017-08-29 22:27:36 +0200 */ Index: libtommath/bn_mp_reduce_setup.c ================================================================== --- libtommath/bn_mp_reduce_setup.c +++ libtommath/bn_mp_reduce_setup.c @@ -27,8 +27,8 @@ } return mp_div (a, b, a, NULL); } #endif -/* $Source$ */ -/* $Revision$ */ -/* $Date$ */ +/* ref: tag: v1.0.1, master */ +/* git commit: 5953f62e42b24af93748b1ee5e1d062e242c2546 */ +/* commit time: 2017-08-29 22:27:36 +0200 */ Index: libtommath/bn_mp_rshd.c ================================================================== --- libtommath/bn_mp_rshd.c +++ libtommath/bn_mp_rshd.c @@ -65,8 +65,8 @@ /* remove excess digits */ a->used -= b; } #endif -/* $Source$ */ -/* $Revision$ */ -/* $Date$ */ +/* ref: tag: v1.0.1, master */ +/* git commit: 5953f62e42b24af93748b1ee5e1d062e242c2546 */ +/* commit time: 2017-08-29 22:27:36 +0200 */ Index: libtommath/bn_mp_set.c ================================================================== --- libtommath/bn_mp_set.c +++ libtommath/bn_mp_set.c @@ -22,8 +22,8 @@ a->dp[0] = b & MP_MASK; a->used = (a->dp[0] != 0) ? 1 : 0; } #endif -/* $Source$ */ -/* $Revision$ */ -/* $Date$ */ +/* ref: tag: v1.0.1, master */ +/* git commit: 5953f62e42b24af93748b1ee5e1d062e242c2546 */ +/* commit time: 2017-08-29 22:27:36 +0200 */ Index: libtommath/bn_mp_set_int.c ================================================================== --- libtommath/bn_mp_set_int.c +++ libtommath/bn_mp_set_int.c @@ -41,8 +41,8 @@ mp_clamp (a); return MP_OKAY; } #endif -/* $Source$ */ -/* $Revision$ */ -/* $Date$ */ +/* ref: tag: v1.0.1, master */ +/* git commit: 5953f62e42b24af93748b1ee5e1d062e242c2546 */ +/* commit time: 2017-08-29 22:27:36 +0200 */ Index: libtommath/bn_mp_set_long.c ================================================================== --- libtommath/bn_mp_set_long.c +++ libtommath/bn_mp_set_long.c @@ -17,8 +17,8 @@ /* set a platform dependent unsigned long int */ MP_SET_XLONG(mp_set_long, unsigned long) #endif -/* $Source$ */ -/* $Revision$ */ -/* $Date$ */ +/* ref: tag: v1.0.1, master */ +/* git commit: 5953f62e42b24af93748b1ee5e1d062e242c2546 */ +/* commit time: 2017-08-29 22:27:36 +0200 */ Index: libtommath/bn_mp_set_long_long.c ================================================================== --- libtommath/bn_mp_set_long_long.c +++ libtommath/bn_mp_set_long_long.c @@ -17,8 +17,8 @@ /* set a platform dependent unsigned long long int */ MP_SET_XLONG(mp_set_long_long, unsigned long long) #endif -/* $Source$ */ -/* $Revision$ */ -/* $Date$ */ +/* ref: tag: v1.0.1, master */ +/* git commit: 5953f62e42b24af93748b1ee5e1d062e242c2546 */ +/* commit time: 2017-08-29 22:27:36 +0200 */ Index: libtommath/bn_mp_shrink.c ================================================================== --- libtommath/bn_mp_shrink.c +++ libtommath/bn_mp_shrink.c @@ -34,8 +34,8 @@ } return MP_OKAY; } #endif -/* $Source$ */ -/* $Revision$ */ -/* $Date$ */ +/* ref: tag: v1.0.1, master */ +/* git commit: 5953f62e42b24af93748b1ee5e1d062e242c2546 */ +/* commit time: 2017-08-29 22:27:36 +0200 */ Index: libtommath/bn_mp_signed_bin_size.c ================================================================== --- libtommath/bn_mp_signed_bin_size.c +++ libtommath/bn_mp_signed_bin_size.c @@ -20,8 +20,8 @@ { return 1 + mp_unsigned_bin_size (a); } #endif -/* $Source$ */ -/* $Revision$ */ -/* $Date$ */ +/* ref: tag: v1.0.1, master */ +/* git commit: 5953f62e42b24af93748b1ee5e1d062e242c2546 */ +/* commit time: 2017-08-29 22:27:36 +0200 */ Index: libtommath/bn_mp_sqr.c ================================================================== --- libtommath/bn_mp_sqr.c +++ libtommath/bn_mp_sqr.c @@ -53,8 +53,8 @@ b->sign = MP_ZPOS; return res; } #endif -/* $Source$ */ -/* $Revision$ */ -/* $Date$ */ +/* ref: tag: v1.0.1, master */ +/* git commit: 5953f62e42b24af93748b1ee5e1d062e242c2546 */ +/* commit time: 2017-08-29 22:27:36 +0200 */ Index: libtommath/bn_mp_sqrmod.c ================================================================== --- libtommath/bn_mp_sqrmod.c +++ libtommath/bn_mp_sqrmod.c @@ -34,8 +34,8 @@ mp_clear (&t); return res; } #endif -/* $Source$ */ -/* $Revision$ */ -/* $Date$ */ +/* ref: tag: v1.0.1, master */ +/* git commit: 5953f62e42b24af93748b1ee5e1d062e242c2546 */ +/* commit time: 2017-08-29 22:27:36 +0200 */ Index: libtommath/bn_mp_sqrt.c ================================================================== --- libtommath/bn_mp_sqrt.c +++ libtommath/bn_mp_sqrt.c @@ -138,8 +138,8 @@ return res; } #endif -/* $Source$ */ -/* $Revision$ */ -/* $Date$ */ +/* ref: tag: v1.0.1, master */ +/* git commit: 5953f62e42b24af93748b1ee5e1d062e242c2546 */ +/* commit time: 2017-08-29 22:27:36 +0200 */ Index: libtommath/bn_mp_sub.c ================================================================== --- libtommath/bn_mp_sub.c +++ libtommath/bn_mp_sub.c @@ -52,8 +52,8 @@ return res; } #endif -/* $Source$ */ -/* $Revision$ */ -/* $Date$ */ +/* ref: tag: v1.0.1, master */ +/* git commit: 5953f62e42b24af93748b1ee5e1d062e242c2546 */ +/* commit time: 2017-08-29 22:27:36 +0200 */ Index: libtommath/bn_mp_sub_d.c ================================================================== --- libtommath/bn_mp_sub_d.c +++ libtommath/bn_mp_sub_d.c @@ -86,8 +86,8 @@ return MP_OKAY; } #endif -/* $Source$ */ -/* $Revision$ */ -/* $Date$ */ +/* ref: tag: v1.0.1, master */ +/* git commit: 5953f62e42b24af93748b1ee5e1d062e242c2546 */ +/* commit time: 2017-08-29 22:27:36 +0200 */ Index: libtommath/bn_mp_submod.c ================================================================== --- libtommath/bn_mp_submod.c +++ libtommath/bn_mp_submod.c @@ -35,8 +35,8 @@ mp_clear (&t); return res; } #endif -/* $Source$ */ -/* $Revision$ */ -/* $Date$ */ +/* ref: tag: v1.0.1, master */ +/* git commit: 5953f62e42b24af93748b1ee5e1d062e242c2546 */ +/* commit time: 2017-08-29 22:27:36 +0200 */ Index: libtommath/bn_mp_to_signed_bin.c ================================================================== --- libtommath/bn_mp_to_signed_bin.c +++ libtommath/bn_mp_to_signed_bin.c @@ -26,8 +26,8 @@ b[0] = (a->sign == MP_ZPOS) ? (unsigned char)0 : (unsigned char)1; return MP_OKAY; } #endif -/* $Source$ */ -/* $Revision$ */ -/* $Date$ */ +/* ref: tag: v1.0.1, master */ +/* git commit: 5953f62e42b24af93748b1ee5e1d062e242c2546 */ +/* commit time: 2017-08-29 22:27:36 +0200 */ Index: libtommath/bn_mp_to_signed_bin_n.c ================================================================== --- libtommath/bn_mp_to_signed_bin_n.c +++ libtommath/bn_mp_to_signed_bin_n.c @@ -24,8 +24,8 @@ *outlen = mp_signed_bin_size(a); return mp_to_signed_bin(a, b); } #endif -/* $Source$ */ -/* $Revision$ */ -/* $Date$ */ +/* ref: tag: v1.0.1, master */ +/* git commit: 5953f62e42b24af93748b1ee5e1d062e242c2546 */ +/* commit time: 2017-08-29 22:27:36 +0200 */ Index: libtommath/bn_mp_to_unsigned_bin.c ================================================================== --- libtommath/bn_mp_to_unsigned_bin.c +++ libtommath/bn_mp_to_unsigned_bin.c @@ -41,8 +41,8 @@ mp_clear (&t); return MP_OKAY; } #endif -/* $Source$ */ -/* $Revision$ */ -/* $Date$ */ +/* ref: tag: v1.0.1, master */ +/* git commit: 5953f62e42b24af93748b1ee5e1d062e242c2546 */ +/* commit time: 2017-08-29 22:27:36 +0200 */ Index: libtommath/bn_mp_to_unsigned_bin_n.c ================================================================== --- libtommath/bn_mp_to_unsigned_bin_n.c +++ libtommath/bn_mp_to_unsigned_bin_n.c @@ -24,8 +24,8 @@ *outlen = mp_unsigned_bin_size(a); return mp_to_unsigned_bin(a, b); } #endif -/* $Source$ */ -/* $Revision$ */ -/* $Date$ */ +/* ref: tag: v1.0.1, master */ +/* git commit: 5953f62e42b24af93748b1ee5e1d062e242c2546 */ +/* commit time: 2017-08-29 22:27:36 +0200 */ Index: libtommath/bn_mp_toom_mul.c ================================================================== --- libtommath/bn_mp_toom_mul.c +++ libtommath/bn_mp_toom_mul.c @@ -279,8 +279,8 @@ return res; } #endif -/* $Source$ */ -/* $Revision$ */ -/* $Date$ */ +/* ref: tag: v1.0.1, master */ +/* git commit: 5953f62e42b24af93748b1ee5e1d062e242c2546 */ +/* commit time: 2017-08-29 22:27:36 +0200 */ Index: libtommath/bn_mp_toom_sqr.c ================================================================== --- libtommath/bn_mp_toom_sqr.c +++ libtommath/bn_mp_toom_sqr.c @@ -221,8 +221,8 @@ return res; } #endif -/* $Source$ */ -/* $Revision$ */ -/* $Date$ */ +/* ref: tag: v1.0.1, master */ +/* git commit: 5953f62e42b24af93748b1ee5e1d062e242c2546 */ +/* commit time: 2017-08-29 22:27:36 +0200 */ Index: libtommath/bn_mp_toradix.c ================================================================== --- libtommath/bn_mp_toradix.c +++ libtommath/bn_mp_toradix.c @@ -68,8 +68,8 @@ return MP_OKAY; } #endif -/* $Source$ */ -/* $Revision$ */ -/* $Date$ */ +/* ref: tag: v1.0.1, master */ +/* git commit: 5953f62e42b24af93748b1ee5e1d062e242c2546 */ +/* commit time: 2017-08-29 22:27:36 +0200 */ Index: libtommath/bn_mp_toradix_n.c ================================================================== --- libtommath/bn_mp_toradix_n.c +++ libtommath/bn_mp_toradix_n.c @@ -81,8 +81,8 @@ return MP_OKAY; } #endif -/* $Source$ */ -/* $Revision$ */ -/* $Date$ */ +/* ref: tag: v1.0.1, master */ +/* git commit: 5953f62e42b24af93748b1ee5e1d062e242c2546 */ +/* commit time: 2017-08-29 22:27:36 +0200 */ Index: libtommath/bn_mp_unsigned_bin_size.c ================================================================== --- libtommath/bn_mp_unsigned_bin_size.c +++ libtommath/bn_mp_unsigned_bin_size.c @@ -21,8 +21,8 @@ int size = mp_count_bits (a); return (size / 8) + (((size & 7) != 0) ? 1 : 0); } #endif -/* $Source$ */ -/* $Revision$ */ -/* $Date$ */ +/* ref: tag: v1.0.1, master */ +/* git commit: 5953f62e42b24af93748b1ee5e1d062e242c2546 */ +/* commit time: 2017-08-29 22:27:36 +0200 */ Index: libtommath/bn_mp_xor.c ================================================================== --- libtommath/bn_mp_xor.c +++ libtommath/bn_mp_xor.c @@ -44,8 +44,8 @@ mp_clear (&t); return MP_OKAY; } #endif -/* $Source$ */ -/* $Revision$ */ -/* $Date$ */ +/* ref: tag: v1.0.1, master */ +/* git commit: 5953f62e42b24af93748b1ee5e1d062e242c2546 */ +/* commit time: 2017-08-29 22:27:36 +0200 */ Index: libtommath/bn_mp_zero.c ================================================================== --- libtommath/bn_mp_zero.c +++ libtommath/bn_mp_zero.c @@ -29,8 +29,8 @@ *tmp++ = 0; } } #endif -/* $Source$ */ -/* $Revision$ */ -/* $Date$ */ +/* ref: tag: v1.0.1, master */ +/* git commit: 5953f62e42b24af93748b1ee5e1d062e242c2546 */ +/* commit time: 2017-08-29 22:27:36 +0200 */ Index: libtommath/bn_prime_tab.c ================================================================== --- libtommath/bn_prime_tab.c +++ libtommath/bn_prime_tab.c @@ -54,8 +54,8 @@ 0x062B, 0x062F, 0x063D, 0x0641, 0x0647, 0x0649, 0x064D, 0x0653 #endif }; #endif -/* $Source$ */ -/* $Revision$ */ -/* $Date$ */ +/* ref: tag: v1.0.1, master */ +/* git commit: 5953f62e42b24af93748b1ee5e1d062e242c2546 */ +/* commit time: 2017-08-29 22:27:36 +0200 */ Index: libtommath/bn_reverse.c ================================================================== --- libtommath/bn_reverse.c +++ libtommath/bn_reverse.c @@ -32,8 +32,8 @@ --iy; } } #endif -/* $Source$ */ -/* $Revision$ */ -/* $Date$ */ +/* ref: tag: v1.0.1, master */ +/* git commit: 5953f62e42b24af93748b1ee5e1d062e242c2546 */ +/* commit time: 2017-08-29 22:27:36 +0200 */ Index: libtommath/bn_s_mp_add.c ================================================================== --- libtommath/bn_s_mp_add.c +++ libtommath/bn_s_mp_add.c @@ -102,8 +102,8 @@ mp_clamp (c); return MP_OKAY; } #endif -/* $Source$ */ -/* $Revision$ */ -/* $Date$ */ +/* ref: tag: v1.0.1, master */ +/* git commit: 5953f62e42b24af93748b1ee5e1d062e242c2546 */ +/* commit time: 2017-08-29 22:27:36 +0200 */ Index: libtommath/bn_s_mp_exptmod.c ================================================================== --- libtommath/bn_s_mp_exptmod.c +++ libtommath/bn_s_mp_exptmod.c @@ -245,8 +245,8 @@ } return err; } #endif -/* $Source$ */ -/* $Revision$ */ -/* $Date$ */ +/* ref: tag: v1.0.1, master */ +/* git commit: 5953f62e42b24af93748b1ee5e1d062e242c2546 */ +/* commit time: 2017-08-29 22:27:36 +0200 */ Index: libtommath/bn_s_mp_mul_digs.c ================================================================== --- libtommath/bn_s_mp_mul_digs.c +++ libtommath/bn_s_mp_mul_digs.c @@ -83,8 +83,8 @@ mp_clear (&t); return MP_OKAY; } #endif -/* $Source$ */ -/* $Revision$ */ -/* $Date$ */ +/* ref: tag: v1.0.1, master */ +/* git commit: 5953f62e42b24af93748b1ee5e1d062e242c2546 */ +/* commit time: 2017-08-29 22:27:36 +0200 */ Index: libtommath/bn_s_mp_mul_high_digs.c ================================================================== --- libtommath/bn_s_mp_mul_high_digs.c +++ libtommath/bn_s_mp_mul_high_digs.c @@ -74,8 +74,8 @@ mp_clear (&t); return MP_OKAY; } #endif -/* $Source$ */ -/* $Revision$ */ -/* $Date$ */ +/* ref: tag: v1.0.1, master */ +/* git commit: 5953f62e42b24af93748b1ee5e1d062e242c2546 */ +/* commit time: 2017-08-29 22:27:36 +0200 */ Index: libtommath/bn_s_mp_sqr.c ================================================================== --- libtommath/bn_s_mp_sqr.c +++ libtommath/bn_s_mp_sqr.c @@ -77,8 +77,8 @@ mp_clear (&t); return MP_OKAY; } #endif -/* $Source$ */ -/* $Revision$ */ -/* $Date$ */ +/* ref: tag: v1.0.1, master */ +/* git commit: 5953f62e42b24af93748b1ee5e1d062e242c2546 */ +/* commit time: 2017-08-29 22:27:36 +0200 */ Index: libtommath/bn_s_mp_sub.c ================================================================== --- libtommath/bn_s_mp_sub.c +++ libtommath/bn_s_mp_sub.c @@ -82,8 +82,8 @@ return MP_OKAY; } #endif -/* $Source$ */ -/* $Revision$ */ -/* $Date$ */ +/* ref: tag: v1.0.1, master */ +/* git commit: 5953f62e42b24af93748b1ee5e1d062e242c2546 */ +/* commit time: 2017-08-29 22:27:36 +0200 */ Index: libtommath/bncore.c ================================================================== --- libtommath/bncore.c +++ libtommath/bncore.c @@ -29,8 +29,8 @@ TOOM_MUL_CUTOFF = 350, /* no optimal values of these are known yet so set em high */ TOOM_SQR_CUTOFF = 400; #endif -/* $Source$ */ -/* $Revision$ */ -/* $Date$ */ +/* ref: tag: v1.0.1, master */ +/* git commit: 5953f62e42b24af93748b1ee5e1d062e242c2546 */ +/* commit time: 2017-08-29 22:27:36 +0200 */ Index: libtommath/tommath.h ================================================================== --- libtommath/tommath.h +++ libtommath/tommath.h @@ -25,11 +25,16 @@ #ifdef __cplusplus 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 #endif @@ -55,15 +60,10 @@ #ifdef DIGIT_BIT #error You must not define DIGIT_BIT when using MP_16BIT #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 ulong64 mp_digit; #if defined(_WIN32) typedef unsigned __int128 mp_word; #elif defined(__GNUC__) typedef unsigned long mp_word __attribute__ ((mode(TI))); @@ -76,15 +76,10 @@ #define DIGIT_BIT 60 #else /* 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 ulong64 mp_word; #ifdef MP_31BIT /* this is an extension that uses 31-bit digits */ @@ -102,20 +97,20 @@ typedef uint_least32_t mp_min_u32; #else 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 -#endif - -/* use arc4random on platforms that support it */ -#ifdef MP_USE_ALT_RAND #define MP_GEN_RANDOM() arc4random() -#else + #define MP_GEN_RANDOM_MAX 0xffffffff +#endif + +/* 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 #define MP_MASK ((((mp_digit)1)<<((mp_digit)DIGIT_BIT))-((mp_digit)1)) #define MP_DIGIT_MAX MP_MASK @@ -568,8 +563,8 @@ #endif #endif -/* $Source$ */ -/* $Revision$ */ -/* $Date$ */ +/* ref: tag: v1.0.1, master */ +/* git commit: 5953f62e42b24af93748b1ee5e1d062e242c2546 */ +/* commit time: 2017-08-29 22:27:36 +0200 */ Index: libtommath/tommath_class.h ================================================================== --- libtommath/tommath_class.h +++ libtommath/tommath_class.h @@ -280,16 +280,13 @@ #endif #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) #define BN_MP_INIT_SIZE_C #define BN_MP_CLAMP_C @@ -357,11 +354,11 @@ #define BN_MP_EXPTMOD_FAST_C #endif #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 #define BN_MP_MONTGOMERY_REDUCE_C #define BN_MP_DR_SETUP_C @@ -439,10 +436,11 @@ #endif #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) #define BN_MP_ERR_C #define BN_MP_INIT_C @@ -464,10 +462,11 @@ #endif #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 #if defined(BN_MP_INVMOD_SLOW_C) @@ -498,10 +497,11 @@ #define BN_MP_CMP_MAG_C #define BN_MP_CLEAR_C #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 #define BN_MP_CNT_LSB_C #define BN_MP_DIV_2D_C @@ -544,11 +544,11 @@ #define BN_MP_GROW_C #define BN_MP_RSHD_C #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 #define BN_MP_EXCH_C #define BN_MP_ADD_C @@ -608,11 +608,11 @@ #define BN_MP_GROW_C #define BN_MP_CLAMP_C #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 #endif Index: libtommath/tommath_private.h ================================================================== --- libtommath/tommath_private.h +++ libtommath/tommath_private.h @@ -17,15 +17,15 @@ #include #include #ifndef MIN -#define MIN(x,y) (((x) < (y)) ? (x) : (y)) + #define MIN(x,y) (((x) < (y)) ? (x) : (y)) #endif #ifndef MAX -#define MAX(x,y) (((x) > (y)) ? (x) : (y)) + #define MAX(x,y) (((x) > (y)) ? (x) : (y)) #endif #ifdef __cplusplus extern "C" { @@ -118,8 +118,8 @@ #endif #endif -/* $Source$ */ -/* $Revision$ */ -/* $Date$ */ +/* ref: tag: v1.0.1, master */ +/* git commit: 5953f62e42b24af93748b1ee5e1d062e242c2546 */ +/* commit time: 2017-08-29 22:27:36 +0200 */ Index: libtommath/tommath_superclass.h ================================================================== --- libtommath/tommath_superclass.h +++ libtommath/tommath_superclass.h @@ -69,8 +69,8 @@ #undef BN_MP_MONTGOMERY_REDUCE_C #endif #endif -/* $Source$ */ -/* $Revision$ */ -/* $Date$ */ +/* ref: tag: v1.0.1, master */ +/* git commit: 5953f62e42b24af93748b1ee5e1d062e242c2546 */ +/* commit time: 2017-08-29 22:27:36 +0200 */ Index: tools/fix_tommath_h.tcl ================================================================== --- tools/fix_tommath_h.tcl +++ tools/fix_tommath_h.tcl @@ -20,11 +20,10 @@ if {!$eat_semi && !$eat_endif} { switch -regexp -- $line { {#define BN_H_} { puts $line puts {} - puts "\#include \"tclInt.h\"" puts "\#include \"tclTomMathDecls.h\"" puts "\#ifndef MODULE_SCOPE" puts "\#define MODULE_SCOPE extern" puts "\#endif" } @@ -71,14 +70,10 @@ {define heap macros} { puts $line puts "\#if 0 /* these are macros in tclTomMathDecls.h */" set eat_endif 1 } - {__x86_64__} { - puts "[string map {__x86_64__ NEVER} $line]\ - /* 128-bit ints fail in too many places */" - } {#include} { # remove all includes } default { puts $line