summaryrefslogtreecommitdiffstats
path: root/libtommath
diff options
context:
space:
mode:
Diffstat (limited to 'libtommath')
-rw-r--r--libtommath/README.md10
-rw-r--r--libtommath/appveyor.yml18
-rw-r--r--libtommath/bn_deprecated.c10
-rw-r--r--libtommath/bn_mp_get_i32.c2
-rw-r--r--libtommath/bn_mp_get_i64.c2
-rw-r--r--libtommath/bn_mp_get_l.c7
-rw-r--r--libtommath/bn_mp_get_ll.c7
-rw-r--r--libtommath/bn_mp_get_mag_u32.c (renamed from libtommath/bn_mp_get_mag64.c)4
-rw-r--r--libtommath/bn_mp_get_mag_u64.c7
-rw-r--r--libtommath/bn_mp_get_mag_ul.c7
-rw-r--r--libtommath/bn_mp_get_mag_ull.c7
-rw-r--r--libtommath/bn_mp_init_i32.c2
-rw-r--r--libtommath/bn_mp_init_l.c (renamed from libtommath/bn_mp_get_mag32.c)4
-rw-r--r--libtommath/bn_mp_init_ll.c7
-rw-r--r--libtommath/bn_mp_init_u32.c2
-rw-r--r--libtommath/bn_mp_init_ul.c7
-rw-r--r--libtommath/bn_mp_init_ull.c7
-rw-r--r--libtommath/bn_mp_is_square.c2
-rw-r--r--libtommath/bn_mp_prime_is_prime.c1
-rw-r--r--libtommath/bn_mp_prime_strong_lucas_selfridge.c24
-rw-r--r--libtommath/bn_mp_reduce.c6
-rw-r--r--libtommath/bn_mp_set_i32.c2
-rw-r--r--libtommath/bn_mp_set_l.c7
-rw-r--r--libtommath/bn_mp_set_ll.c7
-rw-r--r--libtommath/bn_mp_set_u32.c2
-rw-r--r--libtommath/bn_mp_set_ul.c7
-rw-r--r--libtommath/bn_mp_set_ull.c7
-rw-r--r--libtommath/bn_s_mp_invmod_slow.c3
-rw-r--r--libtommath/bn_s_mp_karatsuba_mul.c54
-rw-r--r--libtommath/libtommath_VS2008.vcproj52
-rw-r--r--libtommath/makefile36
-rw-r--r--libtommath/makefile.mingw36
-rw-r--r--libtommath/makefile.msvc36
-rw-r--r--libtommath/makefile.shared36
-rw-r--r--libtommath/makefile.unix36
-rw-r--r--libtommath/tommath.def16
-rw-r--r--libtommath/tommath.h51
-rw-r--r--libtommath/tommath_class.h77
-rw-r--r--libtommath/tommath_private.h8
39 files changed, 440 insertions, 176 deletions
diff --git a/libtommath/README.md b/libtommath/README.md
index 647e179..70e015d 100644
--- a/libtommath/README.md
+++ b/libtommath/README.md
@@ -4,10 +4,20 @@ This is the git repository for [LibTomMath](http://www.libtom.net/LibTomMath/),
## Build Status
+### Travis CI
+
master: [![Build Status](https://api.travis-ci.org/libtom/libtommath.png?branch=master)](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)
+### AppVeyor
+
+master: [![Build status](https://ci.appveyor.com/api/projects/status/b80lpolw3i8m6hsh/branch/master?svg=true)](https://ci.appveyor.com/project/libtom/libtommath/branch/master)
+
+develop: [![Build status](https://ci.appveyor.com/api/projects/status/b80lpolw3i8m6hsh/branch/develop?svg=true)](https://ci.appveyor.com/project/libtom/libtommath/branch/develop)
+
+### ABI Laboratory
+
API/ABI changes: [check here](https://abi-laboratory.pro/tracker/timeline/libtommath/)
## Summary
diff --git a/libtommath/appveyor.yml b/libtommath/appveyor.yml
new file mode 100644
index 0000000..c4a13a0
--- /dev/null
+++ b/libtommath/appveyor.yml
@@ -0,0 +1,18 @@
+version: 1.1.0-{build}
+branches:
+ only:
+ - master
+ - develop
+ - /^release/
+ - /^travis/
+image:
+- Visual Studio 2017
+- Visual Studio 2015
+build_script:
+- cmd: >-
+ if "Visual Studio 2017"=="%APPVEYOR_BUILD_WORKER_IMAGE%" call "C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Auxiliary\Build\vcvars64.bat"
+ if "Visual Studio 2015"=="%APPVEYOR_BUILD_WORKER_IMAGE%" call "C:\Program Files\Microsoft SDKs\Windows\v7.1\Bin\SetEnv.cmd" /x64
+ if "Visual Studio 2015"=="%APPVEYOR_BUILD_WORKER_IMAGE%" call "C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\vcvarsall.bat" x86_amd64
+ nmake -f makefile.msvc all
+test_script:
+- cmd: test.exe
diff --git a/libtommath/bn_deprecated.c b/libtommath/bn_deprecated.c
index 277477b..62c7f4e 100644
--- a/libtommath/bn_deprecated.c
+++ b/libtommath/bn_deprecated.c
@@ -143,7 +143,7 @@ mp_err mp_tc_div_2d(const mp_int *a, int b, mp_int *c)
#ifdef BN_MP_INIT_SET_INT_C
mp_err mp_init_set_int(mp_int *a, unsigned long b)
{
- return mp_init_u32(a, (unsigned int)b);
+ return mp_init_ul(a, (unsigned int)b);
}
#endif
#ifdef BN_MP_SET_INT_C
@@ -163,26 +163,26 @@ mp_err mp_set_long(mp_int *a, unsigned long b)
#ifdef BN_MP_SET_LONG_LONG_C
mp_err mp_set_long_long(mp_int *a, unsigned long long b)
{
- mp_set_u64(a, b);
+ mp_set_ull(a, b);
return MP_OKAY;
}
#endif
#ifdef BN_MP_GET_INT_C
unsigned long mp_get_int(const mp_int *a)
{
- return mp_get_mag32(a);
+ return (unsigned long)mp_get_mag_u32(a);
}
#endif
#ifdef BN_MP_GET_LONG_C
unsigned long mp_get_long(const mp_int *a)
{
- return (sizeof(long) > sizeof(int32_t)) ? (unsigned long)mp_get_mag64(a) : (unsigned long)mp_get_mag32(a);
+ return (unsigned long)mp_get_mag_ul(a);
}
#endif
#ifdef BN_MP_GET_LONG_LONG_C
unsigned long long mp_get_long_long(const mp_int *a)
{
- return (unsigned long long)mp_get_mag64(a);
+ return mp_get_mag_ull(a);
}
#endif
#ifdef BN_MP_PRIME_IS_DIVISIBLE_C
diff --git a/libtommath/bn_mp_get_i32.c b/libtommath/bn_mp_get_i32.c
index 4227a70..5caaa4f 100644
--- a/libtommath/bn_mp_get_i32.c
+++ b/libtommath/bn_mp_get_i32.c
@@ -3,5 +3,5 @@
/* LibTomMath, multiple-precision integer library -- Tom St Denis */
/* SPDX-License-Identifier: Unlicense */
-MP_GET_SIGNED(int32_t, mp_get_i32, mp_get_mag32)
+MP_GET_SIGNED(mp_get_i32, mp_get_mag_u32, long, unsigned long)
#endif
diff --git a/libtommath/bn_mp_get_i64.c b/libtommath/bn_mp_get_i64.c
index aa9fc8f..e5101c9 100644
--- a/libtommath/bn_mp_get_i64.c
+++ b/libtommath/bn_mp_get_i64.c
@@ -3,5 +3,5 @@
/* LibTomMath, multiple-precision integer library -- Tom St Denis */
/* SPDX-License-Identifier: Unlicense */
-MP_GET_SIGNED(long long, mp_get_i64, mp_get_mag64)
+MP_GET_SIGNED(mp_get_i64, mp_get_mag_u64, long long, unsigned long long)
#endif
diff --git a/libtommath/bn_mp_get_l.c b/libtommath/bn_mp_get_l.c
new file mode 100644
index 0000000..55d78ec
--- /dev/null
+++ b/libtommath/bn_mp_get_l.c
@@ -0,0 +1,7 @@
+#include "tommath_private.h"
+#ifdef BN_MP_GET_L_C
+/* LibTomMath, multiple-precision integer library -- Tom St Denis */
+/* SPDX-License-Identifier: Unlicense */
+
+MP_GET_SIGNED(mp_get_l, mp_get_mag_ul, long, unsigned long)
+#endif
diff --git a/libtommath/bn_mp_get_ll.c b/libtommath/bn_mp_get_ll.c
new file mode 100644
index 0000000..2687534
--- /dev/null
+++ b/libtommath/bn_mp_get_ll.c
@@ -0,0 +1,7 @@
+#include "tommath_private.h"
+#ifdef BN_MP_GET_LL_C
+/* LibTomMath, multiple-precision integer library -- Tom St Denis */
+/* SPDX-License-Identifier: Unlicense */
+
+MP_GET_SIGNED(mp_get_ll, mp_get_mag_ull, long long, unsigned long long)
+#endif
diff --git a/libtommath/bn_mp_get_mag64.c b/libtommath/bn_mp_get_mag_u32.c
index 8cb6a67..86eafe8 100644
--- a/libtommath/bn_mp_get_mag64.c
+++ b/libtommath/bn_mp_get_mag_u32.c
@@ -1,7 +1,7 @@
#include "tommath_private.h"
-#ifdef BN_MP_GET_MAG64_C
+#ifdef BN_MP_GET_MAG_U32_C
/* LibTomMath, multiple-precision integer library -- Tom St Denis */
/* SPDX-License-Identifier: Unlicense */
-MP_GET_MAG(unsigned long long, mp_get_mag64)
+MP_GET_MAG(mp_get_mag_u32, unsigned long)
#endif
diff --git a/libtommath/bn_mp_get_mag_u64.c b/libtommath/bn_mp_get_mag_u64.c
new file mode 100644
index 0000000..a9cf5fd
--- /dev/null
+++ b/libtommath/bn_mp_get_mag_u64.c
@@ -0,0 +1,7 @@
+#include "tommath_private.h"
+#ifdef BN_MP_GET_MAG_U64_C
+/* LibTomMath, multiple-precision integer library -- Tom St Denis */
+/* SPDX-License-Identifier: Unlicense */
+
+MP_GET_MAG(mp_get_mag_u64, unsigned long long)
+#endif
diff --git a/libtommath/bn_mp_get_mag_ul.c b/libtommath/bn_mp_get_mag_ul.c
new file mode 100644
index 0000000..e8819ae
--- /dev/null
+++ b/libtommath/bn_mp_get_mag_ul.c
@@ -0,0 +1,7 @@
+#include "tommath_private.h"
+#ifdef BN_MP_GET_MAG_UL_C
+/* LibTomMath, multiple-precision integer library -- Tom St Denis */
+/* SPDX-License-Identifier: Unlicense */
+
+MP_GET_MAG(mp_get_mag_ul, unsigned long)
+#endif
diff --git a/libtommath/bn_mp_get_mag_ull.c b/libtommath/bn_mp_get_mag_ull.c
new file mode 100644
index 0000000..63a2741
--- /dev/null
+++ b/libtommath/bn_mp_get_mag_ull.c
@@ -0,0 +1,7 @@
+#include "tommath_private.h"
+#ifdef BN_MP_GET_MAG_ULL_C
+/* LibTomMath, multiple-precision integer library -- Tom St Denis */
+/* SPDX-License-Identifier: Unlicense */
+
+MP_GET_MAG(mp_get_mag_ull, unsigned long long)
+#endif
diff --git a/libtommath/bn_mp_init_i32.c b/libtommath/bn_mp_init_i32.c
index bc4de8d..3130afd 100644
--- a/libtommath/bn_mp_init_i32.c
+++ b/libtommath/bn_mp_init_i32.c
@@ -3,5 +3,5 @@
/* LibTomMath, multiple-precision integer library -- Tom St Denis */
/* SPDX-License-Identifier: Unlicense */
-MP_INIT_INT(mp_init_i32, mp_set_i32, int32_t)
+MP_INIT_INT(mp_init_i32, mp_set_i32, long)
#endif
diff --git a/libtommath/bn_mp_get_mag32.c b/libtommath/bn_mp_init_l.c
index 46e8b29..bc380b5 100644
--- a/libtommath/bn_mp_get_mag32.c
+++ b/libtommath/bn_mp_init_l.c
@@ -1,7 +1,7 @@
#include "tommath_private.h"
-#ifdef BN_MP_GET_MAG32_C
+#ifdef BN_MP_INIT_L_C
/* LibTomMath, multiple-precision integer library -- Tom St Denis */
/* SPDX-License-Identifier: Unlicense */
-MP_GET_MAG(uint32_t, mp_get_mag32)
+MP_INIT_INT(mp_init_l, mp_set_l, long)
#endif
diff --git a/libtommath/bn_mp_init_ll.c b/libtommath/bn_mp_init_ll.c
new file mode 100644
index 0000000..dc7c4a4
--- /dev/null
+++ b/libtommath/bn_mp_init_ll.c
@@ -0,0 +1,7 @@
+#include "tommath_private.h"
+#ifdef BN_MP_INIT_LL_C
+/* LibTomMath, multiple-precision integer library -- Tom St Denis */
+/* SPDX-License-Identifier: Unlicense */
+
+MP_INIT_INT(mp_init_ll, mp_set_ll, long long)
+#endif
diff --git a/libtommath/bn_mp_init_u32.c b/libtommath/bn_mp_init_u32.c
index 015d89b..73643cf 100644
--- a/libtommath/bn_mp_init_u32.c
+++ b/libtommath/bn_mp_init_u32.c
@@ -3,5 +3,5 @@
/* LibTomMath, multiple-precision integer library -- Tom St Denis */
/* SPDX-License-Identifier: Unlicense */
-MP_INIT_INT(mp_init_u32, mp_set_u32, uint32_t)
+MP_INIT_INT(mp_init_u32, mp_set_u32, unsigned long)
#endif
diff --git a/libtommath/bn_mp_init_ul.c b/libtommath/bn_mp_init_ul.c
new file mode 100644
index 0000000..5164f72
--- /dev/null
+++ b/libtommath/bn_mp_init_ul.c
@@ -0,0 +1,7 @@
+#include "tommath_private.h"
+#ifdef BN_MP_INIT_UL_C
+/* LibTomMath, multiple-precision integer library -- Tom St Denis */
+/* SPDX-License-Identifier: Unlicense */
+
+MP_INIT_INT(mp_init_ul, mp_set_ul, unsigned long)
+#endif
diff --git a/libtommath/bn_mp_init_ull.c b/libtommath/bn_mp_init_ull.c
new file mode 100644
index 0000000..84110c0
--- /dev/null
+++ b/libtommath/bn_mp_init_ull.c
@@ -0,0 +1,7 @@
+#include "tommath_private.h"
+#ifdef BN_MP_INIT_ULL_C
+/* LibTomMath, multiple-precision integer library -- Tom St Denis */
+/* SPDX-License-Identifier: Unlicense */
+
+MP_INIT_INT(mp_init_ull, mp_set_ull, unsigned long long)
+#endif
diff --git a/libtommath/bn_mp_is_square.c b/libtommath/bn_mp_is_square.c
index 69e77a2..e229bf7 100644
--- a/libtommath/bn_mp_is_square.c
+++ b/libtommath/bn_mp_is_square.c
@@ -58,7 +58,7 @@ mp_err mp_is_square(const mp_int *arg, mp_bool *ret)
}
- if ((err = mp_init_u32(&t, 11u*13u*17u*19u*23u*29u*31u)) != MP_OKAY) {
+ if ((err = mp_init_ul(&t, 11u*13u*17u*19u*23u*29u*31u)) != MP_OKAY) {
return err;
}
if ((err = mp_mod(arg, &t, &t)) != MP_OKAY) {
diff --git a/libtommath/bn_mp_prime_is_prime.c b/libtommath/bn_mp_prime_is_prime.c
index f497822..0c5131e 100644
--- a/libtommath/bn_mp_prime_is_prime.c
+++ b/libtommath/bn_mp_prime_is_prime.c
@@ -145,7 +145,6 @@ mp_err mp_prime_is_prime(const mp_int *a, int t, mp_bool *result)
TODO: can be made a bit finer grained but comparing is not free.
*/
if (t < 0) {
- t = -t;
/*
Sorenson, Jonathan; Webster, Jonathan (2015).
"Strong Pseudoprimes to Twelve Prime Bases".
diff --git a/libtommath/bn_mp_prime_strong_lucas_selfridge.c b/libtommath/bn_mp_prime_strong_lucas_selfridge.c
index 48b3654..4e17d32 100644
--- a/libtommath/bn_mp_prime_strong_lucas_selfridge.c
+++ b/libtommath/bn_mp_prime_strong_lucas_selfridge.c
@@ -177,26 +177,12 @@ mp_err mp_prime_strong_lucas_selfridge(const mp_int *a, mp_bool *result)
mp_set(&U2mz, 1uL); /* U_1 */
mp_set(&V2mz, (mp_digit)P); /* V_1 */
- if (Q < 0) {
- Q = -Q;
- mp_set_u32(&Qmz, (uint32_t)Q);
- if ((err = mp_mul_2(&Qmz, &Q2mz)) != MP_OKAY) {
- goto LBL_LS_ERR;
- }
- /* Initializes calculation of Q^d */
- mp_set_u32(&Qkdz, (uint32_t)Q);
- Qmz.sign = MP_NEG;
- Q2mz.sign = MP_NEG;
- Qkdz.sign = MP_NEG;
- Q = -Q;
- } else {
- mp_set_u32(&Qmz, (uint32_t)Q);
- if ((err = mp_mul_2(&Qmz, &Q2mz)) != MP_OKAY) {
- goto LBL_LS_ERR;
- }
- /* Initializes calculation of Q^d */
- mp_set_u32(&Qkdz, (uint32_t)Q);
+ mp_set_i32(&Qmz, Q);
+ if ((err = mp_mul_2(&Qmz, &Q2mz)) != MP_OKAY) {
+ goto LBL_LS_ERR;
}
+ /* Initializes calculation of Q^d */
+ mp_set_i32(&Qkdz, Q);
Nbits = mp_count_bits(&Dz);
diff --git a/libtommath/bn_mp_reduce.c b/libtommath/bn_mp_reduce.c
index d5d3fb1..5748550 100644
--- a/libtommath/bn_mp_reduce.c
+++ b/libtommath/bn_mp_reduce.c
@@ -64,10 +64,12 @@ mp_err mp_reduce(mp_int *x, const mp_int *m, const mp_int *mu)
/* If x < 0, add b**(k+1) to it */
if (mp_cmp_d(x, 0uL) == MP_LT) {
mp_set(&q, 1uL);
- if ((err = mp_lshd(&q, um + 1)) != MP_OKAY)
+ if ((err = mp_lshd(&q, um + 1)) != MP_OKAY) {
goto CLEANUP;
- if ((err = mp_add(x, &q, x)) != MP_OKAY)
+ }
+ if ((err = mp_add(x, &q, x)) != MP_OKAY) {
goto CLEANUP;
+ }
}
/* Back off if it's too big */
diff --git a/libtommath/bn_mp_set_i32.c b/libtommath/bn_mp_set_i32.c
index df4513d..8bef77c 100644
--- a/libtommath/bn_mp_set_i32.c
+++ b/libtommath/bn_mp_set_i32.c
@@ -3,5 +3,5 @@
/* LibTomMath, multiple-precision integer library -- Tom St Denis */
/* SPDX-License-Identifier: Unlicense */
-MP_SET_SIGNED(mp_set_i32, mp_set_u32, int32_t, uint32_t)
+MP_SET_SIGNED(mp_set_i32, mp_set_u32, long, unsigned long)
#endif
diff --git a/libtommath/bn_mp_set_l.c b/libtommath/bn_mp_set_l.c
new file mode 100644
index 0000000..1e445fb
--- /dev/null
+++ b/libtommath/bn_mp_set_l.c
@@ -0,0 +1,7 @@
+#include "tommath_private.h"
+#ifdef BN_MP_SET_L_C
+/* LibTomMath, multiple-precision integer library -- Tom St Denis */
+/* SPDX-License-Identifier: Unlicense */
+
+MP_SET_SIGNED(mp_set_l, mp_set_ul, long, unsigned long)
+#endif
diff --git a/libtommath/bn_mp_set_ll.c b/libtommath/bn_mp_set_ll.c
new file mode 100644
index 0000000..3e2324f
--- /dev/null
+++ b/libtommath/bn_mp_set_ll.c
@@ -0,0 +1,7 @@
+#include "tommath_private.h"
+#ifdef BN_MP_SET_LL_C
+/* LibTomMath, multiple-precision integer library -- Tom St Denis */
+/* SPDX-License-Identifier: Unlicense */
+
+MP_SET_SIGNED(mp_set_ll, mp_set_ull, long long, unsigned long long)
+#endif
diff --git a/libtommath/bn_mp_set_u32.c b/libtommath/bn_mp_set_u32.c
index 18ba5e1..5601ea5 100644
--- a/libtommath/bn_mp_set_u32.c
+++ b/libtommath/bn_mp_set_u32.c
@@ -3,5 +3,5 @@
/* LibTomMath, multiple-precision integer library -- Tom St Denis */
/* SPDX-License-Identifier: Unlicense */
-MP_SET_UNSIGNED(mp_set_u32, uint32_t)
+MP_SET_UNSIGNED(mp_set_u32, unsigned long)
#endif
diff --git a/libtommath/bn_mp_set_ul.c b/libtommath/bn_mp_set_ul.c
new file mode 100644
index 0000000..adfd85c
--- /dev/null
+++ b/libtommath/bn_mp_set_ul.c
@@ -0,0 +1,7 @@
+#include "tommath_private.h"
+#ifdef BN_MP_SET_UL_C
+/* LibTomMath, multiple-precision integer library -- Tom St Denis */
+/* SPDX-License-Identifier: Unlicense */
+
+MP_SET_UNSIGNED(mp_set_ul, unsigned long)
+#endif
diff --git a/libtommath/bn_mp_set_ull.c b/libtommath/bn_mp_set_ull.c
new file mode 100644
index 0000000..8fbc1bd
--- /dev/null
+++ b/libtommath/bn_mp_set_ull.c
@@ -0,0 +1,7 @@
+#include "tommath_private.h"
+#ifdef BN_MP_SET_ULL_C
+/* LibTomMath, multiple-precision integer library -- Tom St Denis */
+/* SPDX-License-Identifier: Unlicense */
+
+MP_SET_UNSIGNED(mp_set_ull, unsigned long long)
+#endif
diff --git a/libtommath/bn_s_mp_invmod_slow.c b/libtommath/bn_s_mp_invmod_slow.c
index faf6221..c03a3d7 100644
--- a/libtommath/bn_s_mp_invmod_slow.c
+++ b/libtommath/bn_s_mp_invmod_slow.c
@@ -125,8 +125,9 @@ top:
}
/* if not zero goto step 4 */
- if (!MP_IS_ZERO(&u))
+ if (!MP_IS_ZERO(&u)) {
goto top;
+ }
/* now a = C, b = D, gcd == g*v */
diff --git a/libtommath/bn_s_mp_karatsuba_mul.c b/libtommath/bn_s_mp_karatsuba_mul.c
index 6ef96c7..85899fb 100644
--- a/libtommath/bn_s_mp_karatsuba_mul.c
+++ b/libtommath/bn_s_mp_karatsuba_mul.c
@@ -45,22 +45,29 @@ mp_err s_mp_karatsuba_mul(const mp_int *a, const mp_int *b, mp_int *c)
B = B >> 1;
/* init copy all the temps */
- if (mp_init_size(&x0, B) != MP_OKAY)
+ if (mp_init_size(&x0, B) != MP_OKAY) {
goto LBL_ERR;
- if (mp_init_size(&x1, a->used - B) != MP_OKAY)
+ }
+ if (mp_init_size(&x1, a->used - B) != MP_OKAY) {
goto X0;
- if (mp_init_size(&y0, B) != MP_OKAY)
+ }
+ if (mp_init_size(&y0, B) != MP_OKAY) {
goto X1;
- if (mp_init_size(&y1, b->used - B) != MP_OKAY)
+ }
+ if (mp_init_size(&y1, b->used - B) != MP_OKAY) {
goto Y0;
+ }
/* init temps */
- if (mp_init_size(&t1, B * 2) != MP_OKAY)
+ if (mp_init_size(&t1, B * 2) != MP_OKAY) {
goto Y1;
- if (mp_init_size(&x0y0, B * 2) != MP_OKAY)
+ }
+ if (mp_init_size(&x0y0, B * 2) != MP_OKAY) {
goto T1;
- if (mp_init_size(&x1y1, B * 2) != MP_OKAY)
+ }
+ if (mp_init_size(&x1y1, B * 2) != MP_OKAY) {
goto X0Y0;
+ }
/* now shift the digits */
x0.used = y0.used = B;
@@ -103,35 +110,46 @@ mp_err s_mp_karatsuba_mul(const mp_int *a, const mp_int *b, mp_int *c)
/* now calc the products x0y0 and x1y1 */
/* after this x0 is no longer required, free temp [x0==t2]! */
- if (mp_mul(&x0, &y0, &x0y0) != MP_OKAY)
+ if (mp_mul(&x0, &y0, &x0y0) != MP_OKAY) {
goto X1Y1; /* x0y0 = x0*y0 */
- if (mp_mul(&x1, &y1, &x1y1) != MP_OKAY)
+ }
+ if (mp_mul(&x1, &y1, &x1y1) != MP_OKAY) {
goto X1Y1; /* x1y1 = x1*y1 */
+ }
/* now calc x1+x0 and y1+y0 */
- if (s_mp_add(&x1, &x0, &t1) != MP_OKAY)
+ if (s_mp_add(&x1, &x0, &t1) != MP_OKAY) {
goto X1Y1; /* t1 = x1 - x0 */
- if (s_mp_add(&y1, &y0, &x0) != MP_OKAY)
+ }
+ if (s_mp_add(&y1, &y0, &x0) != MP_OKAY) {
goto X1Y1; /* t2 = y1 - y0 */
- if (mp_mul(&t1, &x0, &t1) != MP_OKAY)
+ }
+ if (mp_mul(&t1, &x0, &t1) != MP_OKAY) {
goto X1Y1; /* t1 = (x1 + x0) * (y1 + y0) */
+ }
/* add x0y0 */
- if (mp_add(&x0y0, &x1y1, &x0) != MP_OKAY)
+ if (mp_add(&x0y0, &x1y1, &x0) != MP_OKAY) {
goto X1Y1; /* t2 = x0y0 + x1y1 */
- if (s_mp_sub(&t1, &x0, &t1) != MP_OKAY)
+ }
+ if (s_mp_sub(&t1, &x0, &t1) != MP_OKAY) {
goto X1Y1; /* t1 = (x1+x0)*(y1+y0) - (x1y1 + x0y0) */
+ }
/* shift by B */
- if (mp_lshd(&t1, B) != MP_OKAY)
+ if (mp_lshd(&t1, B) != MP_OKAY) {
goto X1Y1; /* t1 = (x0y0 + x1y1 - (x1-x0)*(y1-y0))<<B */
- if (mp_lshd(&x1y1, B * 2) != MP_OKAY)
+ }
+ if (mp_lshd(&x1y1, B * 2) != MP_OKAY) {
goto X1Y1; /* x1y1 = x1y1 << 2*B */
+ }
- if (mp_add(&x0y0, &t1, &t1) != MP_OKAY)
+ if (mp_add(&x0y0, &t1, &t1) != MP_OKAY) {
goto X1Y1; /* t1 = x0y0 + t1 */
- if (mp_add(&t1, &x1y1, c) != MP_OKAY)
+ }
+ if (mp_add(&t1, &x1y1, c) != MP_OKAY) {
goto X1Y1; /* t1 = x0y0 + t1 + x1y1 */
+ }
/* Algorithm succeeded set the return code to MP_OKAY */
err = MP_OKAY;
diff --git a/libtommath/libtommath_VS2008.vcproj b/libtommath/libtommath_VS2008.vcproj
index ad4a237..6676639 100644
--- a/libtommath/libtommath_VS2008.vcproj
+++ b/libtommath/libtommath_VS2008.vcproj
@@ -469,11 +469,27 @@
>
</File>
<File
- RelativePath="bn_mp_get_mag32.c"
+ RelativePath="bn_mp_get_l.c"
>
</File>
<File
- RelativePath="bn_mp_get_mag64.c"
+ RelativePath="bn_mp_get_ll.c"
+ >
+ </File>
+ <File
+ RelativePath="bn_mp_get_mag_u32.c"
+ >
+ </File>
+ <File
+ RelativePath="bn_mp_get_mag_u64.c"
+ >
+ </File>
+ <File
+ RelativePath="bn_mp_get_mag_ul.c"
+ >
+ </File>
+ <File
+ RelativePath="bn_mp_get_mag_ull.c"
>
</File>
<File
@@ -509,6 +525,14 @@
>
</File>
<File
+ RelativePath="bn_mp_init_l.c"
+ >
+ </File>
+ <File
+ RelativePath="bn_mp_init_ll.c"
+ >
+ </File>
+ <File
RelativePath="bn_mp_init_multi.c"
>
</File>
@@ -529,6 +553,14 @@
>
</File>
<File
+ RelativePath="bn_mp_init_ul.c"
+ >
+ </File>
+ <File
+ RelativePath="bn_mp_init_ull.c"
+ >
+ </File>
+ <File
RelativePath="bn_mp_invmod.c"
>
</File>
@@ -721,6 +753,14 @@
>
</File>
<File
+ RelativePath="bn_mp_set_l.c"
+ >
+ </File>
+ <File
+ RelativePath="bn_mp_set_ll.c"
+ >
+ </File>
+ <File
RelativePath="bn_mp_set_u32.c"
>
</File>
@@ -729,6 +769,14 @@
>
</File>
<File
+ RelativePath="bn_mp_set_ul.c"
+ >
+ </File>
+ <File
+ RelativePath="bn_mp_set_ull.c"
+ >
+ </File>
+ <File
RelativePath="bn_mp_shrink.c"
>
</File>
diff --git a/libtommath/makefile b/libtommath/makefile
index fdc8ae3..9276636 100644
--- a/libtommath/makefile
+++ b/libtommath/makefile
@@ -31,29 +31,31 @@ bn_mp_and.o bn_mp_clamp.o bn_mp_clear.o bn_mp_clear_multi.o bn_mp_cmp.o bn_mp_cm
bn_mp_cnt_lsb.o bn_mp_complement.o bn_mp_copy.o bn_mp_count_bits.o bn_mp_decr.o bn_mp_div.o bn_mp_div_2.o \
bn_mp_div_2d.o bn_mp_div_3.o bn_mp_div_d.o bn_mp_dr_is_modulus.o bn_mp_dr_reduce.o bn_mp_dr_setup.o \
bn_mp_error_to_string.o bn_mp_exch.o bn_mp_export.o bn_mp_expt_d.o bn_mp_exptmod.o bn_mp_exteuclid.o \
-bn_mp_fread.o bn_mp_fwrite.o bn_mp_gcd.o bn_mp_get_double.o bn_mp_get_i32.o bn_mp_get_i64.o \
-bn_mp_get_mag32.o bn_mp_get_mag64.o bn_mp_grow.o bn_mp_ilogb.o bn_mp_import.o bn_mp_incr.o bn_mp_init.o \
-bn_mp_init_copy.o bn_mp_init_i32.o bn_mp_init_i64.o bn_mp_init_multi.o bn_mp_init_set.o bn_mp_init_size.o \
-bn_mp_init_u32.o bn_mp_init_u64.o bn_mp_invmod.o bn_mp_is_square.o bn_mp_iseven.o bn_mp_isodd.o \
-bn_mp_kronecker.o bn_mp_lcm.o bn_mp_lshd.o bn_mp_mod.o bn_mp_mod_2d.o bn_mp_mod_d.o \
-bn_mp_montgomery_calc_normalization.o bn_mp_montgomery_reduce.o bn_mp_montgomery_setup.o bn_mp_mul.o \
-bn_mp_mul_2.o bn_mp_mul_2d.o bn_mp_mul_d.o bn_mp_mulmod.o bn_mp_n_root.o bn_mp_neg.o bn_mp_or.o \
+bn_mp_fread.o bn_mp_fwrite.o bn_mp_gcd.o bn_mp_get_double.o bn_mp_get_i32.o bn_mp_get_i64.o bn_mp_get_l.o \
+bn_mp_get_ll.o bn_mp_get_mag_u32.o bn_mp_get_mag_u64.o bn_mp_get_mag_ul.o bn_mp_get_mag_ull.o \
+bn_mp_grow.o bn_mp_ilogb.o bn_mp_import.o bn_mp_incr.o bn_mp_init.o bn_mp_init_copy.o bn_mp_init_i32.o \
+bn_mp_init_i64.o bn_mp_init_l.o bn_mp_init_ll.o bn_mp_init_multi.o bn_mp_init_set.o bn_mp_init_size.o \
+bn_mp_init_u32.o bn_mp_init_u64.o bn_mp_init_ul.o bn_mp_init_ull.o bn_mp_invmod.o bn_mp_is_square.o \
+bn_mp_iseven.o bn_mp_isodd.o bn_mp_kronecker.o bn_mp_lcm.o bn_mp_lshd.o bn_mp_mod.o bn_mp_mod_2d.o \
+bn_mp_mod_d.o bn_mp_montgomery_calc_normalization.o bn_mp_montgomery_reduce.o bn_mp_montgomery_setup.o \
+bn_mp_mul.o bn_mp_mul_2.o bn_mp_mul_2d.o bn_mp_mul_d.o bn_mp_mulmod.o bn_mp_n_root.o bn_mp_neg.o bn_mp_or.o \
bn_mp_prime_fermat.o bn_mp_prime_frobenius_underwood.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_rand.o bn_mp_prime_strong_lucas_selfridge.o bn_mp_radix_size.o bn_mp_radix_smap.o \
bn_mp_rand.o bn_mp_read_radix.o bn_mp_read_signed_bin.o bn_mp_read_unsigned_bin.o bn_mp_reduce.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_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_double.o bn_mp_set_i32.o bn_mp_set_i64.o bn_mp_set_u32.o bn_mp_set_u64.o bn_mp_shrink.o \
-bn_mp_signed_bin_size.o bn_mp_signed_rsh.o bn_mp_sqr.o bn_mp_sqrmod.o bn_mp_sqrt.o bn_mp_sqrtmod_prime.o \
-bn_mp_sub.o bn_mp_sub_d.o bn_mp_submod.o bn_mp_to_signed_bin.o bn_mp_to_signed_bin_n.o \
-bn_mp_to_unsigned_bin.o bn_mp_to_unsigned_bin_n.o bn_mp_toradix.o bn_mp_toradix_n.o \
-bn_mp_unsigned_bin_size.o bn_mp_xor.o bn_mp_zero.o bn_prime_tab.o bn_s_mp_add.o bn_s_mp_balance_mul.o \
-bn_s_mp_exptmod.o bn_s_mp_exptmod_fast.o bn_s_mp_get_bit.o bn_s_mp_invmod_fast.o bn_s_mp_invmod_slow.o \
-bn_s_mp_karatsuba_mul.o bn_s_mp_karatsuba_sqr.o bn_s_mp_montgomery_reduce_fast.o bn_s_mp_mul_digs.o \
-bn_s_mp_mul_digs_fast.o bn_s_mp_mul_high_digs.o bn_s_mp_mul_high_digs_fast.o \
-bn_s_mp_prime_is_divisible.o bn_s_mp_rand_jenkins.o bn_s_mp_rand_platform.o bn_s_mp_reverse.o \
-bn_s_mp_sqr.o bn_s_mp_sqr_fast.o bn_s_mp_sub.o bn_s_mp_toom_mul.o bn_s_mp_toom_sqr.o
+bn_mp_set_double.o bn_mp_set_i32.o bn_mp_set_i64.o bn_mp_set_l.o bn_mp_set_ll.o bn_mp_set_u32.o \
+bn_mp_set_u64.o bn_mp_set_ul.o bn_mp_set_ull.o bn_mp_shrink.o bn_mp_signed_bin_size.o bn_mp_signed_rsh.o \
+bn_mp_sqr.o bn_mp_sqrmod.o bn_mp_sqrt.o bn_mp_sqrtmod_prime.o bn_mp_sub.o bn_mp_sub_d.o bn_mp_submod.o \
+bn_mp_to_signed_bin.o bn_mp_to_signed_bin_n.o bn_mp_to_unsigned_bin.o bn_mp_to_unsigned_bin_n.o \
+bn_mp_toradix.o bn_mp_toradix_n.o bn_mp_unsigned_bin_size.o bn_mp_xor.o bn_mp_zero.o bn_prime_tab.o \
+bn_s_mp_add.o bn_s_mp_balance_mul.o bn_s_mp_exptmod.o bn_s_mp_exptmod_fast.o bn_s_mp_get_bit.o \
+bn_s_mp_invmod_fast.o bn_s_mp_invmod_slow.o bn_s_mp_karatsuba_mul.o bn_s_mp_karatsuba_sqr.o \
+bn_s_mp_montgomery_reduce_fast.o bn_s_mp_mul_digs.o bn_s_mp_mul_digs_fast.o bn_s_mp_mul_high_digs.o \
+bn_s_mp_mul_high_digs_fast.o bn_s_mp_prime_is_divisible.o bn_s_mp_rand_jenkins.o \
+bn_s_mp_rand_platform.o bn_s_mp_reverse.o bn_s_mp_sqr.o bn_s_mp_sqr_fast.o bn_s_mp_sub.o \
+bn_s_mp_toom_mul.o bn_s_mp_toom_sqr.o
#END_INS
diff --git a/libtommath/makefile.mingw b/libtommath/makefile.mingw
index 245047a..0ca4f48 100644
--- a/libtommath/makefile.mingw
+++ b/libtommath/makefile.mingw
@@ -34,29 +34,31 @@ bn_mp_and.o bn_mp_clamp.o bn_mp_clear.o bn_mp_clear_multi.o bn_mp_cmp.o bn_mp_cm
bn_mp_cnt_lsb.o bn_mp_complement.o bn_mp_copy.o bn_mp_count_bits.o bn_mp_decr.o bn_mp_div.o bn_mp_div_2.o \
bn_mp_div_2d.o bn_mp_div_3.o bn_mp_div_d.o bn_mp_dr_is_modulus.o bn_mp_dr_reduce.o bn_mp_dr_setup.o \
bn_mp_error_to_string.o bn_mp_exch.o bn_mp_export.o bn_mp_expt_d.o bn_mp_exptmod.o bn_mp_exteuclid.o \
-bn_mp_fread.o bn_mp_fwrite.o bn_mp_gcd.o bn_mp_get_double.o bn_mp_get_i32.o bn_mp_get_i64.o \
-bn_mp_get_mag32.o bn_mp_get_mag64.o bn_mp_grow.o bn_mp_ilogb.o bn_mp_import.o bn_mp_incr.o bn_mp_init.o \
-bn_mp_init_copy.o bn_mp_init_i32.o bn_mp_init_i64.o bn_mp_init_multi.o bn_mp_init_set.o bn_mp_init_size.o \
-bn_mp_init_u32.o bn_mp_init_u64.o bn_mp_invmod.o bn_mp_is_square.o bn_mp_iseven.o bn_mp_isodd.o \
-bn_mp_kronecker.o bn_mp_lcm.o bn_mp_lshd.o bn_mp_mod.o bn_mp_mod_2d.o bn_mp_mod_d.o \
-bn_mp_montgomery_calc_normalization.o bn_mp_montgomery_reduce.o bn_mp_montgomery_setup.o bn_mp_mul.o \
-bn_mp_mul_2.o bn_mp_mul_2d.o bn_mp_mul_d.o bn_mp_mulmod.o bn_mp_n_root.o bn_mp_neg.o bn_mp_or.o \
+bn_mp_fread.o bn_mp_fwrite.o bn_mp_gcd.o bn_mp_get_double.o bn_mp_get_i32.o bn_mp_get_i64.o bn_mp_get_l.o \
+bn_mp_get_ll.o bn_mp_get_mag_u32.o bn_mp_get_mag_u64.o bn_mp_get_mag_ul.o bn_mp_get_mag_ull.o \
+bn_mp_grow.o bn_mp_ilogb.o bn_mp_import.o bn_mp_incr.o bn_mp_init.o bn_mp_init_copy.o bn_mp_init_i32.o \
+bn_mp_init_i64.o bn_mp_init_l.o bn_mp_init_ll.o bn_mp_init_multi.o bn_mp_init_set.o bn_mp_init_size.o \
+bn_mp_init_u32.o bn_mp_init_u64.o bn_mp_init_ul.o bn_mp_init_ull.o bn_mp_invmod.o bn_mp_is_square.o \
+bn_mp_iseven.o bn_mp_isodd.o bn_mp_kronecker.o bn_mp_lcm.o bn_mp_lshd.o bn_mp_mod.o bn_mp_mod_2d.o \
+bn_mp_mod_d.o bn_mp_montgomery_calc_normalization.o bn_mp_montgomery_reduce.o bn_mp_montgomery_setup.o \
+bn_mp_mul.o bn_mp_mul_2.o bn_mp_mul_2d.o bn_mp_mul_d.o bn_mp_mulmod.o bn_mp_n_root.o bn_mp_neg.o bn_mp_or.o \
bn_mp_prime_fermat.o bn_mp_prime_frobenius_underwood.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_rand.o bn_mp_prime_strong_lucas_selfridge.o bn_mp_radix_size.o bn_mp_radix_smap.o \
bn_mp_rand.o bn_mp_read_radix.o bn_mp_read_signed_bin.o bn_mp_read_unsigned_bin.o bn_mp_reduce.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_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_double.o bn_mp_set_i32.o bn_mp_set_i64.o bn_mp_set_u32.o bn_mp_set_u64.o bn_mp_shrink.o \
-bn_mp_signed_bin_size.o bn_mp_signed_rsh.o bn_mp_sqr.o bn_mp_sqrmod.o bn_mp_sqrt.o bn_mp_sqrtmod_prime.o \
-bn_mp_sub.o bn_mp_sub_d.o bn_mp_submod.o bn_mp_to_signed_bin.o bn_mp_to_signed_bin_n.o \
-bn_mp_to_unsigned_bin.o bn_mp_to_unsigned_bin_n.o bn_mp_toradix.o bn_mp_toradix_n.o \
-bn_mp_unsigned_bin_size.o bn_mp_xor.o bn_mp_zero.o bn_prime_tab.o bn_s_mp_add.o bn_s_mp_balance_mul.o \
-bn_s_mp_exptmod.o bn_s_mp_exptmod_fast.o bn_s_mp_get_bit.o bn_s_mp_invmod_fast.o bn_s_mp_invmod_slow.o \
-bn_s_mp_karatsuba_mul.o bn_s_mp_karatsuba_sqr.o bn_s_mp_montgomery_reduce_fast.o bn_s_mp_mul_digs.o \
-bn_s_mp_mul_digs_fast.o bn_s_mp_mul_high_digs.o bn_s_mp_mul_high_digs_fast.o \
-bn_s_mp_prime_is_divisible.o bn_s_mp_rand_jenkins.o bn_s_mp_rand_platform.o bn_s_mp_reverse.o \
-bn_s_mp_sqr.o bn_s_mp_sqr_fast.o bn_s_mp_sub.o bn_s_mp_toom_mul.o bn_s_mp_toom_sqr.o
+bn_mp_set_double.o bn_mp_set_i32.o bn_mp_set_i64.o bn_mp_set_l.o bn_mp_set_ll.o bn_mp_set_u32.o \
+bn_mp_set_u64.o bn_mp_set_ul.o bn_mp_set_ull.o bn_mp_shrink.o bn_mp_signed_bin_size.o bn_mp_signed_rsh.o \
+bn_mp_sqr.o bn_mp_sqrmod.o bn_mp_sqrt.o bn_mp_sqrtmod_prime.o bn_mp_sub.o bn_mp_sub_d.o bn_mp_submod.o \
+bn_mp_to_signed_bin.o bn_mp_to_signed_bin_n.o bn_mp_to_unsigned_bin.o bn_mp_to_unsigned_bin_n.o \
+bn_mp_toradix.o bn_mp_toradix_n.o bn_mp_unsigned_bin_size.o bn_mp_xor.o bn_mp_zero.o bn_prime_tab.o \
+bn_s_mp_add.o bn_s_mp_balance_mul.o bn_s_mp_exptmod.o bn_s_mp_exptmod_fast.o bn_s_mp_get_bit.o \
+bn_s_mp_invmod_fast.o bn_s_mp_invmod_slow.o bn_s_mp_karatsuba_mul.o bn_s_mp_karatsuba_sqr.o \
+bn_s_mp_montgomery_reduce_fast.o bn_s_mp_mul_digs.o bn_s_mp_mul_digs_fast.o bn_s_mp_mul_high_digs.o \
+bn_s_mp_mul_high_digs_fast.o bn_s_mp_prime_is_divisible.o bn_s_mp_rand_jenkins.o \
+bn_s_mp_rand_platform.o bn_s_mp_reverse.o bn_s_mp_sqr.o bn_s_mp_sqr_fast.o bn_s_mp_sub.o \
+bn_s_mp_toom_mul.o bn_s_mp_toom_sqr.o
HEADERS_PUB=tommath.h
HEADERS=tommath_private.h tommath_class.h tommath_superclass.h $(HEADERS_PUB)
diff --git a/libtommath/makefile.msvc b/libtommath/makefile.msvc
index c7dabcf..f5ab1ee 100644
--- a/libtommath/makefile.msvc
+++ b/libtommath/makefile.msvc
@@ -26,29 +26,31 @@ bn_mp_and.obj bn_mp_clamp.obj bn_mp_clear.obj bn_mp_clear_multi.obj bn_mp_cmp.ob
bn_mp_cnt_lsb.obj bn_mp_complement.obj bn_mp_copy.obj bn_mp_count_bits.obj bn_mp_decr.obj bn_mp_div.obj bn_mp_div_2.obj \
bn_mp_div_2d.obj bn_mp_div_3.obj bn_mp_div_d.obj bn_mp_dr_is_modulus.obj bn_mp_dr_reduce.obj bn_mp_dr_setup.obj \
bn_mp_error_to_string.obj bn_mp_exch.obj bn_mp_export.obj bn_mp_expt_d.obj bn_mp_exptmod.obj bn_mp_exteuclid.obj \
-bn_mp_fread.obj bn_mp_fwrite.obj bn_mp_gcd.obj bn_mp_get_double.obj bn_mp_get_i32.obj bn_mp_get_i64.obj \
-bn_mp_get_mag32.obj bn_mp_get_mag64.obj bn_mp_grow.obj bn_mp_ilogb.obj bn_mp_import.obj bn_mp_incr.obj bn_mp_init.obj \
-bn_mp_init_copy.obj bn_mp_init_i32.obj bn_mp_init_i64.obj bn_mp_init_multi.obj bn_mp_init_set.obj bn_mp_init_size.obj \
-bn_mp_init_u32.obj bn_mp_init_u64.obj bn_mp_invmod.obj bn_mp_is_square.obj bn_mp_iseven.obj bn_mp_isodd.obj \
-bn_mp_kronecker.obj bn_mp_lcm.obj bn_mp_lshd.obj bn_mp_mod.obj bn_mp_mod_2d.obj bn_mp_mod_d.obj \
-bn_mp_montgomery_calc_normalization.obj bn_mp_montgomery_reduce.obj bn_mp_montgomery_setup.obj bn_mp_mul.obj \
-bn_mp_mul_2.obj bn_mp_mul_2d.obj bn_mp_mul_d.obj bn_mp_mulmod.obj bn_mp_n_root.obj bn_mp_neg.obj bn_mp_or.obj \
+bn_mp_fread.obj bn_mp_fwrite.obj bn_mp_gcd.obj bn_mp_get_double.obj bn_mp_get_i32.obj bn_mp_get_i64.obj bn_mp_get_l.obj \
+bn_mp_get_ll.obj bn_mp_get_mag_u32.obj bn_mp_get_mag_u64.obj bn_mp_get_mag_ul.obj bn_mp_get_mag_ull.obj \
+bn_mp_grow.obj bn_mp_ilogb.obj bn_mp_import.obj bn_mp_incr.obj bn_mp_init.obj bn_mp_init_copy.obj bn_mp_init_i32.obj \
+bn_mp_init_i64.obj bn_mp_init_l.obj bn_mp_init_ll.obj bn_mp_init_multi.obj bn_mp_init_set.obj bn_mp_init_size.obj \
+bn_mp_init_u32.obj bn_mp_init_u64.obj bn_mp_init_ul.obj bn_mp_init_ull.obj bn_mp_invmod.obj bn_mp_is_square.obj \
+bn_mp_iseven.obj bn_mp_isodd.obj bn_mp_kronecker.obj bn_mp_lcm.obj bn_mp_lshd.obj bn_mp_mod.obj bn_mp_mod_2d.obj \
+bn_mp_mod_d.obj bn_mp_montgomery_calc_normalization.obj bn_mp_montgomery_reduce.obj bn_mp_montgomery_setup.obj \
+bn_mp_mul.obj bn_mp_mul_2.obj bn_mp_mul_2d.obj bn_mp_mul_d.obj bn_mp_mulmod.obj bn_mp_n_root.obj bn_mp_neg.obj bn_mp_or.obj \
bn_mp_prime_fermat.obj bn_mp_prime_frobenius_underwood.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_rand.obj bn_mp_prime_strong_lucas_selfridge.obj bn_mp_radix_size.obj bn_mp_radix_smap.obj \
bn_mp_rand.obj bn_mp_read_radix.obj bn_mp_read_signed_bin.obj bn_mp_read_unsigned_bin.obj bn_mp_reduce.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_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_double.obj bn_mp_set_i32.obj bn_mp_set_i64.obj bn_mp_set_u32.obj bn_mp_set_u64.obj bn_mp_shrink.obj \
-bn_mp_signed_bin_size.obj bn_mp_signed_rsh.obj bn_mp_sqr.obj bn_mp_sqrmod.obj bn_mp_sqrt.obj bn_mp_sqrtmod_prime.obj \
-bn_mp_sub.obj bn_mp_sub_d.obj bn_mp_submod.obj bn_mp_to_signed_bin.obj bn_mp_to_signed_bin_n.obj \
-bn_mp_to_unsigned_bin.obj bn_mp_to_unsigned_bin_n.obj bn_mp_toradix.obj bn_mp_toradix_n.obj \
-bn_mp_unsigned_bin_size.obj bn_mp_xor.obj bn_mp_zero.obj bn_prime_tab.obj bn_s_mp_add.obj bn_s_mp_balance_mul.obj \
-bn_s_mp_exptmod.obj bn_s_mp_exptmod_fast.obj bn_s_mp_get_bit.obj bn_s_mp_invmod_fast.obj bn_s_mp_invmod_slow.obj \
-bn_s_mp_karatsuba_mul.obj bn_s_mp_karatsuba_sqr.obj bn_s_mp_montgomery_reduce_fast.obj bn_s_mp_mul_digs.obj \
-bn_s_mp_mul_digs_fast.obj bn_s_mp_mul_high_digs.obj bn_s_mp_mul_high_digs_fast.obj \
-bn_s_mp_prime_is_divisible.obj bn_s_mp_rand_jenkins.obj bn_s_mp_rand_platform.obj bn_s_mp_reverse.obj \
-bn_s_mp_sqr.obj bn_s_mp_sqr_fast.obj bn_s_mp_sub.obj bn_s_mp_toom_mul.obj bn_s_mp_toom_sqr.obj
+bn_mp_set_double.obj bn_mp_set_i32.obj bn_mp_set_i64.obj bn_mp_set_l.obj bn_mp_set_ll.obj bn_mp_set_u32.obj \
+bn_mp_set_u64.obj bn_mp_set_ul.obj bn_mp_set_ull.obj bn_mp_shrink.obj bn_mp_signed_bin_size.obj bn_mp_signed_rsh.obj \
+bn_mp_sqr.obj bn_mp_sqrmod.obj bn_mp_sqrt.obj bn_mp_sqrtmod_prime.obj bn_mp_sub.obj bn_mp_sub_d.obj bn_mp_submod.obj \
+bn_mp_to_signed_bin.obj bn_mp_to_signed_bin_n.obj bn_mp_to_unsigned_bin.obj bn_mp_to_unsigned_bin_n.obj \
+bn_mp_toradix.obj bn_mp_toradix_n.obj bn_mp_unsigned_bin_size.obj bn_mp_xor.obj bn_mp_zero.obj bn_prime_tab.obj \
+bn_s_mp_add.obj bn_s_mp_balance_mul.obj bn_s_mp_exptmod.obj bn_s_mp_exptmod_fast.obj bn_s_mp_get_bit.obj \
+bn_s_mp_invmod_fast.obj bn_s_mp_invmod_slow.obj bn_s_mp_karatsuba_mul.obj bn_s_mp_karatsuba_sqr.obj \
+bn_s_mp_montgomery_reduce_fast.obj bn_s_mp_mul_digs.obj bn_s_mp_mul_digs_fast.obj bn_s_mp_mul_high_digs.obj \
+bn_s_mp_mul_high_digs_fast.obj bn_s_mp_prime_is_divisible.obj bn_s_mp_rand_jenkins.obj \
+bn_s_mp_rand_platform.obj bn_s_mp_reverse.obj bn_s_mp_sqr.obj bn_s_mp_sqr_fast.obj bn_s_mp_sub.obj \
+bn_s_mp_toom_mul.obj bn_s_mp_toom_sqr.obj
HEADERS_PUB=tommath.h
HEADERS=tommath_private.h tommath_class.h tommath_superclass.h $(HEADERS_PUB)
diff --git a/libtommath/makefile.shared b/libtommath/makefile.shared
index 48df13f..33f4007 100644
--- a/libtommath/makefile.shared
+++ b/libtommath/makefile.shared
@@ -28,29 +28,31 @@ bn_mp_and.o bn_mp_clamp.o bn_mp_clear.o bn_mp_clear_multi.o bn_mp_cmp.o bn_mp_cm
bn_mp_cnt_lsb.o bn_mp_complement.o bn_mp_copy.o bn_mp_count_bits.o bn_mp_decr.o bn_mp_div.o bn_mp_div_2.o \
bn_mp_div_2d.o bn_mp_div_3.o bn_mp_div_d.o bn_mp_dr_is_modulus.o bn_mp_dr_reduce.o bn_mp_dr_setup.o \
bn_mp_error_to_string.o bn_mp_exch.o bn_mp_export.o bn_mp_expt_d.o bn_mp_exptmod.o bn_mp_exteuclid.o \
-bn_mp_fread.o bn_mp_fwrite.o bn_mp_gcd.o bn_mp_get_double.o bn_mp_get_i32.o bn_mp_get_i64.o \
-bn_mp_get_mag32.o bn_mp_get_mag64.o bn_mp_grow.o bn_mp_ilogb.o bn_mp_import.o bn_mp_incr.o bn_mp_init.o \
-bn_mp_init_copy.o bn_mp_init_i32.o bn_mp_init_i64.o bn_mp_init_multi.o bn_mp_init_set.o bn_mp_init_size.o \
-bn_mp_init_u32.o bn_mp_init_u64.o bn_mp_invmod.o bn_mp_is_square.o bn_mp_iseven.o bn_mp_isodd.o \
-bn_mp_kronecker.o bn_mp_lcm.o bn_mp_lshd.o bn_mp_mod.o bn_mp_mod_2d.o bn_mp_mod_d.o \
-bn_mp_montgomery_calc_normalization.o bn_mp_montgomery_reduce.o bn_mp_montgomery_setup.o bn_mp_mul.o \
-bn_mp_mul_2.o bn_mp_mul_2d.o bn_mp_mul_d.o bn_mp_mulmod.o bn_mp_n_root.o bn_mp_neg.o bn_mp_or.o \
+bn_mp_fread.o bn_mp_fwrite.o bn_mp_gcd.o bn_mp_get_double.o bn_mp_get_i32.o bn_mp_get_i64.o bn_mp_get_l.o \
+bn_mp_get_ll.o bn_mp_get_mag_u32.o bn_mp_get_mag_u64.o bn_mp_get_mag_ul.o bn_mp_get_mag_ull.o \
+bn_mp_grow.o bn_mp_ilogb.o bn_mp_import.o bn_mp_incr.o bn_mp_init.o bn_mp_init_copy.o bn_mp_init_i32.o \
+bn_mp_init_i64.o bn_mp_init_l.o bn_mp_init_ll.o bn_mp_init_multi.o bn_mp_init_set.o bn_mp_init_size.o \
+bn_mp_init_u32.o bn_mp_init_u64.o bn_mp_init_ul.o bn_mp_init_ull.o bn_mp_invmod.o bn_mp_is_square.o \
+bn_mp_iseven.o bn_mp_isodd.o bn_mp_kronecker.o bn_mp_lcm.o bn_mp_lshd.o bn_mp_mod.o bn_mp_mod_2d.o \
+bn_mp_mod_d.o bn_mp_montgomery_calc_normalization.o bn_mp_montgomery_reduce.o bn_mp_montgomery_setup.o \
+bn_mp_mul.o bn_mp_mul_2.o bn_mp_mul_2d.o bn_mp_mul_d.o bn_mp_mulmod.o bn_mp_n_root.o bn_mp_neg.o bn_mp_or.o \
bn_mp_prime_fermat.o bn_mp_prime_frobenius_underwood.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_rand.o bn_mp_prime_strong_lucas_selfridge.o bn_mp_radix_size.o bn_mp_radix_smap.o \
bn_mp_rand.o bn_mp_read_radix.o bn_mp_read_signed_bin.o bn_mp_read_unsigned_bin.o bn_mp_reduce.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_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_double.o bn_mp_set_i32.o bn_mp_set_i64.o bn_mp_set_u32.o bn_mp_set_u64.o bn_mp_shrink.o \
-bn_mp_signed_bin_size.o bn_mp_signed_rsh.o bn_mp_sqr.o bn_mp_sqrmod.o bn_mp_sqrt.o bn_mp_sqrtmod_prime.o \
-bn_mp_sub.o bn_mp_sub_d.o bn_mp_submod.o bn_mp_to_signed_bin.o bn_mp_to_signed_bin_n.o \
-bn_mp_to_unsigned_bin.o bn_mp_to_unsigned_bin_n.o bn_mp_toradix.o bn_mp_toradix_n.o \
-bn_mp_unsigned_bin_size.o bn_mp_xor.o bn_mp_zero.o bn_prime_tab.o bn_s_mp_add.o bn_s_mp_balance_mul.o \
-bn_s_mp_exptmod.o bn_s_mp_exptmod_fast.o bn_s_mp_get_bit.o bn_s_mp_invmod_fast.o bn_s_mp_invmod_slow.o \
-bn_s_mp_karatsuba_mul.o bn_s_mp_karatsuba_sqr.o bn_s_mp_montgomery_reduce_fast.o bn_s_mp_mul_digs.o \
-bn_s_mp_mul_digs_fast.o bn_s_mp_mul_high_digs.o bn_s_mp_mul_high_digs_fast.o \
-bn_s_mp_prime_is_divisible.o bn_s_mp_rand_jenkins.o bn_s_mp_rand_platform.o bn_s_mp_reverse.o \
-bn_s_mp_sqr.o bn_s_mp_sqr_fast.o bn_s_mp_sub.o bn_s_mp_toom_mul.o bn_s_mp_toom_sqr.o
+bn_mp_set_double.o bn_mp_set_i32.o bn_mp_set_i64.o bn_mp_set_l.o bn_mp_set_ll.o bn_mp_set_u32.o \
+bn_mp_set_u64.o bn_mp_set_ul.o bn_mp_set_ull.o bn_mp_shrink.o bn_mp_signed_bin_size.o bn_mp_signed_rsh.o \
+bn_mp_sqr.o bn_mp_sqrmod.o bn_mp_sqrt.o bn_mp_sqrtmod_prime.o bn_mp_sub.o bn_mp_sub_d.o bn_mp_submod.o \
+bn_mp_to_signed_bin.o bn_mp_to_signed_bin_n.o bn_mp_to_unsigned_bin.o bn_mp_to_unsigned_bin_n.o \
+bn_mp_toradix.o bn_mp_toradix_n.o bn_mp_unsigned_bin_size.o bn_mp_xor.o bn_mp_zero.o bn_prime_tab.o \
+bn_s_mp_add.o bn_s_mp_balance_mul.o bn_s_mp_exptmod.o bn_s_mp_exptmod_fast.o bn_s_mp_get_bit.o \
+bn_s_mp_invmod_fast.o bn_s_mp_invmod_slow.o bn_s_mp_karatsuba_mul.o bn_s_mp_karatsuba_sqr.o \
+bn_s_mp_montgomery_reduce_fast.o bn_s_mp_mul_digs.o bn_s_mp_mul_digs_fast.o bn_s_mp_mul_high_digs.o \
+bn_s_mp_mul_high_digs_fast.o bn_s_mp_prime_is_divisible.o bn_s_mp_rand_jenkins.o \
+bn_s_mp_rand_platform.o bn_s_mp_reverse.o bn_s_mp_sqr.o bn_s_mp_sqr_fast.o bn_s_mp_sub.o \
+bn_s_mp_toom_mul.o bn_s_mp_toom_sqr.o
#END_INS
diff --git a/libtommath/makefile.unix b/libtommath/makefile.unix
index 210802d..fba73b6 100644
--- a/libtommath/makefile.unix
+++ b/libtommath/makefile.unix
@@ -35,29 +35,31 @@ bn_mp_and.o bn_mp_clamp.o bn_mp_clear.o bn_mp_clear_multi.o bn_mp_cmp.o bn_mp_cm
bn_mp_cnt_lsb.o bn_mp_complement.o bn_mp_copy.o bn_mp_count_bits.o bn_mp_decr.o bn_mp_div.o bn_mp_div_2.o \
bn_mp_div_2d.o bn_mp_div_3.o bn_mp_div_d.o bn_mp_dr_is_modulus.o bn_mp_dr_reduce.o bn_mp_dr_setup.o \
bn_mp_error_to_string.o bn_mp_exch.o bn_mp_export.o bn_mp_expt_d.o bn_mp_exptmod.o bn_mp_exteuclid.o \
-bn_mp_fread.o bn_mp_fwrite.o bn_mp_gcd.o bn_mp_get_double.o bn_mp_get_i32.o bn_mp_get_i64.o \
-bn_mp_get_mag32.o bn_mp_get_mag64.o bn_mp_grow.o bn_mp_ilogb.o bn_mp_import.o bn_mp_incr.o bn_mp_init.o \
-bn_mp_init_copy.o bn_mp_init_i32.o bn_mp_init_i64.o bn_mp_init_multi.o bn_mp_init_set.o bn_mp_init_size.o \
-bn_mp_init_u32.o bn_mp_init_u64.o bn_mp_invmod.o bn_mp_is_square.o bn_mp_iseven.o bn_mp_isodd.o \
-bn_mp_kronecker.o bn_mp_lcm.o bn_mp_lshd.o bn_mp_mod.o bn_mp_mod_2d.o bn_mp_mod_d.o \
-bn_mp_montgomery_calc_normalization.o bn_mp_montgomery_reduce.o bn_mp_montgomery_setup.o bn_mp_mul.o \
-bn_mp_mul_2.o bn_mp_mul_2d.o bn_mp_mul_d.o bn_mp_mulmod.o bn_mp_n_root.o bn_mp_neg.o bn_mp_or.o \
+bn_mp_fread.o bn_mp_fwrite.o bn_mp_gcd.o bn_mp_get_double.o bn_mp_get_i32.o bn_mp_get_i64.o bn_mp_get_l.o \
+bn_mp_get_ll.o bn_mp_get_mag_u32.o bn_mp_get_mag_u64.o bn_mp_get_mag_ul.o bn_mp_get_mag_ull.o \
+bn_mp_grow.o bn_mp_ilogb.o bn_mp_import.o bn_mp_incr.o bn_mp_init.o bn_mp_init_copy.o bn_mp_init_i32.o \
+bn_mp_init_i64.o bn_mp_init_l.o bn_mp_init_ll.o bn_mp_init_multi.o bn_mp_init_set.o bn_mp_init_size.o \
+bn_mp_init_u32.o bn_mp_init_u64.o bn_mp_init_ul.o bn_mp_init_ull.o bn_mp_invmod.o bn_mp_is_square.o \
+bn_mp_iseven.o bn_mp_isodd.o bn_mp_kronecker.o bn_mp_lcm.o bn_mp_lshd.o bn_mp_mod.o bn_mp_mod_2d.o \
+bn_mp_mod_d.o bn_mp_montgomery_calc_normalization.o bn_mp_montgomery_reduce.o bn_mp_montgomery_setup.o \
+bn_mp_mul.o bn_mp_mul_2.o bn_mp_mul_2d.o bn_mp_mul_d.o bn_mp_mulmod.o bn_mp_n_root.o bn_mp_neg.o bn_mp_or.o \
bn_mp_prime_fermat.o bn_mp_prime_frobenius_underwood.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_rand.o bn_mp_prime_strong_lucas_selfridge.o bn_mp_radix_size.o bn_mp_radix_smap.o \
bn_mp_rand.o bn_mp_read_radix.o bn_mp_read_signed_bin.o bn_mp_read_unsigned_bin.o bn_mp_reduce.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_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_double.o bn_mp_set_i32.o bn_mp_set_i64.o bn_mp_set_u32.o bn_mp_set_u64.o bn_mp_shrink.o \
-bn_mp_signed_bin_size.o bn_mp_signed_rsh.o bn_mp_sqr.o bn_mp_sqrmod.o bn_mp_sqrt.o bn_mp_sqrtmod_prime.o \
-bn_mp_sub.o bn_mp_sub_d.o bn_mp_submod.o bn_mp_to_signed_bin.o bn_mp_to_signed_bin_n.o \
-bn_mp_to_unsigned_bin.o bn_mp_to_unsigned_bin_n.o bn_mp_toradix.o bn_mp_toradix_n.o \
-bn_mp_unsigned_bin_size.o bn_mp_xor.o bn_mp_zero.o bn_prime_tab.o bn_s_mp_add.o bn_s_mp_balance_mul.o \
-bn_s_mp_exptmod.o bn_s_mp_exptmod_fast.o bn_s_mp_get_bit.o bn_s_mp_invmod_fast.o bn_s_mp_invmod_slow.o \
-bn_s_mp_karatsuba_mul.o bn_s_mp_karatsuba_sqr.o bn_s_mp_montgomery_reduce_fast.o bn_s_mp_mul_digs.o \
-bn_s_mp_mul_digs_fast.o bn_s_mp_mul_high_digs.o bn_s_mp_mul_high_digs_fast.o \
-bn_s_mp_prime_is_divisible.o bn_s_mp_rand_jenkins.o bn_s_mp_rand_platform.o bn_s_mp_reverse.o \
-bn_s_mp_sqr.o bn_s_mp_sqr_fast.o bn_s_mp_sub.o bn_s_mp_toom_mul.o bn_s_mp_toom_sqr.o
+bn_mp_set_double.o bn_mp_set_i32.o bn_mp_set_i64.o bn_mp_set_l.o bn_mp_set_ll.o bn_mp_set_u32.o \
+bn_mp_set_u64.o bn_mp_set_ul.o bn_mp_set_ull.o bn_mp_shrink.o bn_mp_signed_bin_size.o bn_mp_signed_rsh.o \
+bn_mp_sqr.o bn_mp_sqrmod.o bn_mp_sqrt.o bn_mp_sqrtmod_prime.o bn_mp_sub.o bn_mp_sub_d.o bn_mp_submod.o \
+bn_mp_to_signed_bin.o bn_mp_to_signed_bin_n.o bn_mp_to_unsigned_bin.o bn_mp_to_unsigned_bin_n.o \
+bn_mp_toradix.o bn_mp_toradix_n.o bn_mp_unsigned_bin_size.o bn_mp_xor.o bn_mp_zero.o bn_prime_tab.o \
+bn_s_mp_add.o bn_s_mp_balance_mul.o bn_s_mp_exptmod.o bn_s_mp_exptmod_fast.o bn_s_mp_get_bit.o \
+bn_s_mp_invmod_fast.o bn_s_mp_invmod_slow.o bn_s_mp_karatsuba_mul.o bn_s_mp_karatsuba_sqr.o \
+bn_s_mp_montgomery_reduce_fast.o bn_s_mp_mul_digs.o bn_s_mp_mul_digs_fast.o bn_s_mp_mul_high_digs.o \
+bn_s_mp_mul_high_digs_fast.o bn_s_mp_prime_is_divisible.o bn_s_mp_rand_jenkins.o \
+bn_s_mp_rand_platform.o bn_s_mp_reverse.o bn_s_mp_sqr.o bn_s_mp_sqr_fast.o bn_s_mp_sub.o \
+bn_s_mp_toom_mul.o bn_s_mp_toom_sqr.o
HEADERS_PUB=tommath.h
HEADERS=tommath_private.h tommath_class.h tommath_superclass.h $(HEADERS_PUB)
diff --git a/libtommath/tommath.def b/libtommath/tommath.def
index 7f061ed..66fbd7e 100644
--- a/libtommath/tommath.def
+++ b/libtommath/tommath.def
@@ -44,10 +44,14 @@ EXPORTS
mp_get_i32
mp_get_i64
mp_get_int
+ mp_get_l
+ mp_get_ll
mp_get_long
mp_get_long_long
- mp_get_mag32
- mp_get_mag64
+ mp_get_mag_u32
+ mp_get_mag_u64
+ mp_get_mag_ul
+ mp_get_mag_ull
mp_grow
mp_ilogb
mp_import
@@ -56,12 +60,16 @@ EXPORTS
mp_init_copy
mp_init_i32
mp_init_i64
+ mp_init_l
+ mp_init_ll
mp_init_multi
mp_init_set
mp_init_set_int
mp_init_size
mp_init_u32
mp_init_u64
+ mp_init_ul
+ mp_init_ull
mp_invmod
mp_is_square
mp_iseven
@@ -110,10 +118,14 @@ EXPORTS
mp_set_i32
mp_set_i64
mp_set_int
+ mp_set_l
+ mp_set_ll
mp_set_long
mp_set_long_long
mp_set_u32
mp_set_u64
+ mp_set_ul
+ mp_set_ull
mp_shrink
mp_signed_bin_size
mp_signed_rsh
diff --git a/libtommath/tommath.h b/libtommath/tommath.h
index 26f5416..982470f 100644
--- a/libtommath/tommath.h
+++ b/libtommath/tommath.h
@@ -274,14 +274,14 @@ double mp_get_double(const mp_int *a) MP_WUR;
mp_err mp_set_double(mp_int *a, double b) MP_WUR;
/* get integer, set integer and init with integer () */
-int mp_get_i32(const mp_int *a) MP_WUR;
-void mp_set_i32(mp_int *a, int b);
-mp_err mp_init_i32(mp_int *a, int b) MP_WUR;
+long mp_get_i32(const mp_int *a) MP_WUR;
+void mp_set_i32(mp_int *a, long b);
+mp_err mp_init_i32(mp_int *a, long b) MP_WUR;
/* get integer, set integer and init with integer, behaves like two complement for negative numbers (unsigned int) */
-#define mp_get_u32(a) ((unsigned int)mp_get_i32(a))
-void mp_set_u32(mp_int *a, unsigned int b);
-mp_err mp_init_u32(mp_int *a, unsigned int b) MP_WUR;
+#define mp_get_u32(a) ((unsigned long)mp_get_i32(a))
+void mp_set_u32(mp_int *a, unsigned long b);
+mp_err mp_init_u32(mp_int *a, unsigned long b) MP_WUR;
/* get integer, set integer and init with integer (long long) */
long long mp_get_i64(const mp_int *a) MP_WUR;
@@ -294,30 +294,43 @@ void mp_set_u64(mp_int *a, unsigned long long b);
mp_err mp_init_u64(mp_int *a, unsigned long long b) MP_WUR;
/* get magnitude */
-unsigned int mp_get_mag32(const mp_int *a) MP_WUR;
-unsigned long long mp_get_mag64(const mp_int *a) MP_WUR;
+unsigned long mp_get_mag_u32(const mp_int *a) MP_WUR;
+unsigned long long mp_get_mag_u64(const mp_int *a) MP_WUR;
+unsigned long mp_get_mag_ul(const mp_int *a) MP_WUR;
+unsigned long long mp_get_mag_ull(const mp_int *a) MP_WUR;
/* get integer, set integer (long) */
-#define mp_get_l(a) (sizeof (long) == 8 ? (long)mp_get_i64(a) : (long)mp_get_i32(a))
-#define mp_set_l(a, b) (sizeof (long) == 8 ? mp_set_i64((a), (b)) : mp_set_i32((a), (int)(b)))
+long mp_get_l(const mp_int *a) MP_WUR;
+void mp_set_l(mp_int *a, long b);
+mp_err mp_init_l(mp_int *a, long b) MP_WUR;
/* get integer, set integer (unsigned long) */
-#define mp_get_ul(a) (sizeof (long) == 8 ? (unsigned long)mp_get_u64(a) : (unsigned long)mp_get_u32(a))
-#define mp_set_ul(a, b) (sizeof (long) == 8 ? mp_set_u64((a), (b)) : mp_set_u32((a), (unsigned int)(b)))
-#define mp_get_magl(a) (sizeof (long) == 8 ? (unsigned long)mp_get_mag64(a) : (unsigned long)mp_get_mag32(a))
+#define mp_get_ul(a) ((unsigned long)mp_get_l(a))
+void mp_set_ul(mp_int *a, unsigned long b);
+mp_err mp_init_ul(mp_int *a, unsigned long b) MP_WUR;
+
+/* get integer, set integer (long long) */
+long long mp_get_ll(const mp_int *a) MP_WUR;
+void mp_set_ll(mp_int *a, long long b);
+mp_err mp_init_ll(mp_int *a, long long b) MP_WUR;
+
+/* get integer, set integer (unsigned long long) */
+#define mp_get_ull(a) ((unsigned long long)mp_get_ll(a))
+void mp_set_ull(mp_int *a, unsigned long long b);
+mp_err mp_init_ull(mp_int *a, unsigned long long b) MP_WUR;
/* set to single unsigned digit, up to MP_DIGIT_MAX */
void mp_set(mp_int *a, mp_digit b);
mp_err mp_init_set(mp_int *a, mp_digit b) MP_WUR;
/* get integer, set integer and init with integer (deprecated) */
-MP_DEPRECATED(mp_get_mag32/mp_get_u32) unsigned long mp_get_int(const mp_int *a) MP_WUR;
-MP_DEPRECATED(mp_get_magl/mp_get_ul) unsigned long mp_get_long(const mp_int *a) MP_WUR;
-MP_DEPRECATED(mp_get_mag64/mp_get_u64) unsigned long long mp_get_long_long(const mp_int *a) MP_WUR;
-MP_DEPRECATED(mp_set_u32) mp_err mp_set_int(mp_int *a, unsigned long b);
+MP_DEPRECATED(mp_get_mag_u32/mp_get_u32) unsigned long mp_get_int(const mp_int *a) MP_WUR;
+MP_DEPRECATED(mp_get_mag_ul/mp_get_ul) unsigned long mp_get_long(const mp_int *a) MP_WUR;
+MP_DEPRECATED(mp_get_mag_ull/mp_get_ull) unsigned long long mp_get_long_long(const mp_int *a) MP_WUR;
+MP_DEPRECATED(mp_set_ul) mp_err mp_set_int(mp_int *a, unsigned long b);
MP_DEPRECATED(mp_set_ul) mp_err mp_set_long(mp_int *a, unsigned long b);
-MP_DEPRECATED(mp_set_u64) mp_err mp_set_long_long(mp_int *a, unsigned long long b);
-MP_DEPRECATED(mp_init_u32) mp_err mp_init_set_int(mp_int *a, unsigned long b) MP_WUR;
+MP_DEPRECATED(mp_set_ull) mp_err mp_set_long_long(mp_int *a, unsigned long long b);
+MP_DEPRECATED(mp_init_ul) mp_err mp_init_set_int(mp_int *a, unsigned long b) MP_WUR;
/* copy, b = a */
mp_err mp_copy(const mp_int *a, mp_int *b) MP_WUR;
diff --git a/libtommath/tommath_class.h b/libtommath/tommath_class.h
index dfc0be1..715fc31 100644
--- a/libtommath/tommath_class.h
+++ b/libtommath/tommath_class.h
@@ -50,8 +50,12 @@
# define BN_MP_GET_DOUBLE_C
# define BN_MP_GET_I32_C
# define BN_MP_GET_I64_C
-# define BN_MP_GET_MAG32_C
-# define BN_MP_GET_MAG64_C
+# define BN_MP_GET_L_C
+# define BN_MP_GET_LL_C
+# define BN_MP_GET_MAG_U32_C
+# define BN_MP_GET_MAG_U64_C
+# define BN_MP_GET_MAG_UL_C
+# define BN_MP_GET_MAG_ULL_C
# define BN_MP_GROW_C
# define BN_MP_ILOGB_C
# define BN_MP_IMPORT_C
@@ -60,11 +64,15 @@
# define BN_MP_INIT_COPY_C
# define BN_MP_INIT_I32_C
# define BN_MP_INIT_I64_C
+# define BN_MP_INIT_L_C
+# define BN_MP_INIT_LL_C
# define BN_MP_INIT_MULTI_C
# define BN_MP_INIT_SET_C
# define BN_MP_INIT_SIZE_C
# define BN_MP_INIT_U32_C
# define BN_MP_INIT_U64_C
+# define BN_MP_INIT_UL_C
+# define BN_MP_INIT_ULL_C
# define BN_MP_INVMOD_C
# define BN_MP_IS_SQUARE_C
# define BN_MP_ISEVEN_C
@@ -113,8 +121,12 @@
# define BN_MP_SET_DOUBLE_C
# define BN_MP_SET_I32_C
# define BN_MP_SET_I64_C
+# define BN_MP_SET_L_C
+# define BN_MP_SET_LL_C
# define BN_MP_SET_U32_C
# define BN_MP_SET_U64_C
+# define BN_MP_SET_UL_C
+# define BN_MP_SET_ULL_C
# define BN_MP_SHRINK_C
# define BN_MP_SIGNED_BIN_SIZE_C
# define BN_MP_SIGNED_RSH_C
@@ -179,8 +191,9 @@
# define BN_MP_GET_INT_C
# define BN_MP_GET_LONG_C
# define BN_MP_GET_LONG_LONG_C
-# define BN_MP_GET_MAG32_C
-# define BN_MP_GET_MAG64_C
+# define BN_MP_GET_MAG_U32_C
+# define BN_MP_GET_MAG_ULL_C
+# define BN_MP_GET_MAG_UL_C
# define BN_MP_INIT_SET_INT_C
# define BN_MP_INIT_U32_C
# define BN_MP_INVMOD_SLOW_C
@@ -438,17 +451,31 @@
#endif
#if defined(BN_MP_GET_I32_C)
-# define BN_MP_GET_MAG32_C
+# define BN_MP_GET_MAG_U32_C
#endif
#if defined(BN_MP_GET_I64_C)
-# define BN_MP_GET_MAG64_C
+# define BN_MP_GET_MAG_U64_C
#endif
-#if defined(BN_MP_GET_MAG32_C)
+#if defined(BN_MP_GET_L_C)
+# define BN_MP_GET_MAG_UL_C
#endif
-#if defined(BN_MP_GET_MAG64_C)
+#if defined(BN_MP_GET_LL_C)
+# define BN_MP_GET_MAG_ULL_C
+#endif
+
+#if defined(BN_MP_GET_MAG_U32_C)
+#endif
+
+#if defined(BN_MP_GET_MAG_U64_C)
+#endif
+
+#if defined(BN_MP_GET_MAG_UL_C)
+#endif
+
+#if defined(BN_MP_GET_MAG_ULL_C)
#endif
#if defined(BN_MP_GROW_C)
@@ -501,6 +528,16 @@
# define BN_MP_SET_I64_C
#endif
+#if defined(BN_MP_INIT_L_C)
+# define BN_MP_INIT_C
+# define BN_MP_SET_L_C
+#endif
+
+#if defined(BN_MP_INIT_LL_C)
+# define BN_MP_INIT_C
+# define BN_MP_SET_LL_C
+#endif
+
#if defined(BN_MP_INIT_MULTI_C)
# define BN_MP_CLEAR_C
# define BN_MP_INIT_C
@@ -524,6 +561,16 @@
# define BN_MP_SET_U64_C
#endif
+#if defined(BN_MP_INIT_UL_C)
+# define BN_MP_INIT_C
+# define BN_MP_SET_UL_C
+#endif
+
+#if defined(BN_MP_INIT_ULL_C)
+# define BN_MP_INIT_C
+# define BN_MP_SET_ULL_C
+#endif
+
#if defined(BN_MP_INVMOD_C)
# define BN_MP_CMP_D_C
# define BN_S_MP_INVMOD_FAST_C
@@ -903,12 +950,26 @@
# define BN_MP_SET_U64_C
#endif
+#if defined(BN_MP_SET_L_C)
+# define BN_MP_SET_UL_C
+#endif
+
+#if defined(BN_MP_SET_LL_C)
+# define BN_MP_SET_ULL_C
+#endif
+
#if defined(BN_MP_SET_U32_C)
#endif
#if defined(BN_MP_SET_U64_C)
#endif
+#if defined(BN_MP_SET_UL_C)
+#endif
+
+#if defined(BN_MP_SET_ULL_C)
+#endif
+
#if defined(BN_MP_SHRINK_C)
#endif
diff --git a/libtommath/tommath_private.h b/libtommath/tommath_private.h
index 30e648f..5e0f1ab 100644
--- a/libtommath/tommath_private.h
+++ b/libtommath/tommath_private.h
@@ -201,9 +201,11 @@ MP_PRIVATE mp_err s_mp_prime_random_ex(mp_int *a, int t, int size, int flags, pr
MP_PRIVATE void s_mp_reverse(unsigned char *s, int len);
MP_PRIVATE mp_err s_mp_prime_is_divisible(const mp_int *a, mp_bool *result);
+#if 0
/* TODO: jenkins prng is not thread safe as of now */
MP_PRIVATE mp_err s_mp_rand_jenkins(void *p, size_t n) MP_WUR;
MP_PRIVATE void s_mp_rand_jenkins_init(uint64_t seed);
+#endif
extern MP_PRIVATE const char *const mp_s_rmap;
extern MP_PRIVATE const unsigned char mp_s_rmap_reverse[];
@@ -264,7 +266,7 @@ MP_DEPRECATED(s_mp_reverse) void bn_reverse(unsigned char *s, int len);
return MP_OKAY; \
}
-#define MP_GET_MAG(type, name) \
+#define MP_GET_MAG(name, type) \
type name(const mp_int* a) \
{ \
unsigned i = MP_MIN((unsigned)a->used, (unsigned)((MP_SIZEOF_BITS(type) + MP_DIGIT_BIT - 1) / MP_DIGIT_BIT)); \
@@ -277,10 +279,10 @@ MP_DEPRECATED(s_mp_reverse) void bn_reverse(unsigned char *s, int len);
return res; \
}
-#define MP_GET_SIGNED(type, name, mag) \
+#define MP_GET_SIGNED(name, mag, type, utype) \
type name(const mp_int* a) \
{ \
- uint64_t res = mag(a); \
+ utype res = mag(a); \
return (a->sign == MP_NEG) ? (type)-res : (type)res; \
}