summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--doc/CrtObjCmd.32
-rw-r--r--generic/tclOO.c2
-rw-r--r--generic/tclUtil.c2
-rw-r--r--libtommath/README.md6
-rw-r--r--libtommath/bn_error.c4
-rw-r--r--libtommath/bn_fast_mp_invmod.c12
-rw-r--r--libtommath/bn_fast_mp_montgomery_reduce.c4
-rw-r--r--libtommath/bn_fast_s_mp_mul_digs.c4
-rw-r--r--libtommath/bn_fast_s_mp_mul_high_digs.c4
-rw-r--r--libtommath/bn_fast_s_mp_sqr.c4
-rw-r--r--libtommath/bn_mp_2expt.c4
-rw-r--r--libtommath/bn_mp_abs.c4
-rw-r--r--libtommath/bn_mp_add.c4
-rw-r--r--libtommath/bn_mp_add_d.c4
-rw-r--r--libtommath/bn_mp_addmod.c4
-rw-r--r--libtommath/bn_mp_and.c4
-rw-r--r--libtommath/bn_mp_clamp.c4
-rw-r--r--libtommath/bn_mp_clear.c4
-rw-r--r--libtommath/bn_mp_clear_multi.c4
-rw-r--r--libtommath/bn_mp_cmp.c4
-rw-r--r--libtommath/bn_mp_cmp_d.c4
-rw-r--r--libtommath/bn_mp_cmp_mag.c4
-rw-r--r--libtommath/bn_mp_cnt_lsb.c4
-rw-r--r--libtommath/bn_mp_complement.c26
-rw-r--r--libtommath/bn_mp_copy.c4
-rw-r--r--libtommath/bn_mp_count_bits.c4
-rw-r--r--libtommath/bn_mp_div.c4
-rw-r--r--libtommath/bn_mp_div_2.c4
-rw-r--r--libtommath/bn_mp_div_2d.c4
-rw-r--r--libtommath/bn_mp_div_3.c4
-rw-r--r--libtommath/bn_mp_div_d.c4
-rw-r--r--libtommath/bn_mp_dr_is_modulus.c4
-rw-r--r--libtommath/bn_mp_dr_reduce.c4
-rw-r--r--libtommath/bn_mp_dr_setup.c4
-rw-r--r--libtommath/bn_mp_exch.c4
-rw-r--r--libtommath/bn_mp_export.c4
-rw-r--r--libtommath/bn_mp_expt_d.c4
-rw-r--r--libtommath/bn_mp_expt_d_ex.c4
-rw-r--r--libtommath/bn_mp_exptmod.c4
-rw-r--r--libtommath/bn_mp_exptmod_fast.c4
-rw-r--r--libtommath/bn_mp_exteuclid.c4
-rw-r--r--libtommath/bn_mp_fread.c4
-rw-r--r--libtommath/bn_mp_fwrite.c4
-rw-r--r--libtommath/bn_mp_gcd.c4
-rw-r--r--libtommath/bn_mp_get_int.c4
-rw-r--r--libtommath/bn_mp_get_long.c4
-rw-r--r--libtommath/bn_mp_get_long_long.c4
-rw-r--r--libtommath/bn_mp_grow.c4
-rw-r--r--libtommath/bn_mp_import.c4
-rw-r--r--libtommath/bn_mp_init.c4
-rw-r--r--libtommath/bn_mp_init_copy.c4
-rw-r--r--libtommath/bn_mp_init_multi.c4
-rw-r--r--libtommath/bn_mp_init_set.c4
-rw-r--r--libtommath/bn_mp_init_set_int.c4
-rw-r--r--libtommath/bn_mp_init_size.c4
-rw-r--r--libtommath/bn_mp_invmod.c4
-rw-r--r--libtommath/bn_mp_invmod_slow.c4
-rw-r--r--libtommath/bn_mp_is_square.c28
-rw-r--r--libtommath/bn_mp_jacobi.c4
-rw-r--r--libtommath/bn_mp_karatsuba_mul.c8
-rw-r--r--libtommath/bn_mp_karatsuba_sqr.c8
-rw-r--r--libtommath/bn_mp_lcm.c4
-rw-r--r--libtommath/bn_mp_lshd.c4
-rw-r--r--libtommath/bn_mp_mod.c4
-rw-r--r--libtommath/bn_mp_mod_2d.c4
-rw-r--r--libtommath/bn_mp_mod_d.c4
-rw-r--r--libtommath/bn_mp_montgomery_calc_normalization.c4
-rw-r--r--libtommath/bn_mp_montgomery_reduce.c4
-rw-r--r--libtommath/bn_mp_montgomery_setup.c4
-rw-r--r--libtommath/bn_mp_mul.c4
-rw-r--r--libtommath/bn_mp_mul_2.c4
-rw-r--r--libtommath/bn_mp_mul_2d.c4
-rw-r--r--libtommath/bn_mp_mul_d.c4
-rw-r--r--libtommath/bn_mp_mulmod.c4
-rw-r--r--libtommath/bn_mp_n_root.c4
-rw-r--r--libtommath/bn_mp_n_root_ex.c4
-rw-r--r--libtommath/bn_mp_neg.c4
-rw-r--r--libtommath/bn_mp_or.c4
-rw-r--r--libtommath/bn_mp_prime_fermat.c4
-rw-r--r--libtommath/bn_mp_prime_is_divisible.c4
-rw-r--r--libtommath/bn_mp_prime_is_prime.c4
-rw-r--r--libtommath/bn_mp_prime_miller_rabin.c4
-rw-r--r--libtommath/bn_mp_prime_next_prime.c4
-rw-r--r--libtommath/bn_mp_prime_rabin_miller_trials.c4
-rw-r--r--libtommath/bn_mp_prime_random_ex.c4
-rw-r--r--libtommath/bn_mp_radix_size.c4
-rw-r--r--libtommath/bn_mp_radix_smap.c28
-rw-r--r--libtommath/bn_mp_rand.c190
-rw-r--r--libtommath/bn_mp_read_radix.c4
-rw-r--r--libtommath/bn_mp_read_signed_bin.c4
-rw-r--r--libtommath/bn_mp_read_unsigned_bin.c4
-rw-r--r--libtommath/bn_mp_reduce.c4
-rw-r--r--libtommath/bn_mp_reduce_2k.c14
-rw-r--r--libtommath/bn_mp_reduce_2k_l.c14
-rw-r--r--libtommath/bn_mp_reduce_2k_setup.c4
-rw-r--r--libtommath/bn_mp_reduce_2k_setup_l.c10
-rw-r--r--libtommath/bn_mp_reduce_is_2k.c4
-rw-r--r--libtommath/bn_mp_reduce_is_2k_l.c4
-rw-r--r--libtommath/bn_mp_reduce_setup.c4
-rw-r--r--libtommath/bn_mp_rshd.c4
-rw-r--r--libtommath/bn_mp_set.c4
-rw-r--r--libtommath/bn_mp_set_int.c4
-rw-r--r--libtommath/bn_mp_set_long.c4
-rw-r--r--libtommath/bn_mp_set_long_long.c4
-rw-r--r--libtommath/bn_mp_shrink.c4
-rw-r--r--libtommath/bn_mp_signed_bin_size.c4
-rw-r--r--libtommath/bn_mp_sqr.c4
-rw-r--r--libtommath/bn_mp_sqrmod.c4
-rw-r--r--libtommath/bn_mp_sqrt.c22
-rw-r--r--libtommath/bn_mp_sqrtmod_prime.c2
-rw-r--r--libtommath/bn_mp_sub.c4
-rw-r--r--libtommath/bn_mp_sub_d.c4
-rw-r--r--libtommath/bn_mp_submod.c4
-rw-r--r--libtommath/bn_mp_tc_and.c89
-rw-r--r--libtommath/bn_mp_tc_div_2d.c36
-rw-r--r--libtommath/bn_mp_tc_or.c89
-rw-r--r--libtommath/bn_mp_tc_xor.c89
-rw-r--r--libtommath/bn_mp_to_signed_bin.c4
-rw-r--r--libtommath/bn_mp_to_signed_bin_n.c4
-rw-r--r--libtommath/bn_mp_to_unsigned_bin.c4
-rw-r--r--libtommath/bn_mp_to_unsigned_bin_n.c4
-rw-r--r--libtommath/bn_mp_toom_mul.c124
-rw-r--r--libtommath/bn_mp_toom_sqr.c98
-rw-r--r--libtommath/bn_mp_toradix.c4
-rw-r--r--libtommath/bn_mp_toradix_n.c4
-rw-r--r--libtommath/bn_mp_unsigned_bin_size.c4
-rw-r--r--libtommath/bn_mp_xor.c4
-rw-r--r--libtommath/bn_mp_zero.c4
-rw-r--r--libtommath/bn_prime_tab.c4
-rw-r--r--libtommath/bn_reverse.c4
-rw-r--r--libtommath/bn_s_mp_add.c4
-rw-r--r--libtommath/bn_s_mp_exptmod.c4
-rw-r--r--libtommath/bn_s_mp_mul_digs.c4
-rw-r--r--libtommath/bn_s_mp_mul_high_digs.c4
-rw-r--r--libtommath/bn_s_mp_sqr.c4
-rw-r--r--libtommath/bn_s_mp_sub.c4
-rw-r--r--libtommath/bncore.c4
-rw-r--r--libtommath/callgraph.txt177
-rw-r--r--libtommath/makefile52
-rw-r--r--libtommath/makefile.bcc32
-rw-r--r--libtommath/makefile.cygwin_dll32
-rw-r--r--libtommath/makefile.icc48
-rw-r--r--libtommath/makefile.msvc39
-rw-r--r--libtommath/makefile.shared54
-rw-r--r--libtommath/makefile_include.mk37
-rw-r--r--libtommath/tommath.h54
-rw-r--r--libtommath/tommath_class.h67
-rw-r--r--libtommath/tommath_private.h4
148 files changed, 1227 insertions, 728 deletions
diff --git a/doc/CrtObjCmd.3 b/doc/CrtObjCmd.3
index 69cadb8..746faba 100644
--- a/doc/CrtObjCmd.3
+++ b/doc/CrtObjCmd.3
@@ -8,7 +8,7 @@
.so man.macros
.BS
.SH NAME
-Tcl_CreateObjCommand, Tcl_DeleteCommand, Tcl_DeleteCommandFromToken, Tcl_GetCommandInfo, Tcl_GetCommandInfoFromToken, Tcl_SetCommandInfo, Tcl_SetCommandInfoFromToken, Tcl_GetCommandName, Tcl_GetCommandFullName, Tcl_GetCommandFromObj Tcl_RegisterCommandTypeName, Tcl_GetCommandTypeName \- implement new commands in C
+Tcl_CreateObjCommand, Tcl_DeleteCommand, Tcl_DeleteCommandFromToken, Tcl_GetCommandInfo, Tcl_GetCommandInfoFromToken, Tcl_SetCommandInfo, Tcl_SetCommandInfoFromToken, Tcl_GetCommandName, Tcl_GetCommandFullName, Tcl_GetCommandFromObj, Tcl_RegisterCommandTypeName, Tcl_GetCommandTypeName \- implement new commands in C
.SH SYNOPSIS
.nf
\fB#include <tcl.h>\fR
diff --git a/generic/tclOO.c b/generic/tclOO.c
index f16d662..440f8e4 100644
--- a/generic/tclOO.c
+++ b/generic/tclOO.c
@@ -1237,7 +1237,7 @@ ObjectNamespaceDeleted(
/*
* Because an object can be a class that is an instance of itself, the
* class object's class structure should only be cleaned after most of
- * the cleanup on the object is done.
+ * the cleanup on the object is done.
*
* The class of objects needs some special care; if it is deleted (and
* we're not killing the whole interpreter) we force the delete of the
diff --git a/generic/tclUtil.c b/generic/tclUtil.c
index d4fa5e0..629eb0d 100644
--- a/generic/tclUtil.c
+++ b/generic/tclUtil.c
@@ -3387,7 +3387,7 @@ TclFormatInt(
* GetWideForIndex --
*
* This function produces a wide integer value corresponding to the
- * list index held in *objPtr. The parsing supports all values
+ * list index held in *objPtr. The parsing supports all values
* recognized as any size of integer, and the syntaxes end[-+]$integer
* and $integer[-+]$integer. The argument endValue is used to give
* the meaning of the literal index value "end".
diff --git a/libtommath/README.md b/libtommath/README.md
index 3bc491d..0e57a4d 100644
--- a/libtommath/README.md
+++ b/libtommath/README.md
@@ -4,9 +4,11 @@ This is the git repository for [LibTomMath](http://www.libtom.net/LibTomMath/),
## Build Status
-master - [![Build Status - master](https://travis-ci.org/libtom/libtommath.png?branch=master)](https://travis-ci.org/libtom/libtommath)
+master: [![Build Status](https://api.travis-ci.org/libtom/libtommath.png?branch=master)](https://travis-ci.org/libtom/libtommath)
-develop - [![Build Status - develop](https://travis-ci.org/libtom/libtommath.png?branch=develop)](https://travis-ci.org/libtom/libtommath)
+develop: [![Build Status](https://api.travis-ci.org/libtom/libtommath.png?branch=develop)](https://travis-ci.org/libtom/libtommath)
+
+API/ABI changes: [check here](https://abi-laboratory.pro/tracker/timeline/libtommath/)
## Summary
diff --git a/libtommath/bn_error.c b/libtommath/bn_error.c
index 7e816bf..05b398a 100644
--- a/libtommath/bn_error.c
+++ b/libtommath/bn_error.c
@@ -1,4 +1,4 @@
-#include <tommath_private.h>
+#include "tommath_private.h"
#ifdef BN_ERROR_C
/* LibTomMath, multiple-precision integer library -- Tom St Denis
*
@@ -11,8 +11,6 @@
*
* The library is free for all purposes without any express
* guarantee it works.
- *
- * Tom St Denis, tstdenis82@gmail.com, http://libtom.org
*/
static const struct {
diff --git a/libtommath/bn_fast_mp_invmod.c b/libtommath/bn_fast_mp_invmod.c
index 6be44f8..be1a810 100644
--- a/libtommath/bn_fast_mp_invmod.c
+++ b/libtommath/bn_fast_mp_invmod.c
@@ -1,4 +1,4 @@
-#include <tommath_private.h>
+#include "tommath_private.h"
#ifdef BN_FAST_MP_INVMOD_C
/* LibTomMath, multiple-precision integer library -- Tom St Denis
*
@@ -11,8 +11,6 @@
*
* The library is free for all purposes without any express
* guarantee it works.
- *
- * Tom St Denis, tstdenis82@gmail.com, http://libtom.org
*/
/* computes the modular inverse via binary extended euclidean algorithm,
@@ -140,6 +138,14 @@ top:
goto LBL_ERR;
}
}
+
+ /* too big */
+ while (mp_cmp_mag(&D, b) != MP_LT) {
+ if ((res = mp_sub(&D, b, &D)) != MP_OKAY) {
+ goto LBL_ERR;
+ }
+ }
+
mp_exch(&D, c);
c->sign = neg;
res = MP_OKAY;
diff --git a/libtommath/bn_fast_mp_montgomery_reduce.c b/libtommath/bn_fast_mp_montgomery_reduce.c
index 8f91196..3454f58 100644
--- a/libtommath/bn_fast_mp_montgomery_reduce.c
+++ b/libtommath/bn_fast_mp_montgomery_reduce.c
@@ -1,4 +1,4 @@
-#include <tommath_private.h>
+#include "tommath_private.h"
#ifdef BN_FAST_MP_MONTGOMERY_REDUCE_C
/* LibTomMath, multiple-precision integer library -- Tom St Denis
*
@@ -11,8 +11,6 @@
*
* The library is free for all purposes without any express
* guarantee it works.
- *
- * Tom St Denis, tstdenis82@gmail.com, http://libtom.org
*/
/* computes xR**-1 == x (mod N) via Montgomery Reduction
diff --git a/libtommath/bn_fast_s_mp_mul_digs.c b/libtommath/bn_fast_s_mp_mul_digs.c
index e542c2e..1da314c 100644
--- a/libtommath/bn_fast_s_mp_mul_digs.c
+++ b/libtommath/bn_fast_s_mp_mul_digs.c
@@ -1,4 +1,4 @@
-#include <tommath_private.h>
+#include "tommath_private.h"
#ifdef BN_FAST_S_MP_MUL_DIGS_C
/* LibTomMath, multiple-precision integer library -- Tom St Denis
*
@@ -11,8 +11,6 @@
*
* The library is free for all purposes without any express
* guarantee it works.
- *
- * Tom St Denis, tstdenis82@gmail.com, http://libtom.org
*/
/* Fast (comba) multiplier
diff --git a/libtommath/bn_fast_s_mp_mul_high_digs.c b/libtommath/bn_fast_s_mp_mul_high_digs.c
index 6ea8a6c..45d30ca 100644
--- a/libtommath/bn_fast_s_mp_mul_high_digs.c
+++ b/libtommath/bn_fast_s_mp_mul_high_digs.c
@@ -1,4 +1,4 @@
-#include <tommath_private.h>
+#include "tommath_private.h"
#ifdef BN_FAST_S_MP_MUL_HIGH_DIGS_C
/* LibTomMath, multiple-precision integer library -- Tom St Denis
*
@@ -11,8 +11,6 @@
*
* The library is free for all purposes without any express
* guarantee it works.
- *
- * Tom St Denis, tstdenis82@gmail.com, http://libtom.org
*/
/* this is a modified version of fast_s_mul_digs that only produces
diff --git a/libtommath/bn_fast_s_mp_sqr.c b/libtommath/bn_fast_s_mp_sqr.c
index 1050121..3614a44 100644
--- a/libtommath/bn_fast_s_mp_sqr.c
+++ b/libtommath/bn_fast_s_mp_sqr.c
@@ -1,4 +1,4 @@
-#include <tommath_private.h>
+#include "tommath_private.h"
#ifdef BN_FAST_S_MP_SQR_C
/* LibTomMath, multiple-precision integer library -- Tom St Denis
*
@@ -11,8 +11,6 @@
*
* The library is free for all purposes without any express
* guarantee it works.
- *
- * Tom St Denis, tstdenis82@gmail.com, http://libtom.org
*/
/* the jist of squaring...
diff --git a/libtommath/bn_mp_2expt.c b/libtommath/bn_mp_2expt.c
index 5333d48..6737a55 100644
--- a/libtommath/bn_mp_2expt.c
+++ b/libtommath/bn_mp_2expt.c
@@ -1,4 +1,4 @@
-#include <tommath_private.h>
+#include "tommath_private.h"
#ifdef BN_MP_2EXPT_C
/* LibTomMath, multiple-precision integer library -- Tom St Denis
*
@@ -11,8 +11,6 @@
*
* The library is free for all purposes without any express
* guarantee it works.
- *
- * Tom St Denis, tstdenis82@gmail.com, http://libtom.org
*/
/* computes a = 2**b
diff --git a/libtommath/bn_mp_abs.c b/libtommath/bn_mp_abs.c
index 9b6bcec..7c60014 100644
--- a/libtommath/bn_mp_abs.c
+++ b/libtommath/bn_mp_abs.c
@@ -1,4 +1,4 @@
-#include <tommath_private.h>
+#include "tommath_private.h"
#ifdef BN_MP_ABS_C
/* LibTomMath, multiple-precision integer library -- Tom St Denis
*
@@ -11,8 +11,6 @@
*
* The library is free for all purposes without any express
* guarantee it works.
- *
- * Tom St Denis, tstdenis82@gmail.com, http://libtom.org
*/
/* b = |a|
diff --git a/libtommath/bn_mp_add.c b/libtommath/bn_mp_add.c
index d31d5a0..af53713 100644
--- a/libtommath/bn_mp_add.c
+++ b/libtommath/bn_mp_add.c
@@ -1,4 +1,4 @@
-#include <tommath_private.h>
+#include "tommath_private.h"
#ifdef BN_MP_ADD_C
/* LibTomMath, multiple-precision integer library -- Tom St Denis
*
@@ -11,8 +11,6 @@
*
* The library is free for all purposes without any express
* guarantee it works.
- *
- * Tom St Denis, tstdenis82@gmail.com, http://libtom.org
*/
/* high level addition (handles signs) */
diff --git a/libtommath/bn_mp_add_d.c b/libtommath/bn_mp_add_d.c
index e5ede1f..69cbd12 100644
--- a/libtommath/bn_mp_add_d.c
+++ b/libtommath/bn_mp_add_d.c
@@ -1,4 +1,4 @@
-#include <tommath_private.h>
+#include "tommath_private.h"
#ifdef BN_MP_ADD_D_C
/* LibTomMath, multiple-precision integer library -- Tom St Denis
*
@@ -11,8 +11,6 @@
*
* The library is free for all purposes without any express
* guarantee it works.
- *
- * Tom St Denis, tstdenis82@gmail.com, http://libtom.org
*/
/* single digit addition */
diff --git a/libtommath/bn_mp_addmod.c b/libtommath/bn_mp_addmod.c
index 0d612c3..b7907e5 100644
--- a/libtommath/bn_mp_addmod.c
+++ b/libtommath/bn_mp_addmod.c
@@ -1,4 +1,4 @@
-#include <tommath_private.h>
+#include "tommath_private.h"
#ifdef BN_MP_ADDMOD_C
/* LibTomMath, multiple-precision integer library -- Tom St Denis
*
@@ -11,8 +11,6 @@
*
* The library is free for all purposes without any express
* guarantee it works.
- *
- * Tom St Denis, tstdenis82@gmail.com, http://libtom.org
*/
/* d = a + b (mod c) */
diff --git a/libtommath/bn_mp_and.c b/libtommath/bn_mp_and.c
index 09ff772..24f380e 100644
--- a/libtommath/bn_mp_and.c
+++ b/libtommath/bn_mp_and.c
@@ -1,4 +1,4 @@
-#include <tommath_private.h>
+#include "tommath_private.h"
#ifdef BN_MP_AND_C
/* LibTomMath, multiple-precision integer library -- Tom St Denis
*
@@ -11,8 +11,6 @@
*
* The library is free for all purposes without any express
* guarantee it works.
- *
- * Tom St Denis, tstdenis82@gmail.com, http://libtom.org
*/
/* AND two ints together */
diff --git a/libtommath/bn_mp_clamp.c b/libtommath/bn_mp_clamp.c
index 79a5b20..1bdfdc9 100644
--- a/libtommath/bn_mp_clamp.c
+++ b/libtommath/bn_mp_clamp.c
@@ -1,4 +1,4 @@
-#include <tommath_private.h>
+#include "tommath_private.h"
#ifdef BN_MP_CLAMP_C
/* LibTomMath, multiple-precision integer library -- Tom St Denis
*
@@ -11,8 +11,6 @@
*
* The library is free for all purposes without any express
* guarantee it works.
- *
- * Tom St Denis, tstdenis82@gmail.com, http://libtom.org
*/
/* trim unused digits
diff --git a/libtommath/bn_mp_clear.c b/libtommath/bn_mp_clear.c
index fcf4d61..fc01cb8 100644
--- a/libtommath/bn_mp_clear.c
+++ b/libtommath/bn_mp_clear.c
@@ -1,4 +1,4 @@
-#include <tommath_private.h>
+#include "tommath_private.h"
#ifdef BN_MP_CLEAR_C
/* LibTomMath, multiple-precision integer library -- Tom St Denis
*
@@ -11,8 +11,6 @@
*
* The library is free for all purposes without any express
* guarantee it works.
- *
- * Tom St Denis, tstdenis82@gmail.com, http://libtom.org
*/
/* clear one (frees) */
diff --git a/libtommath/bn_mp_clear_multi.c b/libtommath/bn_mp_clear_multi.c
index ac3949a..9d7d9da 100644
--- a/libtommath/bn_mp_clear_multi.c
+++ b/libtommath/bn_mp_clear_multi.c
@@ -1,4 +1,4 @@
-#include <tommath_private.h>
+#include "tommath_private.h"
#ifdef BN_MP_CLEAR_MULTI_C
/* LibTomMath, multiple-precision integer library -- Tom St Denis
*
@@ -11,8 +11,6 @@
*
* The library is free for all purposes without any express
* guarantee it works.
- *
- * Tom St Denis, tstdenis82@gmail.com, http://libtom.org
*/
#include <stdarg.h>
diff --git a/libtommath/bn_mp_cmp.c b/libtommath/bn_mp_cmp.c
index a33d483..d6e3761 100644
--- a/libtommath/bn_mp_cmp.c
+++ b/libtommath/bn_mp_cmp.c
@@ -1,4 +1,4 @@
-#include <tommath_private.h>
+#include "tommath_private.h"
#ifdef BN_MP_CMP_C
/* LibTomMath, multiple-precision integer library -- Tom St Denis
*
@@ -11,8 +11,6 @@
*
* The library is free for all purposes without any express
* guarantee it works.
- *
- * Tom St Denis, tstdenis82@gmail.com, http://libtom.org
*/
/* compare two ints (signed)*/
diff --git a/libtommath/bn_mp_cmp_d.c b/libtommath/bn_mp_cmp_d.c
index 576a073..9816018 100644
--- a/libtommath/bn_mp_cmp_d.c
+++ b/libtommath/bn_mp_cmp_d.c
@@ -1,4 +1,4 @@
-#include <tommath_private.h>
+#include "tommath_private.h"
#ifdef BN_MP_CMP_D_C
/* LibTomMath, multiple-precision integer library -- Tom St Denis
*
@@ -11,8 +11,6 @@
*
* The library is free for all purposes without any express
* guarantee it works.
- *
- * Tom St Denis, tstdenis82@gmail.com, http://libtom.org
*/
/* compare a digit */
diff --git a/libtommath/bn_mp_cmp_mag.c b/libtommath/bn_mp_cmp_mag.c
index e2c723f..a5f629a 100644
--- a/libtommath/bn_mp_cmp_mag.c
+++ b/libtommath/bn_mp_cmp_mag.c
@@ -1,4 +1,4 @@
-#include <tommath_private.h>
+#include "tommath_private.h"
#ifdef BN_MP_CMP_MAG_C
/* LibTomMath, multiple-precision integer library -- Tom St Denis
*
@@ -11,8 +11,6 @@
*
* The library is free for all purposes without any express
* guarantee it works.
- *
- * Tom St Denis, tstdenis82@gmail.com, http://libtom.org
*/
/* compare maginitude of two ints (unsigned) */
diff --git a/libtommath/bn_mp_cnt_lsb.c b/libtommath/bn_mp_cnt_lsb.c
index 219c369..8e8f488 100644
--- a/libtommath/bn_mp_cnt_lsb.c
+++ b/libtommath/bn_mp_cnt_lsb.c
@@ -1,4 +1,4 @@
-#include <tommath_private.h>
+#include "tommath_private.h"
#ifdef BN_MP_CNT_LSB_C
/* LibTomMath, multiple-precision integer library -- Tom St Denis
*
@@ -11,8 +11,6 @@
*
* The library is free for all purposes without any express
* guarantee it works.
- *
- * Tom St Denis, tstdenis82@gmail.com, http://libtom.org
*/
static const int lnz[16] = {
diff --git a/libtommath/bn_mp_complement.c b/libtommath/bn_mp_complement.c
new file mode 100644
index 0000000..9dfddc3
--- /dev/null
+++ b/libtommath/bn_mp_complement.c
@@ -0,0 +1,26 @@
+#include "tommath_private.h"
+#ifdef BN_MP_COMPLEMENT_C
+/* LibTomMath, multiple-precision integer library -- Tom St Denis
+ *
+ * LibTomMath is a library that provides multiple-precision
+ * integer arithmetic as well as number theoretic functionality.
+ *
+ * The library was designed directly after the MPI library by
+ * Michael Fromberger but has been written from scratch with
+ * additional optimizations in place.
+ *
+ * The library is free for all purposes without any express
+ * guarantee it works.
+ */
+
+/* b = ~a */
+int mp_complement(const mp_int *a, mp_int *b)
+{
+ int res = mp_neg(a, b);
+ return (res == MP_OKAY) ? mp_sub_d(b, 1uL, b) : res;
+}
+#endif
+
+/* ref: $Format:%D$ */
+/* git commit: $Format:%H$ */
+/* commit time: $Format:%ai$ */
diff --git a/libtommath/bn_mp_copy.c b/libtommath/bn_mp_copy.c
index 17816e8..718febd 100644
--- a/libtommath/bn_mp_copy.c
+++ b/libtommath/bn_mp_copy.c
@@ -1,4 +1,4 @@
-#include <tommath_private.h>
+#include "tommath_private.h"
#ifdef BN_MP_COPY_C
/* LibTomMath, multiple-precision integer library -- Tom St Denis
*
@@ -11,8 +11,6 @@
*
* The library is free for all purposes without any express
* guarantee it works.
- *
- * Tom St Denis, tstdenis82@gmail.com, http://libtom.org
*/
/* copy, b = a */
diff --git a/libtommath/bn_mp_count_bits.c b/libtommath/bn_mp_count_bits.c
index 4530c92..11b84b2 100644
--- a/libtommath/bn_mp_count_bits.c
+++ b/libtommath/bn_mp_count_bits.c
@@ -1,4 +1,4 @@
-#include <tommath_private.h>
+#include "tommath_private.h"
#ifdef BN_MP_COUNT_BITS_C
/* LibTomMath, multiple-precision integer library -- Tom St Denis
*
@@ -11,8 +11,6 @@
*
* The library is free for all purposes without any express
* guarantee it works.
- *
- * Tom St Denis, tstdenis82@gmail.com, http://libtom.org
*/
/* returns the number of bits in an int */
diff --git a/libtommath/bn_mp_div.c b/libtommath/bn_mp_div.c
index f64f485..0d459d1 100644
--- a/libtommath/bn_mp_div.c
+++ b/libtommath/bn_mp_div.c
@@ -1,4 +1,4 @@
-#include <tommath_private.h>
+#include "tommath_private.h"
#ifdef BN_MP_DIV_C
/* LibTomMath, multiple-precision integer library -- Tom St Denis
*
@@ -11,8 +11,6 @@
*
* The library is free for all purposes without any express
* guarantee it works.
- *
- * Tom St Denis, tstdenis82@gmail.com, http://libtom.org
*/
#ifdef BN_MP_DIV_SMALL
diff --git a/libtommath/bn_mp_div_2.c b/libtommath/bn_mp_div_2.c
index 2907a1b..7ced424 100644
--- a/libtommath/bn_mp_div_2.c
+++ b/libtommath/bn_mp_div_2.c
@@ -1,4 +1,4 @@
-#include <tommath_private.h>
+#include "tommath_private.h"
#ifdef BN_MP_DIV_2_C
/* LibTomMath, multiple-precision integer library -- Tom St Denis
*
@@ -11,8 +11,6 @@
*
* The library is free for all purposes without any express
* guarantee it works.
- *
- * Tom St Denis, tstdenis82@gmail.com, http://libtom.org
*/
/* b = a/2 */
diff --git a/libtommath/bn_mp_div_2d.c b/libtommath/bn_mp_div_2d.c
index aeaa8f2..3fb822c 100644
--- a/libtommath/bn_mp_div_2d.c
+++ b/libtommath/bn_mp_div_2d.c
@@ -1,4 +1,4 @@
-#include <tommath_private.h>
+#include "tommath_private.h"
#ifdef BN_MP_DIV_2D_C
/* LibTomMath, multiple-precision integer library -- Tom St Denis
*
@@ -11,8 +11,6 @@
*
* The library is free for all purposes without any express
* guarantee it works.
- *
- * Tom St Denis, tstdenis82@gmail.com, http://libtom.org
*/
/* shift right by a certain bit count (store quotient in c, optional remainder in d) */
diff --git a/libtommath/bn_mp_div_3.c b/libtommath/bn_mp_div_3.c
index 9d41793..c5ca137 100644
--- a/libtommath/bn_mp_div_3.c
+++ b/libtommath/bn_mp_div_3.c
@@ -1,4 +1,4 @@
-#include <tommath_private.h>
+#include "tommath_private.h"
#ifdef BN_MP_DIV_3_C
/* LibTomMath, multiple-precision integer library -- Tom St Denis
*
@@ -11,8 +11,6 @@
*
* The library is free for all purposes without any express
* guarantee it works.
- *
- * Tom St Denis, tstdenis82@gmail.com, http://libtom.org
*/
/* divide by three (based on routine from MPI and the GMP manual) */
diff --git a/libtommath/bn_mp_div_d.c b/libtommath/bn_mp_div_d.c
index 7c0ab0b..93cae1e 100644
--- a/libtommath/bn_mp_div_d.c
+++ b/libtommath/bn_mp_div_d.c
@@ -1,4 +1,4 @@
-#include <tommath_private.h>
+#include "tommath_private.h"
#ifdef BN_MP_DIV_D_C
/* LibTomMath, multiple-precision integer library -- Tom St Denis
*
@@ -11,8 +11,6 @@
*
* The library is free for all purposes without any express
* guarantee it works.
- *
- * Tom St Denis, tstdenis82@gmail.com, http://libtom.org
*/
/* single digit division (based on routine from MPI) */
diff --git a/libtommath/bn_mp_dr_is_modulus.c b/libtommath/bn_mp_dr_is_modulus.c
index bf4ed8b..b01c77c 100644
--- a/libtommath/bn_mp_dr_is_modulus.c
+++ b/libtommath/bn_mp_dr_is_modulus.c
@@ -1,4 +1,4 @@
-#include <tommath_private.h>
+#include "tommath_private.h"
#ifdef BN_MP_DR_IS_MODULUS_C
/* LibTomMath, multiple-precision integer library -- Tom St Denis
*
@@ -11,8 +11,6 @@
*
* The library is free for all purposes without any express
* guarantee it works.
- *
- * Tom St Denis, tstdenis82@gmail.com, http://libtom.org
*/
/* determines if a number is a valid DR modulus */
diff --git a/libtommath/bn_mp_dr_reduce.c b/libtommath/bn_mp_dr_reduce.c
index d677b03..da36b85 100644
--- a/libtommath/bn_mp_dr_reduce.c
+++ b/libtommath/bn_mp_dr_reduce.c
@@ -1,4 +1,4 @@
-#include <tommath_private.h>
+#include "tommath_private.h"
#ifdef BN_MP_DR_REDUCE_C
/* LibTomMath, multiple-precision integer library -- Tom St Denis
*
@@ -11,8 +11,6 @@
*
* The library is free for all purposes without any express
* guarantee it works.
- *
- * Tom St Denis, tstdenis82@gmail.com, http://libtom.org
*/
/* reduce "x" in place modulo "n" using the Diminished Radix algorithm.
diff --git a/libtommath/bn_mp_dr_setup.c b/libtommath/bn_mp_dr_setup.c
index 32aa582..afcdaf0 100644
--- a/libtommath/bn_mp_dr_setup.c
+++ b/libtommath/bn_mp_dr_setup.c
@@ -1,4 +1,4 @@
-#include <tommath_private.h>
+#include "tommath_private.h"
#ifdef BN_MP_DR_SETUP_C
/* LibTomMath, multiple-precision integer library -- Tom St Denis
*
@@ -11,8 +11,6 @@
*
* The library is free for all purposes without any express
* guarantee it works.
- *
- * Tom St Denis, tstdenis82@gmail.com, http://libtom.org
*/
/* determines the setup value */
diff --git a/libtommath/bn_mp_exch.c b/libtommath/bn_mp_exch.c
index 2bc635f..b846928 100644
--- a/libtommath/bn_mp_exch.c
+++ b/libtommath/bn_mp_exch.c
@@ -1,4 +1,4 @@
-#include <tommath_private.h>
+#include "tommath_private.h"
#ifdef BN_MP_EXCH_C
/* LibTomMath, multiple-precision integer library -- Tom St Denis
*
@@ -11,8 +11,6 @@
*
* The library is free for all purposes without any express
* guarantee it works.
- *
- * Tom St Denis, tstdenis82@gmail.com, http://libtom.org
*/
/* swap the elements of two integers, for cases where you can't simply swap the
diff --git a/libtommath/bn_mp_export.c b/libtommath/bn_mp_export.c
index 92a85d5..e55101a 100644
--- a/libtommath/bn_mp_export.c
+++ b/libtommath/bn_mp_export.c
@@ -1,4 +1,4 @@
-#include <tommath_private.h>
+#include "tommath_private.h"
#ifdef BN_MP_EXPORT_C
/* LibTomMath, multiple-precision integer library -- Tom St Denis
*
@@ -11,8 +11,6 @@
*
* The library is free for all purposes without any express
* guarantee it works.
- *
- * Tom St Denis, tstdenis82@gmail.com, http://libtom.org
*/
/* based on gmp's mpz_export.
diff --git a/libtommath/bn_mp_expt_d.c b/libtommath/bn_mp_expt_d.c
index f5ce3c1..7aff105 100644
--- a/libtommath/bn_mp_expt_d.c
+++ b/libtommath/bn_mp_expt_d.c
@@ -1,4 +1,4 @@
-#include <tommath_private.h>
+#include "tommath_private.h"
#ifdef BN_MP_EXPT_D_C
/* LibTomMath, multiple-precision integer library -- Tom St Denis
*
@@ -11,8 +11,6 @@
*
* The library is free for all purposes without any express
* guarantee it works.
- *
- * Tom St Denis, tstdenis82@gmail.com, http://libtom.org
*/
/* wrapper function for mp_expt_d_ex() */
diff --git a/libtommath/bn_mp_expt_d_ex.c b/libtommath/bn_mp_expt_d_ex.c
index d363d59..53e880c 100644
--- a/libtommath/bn_mp_expt_d_ex.c
+++ b/libtommath/bn_mp_expt_d_ex.c
@@ -1,4 +1,4 @@
-#include <tommath_private.h>
+#include "tommath_private.h"
#ifdef BN_MP_EXPT_D_EX_C
/* LibTomMath, multiple-precision integer library -- Tom St Denis
*
@@ -11,8 +11,6 @@
*
* The library is free for all purposes without any express
* guarantee it works.
- *
- * Tom St Denis, tstdenis82@gmail.com, http://libtom.org
*/
/* calculate c = a**b using a square-multiply algorithm */
diff --git a/libtommath/bn_mp_exptmod.c b/libtommath/bn_mp_exptmod.c
index 934fd25..ec0cf7e 100644
--- a/libtommath/bn_mp_exptmod.c
+++ b/libtommath/bn_mp_exptmod.c
@@ -1,4 +1,4 @@
-#include <tommath_private.h>
+#include "tommath_private.h"
#ifdef BN_MP_EXPTMOD_C
/* LibTomMath, multiple-precision integer library -- Tom St Denis
*
@@ -11,8 +11,6 @@
*
* The library is free for all purposes without any express
* guarantee it works.
- *
- * Tom St Denis, tstdenis82@gmail.com, http://libtom.org
*/
diff --git a/libtommath/bn_mp_exptmod_fast.c b/libtommath/bn_mp_exptmod_fast.c
index 52d4a55..0d01e38 100644
--- a/libtommath/bn_mp_exptmod_fast.c
+++ b/libtommath/bn_mp_exptmod_fast.c
@@ -1,4 +1,4 @@
-#include <tommath_private.h>
+#include "tommath_private.h"
#ifdef BN_MP_EXPTMOD_FAST_C
/* LibTomMath, multiple-precision integer library -- Tom St Denis
*
@@ -11,8 +11,6 @@
*
* The library is free for all purposes without any express
* guarantee it works.
- *
- * Tom St Denis, tstdenis82@gmail.com, http://libtom.org
*/
/* computes Y == G**X mod P, HAC pp.616, Algorithm 14.85
diff --git a/libtommath/bn_mp_exteuclid.c b/libtommath/bn_mp_exteuclid.c
index 29bad83..b13ee30 100644
--- a/libtommath/bn_mp_exteuclid.c
+++ b/libtommath/bn_mp_exteuclid.c
@@ -1,4 +1,4 @@
-#include <tommath_private.h>
+#include "tommath_private.h"
#ifdef BN_MP_EXTEUCLID_C
/* LibTomMath, multiple-precision integer library -- Tom St Denis
*
@@ -11,8 +11,6 @@
*
* The library is free for all purposes without any express
* guarantee it works.
- *
- * Tom St Denis, tstdenis82@gmail.com, http://libtom.org
*/
/* Extended euclidean algorithm of (a, b) produces
diff --git a/libtommath/bn_mp_fread.c b/libtommath/bn_mp_fread.c
index 6922183..7652aac 100644
--- a/libtommath/bn_mp_fread.c
+++ b/libtommath/bn_mp_fread.c
@@ -1,4 +1,4 @@
-#include <tommath_private.h>
+#include "tommath_private.h"
#ifdef BN_MP_FREAD_C
/* LibTomMath, multiple-precision integer library -- Tom St Denis
*
@@ -11,8 +11,6 @@
*
* The library is free for all purposes without any express
* guarantee it works.
- *
- * Tom St Denis, tstdenis82@gmail.com, http://libtom.org
*/
#ifndef LTM_NO_FILE
diff --git a/libtommath/bn_mp_fwrite.c b/libtommath/bn_mp_fwrite.c
index 8541bc7..8df2134 100644
--- a/libtommath/bn_mp_fwrite.c
+++ b/libtommath/bn_mp_fwrite.c
@@ -1,4 +1,4 @@
-#include <tommath_private.h>
+#include "tommath_private.h"
#ifdef BN_MP_FWRITE_C
/* LibTomMath, multiple-precision integer library -- Tom St Denis
*
@@ -11,8 +11,6 @@
*
* The library is free for all purposes without any express
* guarantee it works.
- *
- * Tom St Denis, tstdenis82@gmail.com, http://libtom.org
*/
#ifndef LTM_NO_FILE
diff --git a/libtommath/bn_mp_gcd.c b/libtommath/bn_mp_gcd.c
index f5aa78b..0a5000e 100644
--- a/libtommath/bn_mp_gcd.c
+++ b/libtommath/bn_mp_gcd.c
@@ -1,4 +1,4 @@
-#include <tommath_private.h>
+#include "tommath_private.h"
#ifdef BN_MP_GCD_C
/* LibTomMath, multiple-precision integer library -- Tom St Denis
*
@@ -11,8 +11,6 @@
*
* The library is free for all purposes without any express
* guarantee it works.
- *
- * Tom St Denis, tstdenis82@gmail.com, http://libtom.org
*/
/* Greatest Common Divisor using the binary method */
diff --git a/libtommath/bn_mp_get_int.c b/libtommath/bn_mp_get_int.c
index d99a0a0..4f99363 100644
--- a/libtommath/bn_mp_get_int.c
+++ b/libtommath/bn_mp_get_int.c
@@ -1,4 +1,4 @@
-#include <tommath_private.h>
+#include "tommath_private.h"
#ifdef BN_MP_GET_INT_C
/* LibTomMath, multiple-precision integer library -- Tom St Denis
*
@@ -11,8 +11,6 @@
*
* The library is free for all purposes without any express
* guarantee it works.
- *
- * Tom St Denis, tstdenis82@gmail.com, http://libtom.org
*/
/* get the lower 32-bits of an mp_int */
diff --git a/libtommath/bn_mp_get_long.c b/libtommath/bn_mp_get_long.c
index 9ec2664..bb9bd75 100644
--- a/libtommath/bn_mp_get_long.c
+++ b/libtommath/bn_mp_get_long.c
@@ -1,4 +1,4 @@
-#include <tommath_private.h>
+#include "tommath_private.h"
#ifdef BN_MP_GET_LONG_C
/* LibTomMath, multiple-precision integer library -- Tom St Denis
*
@@ -11,8 +11,6 @@
*
* The library is free for all purposes without any express
* guarantee it works.
- *
- * Tom St Denis, tstdenis82@gmail.com, http://libtom.org
*/
/* get the lower unsigned long of an mp_int, platform dependent */
diff --git a/libtommath/bn_mp_get_long_long.c b/libtommath/bn_mp_get_long_long.c
index df2aa77..6eb33c9 100644
--- a/libtommath/bn_mp_get_long_long.c
+++ b/libtommath/bn_mp_get_long_long.c
@@ -1,4 +1,4 @@
-#include <tommath_private.h>
+#include "tommath_private.h"
#ifdef BN_MP_GET_LONG_LONG_C
/* LibTomMath, multiple-precision integer library -- Tom St Denis
*
@@ -11,8 +11,6 @@
*
* The library is free for all purposes without any express
* guarantee it works.
- *
- * Tom St Denis, tstdenis82@gmail.com, http://libtom.org
*/
/* get the lower unsigned long long of an mp_int, platform dependent */
diff --git a/libtommath/bn_mp_grow.c b/libtommath/bn_mp_grow.c
index 60f8f32..d336ba1 100644
--- a/libtommath/bn_mp_grow.c
+++ b/libtommath/bn_mp_grow.c
@@ -1,4 +1,4 @@
-#include <tommath_private.h>
+#include "tommath_private.h"
#ifdef BN_MP_GROW_C
/* LibTomMath, multiple-precision integer library -- Tom St Denis
*
@@ -11,8 +11,6 @@
*
* The library is free for all purposes without any express
* guarantee it works.
- *
- * Tom St Denis, tstdenis82@gmail.com, http://libtom.org
*/
/* grow as required */
diff --git a/libtommath/bn_mp_import.c b/libtommath/bn_mp_import.c
index 9bbd215..e28d20e 100644
--- a/libtommath/bn_mp_import.c
+++ b/libtommath/bn_mp_import.c
@@ -1,4 +1,4 @@
-#include <tommath_private.h>
+#include "tommath_private.h"
#ifdef BN_MP_IMPORT_C
/* LibTomMath, multiple-precision integer library -- Tom St Denis
*
@@ -11,8 +11,6 @@
*
* The library is free for all purposes without any express
* guarantee it works.
- *
- * Tom St Denis, tstdenis82@gmail.com, http://libtom.org
*/
/* based on gmp's mpz_import.
diff --git a/libtommath/bn_mp_init.c b/libtommath/bn_mp_init.c
index ad630e3..cdc0bd2 100644
--- a/libtommath/bn_mp_init.c
+++ b/libtommath/bn_mp_init.c
@@ -1,4 +1,4 @@
-#include <tommath_private.h>
+#include "tommath_private.h"
#ifdef BN_MP_INIT_C
/* LibTomMath, multiple-precision integer library -- Tom St Denis
*
@@ -11,8 +11,6 @@
*
* The library is free for all purposes without any express
* guarantee it works.
- *
- * Tom St Denis, tstdenis82@gmail.com, http://libtom.org
*/
/* init a new mp_int */
diff --git a/libtommath/bn_mp_init_copy.c b/libtommath/bn_mp_init_copy.c
index 5681015..3d3e6cd 100644
--- a/libtommath/bn_mp_init_copy.c
+++ b/libtommath/bn_mp_init_copy.c
@@ -1,4 +1,4 @@
-#include <tommath_private.h>
+#include "tommath_private.h"
#ifdef BN_MP_INIT_COPY_C
/* LibTomMath, multiple-precision integer library -- Tom St Denis
*
@@ -11,8 +11,6 @@
*
* The library is free for all purposes without any express
* guarantee it works.
- *
- * Tom St Denis, tstdenis82@gmail.com, http://libtom.org
*/
/* creates "a" then copies b into it */
diff --git a/libtommath/bn_mp_init_multi.c b/libtommath/bn_mp_init_multi.c
index 9ed777c..d254696 100644
--- a/libtommath/bn_mp_init_multi.c
+++ b/libtommath/bn_mp_init_multi.c
@@ -1,4 +1,4 @@
-#include <tommath_private.h>
+#include "tommath_private.h"
#ifdef BN_MP_INIT_MULTI_C
/* LibTomMath, multiple-precision integer library -- Tom St Denis
*
@@ -11,8 +11,6 @@
*
* The library is free for all purposes without any express
* guarantee it works.
- *
- * Tom St Denis, tstdenis82@gmail.com, http://libtom.org
*/
#include <stdarg.h>
diff --git a/libtommath/bn_mp_init_set.c b/libtommath/bn_mp_init_set.c
index e9c1b12..4bce757 100644
--- a/libtommath/bn_mp_init_set.c
+++ b/libtommath/bn_mp_init_set.c
@@ -1,4 +1,4 @@
-#include <tommath_private.h>
+#include "tommath_private.h"
#ifdef BN_MP_INIT_SET_C
/* LibTomMath, multiple-precision integer library -- Tom St Denis
*
@@ -11,8 +11,6 @@
*
* The library is free for all purposes without any express
* guarantee it works.
- *
- * Tom St Denis, tstdenis82@gmail.com, http://libtom.org
*/
/* initialize and set a digit */
diff --git a/libtommath/bn_mp_init_set_int.c b/libtommath/bn_mp_init_set_int.c
index 8e7441a..10c5bb7 100644
--- a/libtommath/bn_mp_init_set_int.c
+++ b/libtommath/bn_mp_init_set_int.c
@@ -1,4 +1,4 @@
-#include <tommath_private.h>
+#include "tommath_private.h"
#ifdef BN_MP_INIT_SET_INT_C
/* LibTomMath, multiple-precision integer library -- Tom St Denis
*
@@ -11,8 +11,6 @@
*
* The library is free for all purposes without any express
* guarantee it works.
- *
- * Tom St Denis, tstdenis82@gmail.com, http://libtom.org
*/
/* initialize and set a digit */
diff --git a/libtommath/bn_mp_init_size.c b/libtommath/bn_mp_init_size.c
index 35713ac..ccca5b9 100644
--- a/libtommath/bn_mp_init_size.c
+++ b/libtommath/bn_mp_init_size.c
@@ -1,4 +1,4 @@
-#include <tommath_private.h>
+#include "tommath_private.h"
#ifdef BN_MP_INIT_SIZE_C
/* LibTomMath, multiple-precision integer library -- Tom St Denis
*
@@ -11,8 +11,6 @@
*
* The library is free for all purposes without any express
* guarantee it works.
- *
- * Tom St Denis, tstdenis82@gmail.com, http://libtom.org
*/
/* init an mp_init for a given size */
diff --git a/libtommath/bn_mp_invmod.c b/libtommath/bn_mp_invmod.c
index 96717ea..8dd188c 100644
--- a/libtommath/bn_mp_invmod.c
+++ b/libtommath/bn_mp_invmod.c
@@ -1,4 +1,4 @@
-#include <tommath_private.h>
+#include "tommath_private.h"
#ifdef BN_MP_INVMOD_C
/* LibTomMath, multiple-precision integer library -- Tom St Denis
*
@@ -11,8 +11,6 @@
*
* The library is free for all purposes without any express
* guarantee it works.
- *
- * Tom St Denis, tstdenis82@gmail.com, http://libtom.org
*/
/* hac 14.61, pp608 */
diff --git a/libtommath/bn_mp_invmod_slow.c b/libtommath/bn_mp_invmod_slow.c
index 360f161..49ed095 100644
--- a/libtommath/bn_mp_invmod_slow.c
+++ b/libtommath/bn_mp_invmod_slow.c
@@ -1,4 +1,4 @@
-#include <tommath_private.h>
+#include "tommath_private.h"
#ifdef BN_MP_INVMOD_SLOW_C
/* LibTomMath, multiple-precision integer library -- Tom St Denis
*
@@ -11,8 +11,6 @@
*
* The library is free for all purposes without any express
* guarantee it works.
- *
- * Tom St Denis, tstdenis82@gmail.com, http://libtom.org
*/
/* hac 14.61, pp608 */
diff --git a/libtommath/bn_mp_is_square.c b/libtommath/bn_mp_is_square.c
index 329d727..6e3cb56 100644
--- a/libtommath/bn_mp_is_square.c
+++ b/libtommath/bn_mp_is_square.c
@@ -1,4 +1,4 @@
-#include <tommath_private.h>
+#include "tommath_private.h"
#ifdef BN_MP_IS_SQUARE_C
/* LibTomMath, multiple-precision integer library -- Tom St Denis
*
@@ -11,8 +11,6 @@
*
* The library is free for all purposes without any express
* guarantee it works.
- *
- * Tom St Denis, tstdenis82@gmail.com, http://libtom.org
*/
/* Check if remainders are possible squares - fast exclude non-squares */
@@ -75,31 +73,31 @@ int mp_is_square(const mp_int *arg, int *ret)
return res;
}
if ((res = mp_mod(arg, &t, &t)) != MP_OKAY) {
- goto ERR;
+ goto LBL_ERR;
}
r = mp_get_int(&t);
/* Check for other prime modules, note it's not an ERROR but we must
- * free "t" so the easiest way is to goto ERR. We know that res
+ * free "t" so the easiest way is to goto LBL_ERR. We know that res
* is already equal to MP_OKAY from the mp_mod call
*/
- if (((1uL<<(r%11uL)) & 0x5C4uL) != 0uL) goto ERR;
- if (((1uL<<(r%13uL)) & 0x9E4uL) != 0uL) goto ERR;
- if (((1uL<<(r%17uL)) & 0x5CE8uL) != 0uL) goto ERR;
- if (((1uL<<(r%19uL)) & 0x4F50CuL) != 0uL) goto ERR;
- if (((1uL<<(r%23uL)) & 0x7ACCA0uL) != 0uL) goto ERR;
- if (((1uL<<(r%29uL)) & 0xC2EDD0CuL) != 0uL) goto ERR;
- if (((1uL<<(r%31uL)) & 0x6DE2B848uL) != 0uL) goto ERR;
+ if (((1uL<<(r%11uL)) & 0x5C4uL) != 0uL) goto LBL_ERR;
+ if (((1uL<<(r%13uL)) & 0x9E4uL) != 0uL) goto LBL_ERR;
+ if (((1uL<<(r%17uL)) & 0x5CE8uL) != 0uL) goto LBL_ERR;
+ if (((1uL<<(r%19uL)) & 0x4F50CuL) != 0uL) goto LBL_ERR;
+ if (((1uL<<(r%23uL)) & 0x7ACCA0uL) != 0uL) goto LBL_ERR;
+ if (((1uL<<(r%29uL)) & 0xC2EDD0CuL) != 0uL) goto LBL_ERR;
+ if (((1uL<<(r%31uL)) & 0x6DE2B848uL) != 0uL) goto LBL_ERR;
/* Final check - is sqr(sqrt(arg)) == arg ? */
if ((res = mp_sqrt(arg, &t)) != MP_OKAY) {
- goto ERR;
+ goto LBL_ERR;
}
if ((res = mp_sqr(&t, &t)) != MP_OKAY) {
- goto ERR;
+ goto LBL_ERR;
}
*ret = (mp_cmp_mag(&t, arg) == MP_EQ) ? MP_YES : MP_NO;
-ERR:
+LBL_ERR:
mp_clear(&t);
return res;
}
diff --git a/libtommath/bn_mp_jacobi.c b/libtommath/bn_mp_jacobi.c
index ef2e72f..fe37f22 100644
--- a/libtommath/bn_mp_jacobi.c
+++ b/libtommath/bn_mp_jacobi.c
@@ -1,4 +1,4 @@
-#include <tommath_private.h>
+#include "tommath_private.h"
#ifdef BN_MP_JACOBI_C
/* LibTomMath, multiple-precision integer library -- Tom St Denis
*
@@ -11,8 +11,6 @@
*
* The library is free for all purposes without any express
* guarantee it works.
- *
- * Tom St Denis, tstdenis82@gmail.com, http://libtom.org
*/
/* computes the jacobi c = (a | n) (or Legendre if n is prime)
diff --git a/libtommath/bn_mp_karatsuba_mul.c b/libtommath/bn_mp_karatsuba_mul.c
index 1a84211..af12c55 100644
--- a/libtommath/bn_mp_karatsuba_mul.c
+++ b/libtommath/bn_mp_karatsuba_mul.c
@@ -1,4 +1,4 @@
-#include <tommath_private.h>
+#include "tommath_private.h"
#ifdef BN_MP_KARATSUBA_MUL_C
/* LibTomMath, multiple-precision integer library -- Tom St Denis
*
@@ -11,8 +11,6 @@
*
* The library is free for all purposes without any express
* guarantee it works.
- *
- * Tom St Denis, tstdenis82@gmail.com, http://libtom.org
*/
/* c = |a| * |b| using Karatsuba Multiplication using
@@ -60,7 +58,7 @@ int mp_karatsuba_mul(const mp_int *a, const mp_int *b, mp_int *c)
/* init copy all the temps */
if (mp_init_size(&x0, B) != MP_OKAY)
- goto ERR;
+ goto LBL_ERR;
if (mp_init_size(&x1, a->used - B) != MP_OKAY)
goto X0;
if (mp_init_size(&y0, B) != MP_OKAY)
@@ -164,7 +162,7 @@ X1:
mp_clear(&x1);
X0:
mp_clear(&x0);
-ERR:
+LBL_ERR:
return err;
}
#endif
diff --git a/libtommath/bn_mp_karatsuba_sqr.c b/libtommath/bn_mp_karatsuba_sqr.c
index c566b06..99a31b8 100644
--- a/libtommath/bn_mp_karatsuba_sqr.c
+++ b/libtommath/bn_mp_karatsuba_sqr.c
@@ -1,4 +1,4 @@
-#include <tommath_private.h>
+#include "tommath_private.h"
#ifdef BN_MP_KARATSUBA_SQR_C
/* LibTomMath, multiple-precision integer library -- Tom St Denis
*
@@ -11,8 +11,6 @@
*
* The library is free for all purposes without any express
* guarantee it works.
- *
- * Tom St Denis, tstdenis82@gmail.com, http://libtom.org
*/
/* Karatsuba squaring, computes b = a*a using three
@@ -37,7 +35,7 @@ int mp_karatsuba_sqr(const mp_int *a, mp_int *b)
/* init copy all the temps */
if (mp_init_size(&x0, B) != MP_OKAY)
- goto ERR;
+ goto LBL_ERR;
if (mp_init_size(&x1, a->used - B) != MP_OKAY)
goto X0;
@@ -117,7 +115,7 @@ X1:
mp_clear(&x1);
X0:
mp_clear(&x0);
-ERR:
+LBL_ERR:
return err;
}
#endif
diff --git a/libtommath/bn_mp_lcm.c b/libtommath/bn_mp_lcm.c
index 24b621c..3798afc 100644
--- a/libtommath/bn_mp_lcm.c
+++ b/libtommath/bn_mp_lcm.c
@@ -1,4 +1,4 @@
-#include <tommath_private.h>
+#include "tommath_private.h"
#ifdef BN_MP_LCM_C
/* LibTomMath, multiple-precision integer library -- Tom St Denis
*
@@ -11,8 +11,6 @@
*
* The library is free for all purposes without any express
* guarantee it works.
- *
- * Tom St Denis, tstdenis82@gmail.com, http://libtom.org
*/
/* computes least common multiple as |a*b|/(a, b) */
diff --git a/libtommath/bn_mp_lshd.c b/libtommath/bn_mp_lshd.c
index b49b545..649df90 100644
--- a/libtommath/bn_mp_lshd.c
+++ b/libtommath/bn_mp_lshd.c
@@ -1,4 +1,4 @@
-#include <tommath_private.h>
+#include "tommath_private.h"
#ifdef BN_MP_LSHD_C
/* LibTomMath, multiple-precision integer library -- Tom St Denis
*
@@ -11,8 +11,6 @@
*
* The library is free for all purposes without any express
* guarantee it works.
- *
- * Tom St Denis, tstdenis82@gmail.com, http://libtom.org
*/
/* shift left a certain amount of digits */
diff --git a/libtommath/bn_mp_mod.c b/libtommath/bn_mp_mod.c
index 64e73ea..21acf8c 100644
--- a/libtommath/bn_mp_mod.c
+++ b/libtommath/bn_mp_mod.c
@@ -1,4 +1,4 @@
-#include <tommath_private.h>
+#include "tommath_private.h"
#ifdef BN_MP_MOD_C
/* LibTomMath, multiple-precision integer library -- Tom St Denis
*
@@ -11,8 +11,6 @@
*
* The library is free for all purposes without any express
* guarantee it works.
- *
- * Tom St Denis, tstdenis82@gmail.com, http://libtom.org
*/
/* c = a mod b, 0 <= c < b if b > 0, b < c <= 0 if b < 0 */
diff --git a/libtommath/bn_mp_mod_2d.c b/libtommath/bn_mp_mod_2d.c
index 7a74746..bf69221 100644
--- a/libtommath/bn_mp_mod_2d.c
+++ b/libtommath/bn_mp_mod_2d.c
@@ -1,4 +1,4 @@
-#include <tommath_private.h>
+#include "tommath_private.h"
#ifdef BN_MP_MOD_2D_C
/* LibTomMath, multiple-precision integer library -- Tom St Denis
*
@@ -11,8 +11,6 @@
*
* The library is free for all purposes without any express
* guarantee it works.
- *
- * Tom St Denis, tstdenis82@gmail.com, http://libtom.org
*/
/* calc a value mod 2**b */
diff --git a/libtommath/bn_mp_mod_d.c b/libtommath/bn_mp_mod_d.c
index 9a24e78..5252c4f 100644
--- a/libtommath/bn_mp_mod_d.c
+++ b/libtommath/bn_mp_mod_d.c
@@ -1,4 +1,4 @@
-#include <tommath_private.h>
+#include "tommath_private.h"
#ifdef BN_MP_MOD_D_C
/* LibTomMath, multiple-precision integer library -- Tom St Denis
*
@@ -11,8 +11,6 @@
*
* The library is free for all purposes without any express
* guarantee it works.
- *
- * Tom St Denis, tstdenis82@gmail.com, http://libtom.org
*/
int mp_mod_d(const mp_int *a, mp_digit b, mp_digit *c)
diff --git a/libtommath/bn_mp_montgomery_calc_normalization.c b/libtommath/bn_mp_montgomery_calc_normalization.c
index 360e3e5..8b0a320 100644
--- a/libtommath/bn_mp_montgomery_calc_normalization.c
+++ b/libtommath/bn_mp_montgomery_calc_normalization.c
@@ -1,4 +1,4 @@
-#include <tommath_private.h>
+#include "tommath_private.h"
#ifdef BN_MP_MONTGOMERY_CALC_NORMALIZATION_C
/* LibTomMath, multiple-precision integer library -- Tom St Denis
*
@@ -11,8 +11,6 @@
*
* The library is free for all purposes without any express
* guarantee it works.
- *
- * Tom St Denis, tstdenis82@gmail.com, http://libtom.org
*/
/*
diff --git a/libtommath/bn_mp_montgomery_reduce.c b/libtommath/bn_mp_montgomery_reduce.c
index e3a0eaa..2def073 100644
--- a/libtommath/bn_mp_montgomery_reduce.c
+++ b/libtommath/bn_mp_montgomery_reduce.c
@@ -1,4 +1,4 @@
-#include <tommath_private.h>
+#include "tommath_private.h"
#ifdef BN_MP_MONTGOMERY_REDUCE_C
/* LibTomMath, multiple-precision integer library -- Tom St Denis
*
@@ -11,8 +11,6 @@
*
* The library is free for all purposes without any express
* guarantee it works.
- *
- * Tom St Denis, tstdenis82@gmail.com, http://libtom.org
*/
/* computes xR**-1 == x (mod N) via Montgomery Reduction */
diff --git a/libtommath/bn_mp_montgomery_setup.c b/libtommath/bn_mp_montgomery_setup.c
index 75da42b..cd53b6d 100644
--- a/libtommath/bn_mp_montgomery_setup.c
+++ b/libtommath/bn_mp_montgomery_setup.c
@@ -1,4 +1,4 @@
-#include <tommath_private.h>
+#include "tommath_private.h"
#ifdef BN_MP_MONTGOMERY_SETUP_C
/* LibTomMath, multiple-precision integer library -- Tom St Denis
*
@@ -11,8 +11,6 @@
*
* The library is free for all purposes without any express
* guarantee it works.
- *
- * Tom St Denis, tstdenis82@gmail.com, http://libtom.org
*/
/* setups the montgomery reduction stuff */
diff --git a/libtommath/bn_mp_mul.c b/libtommath/bn_mp_mul.c
index babb12b..e7613a3 100644
--- a/libtommath/bn_mp_mul.c
+++ b/libtommath/bn_mp_mul.c
@@ -1,4 +1,4 @@
-#include <tommath_private.h>
+#include "tommath_private.h"
#ifdef BN_MP_MUL_C
/* LibTomMath, multiple-precision integer library -- Tom St Denis
*
@@ -11,8 +11,6 @@
*
* The library is free for all purposes without any express
* guarantee it works.
- *
- * Tom St Denis, tstdenis82@gmail.com, http://libtom.org
*/
/* high level multiplication (handles sign) */
diff --git a/libtommath/bn_mp_mul_2.c b/libtommath/bn_mp_mul_2.c
index 7611536..e0f051f 100644
--- a/libtommath/bn_mp_mul_2.c
+++ b/libtommath/bn_mp_mul_2.c
@@ -1,4 +1,4 @@
-#include <tommath_private.h>
+#include "tommath_private.h"
#ifdef BN_MP_MUL_2_C
/* LibTomMath, multiple-precision integer library -- Tom St Denis
*
@@ -11,8 +11,6 @@
*
* The library is free for all purposes without any express
* guarantee it works.
- *
- * Tom St Denis, tstdenis82@gmail.com, http://libtom.org
*/
/* b = a*2 */
diff --git a/libtommath/bn_mp_mul_2d.c b/libtommath/bn_mp_mul_2d.c
index 96aef85..42c6535 100644
--- a/libtommath/bn_mp_mul_2d.c
+++ b/libtommath/bn_mp_mul_2d.c
@@ -1,4 +1,4 @@
-#include <tommath_private.h>
+#include "tommath_private.h"
#ifdef BN_MP_MUL_2D_C
/* LibTomMath, multiple-precision integer library -- Tom St Denis
*
@@ -11,8 +11,6 @@
*
* The library is free for all purposes without any express
* guarantee it works.
- *
- * Tom St Denis, tstdenis82@gmail.com, http://libtom.org
*/
/* shift left by a certain bit count */
diff --git a/libtommath/bn_mp_mul_d.c b/libtommath/bn_mp_mul_d.c
index 13f94a2..d6bddfd 100644
--- a/libtommath/bn_mp_mul_d.c
+++ b/libtommath/bn_mp_mul_d.c
@@ -1,4 +1,4 @@
-#include <tommath_private.h>
+#include "tommath_private.h"
#ifdef BN_MP_MUL_D_C
/* LibTomMath, multiple-precision integer library -- Tom St Denis
*
@@ -11,8 +11,6 @@
*
* The library is free for all purposes without any express
* guarantee it works.
- *
- * Tom St Denis, tstdenis82@gmail.com, http://libtom.org
*/
/* multiply by a digit */
diff --git a/libtommath/bn_mp_mulmod.c b/libtommath/bn_mp_mulmod.c
index aeee4ee..ca9ef3e 100644
--- a/libtommath/bn_mp_mulmod.c
+++ b/libtommath/bn_mp_mulmod.c
@@ -1,4 +1,4 @@
-#include <tommath_private.h>
+#include "tommath_private.h"
#ifdef BN_MP_MULMOD_C
/* LibTomMath, multiple-precision integer library -- Tom St Denis
*
@@ -11,8 +11,6 @@
*
* The library is free for all purposes without any express
* guarantee it works.
- *
- * Tom St Denis, tstdenis82@gmail.com, http://libtom.org
*/
/* d = a * b (mod c) */
diff --git a/libtommath/bn_mp_n_root.c b/libtommath/bn_mp_n_root.c
index a09804f..16232d8 100644
--- a/libtommath/bn_mp_n_root.c
+++ b/libtommath/bn_mp_n_root.c
@@ -1,4 +1,4 @@
-#include <tommath_private.h>
+#include "tommath_private.h"
#ifdef BN_MP_N_ROOT_C
/* LibTomMath, multiple-precision integer library -- Tom St Denis
*
@@ -11,8 +11,6 @@
*
* The library is free for all purposes without any express
* guarantee it works.
- *
- * Tom St Denis, tstdenis82@gmail.com, http://libtom.org
*/
/* wrapper function for mp_n_root_ex()
diff --git a/libtommath/bn_mp_n_root_ex.c b/libtommath/bn_mp_n_root_ex.c
index 60c9929..9fd7098 100644
--- a/libtommath/bn_mp_n_root_ex.c
+++ b/libtommath/bn_mp_n_root_ex.c
@@ -1,4 +1,4 @@
-#include <tommath_private.h>
+#include "tommath_private.h"
#ifdef BN_MP_N_ROOT_EX_C
/* LibTomMath, multiple-precision integer library -- Tom St Denis
*
@@ -11,8 +11,6 @@
*
* The library is free for all purposes without any express
* guarantee it works.
- *
- * Tom St Denis, tstdenis82@gmail.com, http://libtom.org
*/
/* find the n'th root of an integer
diff --git a/libtommath/bn_mp_neg.c b/libtommath/bn_mp_neg.c
index 75f8bbd..612b9c7 100644
--- a/libtommath/bn_mp_neg.c
+++ b/libtommath/bn_mp_neg.c
@@ -1,4 +1,4 @@
-#include <tommath_private.h>
+#include "tommath_private.h"
#ifdef BN_MP_NEG_C
/* LibTomMath, multiple-precision integer library -- Tom St Denis
*
@@ -11,8 +11,6 @@
*
* The library is free for all purposes without any express
* guarantee it works.
- *
- * Tom St Denis, tstdenis82@gmail.com, http://libtom.org
*/
/* b = -a */
diff --git a/libtommath/bn_mp_or.c b/libtommath/bn_mp_or.c
index f411509..151dfff 100644
--- a/libtommath/bn_mp_or.c
+++ b/libtommath/bn_mp_or.c
@@ -1,4 +1,4 @@
-#include <tommath_private.h>
+#include "tommath_private.h"
#ifdef BN_MP_OR_C
/* LibTomMath, multiple-precision integer library -- Tom St Denis
*
@@ -11,8 +11,6 @@
*
* The library is free for all purposes without any express
* guarantee it works.
- *
- * Tom St Denis, tstdenis82@gmail.com, http://libtom.org
*/
/* OR two ints together */
diff --git a/libtommath/bn_mp_prime_fermat.c b/libtommath/bn_mp_prime_fermat.c
index e71e0ae..7cd39bd 100644
--- a/libtommath/bn_mp_prime_fermat.c
+++ b/libtommath/bn_mp_prime_fermat.c
@@ -1,4 +1,4 @@
-#include <tommath_private.h>
+#include "tommath_private.h"
#ifdef BN_MP_PRIME_FERMAT_C
/* LibTomMath, multiple-precision integer library -- Tom St Denis
*
@@ -11,8 +11,6 @@
*
* The library is free for all purposes without any express
* guarantee it works.
- *
- * Tom St Denis, tstdenis82@gmail.com, http://libtom.org
*/
/* performs one Fermat test.
diff --git a/libtommath/bn_mp_prime_is_divisible.c b/libtommath/bn_mp_prime_is_divisible.c
index c49fdd2..706521e 100644
--- a/libtommath/bn_mp_prime_is_divisible.c
+++ b/libtommath/bn_mp_prime_is_divisible.c
@@ -1,4 +1,4 @@
-#include <tommath_private.h>
+#include "tommath_private.h"
#ifdef BN_MP_PRIME_IS_DIVISIBLE_C
/* LibTomMath, multiple-precision integer library -- Tom St Denis
*
@@ -11,8 +11,6 @@
*
* The library is free for all purposes without any express
* guarantee it works.
- *
- * Tom St Denis, tstdenis82@gmail.com, http://libtom.org
*/
/* determines if an integers is divisible by one
diff --git a/libtommath/bn_mp_prime_is_prime.c b/libtommath/bn_mp_prime_is_prime.c
index e97712d..209fba0 100644
--- a/libtommath/bn_mp_prime_is_prime.c
+++ b/libtommath/bn_mp_prime_is_prime.c
@@ -1,4 +1,4 @@
-#include <tommath_private.h>
+#include "tommath_private.h"
#ifdef BN_MP_PRIME_IS_PRIME_C
/* LibTomMath, multiple-precision integer library -- Tom St Denis
*
@@ -11,8 +11,6 @@
*
* The library is free for all purposes without any express
* guarantee it works.
- *
- * Tom St Denis, tstdenis82@gmail.com, http://libtom.org
*/
/* performs a variable number of rounds of Miller-Rabin
diff --git a/libtommath/bn_mp_prime_miller_rabin.c b/libtommath/bn_mp_prime_miller_rabin.c
index 34c4d1c..5d94e36 100644
--- a/libtommath/bn_mp_prime_miller_rabin.c
+++ b/libtommath/bn_mp_prime_miller_rabin.c
@@ -1,4 +1,4 @@
-#include <tommath_private.h>
+#include "tommath_private.h"
#ifdef BN_MP_PRIME_MILLER_RABIN_C
/* LibTomMath, multiple-precision integer library -- Tom St Denis
*
@@ -11,8 +11,6 @@
*
* The library is free for all purposes without any express
* guarantee it works.
- *
- * Tom St Denis, tstdenis82@gmail.com, http://libtom.org
*/
/* Miller-Rabin test of "a" to the base of "b" as described in
diff --git a/libtommath/bn_mp_prime_next_prime.c b/libtommath/bn_mp_prime_next_prime.c
index b106a74..89e2841 100644
--- a/libtommath/bn_mp_prime_next_prime.c
+++ b/libtommath/bn_mp_prime_next_prime.c
@@ -1,4 +1,4 @@
-#include <tommath_private.h>
+#include "tommath_private.h"
#ifdef BN_MP_PRIME_NEXT_PRIME_C
/* LibTomMath, multiple-precision integer library -- Tom St Denis
*
@@ -11,8 +11,6 @@
*
* The library is free for all purposes without any express
* guarantee it works.
- *
- * Tom St Denis, tstdenis82@gmail.com, http://libtom.org
*/
/* finds the next prime after the number "a" using "t" trials
diff --git a/libtommath/bn_mp_prime_rabin_miller_trials.c b/libtommath/bn_mp_prime_rabin_miller_trials.c
index cde309a..d400902 100644
--- a/libtommath/bn_mp_prime_rabin_miller_trials.c
+++ b/libtommath/bn_mp_prime_rabin_miller_trials.c
@@ -1,4 +1,4 @@
-#include <tommath_private.h>
+#include "tommath_private.h"
#ifdef BN_MP_PRIME_RABIN_MILLER_TRIALS_C
/* LibTomMath, multiple-precision integer library -- Tom St Denis
*
@@ -11,8 +11,6 @@
*
* The library is free for all purposes without any express
* guarantee it works.
- *
- * Tom St Denis, tstdenis82@gmail.com, http://libtom.org
*/
diff --git a/libtommath/bn_mp_prime_random_ex.c b/libtommath/bn_mp_prime_random_ex.c
index 1ae2934..13fdcdf 100644
--- a/libtommath/bn_mp_prime_random_ex.c
+++ b/libtommath/bn_mp_prime_random_ex.c
@@ -1,4 +1,4 @@
-#include <tommath_private.h>
+#include "tommath_private.h"
#ifdef BN_MP_PRIME_RANDOM_EX_C
/* LibTomMath, multiple-precision integer library -- Tom St Denis
*
@@ -11,8 +11,6 @@
*
* The library is free for all purposes without any express
* guarantee it works.
- *
- * Tom St Denis, tstdenis82@gmail.com, http://libtom.org
*/
/* makes a truly random prime of a given size (bits),
diff --git a/libtommath/bn_mp_radix_size.c b/libtommath/bn_mp_radix_size.c
index 29355cb..1e286ed 100644
--- a/libtommath/bn_mp_radix_size.c
+++ b/libtommath/bn_mp_radix_size.c
@@ -1,4 +1,4 @@
-#include <tommath_private.h>
+#include "tommath_private.h"
#ifdef BN_MP_RADIX_SIZE_C
/* LibTomMath, multiple-precision integer library -- Tom St Denis
*
@@ -11,8 +11,6 @@
*
* The library is free for all purposes without any express
* guarantee it works.
- *
- * Tom St Denis, tstdenis82@gmail.com, http://libtom.org
*/
/* returns size of ASCII reprensentation */
diff --git a/libtommath/bn_mp_radix_smap.c b/libtommath/bn_mp_radix_smap.c
index 5d449f1..caba69f 100644
--- a/libtommath/bn_mp_radix_smap.c
+++ b/libtommath/bn_mp_radix_smap.c
@@ -1,4 +1,4 @@
-#include <tommath_private.h>
+#include "tommath_private.h"
#ifdef BN_MP_RADIX_SMAP_C
/* LibTomMath, multiple-precision integer library -- Tom St Denis
*
@@ -11,24 +11,22 @@
*
* The library is free for all purposes without any express
* guarantee it works.
- *
- * Tom St Denis, tstdenis82@gmail.com, http://libtom.org
*/
/* chars used in radix conversions */
-const char *mp_s_rmap = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz+/";
+const char *const mp_s_rmap = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz+/";
const unsigned char mp_s_rmap_reverse[] = {
- 0xff, 0xff, 0xff, 0x3e, 0xff, 0xff, 0xff, 0x3f, /* ()*+,-./ */
- 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, /* 01234567 */
- 0x08, 0x09, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, /* 89:;<=>? */
- 0xff, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, 0x10, /* @ABCDEFG */
- 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, /* HIJKLMNO */
- 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f, 0x20, /* PQRSTUVW */
- 0x21, 0x22, 0x23, 0xff, 0xff, 0xff, 0xff, 0xff, /* XYZ[\]^_ */
- 0xff, 0x24, 0x25, 0x26, 0x27, 0x28, 0x29, 0x2a, /* `abcdefg */
- 0x2b, 0x2c, 0x2d, 0x2e, 0x2f, 0x30, 0x31, 0x32, /* hijklmno */
- 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x3a, /* pqrstuvw */
- 0x3b, 0x3c, 0x3d, 0xff, 0xff, 0xff, 0xff, 0xff, /* xyz{|}~. */
+ 0xff, 0xff, 0xff, 0x3e, 0xff, 0xff, 0xff, 0x3f, /* ()*+,-./ */
+ 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, /* 01234567 */
+ 0x08, 0x09, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, /* 89:;<=>? */
+ 0xff, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, 0x10, /* @ABCDEFG */
+ 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, /* HIJKLMNO */
+ 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f, 0x20, /* PQRSTUVW */
+ 0x21, 0x22, 0x23, 0xff, 0xff, 0xff, 0xff, 0xff, /* XYZ[\]^_ */
+ 0xff, 0x24, 0x25, 0x26, 0x27, 0x28, 0x29, 0x2a, /* `abcdefg */
+ 0x2b, 0x2c, 0x2d, 0x2e, 0x2f, 0x30, 0x31, 0x32, /* hijklmno */
+ 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x3a, /* pqrstuvw */
+ 0x3b, 0x3c, 0x3d, 0xff, 0xff, 0xff, 0xff, 0xff, /* xyz{|}~. */
};
const size_t mp_s_rmap_reverse_sz = sizeof(mp_s_rmap_reverse);
#endif
diff --git a/libtommath/bn_mp_rand.c b/libtommath/bn_mp_rand.c
index 2ed665e..af017f2 100644
--- a/libtommath/bn_mp_rand.c
+++ b/libtommath/bn_mp_rand.c
@@ -1,4 +1,4 @@
-#include <tommath_private.h>
+#include "tommath_private.h"
#ifdef BN_MP_RAND_C
/* LibTomMath, multiple-precision integer library -- Tom St Denis
*
@@ -11,38 +11,173 @@
*
* The library is free for all purposes without any express
* guarantee it works.
- *
- * Tom St Denis, tstdenis82@gmail.com, http://libtom.org
*/
-#if defined(MP_8BIT) || defined(MP_16BIT)
-#define MP_GEN_RANDOM_SHIFT DIGIT_BIT
-#else
-#if MP_GEN_RANDOM_MAX == 0xffffffffu
-#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
-#endif
+/* First the OS-specific special cases
+ * - *BSD
+ * - Windows
+ */
+#if defined(__FreeBSD__) || defined(__OpenBSD__) || defined(__NetBSD__) || defined(__DragonFly__)
+#define MP_ARC4RANDOM
+#define MP_GEN_RANDOM_MAX 0xffffffffu
+#define MP_GEN_RANDOM_SHIFT 32
-/* makes a pseudo-random int of a given size */
-static mp_digit s_gen_random(void)
+static int s_read_arc4random(mp_digit *p)
{
mp_digit d = 0, msk = 0;
do {
d <<= MP_GEN_RANDOM_SHIFT;
- d |= ((mp_digit) MP_GEN_RANDOM());
+ d |= ((mp_digit) arc4random());
msk <<= MP_GEN_RANDOM_SHIFT;
msk |= (MP_MASK & MP_GEN_RANDOM_MAX);
} while ((MP_MASK & msk) != MP_MASK);
- d &= MP_MASK;
- return d;
+ *p = d;
+ return MP_OKAY;
+}
+#endif
+
+#if defined(_WIN32) || defined(_WIN32_WCE)
+#define MP_WIN_CSP
+
+#ifndef _WIN32_WINNT
+#define _WIN32_WINNT 0x0400
+#endif
+#ifdef _WIN32_WCE
+#define UNDER_CE
+#define ARM
+#endif
+
+#define WIN32_LEAN_AND_MEAN
+#include <windows.h>
+#include <wincrypt.h>
+
+static HCRYPTPROV hProv = 0;
+
+static void s_cleanup_win_csp(void)
+{
+ CryptReleaseContext(hProv, 0);
+ hProv = 0;
+}
+
+static int s_read_win_csp(mp_digit *p)
+{
+ int ret = -1;
+ if (hProv == 0) {
+ if (!CryptAcquireContext(&hProv, NULL, MS_DEF_PROV, PROV_RSA_FULL,
+ (CRYPT_VERIFYCONTEXT | CRYPT_MACHINE_KEYSET)) &&
+ !CryptAcquireContext(&hProv, NULL, MS_DEF_PROV, PROV_RSA_FULL,
+ CRYPT_VERIFYCONTEXT | CRYPT_MACHINE_KEYSET | CRYPT_NEWKEYSET)) {
+ hProv = 0;
+ return ret;
+ }
+ atexit(s_cleanup_win_csp);
+ }
+ if (CryptGenRandom(hProv, sizeof(*p), (void *)p) == TRUE) {
+ ret = MP_OKAY;
+ }
+ return ret;
+}
+#endif /* WIN32 */
+
+#if !defined(MP_WIN_CSP) && defined(__linux__) && defined(__GLIBC_PREREQ)
+#if __GLIBC_PREREQ(2, 25)
+#define MP_GETRANDOM
+#include <sys/random.h>
+#include <errno.h>
+
+static int s_read_getrandom(mp_digit *p)
+{
+ int ret;
+ do {
+ ret = getrandom(p, sizeof(*p), 0);
+ } while ((ret == -1) && (errno == EINTR));
+ if (ret == sizeof(*p)) return MP_OKAY;
+ return -1;
+}
+#endif
+#endif
+
+/* We assume all platforms besides windows provide "/dev/urandom".
+ * In case yours doesn't, define MP_NO_DEV_URANDOM at compile-time.
+ */
+#if !defined(MP_WIN_CSP) && !defined(MP_NO_DEV_URANDOM)
+#ifndef MP_DEV_URANDOM
+#define MP_DEV_URANDOM "/dev/urandom"
+#endif
+#include <fcntl.h>
+#include <errno.h>
+#include <unistd.h>
+
+static int s_read_dev_urandom(mp_digit *p)
+{
+ ssize_t r;
+ int fd;
+ do {
+ fd = open(MP_DEV_URANDOM, O_RDONLY);
+ } while ((fd == -1) && (errno == EINTR));
+ if (fd == -1) return -1;
+ do {
+ r = read(fd, p, sizeof(*p));
+ } while ((r == -1) && (errno == EINTR));
+ close(fd);
+ if (r != sizeof(*p)) return -1;
+ return MP_OKAY;
+}
+#endif
+
+#if defined(MP_PRNG_ENABLE_LTM_RNG)
+unsigned long (*ltm_rng)(unsigned char *out, unsigned long outlen, void (*callback)(void));
+void (*ltm_rng_callback)(void);
+
+static int s_read_ltm_rng(mp_digit *p)
+{
+ unsigned long ret;
+ if (ltm_rng == NULL) return -1;
+ ret = ltm_rng((void *)p, sizeof(*p), ltm_rng_callback);
+ if (ret != sizeof(*p)) return -1;
+ return MP_OKAY;
+}
+#endif
+
+static int s_rand_digit(mp_digit *p)
+{
+ int ret = -1;
+
+#if defined(MP_ARC4RANDOM)
+ ret = s_read_arc4random(p);
+ if (ret == MP_OKAY) return ret;
+#endif
+
+#if defined(MP_WIN_CSP)
+ ret = s_read_win_csp(p);
+ if (ret == MP_OKAY) return ret;
+#else
+
+#if defined(MP_GETRANDOM)
+ ret = s_read_getrandom(p);
+ if (ret == MP_OKAY) return ret;
+#endif
+#if defined(MP_DEV_URANDOM)
+ ret = s_read_dev_urandom(p);
+ if (ret == MP_OKAY) return ret;
+#endif
+
+#endif /* MP_WIN_CSP */
+
+#if defined(MP_PRNG_ENABLE_LTM_RNG)
+ ret = s_read_ltm_rng(p);
+ if (ret == MP_OKAY) return ret;
+#endif
+
+ return ret;
+}
+
+/* makes a pseudo-random int of a given size */
+static int s_gen_random(mp_digit *r)
+{
+ int ret = s_rand_digit(r);
+ *r &= MP_MASK;
+ return ret;
}
int mp_rand(mp_int *a, int digits)
@@ -57,7 +192,9 @@ int mp_rand(mp_int *a, int digits)
/* first place a random non-zero digit */
do {
- d = s_gen_random();
+ if (s_gen_random(&d) != MP_OKAY) {
+ return MP_VAL;
+ }
} while (d == 0u);
if ((res = mp_add_d(a, d, a)) != MP_OKAY) {
@@ -69,7 +206,10 @@ int mp_rand(mp_int *a, int digits)
return res;
}
- if ((res = mp_add_d(a, s_gen_random(), a)) != MP_OKAY) {
+ if (s_gen_random(&d) != MP_OKAY) {
+ return MP_VAL;
+ }
+ if ((res = mp_add_d(a, d, a)) != MP_OKAY) {
return res;
}
}
diff --git a/libtommath/bn_mp_read_radix.c b/libtommath/bn_mp_read_radix.c
index 55c5ee1..02ba113 100644
--- a/libtommath/bn_mp_read_radix.c
+++ b/libtommath/bn_mp_read_radix.c
@@ -1,4 +1,4 @@
-#include <tommath_private.h>
+#include "tommath_private.h"
#ifdef BN_MP_READ_RADIX_C
/* LibTomMath, multiple-precision integer library -- Tom St Denis
*
@@ -11,8 +11,6 @@
*
* The library is free for all purposes without any express
* guarantee it works.
- *
- * Tom St Denis, tstdenis82@gmail.com, http://libtom.org
*/
/* read a string [ASCII] in a given radix */
diff --git a/libtommath/bn_mp_read_signed_bin.c b/libtommath/bn_mp_read_signed_bin.c
index 17bc6ce..3a0e231 100644
--- a/libtommath/bn_mp_read_signed_bin.c
+++ b/libtommath/bn_mp_read_signed_bin.c
@@ -1,4 +1,4 @@
-#include <tommath_private.h>
+#include "tommath_private.h"
#ifdef BN_MP_READ_SIGNED_BIN_C
/* LibTomMath, multiple-precision integer library -- Tom St Denis
*
@@ -11,8 +11,6 @@
*
* The library is free for all purposes without any express
* guarantee it works.
- *
- * Tom St Denis, tstdenis82@gmail.com, http://libtom.org
*/
/* read signed bin, big endian, first byte is 0==positive or 1==negative */
diff --git a/libtommath/bn_mp_read_unsigned_bin.c b/libtommath/bn_mp_read_unsigned_bin.c
index 6398c43..f29e7e6 100644
--- a/libtommath/bn_mp_read_unsigned_bin.c
+++ b/libtommath/bn_mp_read_unsigned_bin.c
@@ -1,4 +1,4 @@
-#include <tommath_private.h>
+#include "tommath_private.h"
#ifdef BN_MP_READ_UNSIGNED_BIN_C
/* LibTomMath, multiple-precision integer library -- Tom St Denis
*
@@ -11,8 +11,6 @@
*
* The library is free for all purposes without any express
* guarantee it works.
- *
- * Tom St Denis, tstdenis82@gmail.com, http://libtom.org
*/
/* reads a unsigned char array, assumes the msb is stored first [big endian] */
diff --git a/libtommath/bn_mp_reduce.c b/libtommath/bn_mp_reduce.c
index 5b1d405..3f93387 100644
--- a/libtommath/bn_mp_reduce.c
+++ b/libtommath/bn_mp_reduce.c
@@ -1,4 +1,4 @@
-#include <tommath_private.h>
+#include "tommath_private.h"
#ifdef BN_MP_REDUCE_C
/* LibTomMath, multiple-precision integer library -- Tom St Denis
*
@@ -11,8 +11,6 @@
*
* The library is free for all purposes without any express
* guarantee it works.
- *
- * Tom St Denis, tstdenis82@gmail.com, http://libtom.org
*/
/* reduces x mod m, assumes 0 < x < m**2, mu is
diff --git a/libtommath/bn_mp_reduce_2k.c b/libtommath/bn_mp_reduce_2k.c
index e1e2bc8..f5c74b8 100644
--- a/libtommath/bn_mp_reduce_2k.c
+++ b/libtommath/bn_mp_reduce_2k.c
@@ -1,4 +1,4 @@
-#include <tommath_private.h>
+#include "tommath_private.h"
#ifdef BN_MP_REDUCE_2K_C
/* LibTomMath, multiple-precision integer library -- Tom St Denis
*
@@ -11,8 +11,6 @@
*
* The library is free for all purposes without any express
* guarantee it works.
- *
- * Tom St Denis, tstdenis82@gmail.com, http://libtom.org
*/
/* reduces a modulo n where n is of the form 2**p - d */
@@ -29,29 +27,29 @@ int mp_reduce_2k(mp_int *a, const mp_int *n, mp_digit d)
top:
/* q = a/2**p, a = a mod 2**p */
if ((res = mp_div_2d(a, p, &q, a)) != MP_OKAY) {
- goto ERR;
+ goto LBL_ERR;
}
if (d != 1u) {
/* q = q * d */
if ((res = mp_mul_d(&q, d, &q)) != MP_OKAY) {
- goto ERR;
+ goto LBL_ERR;
}
}
/* a = a + q */
if ((res = s_mp_add(a, &q, a)) != MP_OKAY) {
- goto ERR;
+ goto LBL_ERR;
}
if (mp_cmp_mag(a, n) != MP_LT) {
if ((res = s_mp_sub(a, n, a)) != MP_OKAY) {
- goto ERR;
+ goto LBL_ERR;
}
goto top;
}
-ERR:
+LBL_ERR:
mp_clear(&q);
return res;
}
diff --git a/libtommath/bn_mp_reduce_2k_l.c b/libtommath/bn_mp_reduce_2k_l.c
index 23381bf..cbdfad7 100644
--- a/libtommath/bn_mp_reduce_2k_l.c
+++ b/libtommath/bn_mp_reduce_2k_l.c
@@ -1,4 +1,4 @@
-#include <tommath_private.h>
+#include "tommath_private.h"
#ifdef BN_MP_REDUCE_2K_L_C
/* LibTomMath, multiple-precision integer library -- Tom St Denis
*
@@ -11,8 +11,6 @@
*
* The library is free for all purposes without any express
* guarantee it works.
- *
- * Tom St Denis, tstdenis82@gmail.com, http://libtom.org
*/
/* reduces a modulo n where n is of the form 2**p - d
@@ -32,27 +30,27 @@ int mp_reduce_2k_l(mp_int *a, const mp_int *n, const mp_int *d)
top:
/* q = a/2**p, a = a mod 2**p */
if ((res = mp_div_2d(a, p, &q, a)) != MP_OKAY) {
- goto ERR;
+ goto LBL_ERR;
}
/* q = q * d */
if ((res = mp_mul(&q, d, &q)) != MP_OKAY) {
- goto ERR;
+ goto LBL_ERR;
}
/* a = a + q */
if ((res = s_mp_add(a, &q, a)) != MP_OKAY) {
- goto ERR;
+ goto LBL_ERR;
}
if (mp_cmp_mag(a, n) != MP_LT) {
if ((res = s_mp_sub(a, n, a)) != MP_OKAY) {
- goto ERR;
+ goto LBL_ERR;
}
goto top;
}
-ERR:
+LBL_ERR:
mp_clear(&q);
return res;
}
diff --git a/libtommath/bn_mp_reduce_2k_setup.c b/libtommath/bn_mp_reduce_2k_setup.c
index e6ae839..11248a3 100644
--- a/libtommath/bn_mp_reduce_2k_setup.c
+++ b/libtommath/bn_mp_reduce_2k_setup.c
@@ -1,4 +1,4 @@
-#include <tommath_private.h>
+#include "tommath_private.h"
#ifdef BN_MP_REDUCE_2K_SETUP_C
/* LibTomMath, multiple-precision integer library -- Tom St Denis
*
@@ -11,8 +11,6 @@
*
* The library is free for all purposes without any express
* guarantee it works.
- *
- * Tom St Denis, tstdenis82@gmail.com, http://libtom.org
*/
/* determines the setup value */
diff --git a/libtommath/bn_mp_reduce_2k_setup_l.c b/libtommath/bn_mp_reduce_2k_setup_l.c
index af81b5b..04c7634 100644
--- a/libtommath/bn_mp_reduce_2k_setup_l.c
+++ b/libtommath/bn_mp_reduce_2k_setup_l.c
@@ -1,4 +1,4 @@
-#include <tommath_private.h>
+#include "tommath_private.h"
#ifdef BN_MP_REDUCE_2K_SETUP_L_C
/* LibTomMath, multiple-precision integer library -- Tom St Denis
*
@@ -11,8 +11,6 @@
*
* The library is free for all purposes without any express
* guarantee it works.
- *
- * Tom St Denis, tstdenis82@gmail.com, http://libtom.org
*/
/* determines the setup value */
@@ -26,14 +24,14 @@ int mp_reduce_2k_setup_l(const mp_int *a, mp_int *d)
}
if ((res = mp_2expt(&tmp, mp_count_bits(a))) != MP_OKAY) {
- goto ERR;
+ goto LBL_ERR;
}
if ((res = s_mp_sub(&tmp, a, d)) != MP_OKAY) {
- goto ERR;
+ goto LBL_ERR;
}
-ERR:
+LBL_ERR:
mp_clear(&tmp);
return res;
}
diff --git a/libtommath/bn_mp_reduce_is_2k.c b/libtommath/bn_mp_reduce_is_2k.c
index f59d535..14612c0 100644
--- a/libtommath/bn_mp_reduce_is_2k.c
+++ b/libtommath/bn_mp_reduce_is_2k.c
@@ -1,4 +1,4 @@
-#include <tommath_private.h>
+#include "tommath_private.h"
#ifdef BN_MP_REDUCE_IS_2K_C
/* LibTomMath, multiple-precision integer library -- Tom St Denis
*
@@ -11,8 +11,6 @@
*
* The library is free for all purposes without any express
* guarantee it works.
- *
- * Tom St Denis, tstdenis82@gmail.com, http://libtom.org
*/
/* determines if mp_reduce_2k can be used */
diff --git a/libtommath/bn_mp_reduce_is_2k_l.c b/libtommath/bn_mp_reduce_is_2k_l.c
index 22c7582..7c9cacf 100644
--- a/libtommath/bn_mp_reduce_is_2k_l.c
+++ b/libtommath/bn_mp_reduce_is_2k_l.c
@@ -1,4 +1,4 @@
-#include <tommath_private.h>
+#include "tommath_private.h"
#ifdef BN_MP_REDUCE_IS_2K_L_C
/* LibTomMath, multiple-precision integer library -- Tom St Denis
*
@@ -11,8 +11,6 @@
*
* The library is free for all purposes without any express
* guarantee it works.
- *
- * Tom St Denis, tstdenis82@gmail.com, http://libtom.org
*/
/* determines if reduce_2k_l can be used */
diff --git a/libtommath/bn_mp_reduce_setup.c b/libtommath/bn_mp_reduce_setup.c
index 70e193a..92d03fc 100644
--- a/libtommath/bn_mp_reduce_setup.c
+++ b/libtommath/bn_mp_reduce_setup.c
@@ -1,4 +1,4 @@
-#include <tommath_private.h>
+#include "tommath_private.h"
#ifdef BN_MP_REDUCE_SETUP_C
/* LibTomMath, multiple-precision integer library -- Tom St Denis
*
@@ -11,8 +11,6 @@
*
* The library is free for all purposes without any express
* guarantee it works.
- *
- * Tom St Denis, tstdenis82@gmail.com, http://libtom.org
*/
/* pre-calculate the value required for Barrett reduction
diff --git a/libtommath/bn_mp_rshd.c b/libtommath/bn_mp_rshd.c
index fd06735..d17ad00 100644
--- a/libtommath/bn_mp_rshd.c
+++ b/libtommath/bn_mp_rshd.c
@@ -1,4 +1,4 @@
-#include <tommath_private.h>
+#include "tommath_private.h"
#ifdef BN_MP_RSHD_C
/* LibTomMath, multiple-precision integer library -- Tom St Denis
*
@@ -11,8 +11,6 @@
*
* The library is free for all purposes without any express
* guarantee it works.
- *
- * Tom St Denis, tstdenis82@gmail.com, http://libtom.org
*/
/* shift right a certain amount of digits */
diff --git a/libtommath/bn_mp_set.c b/libtommath/bn_mp_set.c
index 952d080..dc03f4c 100644
--- a/libtommath/bn_mp_set.c
+++ b/libtommath/bn_mp_set.c
@@ -1,4 +1,4 @@
-#include <tommath_private.h>
+#include "tommath_private.h"
#ifdef BN_MP_SET_C
/* LibTomMath, multiple-precision integer library -- Tom St Denis
*
@@ -11,8 +11,6 @@
*
* The library is free for all purposes without any express
* guarantee it works.
- *
- * Tom St Denis, tstdenis82@gmail.com, http://libtom.org
*/
/* set to a digit */
diff --git a/libtommath/bn_mp_set_int.c b/libtommath/bn_mp_set_int.c
index 006f263..4d6e580 100644
--- a/libtommath/bn_mp_set_int.c
+++ b/libtommath/bn_mp_set_int.c
@@ -1,4 +1,4 @@
-#include <tommath_private.h>
+#include "tommath_private.h"
#ifdef BN_MP_SET_INT_C
/* LibTomMath, multiple-precision integer library -- Tom St Denis
*
@@ -11,8 +11,6 @@
*
* The library is free for all purposes without any express
* guarantee it works.
- *
- * Tom St Denis, tstdenis82@gmail.com, http://libtom.org
*/
/* set a 32-bit const */
diff --git a/libtommath/bn_mp_set_long.c b/libtommath/bn_mp_set_long.c
index 8cbb811..f842632 100644
--- a/libtommath/bn_mp_set_long.c
+++ b/libtommath/bn_mp_set_long.c
@@ -1,4 +1,4 @@
-#include <tommath_private.h>
+#include "tommath_private.h"
#ifdef BN_MP_SET_LONG_C
/* LibTomMath, multiple-precision integer library -- Tom St Denis
*
@@ -11,8 +11,6 @@
*
* The library is free for all purposes without any express
* guarantee it works.
- *
- * Tom St Denis, tstdenis82@gmail.com, http://libtom.org
*/
/* set a platform dependent unsigned long int */
diff --git a/libtommath/bn_mp_set_long_long.c b/libtommath/bn_mp_set_long_long.c
index 0b8be33..0c550a8 100644
--- a/libtommath/bn_mp_set_long_long.c
+++ b/libtommath/bn_mp_set_long_long.c
@@ -1,4 +1,4 @@
-#include <tommath_private.h>
+#include "tommath_private.h"
#ifdef BN_MP_SET_LONG_LONG_C
/* LibTomMath, multiple-precision integer library -- Tom St Denis
*
@@ -11,8 +11,6 @@
*
* The library is free for all purposes without any express
* guarantee it works.
- *
- * Tom St Denis, tstdenis82@gmail.com, http://libtom.org
*/
/* set a platform dependent unsigned long long int */
diff --git a/libtommath/bn_mp_shrink.c b/libtommath/bn_mp_shrink.c
index 3e4dde0..b2e9d89 100644
--- a/libtommath/bn_mp_shrink.c
+++ b/libtommath/bn_mp_shrink.c
@@ -1,4 +1,4 @@
-#include <tommath_private.h>
+#include "tommath_private.h"
#ifdef BN_MP_SHRINK_C
/* LibTomMath, multiple-precision integer library -- Tom St Denis
*
@@ -11,8 +11,6 @@
*
* The library is free for all purposes without any express
* guarantee it works.
- *
- * Tom St Denis, tstdenis82@gmail.com, http://libtom.org
*/
/* shrink a bignum */
diff --git a/libtommath/bn_mp_signed_bin_size.c b/libtommath/bn_mp_signed_bin_size.c
index 1fdfd85..529482f 100644
--- a/libtommath/bn_mp_signed_bin_size.c
+++ b/libtommath/bn_mp_signed_bin_size.c
@@ -1,4 +1,4 @@
-#include <tommath_private.h>
+#include "tommath_private.h"
#ifdef BN_MP_SIGNED_BIN_SIZE_C
/* LibTomMath, multiple-precision integer library -- Tom St Denis
*
@@ -11,8 +11,6 @@
*
* The library is free for all purposes without any express
* guarantee it works.
- *
- * Tom St Denis, tstdenis82@gmail.com, http://libtom.org
*/
/* get the size for an signed equivalent */
diff --git a/libtommath/bn_mp_sqr.c b/libtommath/bn_mp_sqr.c
index a98f16c..237c919 100644
--- a/libtommath/bn_mp_sqr.c
+++ b/libtommath/bn_mp_sqr.c
@@ -1,4 +1,4 @@
-#include <tommath_private.h>
+#include "tommath_private.h"
#ifdef BN_MP_SQR_C
/* LibTomMath, multiple-precision integer library -- Tom St Denis
*
@@ -11,8 +11,6 @@
*
* The library is free for all purposes without any express
* guarantee it works.
- *
- * Tom St Denis, tstdenis82@gmail.com, http://libtom.org
*/
/* computes b = a*a */
diff --git a/libtommath/bn_mp_sqrmod.c b/libtommath/bn_mp_sqrmod.c
index c3c7ec9..f3ed8a8 100644
--- a/libtommath/bn_mp_sqrmod.c
+++ b/libtommath/bn_mp_sqrmod.c
@@ -1,4 +1,4 @@
-#include <tommath_private.h>
+#include "tommath_private.h"
#ifdef BN_MP_SQRMOD_C
/* LibTomMath, multiple-precision integer library -- Tom St Denis
*
@@ -11,8 +11,6 @@
*
* The library is free for all purposes without any express
* guarantee it works.
- *
- * Tom St Denis, tstdenis82@gmail.com, http://libtom.org
*/
/* c = a * a (mod b) */
diff --git a/libtommath/bn_mp_sqrt.c b/libtommath/bn_mp_sqrt.c
index 49a1bd0..d342a32 100644
--- a/libtommath/bn_mp_sqrt.c
+++ b/libtommath/bn_mp_sqrt.c
@@ -1,4 +1,4 @@
-#include <tommath_private.h>
+#include "tommath_private.h"
#ifdef BN_MP_SQRT_C
/* LibTomMath, multiple-precision integer library -- Tom St Denis
*
@@ -11,8 +11,6 @@
*
* The library is free for all purposes without any express
* guarantee it works.
- *
- * Tom St Denis, tstdenis82@gmail.com, http://libtom.org
*/
#ifndef NO_FLOATING_POINT
@@ -23,7 +21,7 @@
int mp_sqrt(const mp_int *arg, mp_int *ret)
{
int res;
- mp_int t1,t2;
+ mp_int t1, t2;
int i, j, k;
#ifndef NO_FLOATING_POINT
volatile double d;
@@ -108,30 +106,30 @@ int mp_sqrt(const mp_int *arg, mp_int *ret)
#endif
/* t1 > 0 */
- if ((res = mp_div(arg,&t1,&t2,NULL)) != MP_OKAY) {
+ if ((res = mp_div(arg, &t1, &t2, NULL)) != MP_OKAY) {
goto E1;
}
- if ((res = mp_add(&t1,&t2,&t1)) != MP_OKAY) {
+ if ((res = mp_add(&t1, &t2, &t1)) != MP_OKAY) {
goto E1;
}
- if ((res = mp_div_2(&t1,&t1)) != MP_OKAY) {
+ if ((res = mp_div_2(&t1, &t1)) != MP_OKAY) {
goto E1;
}
/* And now t1 > sqrt(arg) */
do {
- if ((res = mp_div(arg,&t1,&t2,NULL)) != MP_OKAY) {
+ if ((res = mp_div(arg, &t1, &t2, NULL)) != MP_OKAY) {
goto E1;
}
- if ((res = mp_add(&t1,&t2,&t1)) != MP_OKAY) {
+ if ((res = mp_add(&t1, &t2, &t1)) != MP_OKAY) {
goto E1;
}
- if ((res = mp_div_2(&t1,&t1)) != MP_OKAY) {
+ if ((res = mp_div_2(&t1, &t1)) != MP_OKAY) {
goto E1;
}
/* t1 >= sqrt(arg) >= t2 at this point */
- } while (mp_cmp_mag(&t1,&t2) == MP_GT);
+ } while (mp_cmp_mag(&t1, &t2) == MP_GT);
- mp_exch(&t1,ret);
+ mp_exch(&t1, ret);
E1:
mp_clear(&t2);
diff --git a/libtommath/bn_mp_sqrtmod_prime.c b/libtommath/bn_mp_sqrtmod_prime.c
index d4cf3de..f7647b9 100644
--- a/libtommath/bn_mp_sqrtmod_prime.c
+++ b/libtommath/bn_mp_sqrtmod_prime.c
@@ -1,4 +1,4 @@
-#include <tommath_private.h>
+#include "tommath_private.h"
#ifdef BN_MP_SQRTMOD_PRIME_C
/* LibTomMath, multiple-precision integer library -- Tom St Denis
*
diff --git a/libtommath/bn_mp_sub.c b/libtommath/bn_mp_sub.c
index 19cb65e..9ef1059 100644
--- a/libtommath/bn_mp_sub.c
+++ b/libtommath/bn_mp_sub.c
@@ -1,4 +1,4 @@
-#include <tommath_private.h>
+#include "tommath_private.h"
#ifdef BN_MP_SUB_C
/* LibTomMath, multiple-precision integer library -- Tom St Denis
*
@@ -11,8 +11,6 @@
*
* The library is free for all purposes without any express
* guarantee it works.
- *
- * Tom St Denis, tstdenis82@gmail.com, http://libtom.org
*/
/* high level subtraction (handles signs) */
diff --git a/libtommath/bn_mp_sub_d.c b/libtommath/bn_mp_sub_d.c
index e5fbfff..1ac9859 100644
--- a/libtommath/bn_mp_sub_d.c
+++ b/libtommath/bn_mp_sub_d.c
@@ -1,4 +1,4 @@
-#include <tommath_private.h>
+#include "tommath_private.h"
#ifdef BN_MP_SUB_D_C
/* LibTomMath, multiple-precision integer library -- Tom St Denis
*
@@ -11,8 +11,6 @@
*
* The library is free for all purposes without any express
* guarantee it works.
- *
- * Tom St Denis, tstdenis82@gmail.com, http://libtom.org
*/
/* single digit subtraction */
diff --git a/libtommath/bn_mp_submod.c b/libtommath/bn_mp_submod.c
index c4db397..0325b9d 100644
--- a/libtommath/bn_mp_submod.c
+++ b/libtommath/bn_mp_submod.c
@@ -1,4 +1,4 @@
-#include <tommath_private.h>
+#include "tommath_private.h"
#ifdef BN_MP_SUBMOD_C
/* LibTomMath, multiple-precision integer library -- Tom St Denis
*
@@ -11,8 +11,6 @@
*
* The library is free for all purposes without any express
* guarantee it works.
- *
- * Tom St Denis, tstdenis82@gmail.com, http://libtom.org
*/
/* d = a - b (mod c) */
diff --git a/libtommath/bn_mp_tc_and.c b/libtommath/bn_mp_tc_and.c
new file mode 100644
index 0000000..e9fe4c6
--- /dev/null
+++ b/libtommath/bn_mp_tc_and.c
@@ -0,0 +1,89 @@
+#include "tommath_private.h"
+#ifdef BN_MP_TC_AND_C
+/* LibTomMath, multiple-precision integer library -- Tom St Denis
+ *
+ * LibTomMath is a library that provides multiple-precision
+ * integer arithmetic as well as number theoretic functionality.
+ *
+ * The library was designed directly after the MPI library by
+ * Michael Fromberger but has been written from scratch with
+ * additional optimizations in place.
+ *
+ * The library is free for all purposes without any express
+ * guarantee it works.
+ */
+
+/* two complement and */
+int mp_tc_and(const mp_int *a, const mp_int *b, mp_int *c)
+{
+ int res = MP_OKAY, bits;
+ int as = mp_isneg(a), bs = mp_isneg(b);
+ mp_int *mx = NULL, _mx, acpy, bcpy;
+
+ if ((as != MP_NO) || (bs != MP_NO)) {
+ bits = MAX(mp_count_bits(a), mp_count_bits(b));
+ res = mp_init_set_int(&_mx, 1uL);
+ if (res != MP_OKAY) {
+ goto end;
+ }
+
+ mx = &_mx;
+ res = mp_mul_2d(mx, bits + 1, mx);
+ if (res != MP_OKAY) {
+ goto end;
+ }
+
+ if (as != MP_NO) {
+ res = mp_init(&acpy);
+ if (res != MP_OKAY) {
+ goto end;
+ }
+
+ res = mp_add(mx, a, &acpy);
+ if (res != MP_OKAY) {
+ mp_clear(&acpy);
+ goto end;
+ }
+ a = &acpy;
+ }
+ if (bs != MP_NO) {
+ res = mp_init(&bcpy);
+ if (res != MP_OKAY) {
+ goto end;
+ }
+
+ res = mp_add(mx, b, &bcpy);
+ if (res != MP_OKAY) {
+ mp_clear(&bcpy);
+ goto end;
+ }
+ b = &bcpy;
+ }
+ }
+
+ res = mp_and(a, b, c);
+
+ if ((as != MP_NO) && (bs != MP_NO) && (res == MP_OKAY)) {
+ res = mp_sub(c, mx, c);
+ }
+
+end:
+ if (a == &acpy) {
+ mp_clear(&acpy);
+ }
+
+ if (b == &bcpy) {
+ mp_clear(&bcpy);
+ }
+
+ if (mx == &_mx) {
+ mp_clear(mx);
+ }
+
+ return res;
+}
+#endif
+
+/* ref: $Format:%D$ */
+/* git commit: $Format:%H$ */
+/* commit time: $Format:%ai$ */
diff --git a/libtommath/bn_mp_tc_div_2d.c b/libtommath/bn_mp_tc_div_2d.c
new file mode 100644
index 0000000..ea190c3
--- /dev/null
+++ b/libtommath/bn_mp_tc_div_2d.c
@@ -0,0 +1,36 @@
+#include "tommath_private.h"
+#ifdef BN_MP_TC_DIV_2D_C
+/* LibTomMath, multiple-precision integer library -- Tom St Denis
+ *
+ * LibTomMath is a library that provides multiple-precision
+ * integer arithmetic as well as number theoretic functionality.
+ *
+ * The library was designed directly after the MPI library by
+ * Michael Fromberger but has been written from scratch with
+ * additional optimizations in place.
+ *
+ * The library is free for all purposes without any express
+ * guarantee it works.
+ */
+
+/* two complement right shift */
+int mp_tc_div_2d(const mp_int *a, int b, mp_int *c)
+{
+ int res;
+ if (mp_isneg(a) == MP_NO) {
+ return mp_div_2d(a, b, c, NULL);
+ }
+
+ res = mp_add_d(a, 1uL, c);
+ if (res != MP_OKAY) {
+ return res;
+ }
+
+ res = mp_div_2d(c, b, c, NULL);
+ return (res == MP_OKAY) ? mp_sub_d(c, 1uL, c) : res;
+}
+#endif
+
+/* ref: $Format:%D$ */
+/* git commit: $Format:%H$ */
+/* commit time: $Format:%ai$ */
diff --git a/libtommath/bn_mp_tc_or.c b/libtommath/bn_mp_tc_or.c
new file mode 100644
index 0000000..91b6b40
--- /dev/null
+++ b/libtommath/bn_mp_tc_or.c
@@ -0,0 +1,89 @@
+#include "tommath_private.h"
+#ifdef BN_MP_TC_OR_C
+/* LibTomMath, multiple-precision integer library -- Tom St Denis
+ *
+ * LibTomMath is a library that provides multiple-precision
+ * integer arithmetic as well as number theoretic functionality.
+ *
+ * The library was designed directly after the MPI library by
+ * Michael Fromberger but has been written from scratch with
+ * additional optimizations in place.
+ *
+ * The library is free for all purposes without any express
+ * guarantee it works.
+ */
+
+/* two complement or */
+int mp_tc_or(const mp_int *a, const mp_int *b, mp_int *c)
+{
+ int res = MP_OKAY, bits;
+ int as = mp_isneg(a), bs = mp_isneg(b);
+ mp_int *mx = NULL, _mx, acpy, bcpy;
+
+ if ((as != MP_NO) || (bs != MP_NO)) {
+ bits = MAX(mp_count_bits(a), mp_count_bits(b));
+ res = mp_init_set_int(&_mx, 1uL);
+ if (res != MP_OKAY) {
+ goto end;
+ }
+
+ mx = &_mx;
+ res = mp_mul_2d(mx, bits + 1, mx);
+ if (res != MP_OKAY) {
+ goto end;
+ }
+
+ if (as != MP_NO) {
+ res = mp_init(&acpy);
+ if (res != MP_OKAY) {
+ goto end;
+ }
+
+ res = mp_add(mx, a, &acpy);
+ if (res != MP_OKAY) {
+ mp_clear(&acpy);
+ goto end;
+ }
+ a = &acpy;
+ }
+ if (bs != MP_NO) {
+ res = mp_init(&bcpy);
+ if (res != MP_OKAY) {
+ goto end;
+ }
+
+ res = mp_add(mx, b, &bcpy);
+ if (res != MP_OKAY) {
+ mp_clear(&bcpy);
+ goto end;
+ }
+ b = &bcpy;
+ }
+ }
+
+ res = mp_or(a, b, c);
+
+ if (((as != MP_NO) || (bs != MP_NO)) && (res == MP_OKAY)) {
+ res = mp_sub(c, mx, c);
+ }
+
+end:
+ if (a == &acpy) {
+ mp_clear(&acpy);
+ }
+
+ if (b == &bcpy) {
+ mp_clear(&bcpy);
+ }
+
+ if (mx == &_mx) {
+ mp_clear(mx);
+ }
+
+ return res;
+}
+#endif
+
+/* ref: $Format:%D$ */
+/* git commit: $Format:%H$ */
+/* commit time: $Format:%ai$ */
diff --git a/libtommath/bn_mp_tc_xor.c b/libtommath/bn_mp_tc_xor.c
new file mode 100644
index 0000000..50fb12d
--- /dev/null
+++ b/libtommath/bn_mp_tc_xor.c
@@ -0,0 +1,89 @@
+#include "tommath_private.h"
+#ifdef BN_MP_TC_XOR_C
+/* LibTomMath, multiple-precision integer library -- Tom St Denis
+ *
+ * LibTomMath is a library that provides multiple-precision
+ * integer arithmetic as well as number theoretic functionality.
+ *
+ * The library was designed directly after the MPI library by
+ * Michael Fromberger but has been written from scratch with
+ * additional optimizations in place.
+ *
+ * The library is free for all purposes without any express
+ * guarantee it works.
+ */
+
+/* two complement xor */
+int mp_tc_xor(const mp_int *a, const mp_int *b, mp_int *c)
+{
+ int res = MP_OKAY, bits;
+ int as = mp_isneg(a), bs = mp_isneg(b);
+ mp_int *mx = NULL, _mx, acpy, bcpy;
+
+ if ((as != MP_NO) || (bs != MP_NO)) {
+ bits = MAX(mp_count_bits(a), mp_count_bits(b));
+ res = mp_init_set_int(&_mx, 1uL);
+ if (res != MP_OKAY) {
+ goto end;
+ }
+
+ mx = &_mx;
+ res = mp_mul_2d(mx, bits + 1, mx);
+ if (res != MP_OKAY) {
+ goto end;
+ }
+
+ if (as != MP_NO) {
+ res = mp_init(&acpy);
+ if (res != MP_OKAY) {
+ goto end;
+ }
+
+ res = mp_add(mx, a, &acpy);
+ if (res != MP_OKAY) {
+ mp_clear(&acpy);
+ goto end;
+ }
+ a = &acpy;
+ }
+ if (bs != MP_NO) {
+ res = mp_init(&bcpy);
+ if (res != MP_OKAY) {
+ goto end;
+ }
+
+ res = mp_add(mx, b, &bcpy);
+ if (res != MP_OKAY) {
+ mp_clear(&bcpy);
+ goto end;
+ }
+ b = &bcpy;
+ }
+ }
+
+ res = mp_xor(a, b, c);
+
+ if ((as != bs) && (res == MP_OKAY)) {
+ res = mp_sub(c, mx, c);
+ }
+
+end:
+ if (a == &acpy) {
+ mp_clear(&acpy);
+ }
+
+ if (b == &bcpy) {
+ mp_clear(&bcpy);
+ }
+
+ if (mx == &_mx) {
+ mp_clear(mx);
+ }
+
+ return res;
+}
+#endif
+
+/* ref: $Format:%D$ */
+/* git commit: $Format:%H$ */
+/* commit time: $Format:%ai$ */
diff --git a/libtommath/bn_mp_to_signed_bin.c b/libtommath/bn_mp_to_signed_bin.c
index 4d4be88..22a938e 100644
--- a/libtommath/bn_mp_to_signed_bin.c
+++ b/libtommath/bn_mp_to_signed_bin.c
@@ -1,4 +1,4 @@
-#include <tommath_private.h>
+#include "tommath_private.h"
#ifdef BN_MP_TO_SIGNED_BIN_C
/* LibTomMath, multiple-precision integer library -- Tom St Denis
*
@@ -11,8 +11,6 @@
*
* The library is free for all purposes without any express
* guarantee it works.
- *
- * Tom St Denis, tstdenis82@gmail.com, http://libtom.org
*/
/* store in signed [big endian] format */
diff --git a/libtommath/bn_mp_to_signed_bin_n.c b/libtommath/bn_mp_to_signed_bin_n.c
index f1d7c8b..417a380 100644
--- a/libtommath/bn_mp_to_signed_bin_n.c
+++ b/libtommath/bn_mp_to_signed_bin_n.c
@@ -1,4 +1,4 @@
-#include <tommath_private.h>
+#include "tommath_private.h"
#ifdef BN_MP_TO_SIGNED_BIN_N_C
/* LibTomMath, multiple-precision integer library -- Tom St Denis
*
@@ -11,8 +11,6 @@
*
* The library is free for all purposes without any express
* guarantee it works.
- *
- * Tom St Denis, tstdenis82@gmail.com, http://libtom.org
*/
/* store in signed [big endian] format */
diff --git a/libtommath/bn_mp_to_unsigned_bin.c b/libtommath/bn_mp_to_unsigned_bin.c
index a53f711..aa719ae 100644
--- a/libtommath/bn_mp_to_unsigned_bin.c
+++ b/libtommath/bn_mp_to_unsigned_bin.c
@@ -1,4 +1,4 @@
-#include <tommath_private.h>
+#include "tommath_private.h"
#ifdef BN_MP_TO_UNSIGNED_BIN_C
/* LibTomMath, multiple-precision integer library -- Tom St Denis
*
@@ -11,8 +11,6 @@
*
* The library is free for all purposes without any express
* guarantee it works.
- *
- * Tom St Denis, tstdenis82@gmail.com, http://libtom.org
*/
/* store in unsigned [big endian] format */
diff --git a/libtommath/bn_mp_to_unsigned_bin_n.c b/libtommath/bn_mp_to_unsigned_bin_n.c
index e7d303c..43676e8 100644
--- a/libtommath/bn_mp_to_unsigned_bin_n.c
+++ b/libtommath/bn_mp_to_unsigned_bin_n.c
@@ -1,4 +1,4 @@
-#include <tommath_private.h>
+#include "tommath_private.h"
#ifdef BN_MP_TO_UNSIGNED_BIN_N_C
/* LibTomMath, multiple-precision integer library -- Tom St Denis
*
@@ -11,8 +11,6 @@
*
* The library is free for all purposes without any express
* guarantee it works.
- *
- * Tom St Denis, tstdenis82@gmail.com, http://libtom.org
*/
/* store in unsigned [big endian] format */
diff --git a/libtommath/bn_mp_toom_mul.c b/libtommath/bn_mp_toom_mul.c
index 00b6bfb..ff7df02 100644
--- a/libtommath/bn_mp_toom_mul.c
+++ b/libtommath/bn_mp_toom_mul.c
@@ -1,4 +1,4 @@
-#include <tommath_private.h>
+#include "tommath_private.h"
#ifdef BN_MP_TOOM_MUL_C
/* LibTomMath, multiple-precision integer library -- Tom St Denis
*
@@ -11,8 +11,6 @@
*
* The library is free for all purposes without any express
* guarantee it works.
- *
- * Tom St Denis, tstdenis82@gmail.com, http://libtom.org
*/
/* multiplication using the Toom-Cook 3-way algorithm
@@ -39,126 +37,126 @@ int mp_toom_mul(const mp_int *a, const mp_int *b, mp_int *c)
/* a = a2 * B**2 + a1 * B + a0 */
if ((res = mp_mod_2d(a, DIGIT_BIT * B, &a0)) != MP_OKAY) {
- goto ERR;
+ goto LBL_ERR;
}
if ((res = mp_copy(a, &a1)) != MP_OKAY) {
- goto ERR;
+ goto LBL_ERR;
}
mp_rshd(&a1, B);
if ((res = mp_mod_2d(&a1, DIGIT_BIT * B, &a1)) != MP_OKAY) {
- goto ERR;
+ goto LBL_ERR;
}
if ((res = mp_copy(a, &a2)) != MP_OKAY) {
- goto ERR;
+ goto LBL_ERR;
}
mp_rshd(&a2, B*2);
/* b = b2 * B**2 + b1 * B + b0 */
if ((res = mp_mod_2d(b, DIGIT_BIT * B, &b0)) != MP_OKAY) {
- goto ERR;
+ goto LBL_ERR;
}
if ((res = mp_copy(b, &b1)) != MP_OKAY) {
- goto ERR;
+ goto LBL_ERR;
}
mp_rshd(&b1, B);
(void)mp_mod_2d(&b1, DIGIT_BIT * B, &b1);
if ((res = mp_copy(b, &b2)) != MP_OKAY) {
- goto ERR;
+ goto LBL_ERR;
}
mp_rshd(&b2, B*2);
/* w0 = a0*b0 */
if ((res = mp_mul(&a0, &b0, &w0)) != MP_OKAY) {
- goto ERR;
+ goto LBL_ERR;
}
/* w4 = a2 * b2 */
if ((res = mp_mul(&a2, &b2, &w4)) != MP_OKAY) {
- goto ERR;
+ goto LBL_ERR;
}
/* w1 = (a2 + 2(a1 + 2a0))(b2 + 2(b1 + 2b0)) */
if ((res = mp_mul_2(&a0, &tmp1)) != MP_OKAY) {
- goto ERR;
+ goto LBL_ERR;
}
if ((res = mp_add(&tmp1, &a1, &tmp1)) != MP_OKAY) {
- goto ERR;
+ goto LBL_ERR;
}
if ((res = mp_mul_2(&tmp1, &tmp1)) != MP_OKAY) {
- goto ERR;
+ goto LBL_ERR;
}
if ((res = mp_add(&tmp1, &a2, &tmp1)) != MP_OKAY) {
- goto ERR;
+ goto LBL_ERR;
}
if ((res = mp_mul_2(&b0, &tmp2)) != MP_OKAY) {
- goto ERR;
+ goto LBL_ERR;
}
if ((res = mp_add(&tmp2, &b1, &tmp2)) != MP_OKAY) {
- goto ERR;
+ goto LBL_ERR;
}
if ((res = mp_mul_2(&tmp2, &tmp2)) != MP_OKAY) {
- goto ERR;
+ goto LBL_ERR;
}
if ((res = mp_add(&tmp2, &b2, &tmp2)) != MP_OKAY) {
- goto ERR;
+ goto LBL_ERR;
}
if ((res = mp_mul(&tmp1, &tmp2, &w1)) != MP_OKAY) {
- goto ERR;
+ goto LBL_ERR;
}
/* w3 = (a0 + 2(a1 + 2a2))(b0 + 2(b1 + 2b2)) */
if ((res = mp_mul_2(&a2, &tmp1)) != MP_OKAY) {
- goto ERR;
+ goto LBL_ERR;
}
if ((res = mp_add(&tmp1, &a1, &tmp1)) != MP_OKAY) {
- goto ERR;
+ goto LBL_ERR;
}
if ((res = mp_mul_2(&tmp1, &tmp1)) != MP_OKAY) {
- goto ERR;
+ goto LBL_ERR;
}
if ((res = mp_add(&tmp1, &a0, &tmp1)) != MP_OKAY) {
- goto ERR;
+ goto LBL_ERR;
}
if ((res = mp_mul_2(&b2, &tmp2)) != MP_OKAY) {
- goto ERR;
+ goto LBL_ERR;
}
if ((res = mp_add(&tmp2, &b1, &tmp2)) != MP_OKAY) {
- goto ERR;
+ goto LBL_ERR;
}
if ((res = mp_mul_2(&tmp2, &tmp2)) != MP_OKAY) {
- goto ERR;
+ goto LBL_ERR;
}
if ((res = mp_add(&tmp2, &b0, &tmp2)) != MP_OKAY) {
- goto ERR;
+ goto LBL_ERR;
}
if ((res = mp_mul(&tmp1, &tmp2, &w3)) != MP_OKAY) {
- goto ERR;
+ goto LBL_ERR;
}
/* w2 = (a2 + a1 + a0)(b2 + b1 + b0) */
if ((res = mp_add(&a2, &a1, &tmp1)) != MP_OKAY) {
- goto ERR;
+ goto LBL_ERR;
}
if ((res = mp_add(&tmp1, &a0, &tmp1)) != MP_OKAY) {
- goto ERR;
+ goto LBL_ERR;
}
if ((res = mp_add(&b2, &b1, &tmp2)) != MP_OKAY) {
- goto ERR;
+ goto LBL_ERR;
}
if ((res = mp_add(&tmp2, &b0, &tmp2)) != MP_OKAY) {
- goto ERR;
+ goto LBL_ERR;
}
if ((res = mp_mul(&tmp1, &tmp2, &w2)) != MP_OKAY) {
- goto ERR;
+ goto LBL_ERR;
}
/* now solve the matrix
@@ -175,104 +173,104 @@ int mp_toom_mul(const mp_int *a, const mp_int *b, mp_int *c)
/* r1 - r4 */
if ((res = mp_sub(&w1, &w4, &w1)) != MP_OKAY) {
- goto ERR;
+ goto LBL_ERR;
}
/* r3 - r0 */
if ((res = mp_sub(&w3, &w0, &w3)) != MP_OKAY) {
- goto ERR;
+ goto LBL_ERR;
}
/* r1/2 */
if ((res = mp_div_2(&w1, &w1)) != MP_OKAY) {
- goto ERR;
+ goto LBL_ERR;
}
/* r3/2 */
if ((res = mp_div_2(&w3, &w3)) != MP_OKAY) {
- goto ERR;
+ goto LBL_ERR;
}
/* r2 - r0 - r4 */
if ((res = mp_sub(&w2, &w0, &w2)) != MP_OKAY) {
- goto ERR;
+ goto LBL_ERR;
}
if ((res = mp_sub(&w2, &w4, &w2)) != MP_OKAY) {
- goto ERR;
+ goto LBL_ERR;
}
/* r1 - r2 */
if ((res = mp_sub(&w1, &w2, &w1)) != MP_OKAY) {
- goto ERR;
+ goto LBL_ERR;
}
/* r3 - r2 */
if ((res = mp_sub(&w3, &w2, &w3)) != MP_OKAY) {
- goto ERR;
+ goto LBL_ERR;
}
/* r1 - 8r0 */
if ((res = mp_mul_2d(&w0, 3, &tmp1)) != MP_OKAY) {
- goto ERR;
+ goto LBL_ERR;
}
if ((res = mp_sub(&w1, &tmp1, &w1)) != MP_OKAY) {
- goto ERR;
+ goto LBL_ERR;
}
/* r3 - 8r4 */
if ((res = mp_mul_2d(&w4, 3, &tmp1)) != MP_OKAY) {
- goto ERR;
+ goto LBL_ERR;
}
if ((res = mp_sub(&w3, &tmp1, &w3)) != MP_OKAY) {
- goto ERR;
+ goto LBL_ERR;
}
/* 3r2 - r1 - r3 */
if ((res = mp_mul_d(&w2, 3uL, &w2)) != MP_OKAY) {
- goto ERR;
+ goto LBL_ERR;
}
if ((res = mp_sub(&w2, &w1, &w2)) != MP_OKAY) {
- goto ERR;
+ goto LBL_ERR;
}
if ((res = mp_sub(&w2, &w3, &w2)) != MP_OKAY) {
- goto ERR;
+ goto LBL_ERR;
}
/* r1 - r2 */
if ((res = mp_sub(&w1, &w2, &w1)) != MP_OKAY) {
- goto ERR;
+ goto LBL_ERR;
}
/* r3 - r2 */
if ((res = mp_sub(&w3, &w2, &w3)) != MP_OKAY) {
- goto ERR;
+ goto LBL_ERR;
}
/* r1/3 */
if ((res = mp_div_3(&w1, &w1, NULL)) != MP_OKAY) {
- goto ERR;
+ goto LBL_ERR;
}
/* r3/3 */
if ((res = mp_div_3(&w3, &w3, NULL)) != MP_OKAY) {
- goto ERR;
+ goto LBL_ERR;
}
/* at this point shift W[n] by B*n */
if ((res = mp_lshd(&w1, 1*B)) != MP_OKAY) {
- goto ERR;
+ goto LBL_ERR;
}
if ((res = mp_lshd(&w2, 2*B)) != MP_OKAY) {
- goto ERR;
+ goto LBL_ERR;
}
if ((res = mp_lshd(&w3, 3*B)) != MP_OKAY) {
- goto ERR;
+ goto LBL_ERR;
}
if ((res = mp_lshd(&w4, 4*B)) != MP_OKAY) {
- goto ERR;
+ goto LBL_ERR;
}
if ((res = mp_add(&w0, &w1, c)) != MP_OKAY) {
- goto ERR;
+ goto LBL_ERR;
}
if ((res = mp_add(&w2, &w3, &tmp1)) != MP_OKAY) {
- goto ERR;
+ goto LBL_ERR;
}
if ((res = mp_add(&w4, &tmp1, &tmp1)) != MP_OKAY) {
- goto ERR;
+ goto LBL_ERR;
}
if ((res = mp_add(&tmp1, c, c)) != MP_OKAY) {
- goto ERR;
+ goto LBL_ERR;
}
-ERR:
+LBL_ERR:
mp_clear_multi(&w0, &w1, &w2, &w3, &w4,
&a0, &a1, &a2, &b0, &b1,
&b2, &tmp1, &tmp2, NULL);
diff --git a/libtommath/bn_mp_toom_sqr.c b/libtommath/bn_mp_toom_sqr.c
index 183de20..edc89cd 100644
--- a/libtommath/bn_mp_toom_sqr.c
+++ b/libtommath/bn_mp_toom_sqr.c
@@ -1,4 +1,4 @@
-#include <tommath_private.h>
+#include "tommath_private.h"
#ifdef BN_MP_TOOM_SQR_C
/* LibTomMath, multiple-precision integer library -- Tom St Denis
*
@@ -11,8 +11,6 @@
*
* The library is free for all purposes without any express
* guarantee it works.
- *
- * Tom St Denis, tstdenis82@gmail.com, http://libtom.org
*/
/* squaring using Toom-Cook 3-way algorithm */
@@ -31,78 +29,78 @@ int mp_toom_sqr(const mp_int *a, mp_int *b)
/* a = a2 * B**2 + a1 * B + a0 */
if ((res = mp_mod_2d(a, DIGIT_BIT * B, &a0)) != MP_OKAY) {
- goto ERR;
+ goto LBL_ERR;
}
if ((res = mp_copy(a, &a1)) != MP_OKAY) {
- goto ERR;
+ goto LBL_ERR;
}
mp_rshd(&a1, B);
if ((res = mp_mod_2d(&a1, DIGIT_BIT * B, &a1)) != MP_OKAY) {
- goto ERR;
+ goto LBL_ERR;
}
if ((res = mp_copy(a, &a2)) != MP_OKAY) {
- goto ERR;
+ goto LBL_ERR;
}
mp_rshd(&a2, B*2);
/* w0 = a0*a0 */
if ((res = mp_sqr(&a0, &w0)) != MP_OKAY) {
- goto ERR;
+ goto LBL_ERR;
}
/* w4 = a2 * a2 */
if ((res = mp_sqr(&a2, &w4)) != MP_OKAY) {
- goto ERR;
+ goto LBL_ERR;
}
/* w1 = (a2 + 2(a1 + 2a0))**2 */
if ((res = mp_mul_2(&a0, &tmp1)) != MP_OKAY) {
- goto ERR;
+ goto LBL_ERR;
}
if ((res = mp_add(&tmp1, &a1, &tmp1)) != MP_OKAY) {
- goto ERR;
+ goto LBL_ERR;
}
if ((res = mp_mul_2(&tmp1, &tmp1)) != MP_OKAY) {
- goto ERR;
+ goto LBL_ERR;
}
if ((res = mp_add(&tmp1, &a2, &tmp1)) != MP_OKAY) {
- goto ERR;
+ goto LBL_ERR;
}
if ((res = mp_sqr(&tmp1, &w1)) != MP_OKAY) {
- goto ERR;
+ goto LBL_ERR;
}
/* w3 = (a0 + 2(a1 + 2a2))**2 */
if ((res = mp_mul_2(&a2, &tmp1)) != MP_OKAY) {
- goto ERR;
+ goto LBL_ERR;
}
if ((res = mp_add(&tmp1, &a1, &tmp1)) != MP_OKAY) {
- goto ERR;
+ goto LBL_ERR;
}
if ((res = mp_mul_2(&tmp1, &tmp1)) != MP_OKAY) {
- goto ERR;
+ goto LBL_ERR;
}
if ((res = mp_add(&tmp1, &a0, &tmp1)) != MP_OKAY) {
- goto ERR;
+ goto LBL_ERR;
}
if ((res = mp_sqr(&tmp1, &w3)) != MP_OKAY) {
- goto ERR;
+ goto LBL_ERR;
}
/* w2 = (a2 + a1 + a0)**2 */
if ((res = mp_add(&a2, &a1, &tmp1)) != MP_OKAY) {
- goto ERR;
+ goto LBL_ERR;
}
if ((res = mp_add(&tmp1, &a0, &tmp1)) != MP_OKAY) {
- goto ERR;
+ goto LBL_ERR;
}
if ((res = mp_sqr(&tmp1, &w2)) != MP_OKAY) {
- goto ERR;
+ goto LBL_ERR;
}
/* now solve the matrix
@@ -118,104 +116,104 @@ int mp_toom_sqr(const mp_int *a, mp_int *b)
/* r1 - r4 */
if ((res = mp_sub(&w1, &w4, &w1)) != MP_OKAY) {
- goto ERR;
+ goto LBL_ERR;
}
/* r3 - r0 */
if ((res = mp_sub(&w3, &w0, &w3)) != MP_OKAY) {
- goto ERR;
+ goto LBL_ERR;
}
/* r1/2 */
if ((res = mp_div_2(&w1, &w1)) != MP_OKAY) {
- goto ERR;
+ goto LBL_ERR;
}
/* r3/2 */
if ((res = mp_div_2(&w3, &w3)) != MP_OKAY) {
- goto ERR;
+ goto LBL_ERR;
}
/* r2 - r0 - r4 */
if ((res = mp_sub(&w2, &w0, &w2)) != MP_OKAY) {
- goto ERR;
+ goto LBL_ERR;
}
if ((res = mp_sub(&w2, &w4, &w2)) != MP_OKAY) {
- goto ERR;
+ goto LBL_ERR;
}
/* r1 - r2 */
if ((res = mp_sub(&w1, &w2, &w1)) != MP_OKAY) {
- goto ERR;
+ goto LBL_ERR;
}
/* r3 - r2 */
if ((res = mp_sub(&w3, &w2, &w3)) != MP_OKAY) {
- goto ERR;
+ goto LBL_ERR;
}
/* r1 - 8r0 */
if ((res = mp_mul_2d(&w0, 3, &tmp1)) != MP_OKAY) {
- goto ERR;
+ goto LBL_ERR;
}
if ((res = mp_sub(&w1, &tmp1, &w1)) != MP_OKAY) {
- goto ERR;
+ goto LBL_ERR;
}
/* r3 - 8r4 */
if ((res = mp_mul_2d(&w4, 3, &tmp1)) != MP_OKAY) {
- goto ERR;
+ goto LBL_ERR;
}
if ((res = mp_sub(&w3, &tmp1, &w3)) != MP_OKAY) {
- goto ERR;
+ goto LBL_ERR;
}
/* 3r2 - r1 - r3 */
if ((res = mp_mul_d(&w2, 3uL, &w2)) != MP_OKAY) {
- goto ERR;
+ goto LBL_ERR;
}
if ((res = mp_sub(&w2, &w1, &w2)) != MP_OKAY) {
- goto ERR;
+ goto LBL_ERR;
}
if ((res = mp_sub(&w2, &w3, &w2)) != MP_OKAY) {
- goto ERR;
+ goto LBL_ERR;
}
/* r1 - r2 */
if ((res = mp_sub(&w1, &w2, &w1)) != MP_OKAY) {
- goto ERR;
+ goto LBL_ERR;
}
/* r3 - r2 */
if ((res = mp_sub(&w3, &w2, &w3)) != MP_OKAY) {
- goto ERR;
+ goto LBL_ERR;
}
/* r1/3 */
if ((res = mp_div_3(&w1, &w1, NULL)) != MP_OKAY) {
- goto ERR;
+ goto LBL_ERR;
}
/* r3/3 */
if ((res = mp_div_3(&w3, &w3, NULL)) != MP_OKAY) {
- goto ERR;
+ goto LBL_ERR;
}
/* at this point shift W[n] by B*n */
if ((res = mp_lshd(&w1, 1*B)) != MP_OKAY) {
- goto ERR;
+ goto LBL_ERR;
}
if ((res = mp_lshd(&w2, 2*B)) != MP_OKAY) {
- goto ERR;
+ goto LBL_ERR;
}
if ((res = mp_lshd(&w3, 3*B)) != MP_OKAY) {
- goto ERR;
+ goto LBL_ERR;
}
if ((res = mp_lshd(&w4, 4*B)) != MP_OKAY) {
- goto ERR;
+ goto LBL_ERR;
}
if ((res = mp_add(&w0, &w1, b)) != MP_OKAY) {
- goto ERR;
+ goto LBL_ERR;
}
if ((res = mp_add(&w2, &w3, &tmp1)) != MP_OKAY) {
- goto ERR;
+ goto LBL_ERR;
}
if ((res = mp_add(&w4, &tmp1, &tmp1)) != MP_OKAY) {
- goto ERR;
+ goto LBL_ERR;
}
if ((res = mp_add(&tmp1, b, b)) != MP_OKAY) {
- goto ERR;
+ goto LBL_ERR;
}
-ERR:
+LBL_ERR:
mp_clear_multi(&w0, &w1, &w2, &w3, &w4, &a0, &a1, &a2, &tmp1, NULL);
return res;
}
diff --git a/libtommath/bn_mp_toradix.c b/libtommath/bn_mp_toradix.c
index 7dd6e4f..8c05e75 100644
--- a/libtommath/bn_mp_toradix.c
+++ b/libtommath/bn_mp_toradix.c
@@ -1,4 +1,4 @@
-#include <tommath_private.h>
+#include "tommath_private.h"
#ifdef BN_MP_TORADIX_C
/* LibTomMath, multiple-precision integer library -- Tom St Denis
*
@@ -11,8 +11,6 @@
*
* The library is free for all purposes without any express
* guarantee it works.
- *
- * Tom St Denis, tstdenis82@gmail.com, http://libtom.org
*/
/* stores a bignum as a ASCII string in a given radix (2..64) */
diff --git a/libtommath/bn_mp_toradix_n.c b/libtommath/bn_mp_toradix_n.c
index ef885fc..27cb401 100644
--- a/libtommath/bn_mp_toradix_n.c
+++ b/libtommath/bn_mp_toradix_n.c
@@ -1,4 +1,4 @@
-#include <tommath_private.h>
+#include "tommath_private.h"
#ifdef BN_MP_TORADIX_N_C
/* LibTomMath, multiple-precision integer library -- Tom St Denis
*
@@ -11,8 +11,6 @@
*
* The library is free for all purposes without any express
* guarantee it works.
- *
- * Tom St Denis, tstdenis82@gmail.com, http://libtom.org
*/
/* stores a bignum as a ASCII string in a given radix (2..64)
diff --git a/libtommath/bn_mp_unsigned_bin_size.c b/libtommath/bn_mp_unsigned_bin_size.c
index 2b9ce8a..bc9b853 100644
--- a/libtommath/bn_mp_unsigned_bin_size.c
+++ b/libtommath/bn_mp_unsigned_bin_size.c
@@ -1,4 +1,4 @@
-#include <tommath_private.h>
+#include "tommath_private.h"
#ifdef BN_MP_UNSIGNED_BIN_SIZE_C
/* LibTomMath, multiple-precision integer library -- Tom St Denis
*
@@ -11,8 +11,6 @@
*
* The library is free for all purposes without any express
* guarantee it works.
- *
- * Tom St Denis, tstdenis82@gmail.com, http://libtom.org
*/
/* get the size for an unsigned equivalent */
diff --git a/libtommath/bn_mp_xor.c b/libtommath/bn_mp_xor.c
index 9ebc53a..b502eb0 100644
--- a/libtommath/bn_mp_xor.c
+++ b/libtommath/bn_mp_xor.c
@@ -1,4 +1,4 @@
-#include <tommath_private.h>
+#include "tommath_private.h"
#ifdef BN_MP_XOR_C
/* LibTomMath, multiple-precision integer library -- Tom St Denis
*
@@ -11,8 +11,6 @@
*
* The library is free for all purposes without any express
* guarantee it works.
- *
- * Tom St Denis, tstdenis82@gmail.com, http://libtom.org
*/
/* XOR two ints together */
diff --git a/libtommath/bn_mp_zero.c b/libtommath/bn_mp_zero.c
index 08aac2a..78f165b 100644
--- a/libtommath/bn_mp_zero.c
+++ b/libtommath/bn_mp_zero.c
@@ -1,4 +1,4 @@
-#include <tommath_private.h>
+#include "tommath_private.h"
#ifdef BN_MP_ZERO_C
/* LibTomMath, multiple-precision integer library -- Tom St Denis
*
@@ -11,8 +11,6 @@
*
* The library is free for all purposes without any express
* guarantee it works.
- *
- * Tom St Denis, tstdenis82@gmail.com, http://libtom.org
*/
/* set to zero */
diff --git a/libtommath/bn_prime_tab.c b/libtommath/bn_prime_tab.c
index bcd23ed..f23afcb 100644
--- a/libtommath/bn_prime_tab.c
+++ b/libtommath/bn_prime_tab.c
@@ -1,4 +1,4 @@
-#include <tommath_private.h>
+#include "tommath_private.h"
#ifdef BN_PRIME_TAB_C
/* LibTomMath, multiple-precision integer library -- Tom St Denis
*
@@ -11,8 +11,6 @@
*
* The library is free for all purposes without any express
* guarantee it works.
- *
- * Tom St Denis, tstdenis82@gmail.com, http://libtom.org
*/
const mp_digit ltm_prime_tab[] = {
diff --git a/libtommath/bn_reverse.c b/libtommath/bn_reverse.c
index 71e3d03..5b49172 100644
--- a/libtommath/bn_reverse.c
+++ b/libtommath/bn_reverse.c
@@ -1,4 +1,4 @@
-#include <tommath_private.h>
+#include "tommath_private.h"
#ifdef BN_REVERSE_C
/* LibTomMath, multiple-precision integer library -- Tom St Denis
*
@@ -11,8 +11,6 @@
*
* The library is free for all purposes without any express
* guarantee it works.
- *
- * Tom St Denis, tstdenis82@gmail.com, http://libtom.org
*/
/* reverse an array, used for radix code */
diff --git a/libtommath/bn_s_mp_add.c b/libtommath/bn_s_mp_add.c
index 3f908ef..8a3bc82 100644
--- a/libtommath/bn_s_mp_add.c
+++ b/libtommath/bn_s_mp_add.c
@@ -1,4 +1,4 @@
-#include <tommath_private.h>
+#include "tommath_private.h"
#ifdef BN_S_MP_ADD_C
/* LibTomMath, multiple-precision integer library -- Tom St Denis
*
@@ -11,8 +11,6 @@
*
* The library is free for all purposes without any express
* guarantee it works.
- *
- * Tom St Denis, tstdenis82@gmail.com, http://libtom.org
*/
/* low level addition, based on HAC pp.594, Algorithm 14.7 */
diff --git a/libtommath/bn_s_mp_exptmod.c b/libtommath/bn_s_mp_exptmod.c
index a954757..f84da21 100644
--- a/libtommath/bn_s_mp_exptmod.c
+++ b/libtommath/bn_s_mp_exptmod.c
@@ -1,4 +1,4 @@
-#include <tommath_private.h>
+#include "tommath_private.h"
#ifdef BN_S_MP_EXPTMOD_C
/* LibTomMath, multiple-precision integer library -- Tom St Denis
*
@@ -11,8 +11,6 @@
*
* The library is free for all purposes without any express
* guarantee it works.
- *
- * Tom St Denis, tstdenis82@gmail.com, http://libtom.org
*/
#ifdef MP_LOW_MEM
diff --git a/libtommath/bn_s_mp_mul_digs.c b/libtommath/bn_s_mp_mul_digs.c
index 214ae31..442c803 100644
--- a/libtommath/bn_s_mp_mul_digs.c
+++ b/libtommath/bn_s_mp_mul_digs.c
@@ -1,4 +1,4 @@
-#include <tommath_private.h>
+#include "tommath_private.h"
#ifdef BN_S_MP_MUL_DIGS_C
/* LibTomMath, multiple-precision integer library -- Tom St Denis
*
@@ -11,8 +11,6 @@
*
* The library is free for all purposes without any express
* guarantee it works.
- *
- * Tom St Denis, tstdenis82@gmail.com, http://libtom.org
*/
/* multiplies |a| * |b| and only computes upto digs digits of result
diff --git a/libtommath/bn_s_mp_mul_high_digs.c b/libtommath/bn_s_mp_mul_high_digs.c
index 3c0418a..e6efd4e 100644
--- a/libtommath/bn_s_mp_mul_high_digs.c
+++ b/libtommath/bn_s_mp_mul_high_digs.c
@@ -1,4 +1,4 @@
-#include <tommath_private.h>
+#include "tommath_private.h"
#ifdef BN_S_MP_MUL_HIGH_DIGS_C
/* LibTomMath, multiple-precision integer library -- Tom St Denis
*
@@ -11,8 +11,6 @@
*
* The library is free for all purposes without any express
* guarantee it works.
- *
- * Tom St Denis, tstdenis82@gmail.com, http://libtom.org
*/
/* multiplies |a| * |b| and does not compute the lower digs digits
diff --git a/libtommath/bn_s_mp_sqr.c b/libtommath/bn_s_mp_sqr.c
index 71bbccd..4cab045 100644
--- a/libtommath/bn_s_mp_sqr.c
+++ b/libtommath/bn_s_mp_sqr.c
@@ -1,4 +1,4 @@
-#include <tommath_private.h>
+#include "tommath_private.h"
#ifdef BN_S_MP_SQR_C
/* LibTomMath, multiple-precision integer library -- Tom St Denis
*
@@ -11,8 +11,6 @@
*
* The library is free for all purposes without any express
* guarantee it works.
- *
- * Tom St Denis, tstdenis82@gmail.com, http://libtom.org
*/
/* low level squaring, b = a*a, HAC pp.596-597, Algorithm 14.16 */
diff --git a/libtommath/bn_s_mp_sub.c b/libtommath/bn_s_mp_sub.c
index c8472af..fbce7ca 100644
--- a/libtommath/bn_s_mp_sub.c
+++ b/libtommath/bn_s_mp_sub.c
@@ -1,4 +1,4 @@
-#include <tommath_private.h>
+#include "tommath_private.h"
#ifdef BN_S_MP_SUB_C
/* LibTomMath, multiple-precision integer library -- Tom St Denis
*
@@ -11,8 +11,6 @@
*
* The library is free for all purposes without any express
* guarantee it works.
- *
- * Tom St Denis, tstdenis82@gmail.com, http://libtom.org
*/
/* low level subtraction (assumes |a| > |b|), HAC pp.595 Algorithm 14.9 */
diff --git a/libtommath/bncore.c b/libtommath/bncore.c
index cfd19f0..916712d 100644
--- a/libtommath/bncore.c
+++ b/libtommath/bncore.c
@@ -1,4 +1,4 @@
-#include <tommath_private.h>
+#include "tommath_private.h"
#ifdef BNCORE_C
/* LibTomMath, multiple-precision integer library -- Tom St Denis
*
@@ -11,8 +11,6 @@
*
* The library is free for all purposes without any express
* guarantee it works.
- *
- * Tom St Denis, tstdenis82@gmail.com, http://libtom.org
*/
/* Known optimal configurations
diff --git a/libtommath/callgraph.txt b/libtommath/callgraph.txt
index 52007c0..6cc4e45 100644
--- a/libtommath/callgraph.txt
+++ b/libtommath/callgraph.txt
@@ -237,6 +237,17 @@ BN_MP_CMP_MAG_C
BN_MP_CNT_LSB_C
+BN_MP_COMPLEMENT_C
++--->BN_MP_NEG_C
+| +--->BN_MP_COPY_C
+| | +--->BN_MP_GROW_C
++--->BN_MP_SUB_D_C
+| +--->BN_MP_GROW_C
+| +--->BN_MP_ADD_D_C
+| | +--->BN_MP_CLAMP_C
+| +--->BN_MP_CLAMP_C
+
+
BN_MP_COPY_C
+--->BN_MP_GROW_C
@@ -12382,6 +12393,172 @@ BN_MP_SUB_D_C
+--->BN_MP_CLAMP_C
+BN_MP_TC_AND_C
++--->BN_MP_COUNT_BITS_C
++--->BN_MP_INIT_SET_INT_C
+| +--->BN_MP_INIT_C
+| +--->BN_MP_SET_INT_C
+| | +--->BN_MP_ZERO_C
+| | +--->BN_MP_MUL_2D_C
+| | | +--->BN_MP_COPY_C
+| | | | +--->BN_MP_GROW_C
+| | | +--->BN_MP_GROW_C
+| | | +--->BN_MP_LSHD_C
+| | | | +--->BN_MP_RSHD_C
+| | | +--->BN_MP_CLAMP_C
+| | +--->BN_MP_CLAMP_C
++--->BN_MP_MUL_2D_C
+| +--->BN_MP_COPY_C
+| | +--->BN_MP_GROW_C
+| +--->BN_MP_GROW_C
+| +--->BN_MP_LSHD_C
+| | +--->BN_MP_RSHD_C
+| | | +--->BN_MP_ZERO_C
+| +--->BN_MP_CLAMP_C
++--->BN_MP_INIT_C
++--->BN_MP_ADD_C
+| +--->BN_S_MP_ADD_C
+| | +--->BN_MP_GROW_C
+| | +--->BN_MP_CLAMP_C
+| +--->BN_MP_CMP_MAG_C
+| +--->BN_S_MP_SUB_C
+| | +--->BN_MP_GROW_C
+| | +--->BN_MP_CLAMP_C
++--->BN_MP_CLEAR_C
++--->BN_MP_AND_C
+| +--->BN_MP_INIT_COPY_C
+| | +--->BN_MP_INIT_SIZE_C
+| | +--->BN_MP_COPY_C
+| | | +--->BN_MP_GROW_C
+| +--->BN_MP_CLAMP_C
+| +--->BN_MP_EXCH_C
++--->BN_MP_SUB_C
+| +--->BN_S_MP_ADD_C
+| | +--->BN_MP_GROW_C
+| | +--->BN_MP_CLAMP_C
+| +--->BN_MP_CMP_MAG_C
+| +--->BN_S_MP_SUB_C
+| | +--->BN_MP_GROW_C
+| | +--->BN_MP_CLAMP_C
+
+
+BN_MP_TC_DIV_2D_C
++--->BN_MP_DIV_2D_C
+| +--->BN_MP_COPY_C
+| | +--->BN_MP_GROW_C
+| +--->BN_MP_ZERO_C
+| +--->BN_MP_MOD_2D_C
+| | +--->BN_MP_CLAMP_C
+| +--->BN_MP_RSHD_C
+| +--->BN_MP_CLAMP_C
++--->BN_MP_ADD_D_C
+| +--->BN_MP_GROW_C
+| +--->BN_MP_SUB_D_C
+| | +--->BN_MP_CLAMP_C
+| +--->BN_MP_CLAMP_C
++--->BN_MP_SUB_D_C
+| +--->BN_MP_GROW_C
+| +--->BN_MP_CLAMP_C
+
+
+BN_MP_TC_OR_C
++--->BN_MP_COUNT_BITS_C
++--->BN_MP_INIT_SET_INT_C
+| +--->BN_MP_INIT_C
+| +--->BN_MP_SET_INT_C
+| | +--->BN_MP_ZERO_C
+| | +--->BN_MP_MUL_2D_C
+| | | +--->BN_MP_COPY_C
+| | | | +--->BN_MP_GROW_C
+| | | +--->BN_MP_GROW_C
+| | | +--->BN_MP_LSHD_C
+| | | | +--->BN_MP_RSHD_C
+| | | +--->BN_MP_CLAMP_C
+| | +--->BN_MP_CLAMP_C
++--->BN_MP_MUL_2D_C
+| +--->BN_MP_COPY_C
+| | +--->BN_MP_GROW_C
+| +--->BN_MP_GROW_C
+| +--->BN_MP_LSHD_C
+| | +--->BN_MP_RSHD_C
+| | | +--->BN_MP_ZERO_C
+| +--->BN_MP_CLAMP_C
++--->BN_MP_INIT_C
++--->BN_MP_ADD_C
+| +--->BN_S_MP_ADD_C
+| | +--->BN_MP_GROW_C
+| | +--->BN_MP_CLAMP_C
+| +--->BN_MP_CMP_MAG_C
+| +--->BN_S_MP_SUB_C
+| | +--->BN_MP_GROW_C
+| | +--->BN_MP_CLAMP_C
++--->BN_MP_CLEAR_C
++--->BN_MP_OR_C
+| +--->BN_MP_INIT_COPY_C
+| | +--->BN_MP_INIT_SIZE_C
+| | +--->BN_MP_COPY_C
+| | | +--->BN_MP_GROW_C
+| +--->BN_MP_CLAMP_C
+| +--->BN_MP_EXCH_C
++--->BN_MP_SUB_C
+| +--->BN_S_MP_ADD_C
+| | +--->BN_MP_GROW_C
+| | +--->BN_MP_CLAMP_C
+| +--->BN_MP_CMP_MAG_C
+| +--->BN_S_MP_SUB_C
+| | +--->BN_MP_GROW_C
+| | +--->BN_MP_CLAMP_C
+
+
+BN_MP_TC_XOR_C
++--->BN_MP_COUNT_BITS_C
++--->BN_MP_INIT_SET_INT_C
+| +--->BN_MP_INIT_C
+| +--->BN_MP_SET_INT_C
+| | +--->BN_MP_ZERO_C
+| | +--->BN_MP_MUL_2D_C
+| | | +--->BN_MP_COPY_C
+| | | | +--->BN_MP_GROW_C
+| | | +--->BN_MP_GROW_C
+| | | +--->BN_MP_LSHD_C
+| | | | +--->BN_MP_RSHD_C
+| | | +--->BN_MP_CLAMP_C
+| | +--->BN_MP_CLAMP_C
++--->BN_MP_MUL_2D_C
+| +--->BN_MP_COPY_C
+| | +--->BN_MP_GROW_C
+| +--->BN_MP_GROW_C
+| +--->BN_MP_LSHD_C
+| | +--->BN_MP_RSHD_C
+| | | +--->BN_MP_ZERO_C
+| +--->BN_MP_CLAMP_C
++--->BN_MP_INIT_C
++--->BN_MP_ADD_C
+| +--->BN_S_MP_ADD_C
+| | +--->BN_MP_GROW_C
+| | +--->BN_MP_CLAMP_C
+| +--->BN_MP_CMP_MAG_C
+| +--->BN_S_MP_SUB_C
+| | +--->BN_MP_GROW_C
+| | +--->BN_MP_CLAMP_C
++--->BN_MP_CLEAR_C
++--->BN_MP_XOR_C
+| +--->BN_MP_INIT_COPY_C
+| | +--->BN_MP_INIT_SIZE_C
+| | +--->BN_MP_COPY_C
+| | | +--->BN_MP_GROW_C
+| +--->BN_MP_CLAMP_C
+| +--->BN_MP_EXCH_C
++--->BN_MP_SUB_C
+| +--->BN_S_MP_ADD_C
+| | +--->BN_MP_GROW_C
+| | +--->BN_MP_CLAMP_C
+| +--->BN_MP_CMP_MAG_C
+| +--->BN_S_MP_SUB_C
+| | +--->BN_MP_GROW_C
+| | +--->BN_MP_CLAMP_C
+
+
BN_MP_TOOM_MUL_C
+--->BN_MP_INIT_MULTI_C
| +--->BN_MP_INIT_C
diff --git a/libtommath/makefile b/libtommath/makefile
index 5eddae4..7b8f422 100644
--- a/libtommath/makefile
+++ b/libtommath/makefile
@@ -29,27 +29,27 @@ LCOV_ARGS=--directory .
OBJECTS=bncore.o bn_error.o bn_fast_mp_invmod.o bn_fast_mp_montgomery_reduce.o bn_fast_s_mp_mul_digs.o \
bn_fast_s_mp_mul_high_digs.o bn_fast_s_mp_sqr.o bn_mp_2expt.o bn_mp_abs.o bn_mp_add.o bn_mp_add_d.o \
bn_mp_addmod.o bn_mp_and.o bn_mp_clamp.o bn_mp_clear.o bn_mp_clear_multi.o bn_mp_cmp.o bn_mp_cmp_d.o \
-bn_mp_cmp_mag.o bn_mp_cnt_lsb.o bn_mp_copy.o bn_mp_count_bits.o bn_mp_div_2.o bn_mp_div_2d.o bn_mp_div_3.o \
-bn_mp_div.o bn_mp_div_d.o bn_mp_dr_is_modulus.o bn_mp_dr_reduce.o bn_mp_dr_setup.o bn_mp_exch.o \
-bn_mp_export.o bn_mp_expt_d.o bn_mp_expt_d_ex.o bn_mp_exptmod.o bn_mp_exptmod_fast.o bn_mp_exteuclid.o \
-bn_mp_fread.o bn_mp_fwrite.o bn_mp_gcd.o bn_mp_get_int.o bn_mp_get_long.o bn_mp_get_long_long.o \
-bn_mp_grow.o bn_mp_import.o bn_mp_init.o bn_mp_init_copy.o bn_mp_init_multi.o bn_mp_init_set.o \
-bn_mp_init_set_int.o bn_mp_init_size.o bn_mp_invmod.o bn_mp_invmod_slow.o bn_mp_is_square.o \
-bn_mp_jacobi.o bn_mp_karatsuba_mul.o bn_mp_karatsuba_sqr.o bn_mp_lcm.o bn_mp_lshd.o bn_mp_mod_2d.o \
-bn_mp_mod.o bn_mp_mod_d.o bn_mp_montgomery_calc_normalization.o bn_mp_montgomery_reduce.o \
-bn_mp_montgomery_setup.o bn_mp_mul_2.o bn_mp_mul_2d.o bn_mp_mul.o bn_mp_mul_d.o bn_mp_mulmod.o bn_mp_neg.o \
-bn_mp_n_root.o bn_mp_n_root_ex.o bn_mp_or.o bn_mp_prime_fermat.o bn_mp_prime_is_divisible.o \
-bn_mp_prime_is_prime.o bn_mp_prime_miller_rabin.o bn_mp_prime_next_prime.o \
+bn_mp_cmp_mag.o bn_mp_cnt_lsb.o bn_mp_complement.o bn_mp_copy.o bn_mp_count_bits.o bn_mp_div_2.o \
+bn_mp_div_2d.o bn_mp_div_3.o bn_mp_div.o bn_mp_div_d.o bn_mp_dr_is_modulus.o bn_mp_dr_reduce.o \
+bn_mp_dr_setup.o bn_mp_exch.o bn_mp_export.o bn_mp_expt_d.o bn_mp_expt_d_ex.o bn_mp_exptmod.o \
+bn_mp_exptmod_fast.o bn_mp_exteuclid.o bn_mp_fread.o bn_mp_fwrite.o bn_mp_gcd.o bn_mp_get_int.o \
+bn_mp_get_long.o bn_mp_get_long_long.o bn_mp_grow.o bn_mp_import.o bn_mp_init.o bn_mp_init_copy.o \
+bn_mp_init_multi.o bn_mp_init_set.o bn_mp_init_set_int.o bn_mp_init_size.o bn_mp_invmod.o \
+bn_mp_invmod_slow.o bn_mp_is_square.o bn_mp_jacobi.o bn_mp_karatsuba_mul.o bn_mp_karatsuba_sqr.o \
+bn_mp_lcm.o bn_mp_lshd.o bn_mp_mod_2d.o bn_mp_mod.o bn_mp_mod_d.o bn_mp_montgomery_calc_normalization.o \
+bn_mp_montgomery_reduce.o bn_mp_montgomery_setup.o bn_mp_mul_2.o bn_mp_mul_2d.o bn_mp_mul.o bn_mp_mul_d.o \
+bn_mp_mulmod.o bn_mp_neg.o bn_mp_n_root.o bn_mp_n_root_ex.o bn_mp_or.o bn_mp_prime_fermat.o \
+bn_mp_prime_is_divisible.o bn_mp_prime_is_prime.o bn_mp_prime_miller_rabin.o bn_mp_prime_next_prime.o \
bn_mp_prime_rabin_miller_trials.o bn_mp_prime_random_ex.o bn_mp_radix_size.o bn_mp_radix_smap.o \
bn_mp_rand.o bn_mp_read_radix.o bn_mp_read_signed_bin.o bn_mp_read_unsigned_bin.o bn_mp_reduce_2k.o \
bn_mp_reduce_2k_l.o bn_mp_reduce_2k_setup.o bn_mp_reduce_2k_setup_l.o bn_mp_reduce.o \
bn_mp_reduce_is_2k.o bn_mp_reduce_is_2k_l.o bn_mp_reduce_setup.o bn_mp_rshd.o bn_mp_set.o bn_mp_set_int.o \
bn_mp_set_long.o bn_mp_set_long_long.o bn_mp_shrink.o bn_mp_signed_bin_size.o bn_mp_sqr.o bn_mp_sqrmod.o \
-bn_mp_sqrt.o bn_mp_sqrtmod_prime.o bn_mp_sub.o bn_mp_sub_d.o bn_mp_submod.o bn_mp_toom_mul.o \
-bn_mp_toom_sqr.o bn_mp_toradix.o bn_mp_toradix_n.o bn_mp_to_signed_bin.o bn_mp_to_signed_bin_n.o \
-bn_mp_to_unsigned_bin.o bn_mp_to_unsigned_bin_n.o bn_mp_unsigned_bin_size.o bn_mp_xor.o bn_mp_zero.o \
-bn_prime_tab.o bn_reverse.o bn_s_mp_add.o bn_s_mp_exptmod.o bn_s_mp_mul_digs.o bn_s_mp_mul_high_digs.o \
-bn_s_mp_sqr.o bn_s_mp_sub.o
+bn_mp_sqrt.o bn_mp_sqrtmod_prime.o bn_mp_sub.o bn_mp_sub_d.o bn_mp_submod.o bn_mp_tc_and.o \
+bn_mp_tc_div_2d.o bn_mp_tc_or.o bn_mp_tc_xor.o bn_mp_toom_mul.o bn_mp_toom_sqr.o bn_mp_toradix.o \
+bn_mp_toradix_n.o bn_mp_to_signed_bin.o bn_mp_to_signed_bin_n.o bn_mp_to_unsigned_bin.o \
+bn_mp_to_unsigned_bin_n.o bn_mp_unsigned_bin_size.o bn_mp_xor.o bn_mp_zero.o bn_prime_tab.o bn_reverse.o \
+bn_s_mp_add.o bn_s_mp_exptmod.o bn_s_mp_mul_digs.o bn_s_mp_mul_high_digs.o bn_s_mp_sqr.o bn_s_mp_sub.o
#END_INS
@@ -67,17 +67,17 @@ $(LIBNAME): $(OBJECTS)
# So far I've seen improvements in the MP math
profiled:
make CFLAGS="$(CFLAGS) -fprofile-arcs -DTESTING" timing
- ./ltmtest
- rm -f *.a *.o ltmtest
+ ./timing
+ rm -f *.a *.o timing
make CFLAGS="$(CFLAGS) -fbranch-probabilities"
#make a single object profiled library
profiled_single:
perl gen.pl
$(CC) $(CFLAGS) -fprofile-arcs -DTESTING -c mpi.c -o mpi.o
- $(CC) $(CFLAGS) -DTESTING -DTIMER demo/timing.c mpi.o -lgcov -o ltmtest
- ./ltmtest
- rm -f *.o ltmtest
+ $(CC) $(CFLAGS) -DTESTING -DTIMER demo/timing.c mpi.o -lgcov -o timing
+ ./timing
+ rm -f *.o timing
$(CC) $(CFLAGS) -fbranch-probabilities -DTESTING -c mpi.c -o mpi.o
$(AR) $(ARFLAGS) $(LIBNAME) mpi.o
ranlib $(LIBNAME)
@@ -102,8 +102,8 @@ test_standalone: $(LIBNAME) demo/demo.o
mtest:
cd mtest ; $(CC) $(CFLAGS) -O0 mtest.c $(LFLAGS) -o mtest
-timing: $(LIBNAME)
- $(CC) $(CFLAGS) -DTIMER demo/timing.c $(LIBNAME) $(LFLAGS) -o ltmtest
+timing: $(LIBNAME) demo/timing.c
+ $(CC) $(CFLAGS) -DTIMER demo/timing.c $(LIBNAME) $(LFLAGS) -o timing
# You have to create a file .coveralls.yml with the content "repo_token: <the token>"
# in the base folder to be able to submit to coveralls
@@ -118,11 +118,12 @@ pretty:
.PHONY: pre_gen
pre_gen:
+ mkdir -p pre_gen
perl gen.pl
sed -e 's/[[:blank:]]*$$//' mpi.c > pre_gen/mpi.c
rm mpi.c
-zipup: clean pre_gen new_file manual poster docs
+zipup: clean astyle new_file manual poster docs
@# Update the index, so diff-index won't fail in case the pdf has been created.
@# As the pdf creation modifies the tex files, git sometimes detects the
@# modified files, but misses that it's put back to its original version.
@@ -131,8 +132,11 @@ zipup: clean pre_gen new_file manual poster docs
rm -rf libtommath-$(VERSION) ltm-$(VERSION).*
@# files/dirs excluded from "git archive" are defined in .gitattributes
git archive --format=tar --prefix=libtommath-$(VERSION)/ HEAD | tar x
+ @echo 'fixme check'
+ -@(find libtommath-$(VERSION)/ -type f | xargs grep 'FIXM[E]') && echo '############## BEWARE: the "fixme" marker was found !!! ##############' || true
mkdir -p libtommath-$(VERSION)/doc
cp doc/bn.pdf doc/tommath.pdf doc/poster.pdf libtommath-$(VERSION)/doc/
+ $(MAKE) -C libtommath-$(VERSION)/ pre_gen
tar -c libtommath-$(VERSION)/ | xz -6e -c - > ltm-$(VERSION).tar.xz
zip -9rq ltm-$(VERSION).zip libtommath-$(VERSION)
rm -rf libtommath-$(VERSION)
diff --git a/libtommath/makefile.bcc b/libtommath/makefile.bcc
index a0cfd74..7a64695 100644
--- a/libtommath/makefile.bcc
+++ b/libtommath/makefile.bcc
@@ -11,27 +11,27 @@ CFLAGS = -c -O2 -I.
OBJECTS=bncore.obj bn_error.obj bn_fast_mp_invmod.obj bn_fast_mp_montgomery_reduce.obj bn_fast_s_mp_mul_digs.obj \
bn_fast_s_mp_mul_high_digs.obj bn_fast_s_mp_sqr.obj bn_mp_2expt.obj bn_mp_abs.obj bn_mp_add.obj bn_mp_add_d.obj \
bn_mp_addmod.obj bn_mp_and.obj bn_mp_clamp.obj bn_mp_clear.obj bn_mp_clear_multi.obj bn_mp_cmp.obj bn_mp_cmp_d.obj \
-bn_mp_cmp_mag.obj bn_mp_cnt_lsb.obj bn_mp_copy.obj bn_mp_count_bits.obj bn_mp_div_2.obj bn_mp_div_2d.obj bn_mp_div_3.obj \
-bn_mp_div.obj bn_mp_div_d.obj bn_mp_dr_is_modulus.obj bn_mp_dr_reduce.obj bn_mp_dr_setup.obj bn_mp_exch.obj \
-bn_mp_export.obj bn_mp_expt_d.obj bn_mp_expt_d_ex.obj bn_mp_exptmod.obj bn_mp_exptmod_fast.obj bn_mp_exteuclid.obj \
-bn_mp_fread.obj bn_mp_fwrite.obj bn_mp_gcd.obj bn_mp_get_int.obj bn_mp_get_long.obj bn_mp_get_long_long.obj \
-bn_mp_grow.obj bn_mp_import.obj bn_mp_init.obj bn_mp_init_copy.obj bn_mp_init_multi.obj bn_mp_init_set.obj \
-bn_mp_init_set_int.obj bn_mp_init_size.obj bn_mp_invmod.obj bn_mp_invmod_slow.obj bn_mp_is_square.obj \
-bn_mp_jacobi.obj bn_mp_karatsuba_mul.obj bn_mp_karatsuba_sqr.obj bn_mp_lcm.obj bn_mp_lshd.obj bn_mp_mod_2d.obj \
-bn_mp_mod.obj bn_mp_mod_d.obj bn_mp_montgomery_calc_normalization.obj bn_mp_montgomery_reduce.obj \
-bn_mp_montgomery_setup.obj bn_mp_mul_2.obj bn_mp_mul_2d.obj bn_mp_mul.obj bn_mp_mul_d.obj bn_mp_mulmod.obj bn_mp_neg.obj \
-bn_mp_n_root.obj bn_mp_n_root_ex.obj bn_mp_or.obj bn_mp_prime_fermat.obj bn_mp_prime_is_divisible.obj \
-bn_mp_prime_is_prime.obj bn_mp_prime_miller_rabin.obj bn_mp_prime_next_prime.obj \
+bn_mp_cmp_mag.obj bn_mp_cnt_lsb.obj bn_mp_complement.obj bn_mp_copy.obj bn_mp_count_bits.obj bn_mp_div_2.obj \
+bn_mp_div_2d.obj bn_mp_div_3.obj bn_mp_div.obj bn_mp_div_d.obj bn_mp_dr_is_modulus.obj bn_mp_dr_reduce.obj \
+bn_mp_dr_setup.obj bn_mp_exch.obj bn_mp_export.obj bn_mp_expt_d.obj bn_mp_expt_d_ex.obj bn_mp_exptmod.obj \
+bn_mp_exptmod_fast.obj bn_mp_exteuclid.obj bn_mp_fread.obj bn_mp_fwrite.obj bn_mp_gcd.obj bn_mp_get_int.obj \
+bn_mp_get_long.obj bn_mp_get_long_long.obj bn_mp_grow.obj bn_mp_import.obj bn_mp_init.obj bn_mp_init_copy.obj \
+bn_mp_init_multi.obj bn_mp_init_set.obj bn_mp_init_set_int.obj bn_mp_init_size.obj bn_mp_invmod.obj \
+bn_mp_invmod_slow.obj bn_mp_is_square.obj bn_mp_jacobi.obj bn_mp_karatsuba_mul.obj bn_mp_karatsuba_sqr.obj \
+bn_mp_lcm.obj bn_mp_lshd.obj bn_mp_mod_2d.obj bn_mp_mod.obj bn_mp_mod_d.obj bn_mp_montgomery_calc_normalization.obj \
+bn_mp_montgomery_reduce.obj bn_mp_montgomery_setup.obj bn_mp_mul_2.obj bn_mp_mul_2d.obj bn_mp_mul.obj bn_mp_mul_d.obj \
+bn_mp_mulmod.obj bn_mp_neg.obj bn_mp_n_root.obj bn_mp_n_root_ex.obj bn_mp_or.obj bn_mp_prime_fermat.obj \
+bn_mp_prime_is_divisible.obj bn_mp_prime_is_prime.obj bn_mp_prime_miller_rabin.obj bn_mp_prime_next_prime.obj \
bn_mp_prime_rabin_miller_trials.obj bn_mp_prime_random_ex.obj bn_mp_radix_size.obj bn_mp_radix_smap.obj \
bn_mp_rand.obj bn_mp_read_radix.obj bn_mp_read_signed_bin.obj bn_mp_read_unsigned_bin.obj bn_mp_reduce_2k.obj \
bn_mp_reduce_2k_l.obj bn_mp_reduce_2k_setup.obj bn_mp_reduce_2k_setup_l.obj bn_mp_reduce.obj \
bn_mp_reduce_is_2k.obj bn_mp_reduce_is_2k_l.obj bn_mp_reduce_setup.obj bn_mp_rshd.obj bn_mp_set.obj bn_mp_set_int.obj \
bn_mp_set_long.obj bn_mp_set_long_long.obj bn_mp_shrink.obj bn_mp_signed_bin_size.obj bn_mp_sqr.obj bn_mp_sqrmod.obj \
-bn_mp_sqrt.obj bn_mp_sqrtmod_prime.obj bn_mp_sub.obj bn_mp_sub_d.obj bn_mp_submod.obj bn_mp_toom_mul.obj \
-bn_mp_toom_sqr.obj bn_mp_toradix.obj bn_mp_toradix_n.obj bn_mp_to_signed_bin.obj bn_mp_to_signed_bin_n.obj \
-bn_mp_to_unsigned_bin.obj bn_mp_to_unsigned_bin_n.obj bn_mp_unsigned_bin_size.obj bn_mp_xor.obj bn_mp_zero.obj \
-bn_prime_tab.obj bn_reverse.obj bn_s_mp_add.obj bn_s_mp_exptmod.obj bn_s_mp_mul_digs.obj bn_s_mp_mul_high_digs.obj \
-bn_s_mp_sqr.obj bn_s_mp_sub.obj
+bn_mp_sqrt.obj bn_mp_sqrtmod_prime.obj bn_mp_sub.obj bn_mp_sub_d.obj bn_mp_submod.obj bn_mp_tc_and.obj \
+bn_mp_tc_div_2d.obj bn_mp_tc_or.obj bn_mp_tc_xor.obj bn_mp_toom_mul.obj bn_mp_toom_sqr.obj bn_mp_toradix.obj \
+bn_mp_toradix_n.obj bn_mp_to_signed_bin.obj bn_mp_to_signed_bin_n.obj bn_mp_to_unsigned_bin.obj \
+bn_mp_to_unsigned_bin_n.obj bn_mp_unsigned_bin_size.obj bn_mp_xor.obj bn_mp_zero.obj bn_prime_tab.obj bn_reverse.obj \
+bn_s_mp_add.obj bn_s_mp_exptmod.obj bn_s_mp_mul_digs.obj bn_s_mp_mul_high_digs.obj bn_s_mp_sqr.obj bn_s_mp_sub.obj
#END_INS
diff --git a/libtommath/makefile.cygwin_dll b/libtommath/makefile.cygwin_dll
index 6feb5b4..fbec3bf 100644
--- a/libtommath/makefile.cygwin_dll
+++ b/libtommath/makefile.cygwin_dll
@@ -16,27 +16,27 @@ default: windll
OBJECTS=bncore.o bn_error.o bn_fast_mp_invmod.o bn_fast_mp_montgomery_reduce.o bn_fast_s_mp_mul_digs.o \
bn_fast_s_mp_mul_high_digs.o bn_fast_s_mp_sqr.o bn_mp_2expt.o bn_mp_abs.o bn_mp_add.o bn_mp_add_d.o \
bn_mp_addmod.o bn_mp_and.o bn_mp_clamp.o bn_mp_clear.o bn_mp_clear_multi.o bn_mp_cmp.o bn_mp_cmp_d.o \
-bn_mp_cmp_mag.o bn_mp_cnt_lsb.o bn_mp_copy.o bn_mp_count_bits.o bn_mp_div_2.o bn_mp_div_2d.o bn_mp_div_3.o \
-bn_mp_div.o bn_mp_div_d.o bn_mp_dr_is_modulus.o bn_mp_dr_reduce.o bn_mp_dr_setup.o bn_mp_exch.o \
-bn_mp_export.o bn_mp_expt_d.o bn_mp_expt_d_ex.o bn_mp_exptmod.o bn_mp_exptmod_fast.o bn_mp_exteuclid.o \
-bn_mp_fread.o bn_mp_fwrite.o bn_mp_gcd.o bn_mp_get_int.o bn_mp_get_long.o bn_mp_get_long_long.o \
-bn_mp_grow.o bn_mp_import.o bn_mp_init.o bn_mp_init_copy.o bn_mp_init_multi.o bn_mp_init_set.o \
-bn_mp_init_set_int.o bn_mp_init_size.o bn_mp_invmod.o bn_mp_invmod_slow.o bn_mp_is_square.o \
-bn_mp_jacobi.o bn_mp_karatsuba_mul.o bn_mp_karatsuba_sqr.o bn_mp_lcm.o bn_mp_lshd.o bn_mp_mod_2d.o \
-bn_mp_mod.o bn_mp_mod_d.o bn_mp_montgomery_calc_normalization.o bn_mp_montgomery_reduce.o \
-bn_mp_montgomery_setup.o bn_mp_mul_2.o bn_mp_mul_2d.o bn_mp_mul.o bn_mp_mul_d.o bn_mp_mulmod.o bn_mp_neg.o \
-bn_mp_n_root.o bn_mp_n_root_ex.o bn_mp_or.o bn_mp_prime_fermat.o bn_mp_prime_is_divisible.o \
-bn_mp_prime_is_prime.o bn_mp_prime_miller_rabin.o bn_mp_prime_next_prime.o \
+bn_mp_cmp_mag.o bn_mp_cnt_lsb.o bn_mp_complement.o bn_mp_copy.o bn_mp_count_bits.o bn_mp_div_2.o \
+bn_mp_div_2d.o bn_mp_div_3.o bn_mp_div.o bn_mp_div_d.o bn_mp_dr_is_modulus.o bn_mp_dr_reduce.o \
+bn_mp_dr_setup.o bn_mp_exch.o bn_mp_export.o bn_mp_expt_d.o bn_mp_expt_d_ex.o bn_mp_exptmod.o \
+bn_mp_exptmod_fast.o bn_mp_exteuclid.o bn_mp_fread.o bn_mp_fwrite.o bn_mp_gcd.o bn_mp_get_int.o \
+bn_mp_get_long.o bn_mp_get_long_long.o bn_mp_grow.o bn_mp_import.o bn_mp_init.o bn_mp_init_copy.o \
+bn_mp_init_multi.o bn_mp_init_set.o bn_mp_init_set_int.o bn_mp_init_size.o bn_mp_invmod.o \
+bn_mp_invmod_slow.o bn_mp_is_square.o bn_mp_jacobi.o bn_mp_karatsuba_mul.o bn_mp_karatsuba_sqr.o \
+bn_mp_lcm.o bn_mp_lshd.o bn_mp_mod_2d.o bn_mp_mod.o bn_mp_mod_d.o bn_mp_montgomery_calc_normalization.o \
+bn_mp_montgomery_reduce.o bn_mp_montgomery_setup.o bn_mp_mul_2.o bn_mp_mul_2d.o bn_mp_mul.o bn_mp_mul_d.o \
+bn_mp_mulmod.o bn_mp_neg.o bn_mp_n_root.o bn_mp_n_root_ex.o bn_mp_or.o bn_mp_prime_fermat.o \
+bn_mp_prime_is_divisible.o bn_mp_prime_is_prime.o bn_mp_prime_miller_rabin.o bn_mp_prime_next_prime.o \
bn_mp_prime_rabin_miller_trials.o bn_mp_prime_random_ex.o bn_mp_radix_size.o bn_mp_radix_smap.o \
bn_mp_rand.o bn_mp_read_radix.o bn_mp_read_signed_bin.o bn_mp_read_unsigned_bin.o bn_mp_reduce_2k.o \
bn_mp_reduce_2k_l.o bn_mp_reduce_2k_setup.o bn_mp_reduce_2k_setup_l.o bn_mp_reduce.o \
bn_mp_reduce_is_2k.o bn_mp_reduce_is_2k_l.o bn_mp_reduce_setup.o bn_mp_rshd.o bn_mp_set.o bn_mp_set_int.o \
bn_mp_set_long.o bn_mp_set_long_long.o bn_mp_shrink.o bn_mp_signed_bin_size.o bn_mp_sqr.o bn_mp_sqrmod.o \
-bn_mp_sqrt.o bn_mp_sqrtmod_prime.o bn_mp_sub.o bn_mp_sub_d.o bn_mp_submod.o bn_mp_toom_mul.o \
-bn_mp_toom_sqr.o bn_mp_toradix.o bn_mp_toradix_n.o bn_mp_to_signed_bin.o bn_mp_to_signed_bin_n.o \
-bn_mp_to_unsigned_bin.o bn_mp_to_unsigned_bin_n.o bn_mp_unsigned_bin_size.o bn_mp_xor.o bn_mp_zero.o \
-bn_prime_tab.o bn_reverse.o bn_s_mp_add.o bn_s_mp_exptmod.o bn_s_mp_mul_digs.o bn_s_mp_mul_high_digs.o \
-bn_s_mp_sqr.o bn_s_mp_sub.o
+bn_mp_sqrt.o bn_mp_sqrtmod_prime.o bn_mp_sub.o bn_mp_sub_d.o bn_mp_submod.o bn_mp_tc_and.o \
+bn_mp_tc_div_2d.o bn_mp_tc_or.o bn_mp_tc_xor.o bn_mp_toom_mul.o bn_mp_toom_sqr.o bn_mp_toradix.o \
+bn_mp_toradix_n.o bn_mp_to_signed_bin.o bn_mp_to_signed_bin_n.o bn_mp_to_unsigned_bin.o \
+bn_mp_to_unsigned_bin_n.o bn_mp_unsigned_bin_size.o bn_mp_xor.o bn_mp_zero.o bn_prime_tab.o bn_reverse.o \
+bn_s_mp_add.o bn_s_mp_exptmod.o bn_s_mp_mul_digs.o bn_s_mp_mul_high_digs.o bn_s_mp_sqr.o bn_s_mp_sub.o
#END_INS
diff --git a/libtommath/makefile.icc b/libtommath/makefile.icc
index 1563802..e3cfb00 100644
--- a/libtommath/makefile.icc
+++ b/libtommath/makefile.icc
@@ -42,27 +42,27 @@ DATAPATH=/usr/share/doc/libtommath/pdf
OBJECTS=bncore.o bn_error.o bn_fast_mp_invmod.o bn_fast_mp_montgomery_reduce.o bn_fast_s_mp_mul_digs.o \
bn_fast_s_mp_mul_high_digs.o bn_fast_s_mp_sqr.o bn_mp_2expt.o bn_mp_abs.o bn_mp_add.o bn_mp_add_d.o \
bn_mp_addmod.o bn_mp_and.o bn_mp_clamp.o bn_mp_clear.o bn_mp_clear_multi.o bn_mp_cmp.o bn_mp_cmp_d.o \
-bn_mp_cmp_mag.o bn_mp_cnt_lsb.o bn_mp_copy.o bn_mp_count_bits.o bn_mp_div_2.o bn_mp_div_2d.o bn_mp_div_3.o \
-bn_mp_div.o bn_mp_div_d.o bn_mp_dr_is_modulus.o bn_mp_dr_reduce.o bn_mp_dr_setup.o bn_mp_exch.o \
-bn_mp_export.o bn_mp_expt_d.o bn_mp_expt_d_ex.o bn_mp_exptmod.o bn_mp_exptmod_fast.o bn_mp_exteuclid.o \
-bn_mp_fread.o bn_mp_fwrite.o bn_mp_gcd.o bn_mp_get_int.o bn_mp_get_long.o bn_mp_get_long_long.o \
-bn_mp_grow.o bn_mp_import.o bn_mp_init.o bn_mp_init_copy.o bn_mp_init_multi.o bn_mp_init_set.o \
-bn_mp_init_set_int.o bn_mp_init_size.o bn_mp_invmod.o bn_mp_invmod_slow.o bn_mp_is_square.o \
-bn_mp_jacobi.o bn_mp_karatsuba_mul.o bn_mp_karatsuba_sqr.o bn_mp_lcm.o bn_mp_lshd.o bn_mp_mod_2d.o \
-bn_mp_mod.o bn_mp_mod_d.o bn_mp_montgomery_calc_normalization.o bn_mp_montgomery_reduce.o \
-bn_mp_montgomery_setup.o bn_mp_mul_2.o bn_mp_mul_2d.o bn_mp_mul.o bn_mp_mul_d.o bn_mp_mulmod.o bn_mp_neg.o \
-bn_mp_n_root.o bn_mp_n_root_ex.o bn_mp_or.o bn_mp_prime_fermat.o bn_mp_prime_is_divisible.o \
-bn_mp_prime_is_prime.o bn_mp_prime_miller_rabin.o bn_mp_prime_next_prime.o \
+bn_mp_cmp_mag.o bn_mp_cnt_lsb.o bn_mp_complement.o bn_mp_copy.o bn_mp_count_bits.o bn_mp_div_2.o \
+bn_mp_div_2d.o bn_mp_div_3.o bn_mp_div.o bn_mp_div_d.o bn_mp_dr_is_modulus.o bn_mp_dr_reduce.o \
+bn_mp_dr_setup.o bn_mp_exch.o bn_mp_export.o bn_mp_expt_d.o bn_mp_expt_d_ex.o bn_mp_exptmod.o \
+bn_mp_exptmod_fast.o bn_mp_exteuclid.o bn_mp_fread.o bn_mp_fwrite.o bn_mp_gcd.o bn_mp_get_int.o \
+bn_mp_get_long.o bn_mp_get_long_long.o bn_mp_grow.o bn_mp_import.o bn_mp_init.o bn_mp_init_copy.o \
+bn_mp_init_multi.o bn_mp_init_set.o bn_mp_init_set_int.o bn_mp_init_size.o bn_mp_invmod.o \
+bn_mp_invmod_slow.o bn_mp_is_square.o bn_mp_jacobi.o bn_mp_karatsuba_mul.o bn_mp_karatsuba_sqr.o \
+bn_mp_lcm.o bn_mp_lshd.o bn_mp_mod_2d.o bn_mp_mod.o bn_mp_mod_d.o bn_mp_montgomery_calc_normalization.o \
+bn_mp_montgomery_reduce.o bn_mp_montgomery_setup.o bn_mp_mul_2.o bn_mp_mul_2d.o bn_mp_mul.o bn_mp_mul_d.o \
+bn_mp_mulmod.o bn_mp_neg.o bn_mp_n_root.o bn_mp_n_root_ex.o bn_mp_or.o bn_mp_prime_fermat.o \
+bn_mp_prime_is_divisible.o bn_mp_prime_is_prime.o bn_mp_prime_miller_rabin.o bn_mp_prime_next_prime.o \
bn_mp_prime_rabin_miller_trials.o bn_mp_prime_random_ex.o bn_mp_radix_size.o bn_mp_radix_smap.o \
bn_mp_rand.o bn_mp_read_radix.o bn_mp_read_signed_bin.o bn_mp_read_unsigned_bin.o bn_mp_reduce_2k.o \
bn_mp_reduce_2k_l.o bn_mp_reduce_2k_setup.o bn_mp_reduce_2k_setup_l.o bn_mp_reduce.o \
bn_mp_reduce_is_2k.o bn_mp_reduce_is_2k_l.o bn_mp_reduce_setup.o bn_mp_rshd.o bn_mp_set.o bn_mp_set_int.o \
bn_mp_set_long.o bn_mp_set_long_long.o bn_mp_shrink.o bn_mp_signed_bin_size.o bn_mp_sqr.o bn_mp_sqrmod.o \
-bn_mp_sqrt.o bn_mp_sqrtmod_prime.o bn_mp_sub.o bn_mp_sub_d.o bn_mp_submod.o bn_mp_toom_mul.o \
-bn_mp_toom_sqr.o bn_mp_toradix.o bn_mp_toradix_n.o bn_mp_to_signed_bin.o bn_mp_to_signed_bin_n.o \
-bn_mp_to_unsigned_bin.o bn_mp_to_unsigned_bin_n.o bn_mp_unsigned_bin_size.o bn_mp_xor.o bn_mp_zero.o \
-bn_prime_tab.o bn_reverse.o bn_s_mp_add.o bn_s_mp_exptmod.o bn_s_mp_mul_digs.o bn_s_mp_mul_high_digs.o \
-bn_s_mp_sqr.o bn_s_mp_sub.o
+bn_mp_sqrt.o bn_mp_sqrtmod_prime.o bn_mp_sub.o bn_mp_sub_d.o bn_mp_submod.o bn_mp_tc_and.o \
+bn_mp_tc_div_2d.o bn_mp_tc_or.o bn_mp_tc_xor.o bn_mp_toom_mul.o bn_mp_toom_sqr.o bn_mp_toradix.o \
+bn_mp_toradix_n.o bn_mp_to_signed_bin.o bn_mp_to_signed_bin_n.o bn_mp_to_unsigned_bin.o \
+bn_mp_to_unsigned_bin_n.o bn_mp_unsigned_bin_size.o bn_mp_xor.o bn_mp_zero.o bn_prime_tab.o bn_reverse.o \
+bn_s_mp_add.o bn_s_mp_exptmod.o bn_s_mp_mul_digs.o bn_s_mp_mul_high_digs.o bn_s_mp_sqr.o bn_s_mp_sub.o
#END_INS
@@ -80,17 +80,17 @@ libtommath.a: $(OBJECTS)
# So far I've seen improvements in the MP math
profiled:
make -f makefile.icc CFLAGS="$(CFLAGS) -prof_gen -DTESTING" timing
- ./ltmtest
- rm -f *.a *.o ltmtest
+ ./timing
+ rm -f *.a *.o timing
make -f makefile.icc CFLAGS="$(CFLAGS) -prof_use"
#make a single object profiled library
profiled_single:
perl gen.pl
$(CC) $(CFLAGS) -prof_gen -DTESTING -c mpi.c -o mpi.o
- $(CC) $(CFLAGS) -DTESTING -DTIMER demo/demo.c mpi.o -o ltmtest
- ./ltmtest
- rm -f *.o ltmtest
+ $(CC) $(CFLAGS) -DTESTING -DTIMER demo/demo.c mpi.o -o timing
+ ./timing
+ rm -f *.o timing
$(CC) $(CFLAGS) -prof_use -ip -DTESTING -c mpi.c -o mpi.o
$(AR) $(ARFLAGS) libtommath.a mpi.o
ranlib libtommath.a
@@ -107,11 +107,11 @@ test: libtommath.a demo/demo.o
mtest: test
cd mtest ; $(CC) $(CFLAGS) mtest.c -o mtest
-timing: libtommath.a
- $(CC) $(CFLAGS) -DTIMER demo/timing.c libtommath.a -o ltmtest
+timing: libtommath.a demo/timing.c
+ $(CC) $(CFLAGS) -DTIMER demo/timing.c libtommath.a -o timing
clean:
- rm -f *.bat *.pdf *.o *.a *.obj *.lib *.exe *.dll etclib/*.o demo/demo.o test ltmtest mpitest mtest/mtest mtest/mtest.exe \
+ rm -f *.bat *.pdf *.o *.a *.obj *.lib *.exe *.dll etclib/*.o demo/demo.o test timing mpitest mtest/mtest mtest/mtest.exe \
*.idx *.toc *.log *.aux *.dvi *.lof *.ind *.ilg *.ps *.log *.s mpi.c *.il etc/*.il *.dyn
cd etc ; make clean
cd pics ; make clean
diff --git a/libtommath/makefile.msvc b/libtommath/makefile.msvc
index a47aadd..22a27fe 100644
--- a/libtommath/makefile.msvc
+++ b/libtommath/makefile.msvc
@@ -2,7 +2,7 @@
#
#Tom St Denis
-CFLAGS = /I. /Ox /DWIN32 /W3 /Fo$@
+LTM_CFLAGS = /Ox /nologo /I. /D_CRT_SECURE_NO_WARNINGS /D_CRT_NONSTDC_NO_DEPRECATE /W3 $(CFLAGS)
default: library
@@ -10,31 +10,34 @@ default: library
OBJECTS=bncore.obj bn_error.obj bn_fast_mp_invmod.obj bn_fast_mp_montgomery_reduce.obj bn_fast_s_mp_mul_digs.obj \
bn_fast_s_mp_mul_high_digs.obj bn_fast_s_mp_sqr.obj bn_mp_2expt.obj bn_mp_abs.obj bn_mp_add.obj bn_mp_add_d.obj \
bn_mp_addmod.obj bn_mp_and.obj bn_mp_clamp.obj bn_mp_clear.obj bn_mp_clear_multi.obj bn_mp_cmp.obj bn_mp_cmp_d.obj \
-bn_mp_cmp_mag.obj bn_mp_cnt_lsb.obj bn_mp_copy.obj bn_mp_count_bits.obj bn_mp_div_2.obj bn_mp_div_2d.obj bn_mp_div_3.obj \
-bn_mp_div.obj bn_mp_div_d.obj bn_mp_dr_is_modulus.obj bn_mp_dr_reduce.obj bn_mp_dr_setup.obj bn_mp_exch.obj \
-bn_mp_export.obj bn_mp_expt_d.obj bn_mp_expt_d_ex.obj bn_mp_exptmod.obj bn_mp_exptmod_fast.obj bn_mp_exteuclid.obj \
-bn_mp_fread.obj bn_mp_fwrite.obj bn_mp_gcd.obj bn_mp_get_int.obj bn_mp_get_long.obj bn_mp_get_long_long.obj \
-bn_mp_grow.obj bn_mp_import.obj bn_mp_init.obj bn_mp_init_copy.obj bn_mp_init_multi.obj bn_mp_init_set.obj \
-bn_mp_init_set_int.obj bn_mp_init_size.obj bn_mp_invmod.obj bn_mp_invmod_slow.obj bn_mp_is_square.obj \
-bn_mp_jacobi.obj bn_mp_karatsuba_mul.obj bn_mp_karatsuba_sqr.obj bn_mp_lcm.obj bn_mp_lshd.obj bn_mp_mod_2d.obj \
-bn_mp_mod.obj bn_mp_mod_d.obj bn_mp_montgomery_calc_normalization.obj bn_mp_montgomery_reduce.obj \
-bn_mp_montgomery_setup.obj bn_mp_mul_2.obj bn_mp_mul_2d.obj bn_mp_mul.obj bn_mp_mul_d.obj bn_mp_mulmod.obj bn_mp_neg.obj \
-bn_mp_n_root.obj bn_mp_n_root_ex.obj bn_mp_or.obj bn_mp_prime_fermat.obj bn_mp_prime_is_divisible.obj \
-bn_mp_prime_is_prime.obj bn_mp_prime_miller_rabin.obj bn_mp_prime_next_prime.obj \
+bn_mp_cmp_mag.obj bn_mp_cnt_lsb.obj bn_mp_complement.obj bn_mp_copy.obj bn_mp_count_bits.obj bn_mp_div_2.obj \
+bn_mp_div_2d.obj bn_mp_div_3.obj bn_mp_div.obj bn_mp_div_d.obj bn_mp_dr_is_modulus.obj bn_mp_dr_reduce.obj \
+bn_mp_dr_setup.obj bn_mp_exch.obj bn_mp_export.obj bn_mp_expt_d.obj bn_mp_expt_d_ex.obj bn_mp_exptmod.obj \
+bn_mp_exptmod_fast.obj bn_mp_exteuclid.obj bn_mp_fread.obj bn_mp_fwrite.obj bn_mp_gcd.obj bn_mp_get_int.obj \
+bn_mp_get_long.obj bn_mp_get_long_long.obj bn_mp_grow.obj bn_mp_import.obj bn_mp_init.obj bn_mp_init_copy.obj \
+bn_mp_init_multi.obj bn_mp_init_set.obj bn_mp_init_set_int.obj bn_mp_init_size.obj bn_mp_invmod.obj \
+bn_mp_invmod_slow.obj bn_mp_is_square.obj bn_mp_jacobi.obj bn_mp_karatsuba_mul.obj bn_mp_karatsuba_sqr.obj \
+bn_mp_lcm.obj bn_mp_lshd.obj bn_mp_mod_2d.obj bn_mp_mod.obj bn_mp_mod_d.obj bn_mp_montgomery_calc_normalization.obj \
+bn_mp_montgomery_reduce.obj bn_mp_montgomery_setup.obj bn_mp_mul_2.obj bn_mp_mul_2d.obj bn_mp_mul.obj bn_mp_mul_d.obj \
+bn_mp_mulmod.obj bn_mp_neg.obj bn_mp_n_root.obj bn_mp_n_root_ex.obj bn_mp_or.obj bn_mp_prime_fermat.obj \
+bn_mp_prime_is_divisible.obj bn_mp_prime_is_prime.obj bn_mp_prime_miller_rabin.obj bn_mp_prime_next_prime.obj \
bn_mp_prime_rabin_miller_trials.obj bn_mp_prime_random_ex.obj bn_mp_radix_size.obj bn_mp_radix_smap.obj \
bn_mp_rand.obj bn_mp_read_radix.obj bn_mp_read_signed_bin.obj bn_mp_read_unsigned_bin.obj bn_mp_reduce_2k.obj \
bn_mp_reduce_2k_l.obj bn_mp_reduce_2k_setup.obj bn_mp_reduce_2k_setup_l.obj bn_mp_reduce.obj \
bn_mp_reduce_is_2k.obj bn_mp_reduce_is_2k_l.obj bn_mp_reduce_setup.obj bn_mp_rshd.obj bn_mp_set.obj bn_mp_set_int.obj \
bn_mp_set_long.obj bn_mp_set_long_long.obj bn_mp_shrink.obj bn_mp_signed_bin_size.obj bn_mp_sqr.obj bn_mp_sqrmod.obj \
-bn_mp_sqrt.obj bn_mp_sqrtmod_prime.obj bn_mp_sub.obj bn_mp_sub_d.obj bn_mp_submod.obj bn_mp_toom_mul.obj \
-bn_mp_toom_sqr.obj bn_mp_toradix.obj bn_mp_toradix_n.obj bn_mp_to_signed_bin.obj bn_mp_to_signed_bin_n.obj \
-bn_mp_to_unsigned_bin.obj bn_mp_to_unsigned_bin_n.obj bn_mp_unsigned_bin_size.obj bn_mp_xor.obj bn_mp_zero.obj \
-bn_prime_tab.obj bn_reverse.obj bn_s_mp_add.obj bn_s_mp_exptmod.obj bn_s_mp_mul_digs.obj bn_s_mp_mul_high_digs.obj \
-bn_s_mp_sqr.obj bn_s_mp_sub.obj
+bn_mp_sqrt.obj bn_mp_sqrtmod_prime.obj bn_mp_sub.obj bn_mp_sub_d.obj bn_mp_submod.obj bn_mp_tc_and.obj \
+bn_mp_tc_div_2d.obj bn_mp_tc_or.obj bn_mp_tc_xor.obj bn_mp_toom_mul.obj bn_mp_toom_sqr.obj bn_mp_toradix.obj \
+bn_mp_toradix_n.obj bn_mp_to_signed_bin.obj bn_mp_to_signed_bin_n.obj bn_mp_to_unsigned_bin.obj \
+bn_mp_to_unsigned_bin_n.obj bn_mp_unsigned_bin_size.obj bn_mp_xor.obj bn_mp_zero.obj bn_prime_tab.obj bn_reverse.obj \
+bn_s_mp_add.obj bn_s_mp_exptmod.obj bn_s_mp_mul_digs.obj bn_s_mp_mul_high_digs.obj bn_s_mp_sqr.obj bn_s_mp_sub.obj
#END_INS
-HEADERS=tommath.h tommath_class.h tommath_superclass.h
+HEADERS=tommath.h tommath_class.h tommath_private.h tommath_superclass.h
library: $(OBJECTS)
lib /out:tommath.lib $(OBJECTS)
+
+.c.obj:
+ $(CC) $(LTM_CFLAGS) /c $< /Fo$@
diff --git a/libtommath/makefile.shared b/libtommath/makefile.shared
index 67213a2..79e5f86 100644
--- a/libtommath/makefile.shared
+++ b/libtommath/makefile.shared
@@ -10,14 +10,14 @@ endif
include makefile_include.mk
-ifndef LT
+ifndef LIBTOOL
ifeq ($(PLATFORM), Darwin)
- LT:=glibtool
+ LIBTOOL:=glibtool
else
- LT:=libtool
+ LIBTOOL:=libtool
endif
endif
-LTCOMPILE = $(LT) --mode=compile --tag=CC $(CC)
+LTCOMPILE = $(LIBTOOL) --mode=compile --tag=CC $(CC)
LCOV_ARGS=--directory .libs --directory .
@@ -25,27 +25,27 @@ LCOV_ARGS=--directory .libs --directory .
OBJECTS=bncore.o bn_error.o bn_fast_mp_invmod.o bn_fast_mp_montgomery_reduce.o bn_fast_s_mp_mul_digs.o \
bn_fast_s_mp_mul_high_digs.o bn_fast_s_mp_sqr.o bn_mp_2expt.o bn_mp_abs.o bn_mp_add.o bn_mp_add_d.o \
bn_mp_addmod.o bn_mp_and.o bn_mp_clamp.o bn_mp_clear.o bn_mp_clear_multi.o bn_mp_cmp.o bn_mp_cmp_d.o \
-bn_mp_cmp_mag.o bn_mp_cnt_lsb.o bn_mp_copy.o bn_mp_count_bits.o bn_mp_div_2.o bn_mp_div_2d.o bn_mp_div_3.o \
-bn_mp_div.o bn_mp_div_d.o bn_mp_dr_is_modulus.o bn_mp_dr_reduce.o bn_mp_dr_setup.o bn_mp_exch.o \
-bn_mp_export.o bn_mp_expt_d.o bn_mp_expt_d_ex.o bn_mp_exptmod.o bn_mp_exptmod_fast.o bn_mp_exteuclid.o \
-bn_mp_fread.o bn_mp_fwrite.o bn_mp_gcd.o bn_mp_get_int.o bn_mp_get_long.o bn_mp_get_long_long.o \
-bn_mp_grow.o bn_mp_import.o bn_mp_init.o bn_mp_init_copy.o bn_mp_init_multi.o bn_mp_init_set.o \
-bn_mp_init_set_int.o bn_mp_init_size.o bn_mp_invmod.o bn_mp_invmod_slow.o bn_mp_is_square.o \
-bn_mp_jacobi.o bn_mp_karatsuba_mul.o bn_mp_karatsuba_sqr.o bn_mp_lcm.o bn_mp_lshd.o bn_mp_mod_2d.o \
-bn_mp_mod.o bn_mp_mod_d.o bn_mp_montgomery_calc_normalization.o bn_mp_montgomery_reduce.o \
-bn_mp_montgomery_setup.o bn_mp_mul_2.o bn_mp_mul_2d.o bn_mp_mul.o bn_mp_mul_d.o bn_mp_mulmod.o bn_mp_neg.o \
-bn_mp_n_root.o bn_mp_n_root_ex.o bn_mp_or.o bn_mp_prime_fermat.o bn_mp_prime_is_divisible.o \
-bn_mp_prime_is_prime.o bn_mp_prime_miller_rabin.o bn_mp_prime_next_prime.o \
+bn_mp_cmp_mag.o bn_mp_cnt_lsb.o bn_mp_complement.o bn_mp_copy.o bn_mp_count_bits.o bn_mp_div_2.o \
+bn_mp_div_2d.o bn_mp_div_3.o bn_mp_div.o bn_mp_div_d.o bn_mp_dr_is_modulus.o bn_mp_dr_reduce.o \
+bn_mp_dr_setup.o bn_mp_exch.o bn_mp_export.o bn_mp_expt_d.o bn_mp_expt_d_ex.o bn_mp_exptmod.o \
+bn_mp_exptmod_fast.o bn_mp_exteuclid.o bn_mp_fread.o bn_mp_fwrite.o bn_mp_gcd.o bn_mp_get_int.o \
+bn_mp_get_long.o bn_mp_get_long_long.o bn_mp_grow.o bn_mp_import.o bn_mp_init.o bn_mp_init_copy.o \
+bn_mp_init_multi.o bn_mp_init_set.o bn_mp_init_set_int.o bn_mp_init_size.o bn_mp_invmod.o \
+bn_mp_invmod_slow.o bn_mp_is_square.o bn_mp_jacobi.o bn_mp_karatsuba_mul.o bn_mp_karatsuba_sqr.o \
+bn_mp_lcm.o bn_mp_lshd.o bn_mp_mod_2d.o bn_mp_mod.o bn_mp_mod_d.o bn_mp_montgomery_calc_normalization.o \
+bn_mp_montgomery_reduce.o bn_mp_montgomery_setup.o bn_mp_mul_2.o bn_mp_mul_2d.o bn_mp_mul.o bn_mp_mul_d.o \
+bn_mp_mulmod.o bn_mp_neg.o bn_mp_n_root.o bn_mp_n_root_ex.o bn_mp_or.o bn_mp_prime_fermat.o \
+bn_mp_prime_is_divisible.o bn_mp_prime_is_prime.o bn_mp_prime_miller_rabin.o bn_mp_prime_next_prime.o \
bn_mp_prime_rabin_miller_trials.o bn_mp_prime_random_ex.o bn_mp_radix_size.o bn_mp_radix_smap.o \
bn_mp_rand.o bn_mp_read_radix.o bn_mp_read_signed_bin.o bn_mp_read_unsigned_bin.o bn_mp_reduce_2k.o \
bn_mp_reduce_2k_l.o bn_mp_reduce_2k_setup.o bn_mp_reduce_2k_setup_l.o bn_mp_reduce.o \
bn_mp_reduce_is_2k.o bn_mp_reduce_is_2k_l.o bn_mp_reduce_setup.o bn_mp_rshd.o bn_mp_set.o bn_mp_set_int.o \
bn_mp_set_long.o bn_mp_set_long_long.o bn_mp_shrink.o bn_mp_signed_bin_size.o bn_mp_sqr.o bn_mp_sqrmod.o \
-bn_mp_sqrt.o bn_mp_sqrtmod_prime.o bn_mp_sub.o bn_mp_sub_d.o bn_mp_submod.o bn_mp_toom_mul.o \
-bn_mp_toom_sqr.o bn_mp_toradix.o bn_mp_toradix_n.o bn_mp_to_signed_bin.o bn_mp_to_signed_bin_n.o \
-bn_mp_to_unsigned_bin.o bn_mp_to_unsigned_bin_n.o bn_mp_unsigned_bin_size.o bn_mp_xor.o bn_mp_zero.o \
-bn_prime_tab.o bn_reverse.o bn_s_mp_add.o bn_s_mp_exptmod.o bn_s_mp_mul_digs.o bn_s_mp_mul_high_digs.o \
-bn_s_mp_sqr.o bn_s_mp_sub.o
+bn_mp_sqrt.o bn_mp_sqrtmod_prime.o bn_mp_sub.o bn_mp_sub_d.o bn_mp_submod.o bn_mp_tc_and.o \
+bn_mp_tc_div_2d.o bn_mp_tc_or.o bn_mp_tc_xor.o bn_mp_toom_mul.o bn_mp_toom_sqr.o bn_mp_toradix.o \
+bn_mp_toradix_n.o bn_mp_to_signed_bin.o bn_mp_to_signed_bin_n.o bn_mp_to_unsigned_bin.o \
+bn_mp_to_unsigned_bin_n.o bn_mp_unsigned_bin_size.o bn_mp_xor.o bn_mp_zero.o bn_prime_tab.o bn_reverse.o \
+bn_s_mp_add.o bn_s_mp_exptmod.o bn_s_mp_mul_digs.o bn_s_mp_mul_high_digs.o bn_s_mp_sqr.o bn_s_mp_sub.o
#END_INS
@@ -57,32 +57,32 @@ objs: $(OBJECTS)
LOBJECTS = $(OBJECTS:.o=.lo)
$(LIBNAME): $(OBJECTS)
- $(LT) --mode=link --tag=CC $(CC) $(LDFLAGS) $(LOBJECTS) -o $(LIBNAME) -rpath $(LIBPATH) -version-info $(VERSION_SO)
+ $(LIBTOOL) --mode=link --tag=CC $(CC) $(LDFLAGS) $(LOBJECTS) -o $(LIBNAME) -rpath $(LIBPATH) -version-info $(VERSION_SO)
install: $(LIBNAME)
install -d $(DESTDIR)$(LIBPATH)
install -d $(DESTDIR)$(INCPATH)
- $(LT) --mode=install install -m 644 $(LIBNAME) $(DESTDIR)$(LIBPATH)/$(LIBNAME)
+ $(LIBTOOL) --mode=install install -m 644 $(LIBNAME) $(DESTDIR)$(LIBPATH)/$(LIBNAME)
install -m 644 $(HEADERS_PUB) $(DESTDIR)$(INCPATH)
sed -e 's,^prefix=.*,prefix=$(PREFIX),' -e 's,^Version:.*,Version: $(VERSION_PC),' libtommath.pc.in > libtommath.pc
install -d $(DESTDIR)$(LIBPATH)/pkgconfig
install -m 644 libtommath.pc $(DESTDIR)$(LIBPATH)/pkgconfig/
uninstall:
- $(LT) --mode=uninstall rm $(DESTDIR)$(LIBPATH)/$(LIBNAME)
+ $(LIBTOOL) --mode=uninstall rm $(DESTDIR)$(LIBPATH)/$(LIBNAME)
rm $(HEADERS_PUB:%=$(DESTDIR)$(INCPATH)/%)
rm $(DESTDIR)$(LIBPATH)/pkgconfig/libtommath.pc
test: $(LIBNAME) demo/demo.o
$(CC) $(CFLAGS) -c demo/demo.c -o demo/demo.o
- $(LT) --mode=link $(CC) $(LDFLAGS) -o test demo/demo.o $(LIBNAME)
+ $(LIBTOOL) --mode=link $(CC) $(LDFLAGS) -o test demo/demo.o $(LIBNAME)
test_standalone: $(LIBNAME) demo/demo.o
$(CC) $(CFLAGS) -c demo/demo.c -o demo/demo.o
- $(LT) --mode=link $(CC) $(LDFLAGS) -o test demo/demo.o $(LIBNAME)
+ $(LIBTOOL) --mode=link $(CC) $(LDFLAGS) -o test demo/demo.o $(LIBNAME)
mtest:
cd mtest ; $(CC) $(CFLAGS) $(LDFLAGS) mtest.c -o mtest
-timing: $(LIBNAME)
- $(LT) --mode=link $(CC) $(CFLAGS) $(LDFLAGS) -DTIMER demo/timing.c $(LIBNAME) -o ltmtest
+timing: $(LIBNAME) demo/timing.c
+ $(LIBTOOL) --mode=link $(CC) $(CFLAGS) $(LDFLAGS) -DTIMER demo/timing.c $(LIBNAME) -o timing
diff --git a/libtommath/makefile_include.mk b/libtommath/makefile_include.mk
index 45a4895..c4ba8db 100644
--- a/libtommath/makefile_include.mk
+++ b/libtommath/makefile_include.mk
@@ -17,15 +17,34 @@ ifndef CROSS_COMPILE
CROSS_COMPILE=
endif
-ifeq ($(CC),cc)
- CC = $(CROSS_COMPILE)gcc
+# We only need to go through this dance of determining the right compiler if we're using
+# cross compilation, otherwise $(CC) is fine as-is.
+ifneq (,$(CROSS_COMPILE))
+ifeq ($(origin CC),default)
+CSTR := "\#ifdef __clang__\nCLANG\n\#endif\n"
+ifeq ($(PLATFORM),FreeBSD)
+ # XXX: FreeBSD needs extra escaping for some reason
+ CSTR := $$$(CSTR)
endif
+ifneq (,$(shell echo $(CSTR) | $(CC) -E - | grep CLANG))
+ CC := $(CROSS_COMPILE)clang
+else
+ CC := $(CROSS_COMPILE)gcc
+endif # Clang
+endif # cc is Make's default
+endif # CROSS_COMPILE non-empty
+
LD=$(CROSS_COMPILE)ld
AR=$(CROSS_COMPILE)ar
RANLIB=$(CROSS_COMPILE)ranlib
ifndef MAKE
- MAKE=make
+# BSDs refer to GNU Make as gmake
+ifneq (,$(findstring $(PLATFORM),FreeBSD OpenBSD DragonFly NetBSD))
+ MAKE=gmake
+else
+ MAKE=make
+endif
endif
CFLAGS += -I./ -Wall -Wsign-compare -Wextra -Wshadow
@@ -67,10 +86,16 @@ ifeq ($(PLATFORM), Darwin)
CFLAGS += -Wno-nullability-completeness
endif
+ifeq ($(PLATFORM),FreeBSD)
+ _ARCH := $(shell sysctl -b hw.machine_arch)
+else
+ _ARCH := $(shell arch)
+endif
+
# adjust coverage set
-ifneq ($(filter $(shell arch), i386 i686 x86_64 amd64 ia64),)
+ifneq ($(filter $(_ARCH), i386 i686 x86_64 amd64 ia64),)
COVERAGE = test_standalone timing
- COVERAGE_APP = ./test && ./ltmtest
+ COVERAGE_APP = ./test && ./timing
else
COVERAGE = test_standalone
COVERAGE_APP = ./test
@@ -113,7 +138,7 @@ cleancov-clean:
cleancov: cleancov-clean clean
clean:
- rm -f *.gcda *.gcno *.gcov *.bat *.o *.a *.obj *.lib *.exe *.dll etclib/*.o demo/demo.o test ltmtest mpitest mtest/mtest mtest/mtest.exe \
+ rm -f *.gcda *.gcno *.gcov *.bat *.o *.a *.obj *.lib *.exe *.dll etclib/*.o demo/demo.o test timing mpitest mtest/mtest mtest/mtest.exe \
*.idx *.toc *.log *.aux *.dvi *.lof *.ind *.ilg *.ps *.log *.s mpi.c *.da *.dyn *.dpi tommath.tex `find . -type f | grep [~] | xargs` *.lo *.la
rm -rf .libs/
${MAKE} -C etc/ clean MAKE=${MAKE}
diff --git a/libtommath/tommath.h b/libtommath/tommath.h
index 51f703b..c0f3080 100644
--- a/libtommath/tommath.h
+++ b/libtommath/tommath.h
@@ -9,8 +9,6 @@
*
* The library is free for all purposes without any express
* guarantee it works.
- *
- * Tom St Denis, tstdenis82@gmail.com, http://math.libtomcrypt.com
*/
#ifndef BN_H_
#define BN_H_
@@ -27,7 +25,7 @@ extern "C" {
#endif
/* MS Visual C++ doesn't have a 128bit type for words, so fall back to 32bit MPI's (where words are 64bit) */
-#if defined(_MSC_VER) || defined(__LLP64__)
+#if defined(_MSC_VER) || defined(__LLP64__) || defined(__e2k__) || defined(__LCC__)
# define MP_32BIT
#endif
@@ -39,7 +37,13 @@ extern "C" {
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) || defined(_MSC_VER))
-# define MP_64BIT
+# if defined(__GNUC__)
+/* we support 128bit integers only via: __attribute__((mode(TI))) */
+# define MP_64BIT
+# else
+/* otherwise we fall back to MP_32BIT even on 64bit platforms */
+# define MP_32BIT
+# endif
# endif
#endif
@@ -70,14 +74,7 @@ typedef uint32_t mp_word;
#elif defined(MP_64BIT)
/* for GCC only on supported platforms */
typedef uint64_t mp_digit;
-# if defined(__GNUC__)
typedef unsigned long mp_word __attribute__((mode(TI)));
-# else
-/* it seems you have a problem
- * but we assume you can somewhere define your own uint128_t */
-typedef uint128_t mp_word;
-# endif
-
# define DIGIT_BIT 60
#else
/* this is the default case, 28-bit digits */
@@ -104,18 +101,6 @@ typedef uint_least32_t mp_min_u32;
typedef mp_digit mp_min_u32;
#endif
-/* use arc4random on platforms that support it */
-#if defined(__FreeBSD__) || defined(__OpenBSD__) || defined(__NetBSD__) || defined(__DragonFly__)
-# define MP_GEN_RANDOM() arc4random()
-# define MP_GEN_RANDOM_MAX 0xffffffffu
-#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
@@ -291,6 +276,14 @@ int mp_cnt_lsb(const mp_int *a);
/* makes a pseudo-random int of a given size */
int mp_rand(mp_int *a, int digits);
+#ifdef MP_PRNG_ENABLE_LTM_RNG
+/* as last resort we will fall back to libtomcrypt's rng_get_bytes()
+ * in case you don't use libtomcrypt or use it w/o rng_get_bytes()
+ * you have to implement it somewhere else, as it's required */
+extern unsigned long (*ltm_rng)(unsigned char *out, unsigned long outlen, void (*callback)(void));
+extern void (*ltm_rng_callback)(void);
+#endif
+
/* ---> binary operations <--- */
/* c = a XOR b */
int mp_xor(const mp_int *a, const mp_int *b, mp_int *c);
@@ -301,8 +294,23 @@ int mp_or(const mp_int *a, const mp_int *b, mp_int *c);
/* c = a AND b */
int mp_and(const mp_int *a, const mp_int *b, mp_int *c);
+/* c = a XOR b (two complement) */
+int mp_tc_xor(const mp_int *a, const mp_int *b, mp_int *c);
+
+/* c = a OR b (two complement) */
+int mp_tc_or(const mp_int *a, const mp_int *b, mp_int *c);
+
+/* c = a AND b (two complement) */
+int mp_tc_and(const mp_int *a, const mp_int *b, mp_int *c);
+
+/* right shift (two complement) */
+int mp_tc_div_2d(const mp_int *a, int b, mp_int *c);
+
/* ---> Basic arithmetic <--- */
+/* b = ~a */
+int mp_complement(const mp_int *a, mp_int *b);
+
/* b = -a */
int mp_neg(const mp_int *a, mp_int *b);
diff --git a/libtommath/tommath_class.h b/libtommath/tommath_class.h
index f700d66..1989054 100644
--- a/libtommath/tommath_class.h
+++ b/libtommath/tommath_class.h
@@ -27,6 +27,7 @@
# define BN_MP_CMP_D_C
# define BN_MP_CMP_MAG_C
# define BN_MP_CNT_LSB_C
+# define BN_MP_COMPLEMENT_C
# define BN_MP_COPY_C
# define BN_MP_COUNT_BITS_C
# define BN_MP_DIV_C
@@ -116,6 +117,10 @@
# define BN_MP_SUB_C
# define BN_MP_SUB_D_C
# define BN_MP_SUBMOD_C
+# define BN_MP_TC_AND_C
+# define BN_MP_TC_DIV_2D_C
+# define BN_MP_TC_OR_C
+# define BN_MP_TC_XOR_C
# define BN_MP_TO_SIGNED_BIN_C
# define BN_MP_TO_SIGNED_BIN_N_C
# define BN_MP_TO_UNSIGNED_BIN_C
@@ -147,12 +152,12 @@
# define BN_MP_INIT_MULTI_C
# define BN_MP_COPY_C
# define BN_MP_MOD_C
+# define BN_MP_ISZERO_C
# define BN_MP_SET_C
# define BN_MP_DIV_2_C
# define BN_MP_ISODD_C
# define BN_MP_SUB_C
# define BN_MP_CMP_C
-# define BN_MP_ISZERO_C
# define BN_MP_CMP_D_C
# define BN_MP_ADD_C
# define BN_MP_EXCH_C
@@ -241,6 +246,11 @@
# define BN_MP_ISZERO_C
#endif
+#if defined(BN_MP_COMPLEMENT_C)
+# define BN_MP_NEG_C
+# define BN_MP_SUB_D_C
+#endif
+
#if defined(BN_MP_COPY_C)
# define BN_MP_GROW_C
#endif
@@ -390,7 +400,8 @@
#if defined(BN_MP_FREAD_C)
# define BN_MP_ZERO_C
-# define BN_MP_S_RMAP_C
+# define BN_MP_S_RMAP_REVERSE_SZ_C
+# define BN_MP_S_RMAP_REVERSE_C
# define BN_MP_MUL_D_C
# define BN_MP_ADD_D_C
# define BN_MP_CMP_D_C
@@ -462,9 +473,8 @@
#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_MP_ISODD_C
# define BN_FAST_MP_INVMOD_C
# define BN_MP_INVMOD_SLOW_C
#endif
@@ -541,6 +551,7 @@
#endif
#if defined(BN_MP_LSHD_C)
+# define BN_MP_ISZERO_C
# define BN_MP_GROW_C
# define BN_MP_RSHD_C
#endif
@@ -714,6 +725,8 @@
#if defined(BN_MP_RADIX_SMAP_C)
# define BN_MP_S_RMAP_C
+# define BN_MP_S_RMAP_REVERSE_C
+# define BN_MP_S_RMAP_REVERSE_SZ_C
#endif
#if defined(BN_MP_RAND_C)
@@ -724,7 +737,8 @@
#if defined(BN_MP_READ_RADIX_C)
# define BN_MP_ZERO_C
-# define BN_MP_S_RMAP_C
+# define BN_MP_S_RMAP_REVERSE_SZ_C
+# define BN_MP_S_RMAP_REVERSE_C
# define BN_MP_MUL_D_C
# define BN_MP_ADD_D_C
# define BN_MP_ISZERO_C
@@ -904,6 +918,49 @@
# define BN_MP_MOD_C
#endif
+#if defined(BN_MP_TC_AND_C)
+# define BN_MP_ISNEG_C
+# define BN_MP_COUNT_BITS_C
+# define BN_MP_INIT_SET_INT_C
+# define BN_MP_MUL_2D_C
+# define BN_MP_INIT_C
+# define BN_MP_ADD_C
+# define BN_MP_CLEAR_C
+# define BN_MP_AND_C
+# define BN_MP_SUB_C
+#endif
+
+#if defined(BN_MP_TC_DIV_2D_C)
+# define BN_MP_ISNEG_C
+# define BN_MP_DIV_2D_C
+# define BN_MP_ADD_D_C
+# define BN_MP_SUB_D_C
+#endif
+
+#if defined(BN_MP_TC_OR_C)
+# define BN_MP_ISNEG_C
+# define BN_MP_COUNT_BITS_C
+# define BN_MP_INIT_SET_INT_C
+# define BN_MP_MUL_2D_C
+# define BN_MP_INIT_C
+# define BN_MP_ADD_C
+# define BN_MP_CLEAR_C
+# define BN_MP_OR_C
+# define BN_MP_SUB_C
+#endif
+
+#if defined(BN_MP_TC_XOR_C)
+# define BN_MP_ISNEG_C
+# define BN_MP_COUNT_BITS_C
+# define BN_MP_INIT_SET_INT_C
+# define BN_MP_MUL_2D_C
+# define BN_MP_INIT_C
+# define BN_MP_ADD_C
+# define BN_MP_CLEAR_C
+# define BN_MP_XOR_C
+# define BN_MP_SUB_C
+#endif
+
#if defined(BN_MP_TO_SIGNED_BIN_C)
# define BN_MP_TO_UNSIGNED_BIN_C
#endif
diff --git a/libtommath/tommath_private.h b/libtommath/tommath_private.h
index fd25141..f042684 100644
--- a/libtommath/tommath_private.h
+++ b/libtommath/tommath_private.h
@@ -9,8 +9,6 @@
*
* The library is free for all purposes without any express
* guarantee it works.
- *
- * Tom St Denis, tstdenis82@gmail.com, http://math.libtomcrypt.com
*/
#ifndef TOMMATH_PRIV_H_
#define TOMMATH_PRIV_H_
@@ -75,7 +73,7 @@ int mp_exptmod_fast(const mp_int *G, const mp_int *X, const mp_int *P, mp_int *Y
int s_mp_exptmod(const mp_int *G, const mp_int *X, const mp_int *P, mp_int *Y, int redmode);
void bn_reverse(unsigned char *s, int len);
-extern const char *mp_s_rmap;
+extern const char *const mp_s_rmap;
extern const unsigned char mp_s_rmap_reverse[];
extern const size_t mp_s_rmap_reverse_sz;