diff --git a/bn_conversion.c b/bn_conversion.c
deleted file mode 100644
index 19e55325a..000000000
--- a/bn_conversion.c
+++ /dev/null
@@ -1,103 +0,0 @@
-#include "tommath_private.h"
-
-#ifdef BN_CONVERSION_C
-/* LibTomMath, multiple-precision integer library -- Tom St Denis */
-/* SPDX-License-Identifier: Unlicense */
-
-#define MP_SET_UNSIGNED(name, w) \
- void name(mp_int * a, uint##w##_t b) \
- { \
- int i = 0; \
- while (b != 0u) { \
- a->dp[i++] = ((mp_digit)b & MP_MASK); \
- if (w <= MP_DIGIT_BIT) { break; } \
- b >>= ((w <= MP_DIGIT_BIT) ? 0 : MP_DIGIT_BIT); \
- } \
- a->used = i; \
- a->sign = MP_ZPOS; \
- MP_ZERO_DIGITS(a->dp + a->used, a->alloc - a->used); \
- }
-#define MP_SET_SIGNED(name, uname, w) \
- void name(mp_int * a, int##w##_t b) \
- { \
- uname(a, (b < 0) ? -(uint##w##_t)b : (uint##w##_t)b); \
- if (b < 0) { a->sign = MP_NEG; } \
- }
-#define MP_INIT_INT(name , set, type) \
- mp_err name(mp_int * a, type b) \
- { \
- mp_err err; \
- if ((err = mp_init(a)) != MP_OKAY) { \
- return err; \
- } \
- set(a, b); \
- return MP_OKAY; \
- }
-#define MP_GET_MAG(name, w) \
- uint##w##_t name(const mp_int* a) \
- { \
- unsigned i = MP_MIN((unsigned)a->used, (unsigned)((w + MP_DIGIT_BIT - 1) / MP_DIGIT_BIT)); \
- uint##w##_t res = 0u; \
- while (i --> 0u) { \
- res <<= ((w <= MP_DIGIT_BIT) ? 0 : MP_DIGIT_BIT); \
- res |= (uint##w##_t)a->dp[i]; \
- if (w <= MP_DIGIT_BIT) { break; } \
- } \
- return res; \
- }
-#define MP_GET_SIGNED(name, mag, w) \
- int##w##_t name(const mp_int* a) \
- { \
- uint64_t res = mag(a); \
- return (a->sign == MP_NEG) ? (int##w##_t)-res : (int##w##_t)res;\
- }
-
-#ifdef BN_MP_SET_U32_C
-MP_SET_UNSIGNED(mp_set_u32, 32)
-#endif
-
-#ifdef BN_MP_SET_U64_C
-MP_SET_UNSIGNED(mp_set_u64, 64)
-#endif
-
-#ifdef BN_MP_SET_I32_C
-MP_SET_SIGNED(mp_set_i32, mp_set_u32, 32)
-#endif
-
-#ifdef BN_MP_SET_I64_C
-MP_SET_SIGNED(mp_set_i64, mp_set_u64, 64)
-#endif
-
-#if defined(BN_MP_GET_I32_C) || defined(BN_MP_GET_U32_C)
-MP_GET_SIGNED(mp_get_i32, mp_get_mag32, 32)
-#endif
-
-#if defined(BN_MP_GET_I64_C) || defined(BN_MP_GET_U64_C)
-MP_GET_SIGNED(mp_get_i64, mp_get_mag64, 64)
-#endif
-
-#ifdef BN_MP_GET_MAG32_C
-MP_GET_MAG(mp_get_mag32, 32)
-#endif
-
-#ifdef BN_MP_GET_MAG64_C
-MP_GET_MAG(mp_get_mag64, 64)
-#endif
-
-#ifdef BN_MP_INIT_U32_C
-MP_INIT_INT(mp_init_u32, mp_set_u32, uint32_t)
-#endif
-
-#ifdef BN_MP_INIT_I32_C
-MP_INIT_INT(mp_init_i32, mp_set_i32, int32_t)
-#endif
-
-#ifdef BN_MP_INIT_U64_C
-MP_INIT_INT(mp_init_u64, mp_set_u64, uint64_t)
-#endif
-
-#ifdef BN_MP_INIT_I64_C
-MP_INIT_INT(mp_init_i64, mp_set_i64, int64_t)
-#endif
-
-#endif
diff --git a/bn_mp_get_i32.c b/bn_mp_get_i32.c
new file mode 100644
index 000000000..4227a70a6
--- /dev/null
+++ b/bn_mp_get_i32.c
@@ -0,0 +1,7 @@
+#include "tommath_private.h"
+#ifdef BN_MP_GET_I32_C
+/* LibTomMath, multiple-precision integer library -- Tom St Denis */
+/* SPDX-License-Identifier: Unlicense */
+
+MP_GET_SIGNED(int32_t, mp_get_i32, mp_get_mag32)
+#endif
diff --git a/bn_mp_get_i64.c b/bn_mp_get_i64.c
new file mode 100644
index 000000000..cdc2fee1f
--- /dev/null
+++ b/bn_mp_get_i64.c
@@ -0,0 +1,7 @@
+#include "tommath_private.h"
+#ifdef BN_MP_GET_I64_C
+/* LibTomMath, multiple-precision integer library -- Tom St Denis */
+/* SPDX-License-Identifier: Unlicense */
+
+MP_GET_SIGNED(int64_t, mp_get_i64, mp_get_mag64)
+#endif
diff --git a/bn_mp_get_mag32.c b/bn_mp_get_mag32.c
new file mode 100644
index 000000000..46e8b2916
--- /dev/null
+++ b/bn_mp_get_mag32.c
@@ -0,0 +1,7 @@
+#include "tommath_private.h"
+#ifdef BN_MP_GET_MAG32_C
+/* LibTomMath, multiple-precision integer library -- Tom St Denis */
+/* SPDX-License-Identifier: Unlicense */
+
+MP_GET_MAG(uint32_t, mp_get_mag32)
+#endif
diff --git a/bn_mp_get_mag64.c b/bn_mp_get_mag64.c
new file mode 100644
index 000000000..6ff5e5d28
--- /dev/null
+++ b/bn_mp_get_mag64.c
@@ -0,0 +1,7 @@
+#include "tommath_private.h"
+#ifdef BN_MP_GET_MAG64_C
+/* LibTomMath, multiple-precision integer library -- Tom St Denis */
+/* SPDX-License-Identifier: Unlicense */
+
+MP_GET_MAG(uint64_t, mp_get_mag64)
+#endif
diff --git a/bn_mp_init_i32.c b/bn_mp_init_i32.c
new file mode 100644
index 000000000..bc4de8d50
--- /dev/null
+++ b/bn_mp_init_i32.c
@@ -0,0 +1,7 @@
+#include "tommath_private.h"
+#ifdef BN_MP_INIT_I32_C
+/* LibTomMath, multiple-precision integer library -- Tom St Denis */
+/* SPDX-License-Identifier: Unlicense */
+
+MP_INIT_INT(mp_init_i32, mp_set_i32, int32_t)
+#endif
diff --git a/bn_mp_init_i64.c b/bn_mp_init_i64.c
new file mode 100644
index 000000000..2fa1516eb
--- /dev/null
+++ b/bn_mp_init_i64.c
@@ -0,0 +1,7 @@
+#include "tommath_private.h"
+#ifdef BN_MP_INIT_I64_C
+/* LibTomMath, multiple-precision integer library -- Tom St Denis */
+/* SPDX-License-Identifier: Unlicense */
+
+MP_INIT_INT(mp_init_i64, mp_set_i64, int64_t)
+#endif
diff --git a/bn_mp_init_u32.c b/bn_mp_init_u32.c
new file mode 100644
index 000000000..015d89b90
--- /dev/null
+++ b/bn_mp_init_u32.c
@@ -0,0 +1,7 @@
+#include "tommath_private.h"
+#ifdef BN_MP_INIT_U32_C
+/* LibTomMath, multiple-precision integer library -- Tom St Denis */
+/* SPDX-License-Identifier: Unlicense */
+
+MP_INIT_INT(mp_init_u32, mp_set_u32, uint32_t)
+#endif
diff --git a/bn_mp_init_u64.c b/bn_mp_init_u64.c
new file mode 100644
index 000000000..2b35f7ef8
--- /dev/null
+++ b/bn_mp_init_u64.c
@@ -0,0 +1,7 @@
+#include "tommath_private.h"
+#ifdef BN_MP_INIT_U64_C
+/* LibTomMath, multiple-precision integer library -- Tom St Denis */
+/* SPDX-License-Identifier: Unlicense */
+
+MP_INIT_INT(mp_init_u64, mp_set_u64, uint64_t)
+#endif
diff --git a/bn_mp_set_i32.c b/bn_mp_set_i32.c
new file mode 100644
index 000000000..df4513d37
--- /dev/null
+++ b/bn_mp_set_i32.c
@@ -0,0 +1,7 @@
+#include "tommath_private.h"
+#ifdef BN_MP_SET_I32_C
+/* 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)
+#endif
diff --git a/bn_mp_set_i64.c b/bn_mp_set_i64.c
new file mode 100644
index 000000000..395103bf5
--- /dev/null
+++ b/bn_mp_set_i64.c
@@ -0,0 +1,7 @@
+#include "tommath_private.h"
+#ifdef BN_MP_SET_I64_C
+/* LibTomMath, multiple-precision integer library -- Tom St Denis */
+/* SPDX-License-Identifier: Unlicense */
+
+MP_SET_SIGNED(mp_set_i64, mp_set_u64, int64_t, uint64_t)
+#endif
diff --git a/bn_mp_set_u32.c b/bn_mp_set_u32.c
new file mode 100644
index 000000000..18ba5e14c
--- /dev/null
+++ b/bn_mp_set_u32.c
@@ -0,0 +1,7 @@
+#include "tommath_private.h"
+#ifdef BN_MP_SET_U32_C
+/* LibTomMath, multiple-precision integer library -- Tom St Denis */
+/* SPDX-License-Identifier: Unlicense */
+
+MP_SET_UNSIGNED(mp_set_u32, uint32_t)
+#endif
diff --git a/bn_mp_set_u64.c b/bn_mp_set_u64.c
new file mode 100644
index 000000000..88fab6c54
--- /dev/null
+++ b/bn_mp_set_u64.c
@@ -0,0 +1,7 @@
+#include "tommath_private.h"
+#ifdef BN_MP_SET_U64_C
+/* LibTomMath, multiple-precision integer library -- Tom St Denis */
+/* SPDX-License-Identifier: Unlicense */
+
+MP_SET_UNSIGNED(mp_set_u64, uint64_t)
+#endif
diff --git a/demo/test.c b/demo/test.c
index 748be4b98..41e039488 100644
--- a/demo/test.c
+++ b/demo/test.c
@@ -726,7 +726,7 @@ static int test_mp_get_ul(void)
return EXIT_FAILURE;
}
- for (i = 0; i < ((int)(sizeof(unsigned long)*CHAR_BIT) - 1); ++i) {
+ for (i = 0; i < ((int)MP_SIZEOF_BITS(unsigned long) - 1); ++i) {
t = (1UL << (i+1)) - 1;
if (!t)
t = ~0UL;
@@ -759,7 +759,7 @@ static int test_mp_get_u64(void)
return EXIT_FAILURE;
}
- for (i = 0; i < ((int)(sizeof(unsigned long long)*CHAR_BIT) - 1); ++i) {
+ for (i = 0; i < (int)(MP_SIZEOF_BITS(unsigned long long) - 1); ++i) {
r = (1ULL << (i+1)) - 1;
if (!r)
r = ~0ULL;
diff --git a/helper.pl b/helper.pl
index ab3a4a0d8..bde8cdf19 100755
--- a/helper.pl
+++ b/helper.pl
@@ -222,16 +222,6 @@ sub patch_file {
return $content;
}
-sub version_from_tomcrypt_h {
- my $h = read_file(shift);
- if ($h =~ /\n#define\s*SCRYPT\s*"([0-9]+)\.([0-9]+)\.([0-9]+)(.*)"/s) {
- return "VERSION_PC=$1.$2.$3", "VERSION_LT=1:1", "VERSION=$1.$2.$3$4", "PROJECT_NUMBER=$1.$2.$3$4";
- }
- else {
- die "#define SCRYPT not found in tomcrypt.h";
- }
-}
-
sub process_makefiles {
my $write = shift;
my $changed_count = 0;
@@ -308,6 +298,7 @@ sub update_dep
/* SPDX-License-Identifier: Unlicense */
#if !(defined(LTM1) && defined(LTM2) && defined(LTM3))
+#define LTM_INSIDE
#if defined(LTM2)
# define LTM3
#endif
@@ -323,12 +314,10 @@ sub update_dep
print "Processing $filename\n";
- # convert filename to upper case so we can use it as a define
+ # convert filename to upper case so we can use it as a define
$define =~ tr/[a-z]/[A-Z]/;
$define =~ tr/\./_/;
- print {$class} << "EOS";
-# define $define
-EOS
+ print {$class} "# define $define\n";
# now copy text and apply #ifdef as required
my $apply = 0;
@@ -350,14 +339,12 @@ sub update_dep
$apply = 1;
}
while (<$src>) {
- if (!($_ =~ /tommath\.h/)) {
+ if ($_ !~ /tommath\.h/) {
print {$out} $_;
}
}
if ($apply == 1) {
- print {$out} << 'EOS';
-#endif
-EOS
+ print {$out} "#endif\n";
}
close $src;
close $out;
@@ -365,53 +352,58 @@ sub update_dep
unlink $filename;
rename 'tmp', $filename;
}
- print {$class} << 'EOS';
-#endif
-EOS
+ print {$class} "#endif\n#endif\n";
# now do classes
my %depmap;
foreach my $filename (glob 'bn*.c') {
- open(my $src, '<', $filename) or die "Can't open source file!\n";
- read $src, my $content, -s $src;
- close $src;
+ my $content;
+ if ($filename =~ "bn_deprecated.c") {
+ open(my $src, '<', $filename) or die "Can't open source file!\n";
+ read $src, $content, -s $src;
+ close $src;
+ } else {
+ my $cc = $ENV{'CC'} || 'gcc';
+ $content = `$cc -E -x c -DLTM_ALL $filename`;
+ $content =~ s/^# 1 "$filename".*?^# 2 "$filename"//ms;
+ }
# convert filename to upper case so we can use it as a define
$filename =~ tr/[a-z]/[A-Z]/;
$filename =~ tr/\./_/;
- print {$class} << "EOS";
-#if defined($filename)
-EOS
+ print {$class} "#if defined($filename)\n";
my $list = $filename;
# strip comments
$content =~ s{/\*.*?\*/}{}gs;
# scan for mp_* and make classes
+ my @deps = ();
foreach my $line (split /\n/, $content) {
while ($line =~ /(fast_)?(s_)?mp\_[a-z_0-9]*(?=\()|(?<=\()mp\_[a-z_0-9]*(?=,)/g) {
my $a = $&;
next if $a eq "mp_err";
$a =~ tr/[a-z]/[A-Z]/;
$a = 'BN_' . $a . '_C';
- if (!($list =~ /$a/)) {
- print {$class} << "EOS";
-# define $a
-EOS
- }
- $list = $list . ',' . $a;
+ push @deps, $a;
}
}
+ @deps = sort(@deps);
+ foreach my $a (@deps) {
+ if ($list !~ /$a/) {
+ print {$class} "# define $a\n";
+ }
+ $list = $list . ',' . $a;
+ }
$depmap{$filename} = $list;
- print {$class} << 'EOS';
-#endif
-
-EOS
+ print {$class} "#endif\n\n";
}
print {$class} << 'EOS';
+#ifdef LTM_INSIDE
+#undef LTM_INSIDE
#ifdef LTM3
# define LTM_LAST
#endif
@@ -442,8 +434,7 @@ sub generate_def {
@files = map { my $x = $_; $x =~ s/^bn_|\.c$//g; $x; } @files;
@files = grep(!/mp_radix_smap/, @files);
- @files = grep(!/conversion/, @files);
- push(@files, qw(mp_set_i32 mp_set_i64 mp_set_u32 mp_set_u64 mp_set_int mp_set_long mp_set_long_long mp_get_i32 mp_get_i64 mp_get_mag32 mp_get_mag64 mp_get_int mp_get_long mp_get_long_long mp_init_i32 mp_init_i64 mp_init_u32 mp_init_u64 mp_init_set_int));
+ push(@files, qw(mp_set_int mp_set_long mp_set_long_long mp_get_int mp_get_long mp_get_long_long mp_init_set_int));
my $files = join("\n ", sort(grep(/^mp_/, @files)));
write_file "tommath.def", "; libtommath
diff --git a/libtommath_VS2008.vcproj b/libtommath_VS2008.vcproj
index 6e73c7ff9..ad4a237ef 100644
--- a/libtommath_VS2008.vcproj
+++ b/libtommath_VS2008.vcproj
@@ -312,10 +312,6 @@
-
-
@@ -464,6 +460,22 @@
RelativePath="bn_mp_get_double.c"
>
+
+
+
+
+
+
+
+
@@ -488,6 +500,14 @@
RelativePath="bn_mp_init_copy.c"
>
+
+
+
+
@@ -500,6 +520,14 @@
RelativePath="bn_mp_init_size.c"
>
+
+
+
+
@@ -684,6 +712,22 @@
RelativePath="bn_mp_set_double.c"
>
+
+
+
+
+
+
+
+
diff --git a/makefile b/makefile
index e1828da2a..fdc8ae388 100644
--- a/makefile
+++ b/makefile
@@ -26,14 +26,15 @@ endif
LCOV_ARGS=--directory .
#START_INS
-OBJECTS=bn_conversion.o bn_cutoffs.o bn_deprecated.o bn_mp_2expt.o bn_mp_abs.o bn_mp_add.o bn_mp_add_d.o \
-bn_mp_addmod.o bn_mp_and.o bn_mp_clamp.o bn_mp_clear.o bn_mp_clear_multi.o bn_mp_cmp.o bn_mp_cmp_d.o \
-bn_mp_cmp_mag.o bn_mp_cnt_lsb.o bn_mp_complement.o bn_mp_copy.o bn_mp_count_bits.o bn_mp_decr.o \
-bn_mp_div.o bn_mp_div_2.o bn_mp_div_2d.o bn_mp_div_3.o bn_mp_div_d.o bn_mp_dr_is_modulus.o \
-bn_mp_dr_reduce.o bn_mp_dr_setup.o bn_mp_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_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_multi.o \
-bn_mp_init_set.o bn_mp_init_size.o bn_mp_invmod.o bn_mp_is_square.o bn_mp_iseven.o bn_mp_isodd.o \
+OBJECTS=bn_cutoffs.o bn_deprecated.o bn_mp_2expt.o bn_mp_abs.o bn_mp_add.o bn_mp_add_d.o bn_mp_addmod.o \
+bn_mp_and.o bn_mp_clamp.o bn_mp_clear.o bn_mp_clear_multi.o bn_mp_cmp.o bn_mp_cmp_d.o bn_mp_cmp_mag.o \
+bn_mp_cnt_lsb.o bn_mp_complement.o bn_mp_copy.o bn_mp_count_bits.o bn_mp_decr.o bn_mp_div.o bn_mp_div_2.o \
+bn_mp_div_2d.o bn_mp_div_3.o bn_mp_div_d.o bn_mp_dr_is_modulus.o bn_mp_dr_reduce.o bn_mp_dr_setup.o \
+bn_mp_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 \
@@ -43,13 +44,14 @@ bn_mp_prime_rand.o bn_mp_prime_strong_lucas_selfridge.o bn_mp_radix_size.o bn_mp
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_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_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
diff --git a/makefile.mingw b/makefile.mingw
index f46f9301c..245047abc 100644
--- a/makefile.mingw
+++ b/makefile.mingw
@@ -29,14 +29,15 @@ LIBMAIN_I =libtommath.dll.a
LIBMAIN_D =libtommath.dll
#List of objects to compile (all goes to libtommath.a)
-OBJECTS=bn_conversion.o bn_cutoffs.o bn_deprecated.o bn_mp_2expt.o bn_mp_abs.o bn_mp_add.o bn_mp_add_d.o \
-bn_mp_addmod.o bn_mp_and.o bn_mp_clamp.o bn_mp_clear.o bn_mp_clear_multi.o bn_mp_cmp.o bn_mp_cmp_d.o \
-bn_mp_cmp_mag.o bn_mp_cnt_lsb.o bn_mp_complement.o bn_mp_copy.o bn_mp_count_bits.o bn_mp_decr.o \
-bn_mp_div.o bn_mp_div_2.o bn_mp_div_2d.o bn_mp_div_3.o bn_mp_div_d.o bn_mp_dr_is_modulus.o \
-bn_mp_dr_reduce.o bn_mp_dr_setup.o bn_mp_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_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_multi.o \
-bn_mp_init_set.o bn_mp_init_size.o bn_mp_invmod.o bn_mp_is_square.o bn_mp_iseven.o bn_mp_isodd.o \
+OBJECTS=bn_cutoffs.o bn_deprecated.o bn_mp_2expt.o bn_mp_abs.o bn_mp_add.o bn_mp_add_d.o bn_mp_addmod.o \
+bn_mp_and.o bn_mp_clamp.o bn_mp_clear.o bn_mp_clear_multi.o bn_mp_cmp.o bn_mp_cmp_d.o bn_mp_cmp_mag.o \
+bn_mp_cnt_lsb.o bn_mp_complement.o bn_mp_copy.o bn_mp_count_bits.o bn_mp_decr.o bn_mp_div.o bn_mp_div_2.o \
+bn_mp_div_2d.o bn_mp_div_3.o bn_mp_div_d.o bn_mp_dr_is_modulus.o bn_mp_dr_reduce.o bn_mp_dr_setup.o \
+bn_mp_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 \
@@ -46,13 +47,14 @@ bn_mp_prime_rand.o bn_mp_prime_strong_lucas_selfridge.o bn_mp_radix_size.o bn_mp
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_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_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
diff --git a/makefile.msvc b/makefile.msvc
index 3fbae6390..03ef8b8d5 100644
--- a/makefile.msvc
+++ b/makefile.msvc
@@ -21,14 +21,15 @@ LTM_LDFLAGS = advapi32.lib
LIBMAIN_S =tommath.lib
#List of objects to compile (all goes to tommath.lib)
-OBJECTS=bn_conversion.obj bn_cutoffs.obj bn_deprecated.obj bn_mp_2expt.obj bn_mp_abs.obj bn_mp_add.obj bn_mp_add_d.obj \
-bn_mp_addmod.obj bn_mp_and.obj bn_mp_clamp.obj bn_mp_clear.obj bn_mp_clear_multi.obj bn_mp_cmp.obj bn_mp_cmp_d.obj \
-bn_mp_cmp_mag.obj bn_mp_cnt_lsb.obj bn_mp_complement.obj bn_mp_copy.obj bn_mp_count_bits.obj bn_mp_decr.obj \
-bn_mp_div.obj bn_mp_div_2.obj bn_mp_div_2d.obj bn_mp_div_3.obj bn_mp_div_d.obj bn_mp_dr_is_modulus.obj \
-bn_mp_dr_reduce.obj bn_mp_dr_setup.obj bn_mp_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_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_multi.obj \
-bn_mp_init_set.obj bn_mp_init_size.obj bn_mp_invmod.obj bn_mp_is_square.obj bn_mp_iseven.obj bn_mp_isodd.obj \
+OBJECTS=bn_cutoffs.obj bn_deprecated.obj bn_mp_2expt.obj bn_mp_abs.obj bn_mp_add.obj bn_mp_add_d.obj bn_mp_addmod.obj \
+bn_mp_and.obj bn_mp_clamp.obj bn_mp_clear.obj bn_mp_clear_multi.obj bn_mp_cmp.obj bn_mp_cmp_d.obj bn_mp_cmp_mag.obj \
+bn_mp_cnt_lsb.obj bn_mp_complement.obj bn_mp_copy.obj bn_mp_count_bits.obj bn_mp_decr.obj bn_mp_div.obj bn_mp_div_2.obj \
+bn_mp_div_2d.obj bn_mp_div_3.obj bn_mp_div_d.obj bn_mp_dr_is_modulus.obj bn_mp_dr_reduce.obj bn_mp_dr_setup.obj \
+bn_mp_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 \
@@ -38,13 +39,14 @@ bn_mp_prime_rand.obj bn_mp_prime_strong_lucas_selfridge.obj bn_mp_radix_size.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_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_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
diff --git a/makefile.shared b/makefile.shared
index fb7b91a8e..48df13fe5 100644
--- a/makefile.shared
+++ b/makefile.shared
@@ -23,14 +23,15 @@ LTLINK = $(LIBTOOL) --mode=link --tag=CC $(CC)
LCOV_ARGS=--directory .libs --directory .
#START_INS
-OBJECTS=bn_conversion.o bn_cutoffs.o bn_deprecated.o bn_mp_2expt.o bn_mp_abs.o bn_mp_add.o bn_mp_add_d.o \
-bn_mp_addmod.o bn_mp_and.o bn_mp_clamp.o bn_mp_clear.o bn_mp_clear_multi.o bn_mp_cmp.o bn_mp_cmp_d.o \
-bn_mp_cmp_mag.o bn_mp_cnt_lsb.o bn_mp_complement.o bn_mp_copy.o bn_mp_count_bits.o bn_mp_decr.o \
-bn_mp_div.o bn_mp_div_2.o bn_mp_div_2d.o bn_mp_div_3.o bn_mp_div_d.o bn_mp_dr_is_modulus.o \
-bn_mp_dr_reduce.o bn_mp_dr_setup.o bn_mp_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_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_multi.o \
-bn_mp_init_set.o bn_mp_init_size.o bn_mp_invmod.o bn_mp_is_square.o bn_mp_iseven.o bn_mp_isodd.o \
+OBJECTS=bn_cutoffs.o bn_deprecated.o bn_mp_2expt.o bn_mp_abs.o bn_mp_add.o bn_mp_add_d.o bn_mp_addmod.o \
+bn_mp_and.o bn_mp_clamp.o bn_mp_clear.o bn_mp_clear_multi.o bn_mp_cmp.o bn_mp_cmp_d.o bn_mp_cmp_mag.o \
+bn_mp_cnt_lsb.o bn_mp_complement.o bn_mp_copy.o bn_mp_count_bits.o bn_mp_decr.o bn_mp_div.o bn_mp_div_2.o \
+bn_mp_div_2d.o bn_mp_div_3.o bn_mp_div_d.o bn_mp_dr_is_modulus.o bn_mp_dr_reduce.o bn_mp_dr_setup.o \
+bn_mp_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 \
@@ -40,13 +41,14 @@ bn_mp_prime_rand.o bn_mp_prime_strong_lucas_selfridge.o bn_mp_radix_size.o bn_mp
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_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_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
diff --git a/makefile.unix b/makefile.unix
index cec94319f..210802d4a 100644
--- a/makefile.unix
+++ b/makefile.unix
@@ -30,14 +30,15 @@ LTM_LDFLAGS = $(LDFLAGS)
#Library to be created (this makefile builds only static library)
LIBMAIN_S = libtommath.a
-OBJECTS=bn_conversion.o bn_cutoffs.o bn_deprecated.o bn_mp_2expt.o bn_mp_abs.o bn_mp_add.o bn_mp_add_d.o \
-bn_mp_addmod.o bn_mp_and.o bn_mp_clamp.o bn_mp_clear.o bn_mp_clear_multi.o bn_mp_cmp.o bn_mp_cmp_d.o \
-bn_mp_cmp_mag.o bn_mp_cnt_lsb.o bn_mp_complement.o bn_mp_copy.o bn_mp_count_bits.o bn_mp_decr.o \
-bn_mp_div.o bn_mp_div_2.o bn_mp_div_2d.o bn_mp_div_3.o bn_mp_div_d.o bn_mp_dr_is_modulus.o \
-bn_mp_dr_reduce.o bn_mp_dr_setup.o bn_mp_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_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_multi.o \
-bn_mp_init_set.o bn_mp_init_size.o bn_mp_invmod.o bn_mp_is_square.o bn_mp_iseven.o bn_mp_isodd.o \
+OBJECTS=bn_cutoffs.o bn_deprecated.o bn_mp_2expt.o bn_mp_abs.o bn_mp_add.o bn_mp_add_d.o bn_mp_addmod.o \
+bn_mp_and.o bn_mp_clamp.o bn_mp_clear.o bn_mp_clear_multi.o bn_mp_cmp.o bn_mp_cmp_d.o bn_mp_cmp_mag.o \
+bn_mp_cnt_lsb.o bn_mp_complement.o bn_mp_copy.o bn_mp_count_bits.o bn_mp_decr.o bn_mp_div.o bn_mp_div_2.o \
+bn_mp_div_2d.o bn_mp_div_3.o bn_mp_div_d.o bn_mp_dr_is_modulus.o bn_mp_dr_reduce.o bn_mp_dr_setup.o \
+bn_mp_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 \
@@ -47,13 +48,14 @@ bn_mp_prime_rand.o bn_mp_prime_strong_lucas_selfridge.o bn_mp_radix_size.o bn_mp
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_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_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
diff --git a/tommath_class.h b/tommath_class.h
index 90c27e8c6..dfc0be137 100644
--- a/tommath_class.h
+++ b/tommath_class.h
@@ -2,6 +2,7 @@
/* SPDX-License-Identifier: Unlicense */
#if !(defined(LTM1) && defined(LTM2) && defined(LTM3))
+#define LTM_INSIDE
#if defined(LTM2)
# define LTM3
#endif
@@ -10,7 +11,6 @@
#endif
#define LTM1
#if defined(LTM_ALL)
-# define BN_CONVERSION_C
# define BN_CUTOFFS_C
# define BN_DEPRECATED_C
# define BN_MP_2EXPT_C
@@ -48,15 +48,23 @@
# define BN_MP_FWRITE_C
# define BN_MP_GCD_C
# 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_GROW_C
# define BN_MP_ILOGB_C
# define BN_MP_IMPORT_C
# define BN_MP_INCR_C
# define BN_MP_INIT_C
# define BN_MP_INIT_COPY_C
+# define BN_MP_INIT_I32_C
+# define BN_MP_INIT_I64_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_INVMOD_C
# define BN_MP_IS_SQUARE_C
# define BN_MP_ISEVEN_C
@@ -103,6 +111,10 @@
# define BN_MP_RSHD_C
# define BN_MP_SET_C
# define BN_MP_SET_DOUBLE_C
+# define BN_MP_SET_I32_C
+# define BN_MP_SET_I64_C
+# define BN_MP_SET_U32_C
+# define BN_MP_SET_U64_C
# define BN_MP_SHRINK_C
# define BN_MP_SIGNED_BIN_SIZE_C
# define BN_MP_SIGNED_RSH_C
@@ -147,91 +159,76 @@
# define BN_S_MP_TOOM_MUL_C
# define BN_S_MP_TOOM_SQR_C
#endif
-#if defined(BN_CONVERSION_C)
-# define BN_MP_INIT_C
-# define BN_MP_SET_U32_C
-# define BN_MP_SET_U64_C
-# define BN_MP_SET_I32_C
-# define BN_MP_SET_I64_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_INIT_U32_C
-# define BN_MP_INIT_I32_C
-# define BN_MP_INIT_U64_C
-# define BN_MP_INIT_I64_C
#endif
-
#if defined(BN_CUTOFFS_C)
#endif
#if defined(BN_DEPRECATED_C)
-# define BN_MP_GET_BIT_C
-# define BN_S_MP_GET_BIT_C
-# define BN_MP_JACOBI_C
-# define BN_MP_CMP_D_C
-# define BN_MP_KRONECKER_C
-# define BN_MP_PRIME_RANDOM_EX_C
-# define BN_S_MP_PRIME_RANDOM_EX_C
-# define BN_MP_RAND_DIGIT_C
-# define BN_S_MP_RAND_SOURCE_C
# define BN_FAST_MP_INVMOD_C
-# define BN_S_MP_INVMOD_FAST_C
# define BN_FAST_MP_MONTGOMERY_REDUCE_C
-# define BN_S_MP_MONTGOMERY_REDUCE_FAST_C
# define BN_FAST_S_MP_MUL_DIGS_C
-# define BN_S_MP_MUL_DIGS_FAST_C
# define BN_FAST_S_MP_MUL_HIGH_DIGS_C
-# define BN_S_MP_MUL_HIGH_DIGS_FAST_C
# define BN_FAST_S_MP_SQR_C
-# define BN_S_MP_SQR_FAST_C
+# define BN_MP_AND_C
# define BN_MP_BALANCE_MUL_C
-# define BN_S_MP_BALANCE_MUL_C
+# define BN_MP_CMP_D_C
# define BN_MP_EXPTMOD_FAST_C
-# define BN_S_MP_EXPTMOD_FAST_C
+# define BN_MP_EXPT_D_C
+# define BN_MP_EXPT_D_EX_C
+# define BN_MP_GET_BIT_C
+# 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_INIT_SET_INT_C
+# define BN_MP_INIT_U32_C
# define BN_MP_INVMOD_SLOW_C
-# define BN_S_MP_INVMOD_SLOW_C
+# define BN_MP_JACOBI_C
# define BN_MP_KARATSUBA_MUL_C
-# define BN_S_MP_KARATSUBA_MUL_C
# define BN_MP_KARATSUBA_SQR_C
-# define BN_S_MP_KARATSUBA_SQR_C
-# define BN_MP_TOOM_MUL_C
-# define BN_S_MP_TOOM_MUL_C
-# define BN_MP_TOOM_SQR_C
-# define BN_S_MP_TOOM_SQR_C
-# define BN_S_MP_REVERSE_C
-# define BN_MP_TC_AND_C
-# define BN_MP_AND_C
-# define BN_MP_TC_OR_C
+# define BN_MP_KRONECKER_C
+# define BN_MP_N_ROOT_C
+# define BN_MP_N_ROOT_EX_C
# define BN_MP_OR_C
-# define BN_MP_TC_XOR_C
-# define BN_MP_XOR_C
-# define BN_MP_TC_DIV_2D_C
-# define BN_MP_SIGNED_RSH_C
-# define BN_MP_INIT_SET_INT_C
-# define BN_MP_INIT_U32_C
+# define BN_MP_PRIME_IS_DIVISIBLE_C
+# define BN_MP_PRIME_RANDOM_EX_C
+# define BN_MP_RAND_DIGIT_C
# define BN_MP_SET_INT_C
-# define BN_MP_SET_U32_C
# define BN_MP_SET_LONG_C
-# define BN_MP_SET_U64_C
# define BN_MP_SET_LONG_LONG_C
-# define BN_MP_GET_INT_C
-# define BN_MP_GET_MAG32_C
-# define BN_MP_GET_LONG_C
-# define BN_MP_GET_MAG64_C
-# define BN_MP_GET_LONG_LONG_C
-# define BN_MP_PRIME_IS_DIVISIBLE_C
+# define BN_MP_SET_U32_C
+# define BN_MP_SET_U64_C
+# define BN_MP_SIGNED_RSH_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_TOOM_MUL_C
+# define BN_MP_TOOM_SQR_C
+# define BN_MP_XOR_C
+# define BN_S_MP_BALANCE_MUL_C
+# define BN_S_MP_EXPTMOD_FAST_C
+# define BN_S_MP_GET_BIT_C
+# define BN_S_MP_INVMOD_FAST_C
+# define BN_S_MP_INVMOD_SLOW_C
+# define BN_S_MP_KARATSUBA_MUL_C
+# define BN_S_MP_KARATSUBA_SQR_C
+# define BN_S_MP_MONTGOMERY_REDUCE_FAST_C
+# define BN_S_MP_MUL_DIGS_FAST_C
+# define BN_S_MP_MUL_HIGH_DIGS_FAST_C
# define BN_S_MP_PRIME_IS_DIVISIBLE_C
-# define BN_MP_EXPT_D_EX_C
-# define BN_MP_EXPT_D_C
-# define BN_MP_N_ROOT_EX_C
-# define BN_MP_N_ROOT_C
+# define BN_S_MP_PRIME_RANDOM_EX_C
+# define BN_S_MP_RAND_SOURCE_C
+# define BN_S_MP_REVERSE_C
+# define BN_S_MP_SQR_FAST_C
+# define BN_S_MP_TOOM_MUL_C
+# define BN_S_MP_TOOM_SQR_C
#endif
#if defined(BN_MP_2EXPT_C)
-# define BN_MP_ZERO_C
# define BN_MP_GROW_C
+# define BN_MP_ZERO_C
#endif
#if defined(BN_MP_ABS_C)
@@ -239,27 +236,27 @@
#endif
#if defined(BN_MP_ADD_C)
-# define BN_S_MP_ADD_C
# define BN_MP_CMP_MAG_C
+# define BN_S_MP_ADD_C
# define BN_S_MP_SUB_C
#endif
#if defined(BN_MP_ADD_D_C)
+# define BN_MP_CLAMP_C
# define BN_MP_GROW_C
# define BN_MP_SUB_D_C
-# define BN_MP_CLAMP_C
#endif
#if defined(BN_MP_ADDMOD_C)
-# define BN_MP_INIT_C
# define BN_MP_ADD_C
# define BN_MP_CLEAR_C
+# define BN_MP_INIT_C
# define BN_MP_MOD_C
#endif
#if defined(BN_MP_AND_C)
-# define BN_MP_GROW_C
# define BN_MP_CLAMP_C
+# define BN_MP_GROW_C
#endif
#if defined(BN_MP_CLAMP_C)
@@ -298,74 +295,70 @@
#endif
#if defined(BN_MP_DECR_C)
-# define BN_MP_SET_C
# define BN_MP_INCR_C
-# define BN_MP_ZERO_C
+# define BN_MP_SET_C
# define BN_MP_SUB_D_C
+# define BN_MP_ZERO_C
#endif
#if defined(BN_MP_DIV_C)
+# define BN_MP_ADD_C
+# define BN_MP_CLAMP_C
+# define BN_MP_CLEAR_C
+# define BN_MP_CMP_C
# define BN_MP_CMP_MAG_C
# define BN_MP_COPY_C
-# define BN_MP_ZERO_C
-# define BN_MP_INIT_MULTI_C
-# define BN_MP_SET_C
# define BN_MP_COUNT_BITS_C
-# define BN_MP_ABS_C
-# define BN_MP_MUL_2D_C
-# define BN_MP_CMP_C
-# define BN_MP_SUB_C
-# define BN_MP_ADD_C
# define BN_MP_DIV_2D_C
# define BN_MP_EXCH_C
-# define BN_MP_CLEAR_MULTI_C
-# define BN_MP_INIT_SIZE_C
# define BN_MP_INIT_C
# define BN_MP_INIT_COPY_C
+# define BN_MP_INIT_SIZE_C
# define BN_MP_LSHD_C
-# define BN_MP_RSHD_C
+# define BN_MP_MUL_2D_C
# define BN_MP_MUL_D_C
-# define BN_MP_CLAMP_C
-# define BN_MP_CLEAR_C
+# define BN_MP_RSHD_C
+# define BN_MP_SUB_C
+# define BN_MP_ZERO_C
#endif
#if defined(BN_MP_DIV_2_C)
-# define BN_MP_GROW_C
# define BN_MP_CLAMP_C
+# define BN_MP_GROW_C
#endif
#if defined(BN_MP_DIV_2D_C)
+# define BN_MP_CLAMP_C
# define BN_MP_COPY_C
-# define BN_MP_ZERO_C
# define BN_MP_MOD_2D_C
# define BN_MP_RSHD_C
-# define BN_MP_CLAMP_C
+# define BN_MP_ZERO_C
#endif
#if defined(BN_MP_DIV_3_C)
-# define BN_MP_INIT_SIZE_C
# define BN_MP_CLAMP_C
-# define BN_MP_EXCH_C
# define BN_MP_CLEAR_C
+# define BN_MP_EXCH_C
+# define BN_MP_INIT_SIZE_C
#endif
#if defined(BN_MP_DIV_D_C)
+# define BN_MP_CLAMP_C
+# define BN_MP_CLEAR_C
# define BN_MP_COPY_C
# define BN_MP_DIV_2D_C
# define BN_MP_DIV_3_C
-# define BN_MP_INIT_SIZE_C
-# define BN_MP_CLAMP_C
# define BN_MP_EXCH_C
-# define BN_MP_CLEAR_C
+# define BN_MP_INIT_SIZE_C
#endif
#if defined(BN_MP_DR_IS_MODULUS_C)
#endif
#if defined(BN_MP_DR_REDUCE_C)
-# define BN_MP_GROW_C
# define BN_MP_CLAMP_C
# define BN_MP_CMP_MAG_C
+# define BN_MP_GROW_C
# define BN_S_MP_SUB_C
#endif
@@ -379,49 +372,49 @@
#endif
#if defined(BN_MP_EXPORT_C)
-# define BN_MP_INIT_COPY_C
+# define BN_MP_CLEAR_C
# define BN_MP_COUNT_BITS_C
# define BN_MP_DIV_2D_C
-# define BN_MP_CLEAR_C
+# define BN_MP_INIT_COPY_C
#endif
#if defined(BN_MP_EXPT_D_C)
+# define BN_MP_CLEAR_C
# define BN_MP_INIT_COPY_C
-# define BN_MP_SET_C
# define BN_MP_MUL_C
-# define BN_MP_CLEAR_C
+# define BN_MP_SET_C
# define BN_MP_SQR_C
#endif
#if defined(BN_MP_EXPTMOD_C)
-# define BN_MP_INIT_C
-# define BN_MP_INVMOD_C
-# define BN_MP_CLEAR_C
# define BN_MP_ABS_C
+# define BN_MP_CLEAR_C
# define BN_MP_CLEAR_MULTI_C
-# define BN_MP_REDUCE_IS_2K_L_C
-# define BN_S_MP_EXPTMOD_C
# define BN_MP_DR_IS_MODULUS_C
+# define BN_MP_INIT_C
+# define BN_MP_INVMOD_C
# define BN_MP_REDUCE_IS_2K_C
+# define BN_MP_REDUCE_IS_2K_L_C
+# define BN_S_MP_EXPTMOD_C
# define BN_S_MP_EXPTMOD_FAST_C
#endif
#if defined(BN_MP_EXTEUCLID_C)
-# define BN_MP_INIT_MULTI_C
-# define BN_MP_SET_C
+# define BN_MP_CLEAR_MULTI_C
# define BN_MP_COPY_C
# define BN_MP_DIV_C
+# define BN_MP_EXCH_C
+# define BN_MP_INIT_MULTI_C
# define BN_MP_MUL_C
-# define BN_MP_SUB_C
# define BN_MP_NEG_C
-# define BN_MP_EXCH_C
-# define BN_MP_CLEAR_MULTI_C
+# define BN_MP_SET_C
+# define BN_MP_SUB_C
#endif
#if defined(BN_MP_FREAD_C)
-# define BN_MP_ZERO_C
-# define BN_MP_MUL_D_C
# define BN_MP_ADD_D_C
+# define BN_MP_MUL_D_C
+# define BN_MP_ZERO_C
#endif
#if defined(BN_MP_FWRITE_C)
@@ -431,72 +424,106 @@
#if defined(BN_MP_GCD_C)
# define BN_MP_ABS_C
-# define BN_MP_INIT_COPY_C
+# define BN_MP_CLEAR_C
+# define BN_MP_CMP_MAG_C
# define BN_MP_CNT_LSB_C
# define BN_MP_DIV_2D_C
-# define BN_MP_CMP_MAG_C
# define BN_MP_EXCH_C
-# define BN_S_MP_SUB_C
+# define BN_MP_INIT_COPY_C
# define BN_MP_MUL_2D_C
-# define BN_MP_CLEAR_C
+# define BN_S_MP_SUB_C
#endif
#if defined(BN_MP_GET_DOUBLE_C)
#endif
+#if defined(BN_MP_GET_I32_C)
+# define BN_MP_GET_MAG32_C
+#endif
+
+#if defined(BN_MP_GET_I64_C)
+# define BN_MP_GET_MAG64_C
+#endif
+
+#if defined(BN_MP_GET_MAG32_C)
+#endif
+
+#if defined(BN_MP_GET_MAG64_C)
+#endif
+
#if defined(BN_MP_GROW_C)
#endif
#if defined(BN_MP_ILOGB_C)
-# define BN_MP_SET_U32_C
-# define BN_MP_COUNT_BITS_C
-# define BN_MP_SET_C
-# define BN_MP_CMP_D_C
-# define BN_MP_ZERO_C
-# define BN_MP_INIT_MULTI_C
+# define BN_MP_CLEAR_MULTI_C
# define BN_MP_CMP_C
+# define BN_MP_CMP_D_C
# define BN_MP_COPY_C
-# define BN_MP_SQR_C
+# define BN_MP_COUNT_BITS_C
+# define BN_MP_EXCH_C
# define BN_MP_EXPT_D_C
+# define BN_MP_INIT_MULTI_C
# define BN_MP_MUL_C
-# define BN_MP_EXCH_C
-# define BN_MP_CLEAR_MULTI_C
+# define BN_MP_SET_C
+# define BN_MP_SET_U32_C
+# define BN_MP_SQR_C
+# define BN_MP_ZERO_C
#endif
#if defined(BN_MP_IMPORT_C)
-# define BN_MP_ZERO_C
-# define BN_MP_MUL_2D_C
# define BN_MP_CLAMP_C
+# define BN_MP_MUL_2D_C
+# define BN_MP_ZERO_C
#endif
#if defined(BN_MP_INCR_C)
-# define BN_MP_SET_C
-# define BN_MP_DECR_C
# define BN_MP_ADD_D_C
+# define BN_MP_DECR_C
+# define BN_MP_SET_C
#endif
#if defined(BN_MP_INIT_C)
#endif
#if defined(BN_MP_INIT_COPY_C)
-# define BN_MP_INIT_SIZE_C
-# define BN_MP_COPY_C
# define BN_MP_CLEAR_C
+# define BN_MP_COPY_C
+# define BN_MP_INIT_SIZE_C
#endif
-#if defined(BN_MP_INIT_MULTI_C)
+#if defined(BN_MP_INIT_I32_C)
# define BN_MP_INIT_C
-# define BN_MP_CLEAR_C
+# define BN_MP_SET_I32_C
#endif
-#if defined(BN_MP_INIT_SET_C)
+#if defined(BN_MP_INIT_I64_C)
# define BN_MP_INIT_C
-# define BN_MP_SET_C
+# define BN_MP_SET_I64_C
+#endif
+
+#if defined(BN_MP_INIT_MULTI_C)
+# define BN_MP_CLEAR_C
+# define BN_MP_INIT_C
+#endif
+
+#if defined(BN_MP_INIT_SET_C)
+# define BN_MP_INIT_C
+# define BN_MP_SET_C
#endif
#if defined(BN_MP_INIT_SIZE_C)
#endif
+#if defined(BN_MP_INIT_U32_C)
+# define BN_MP_INIT_C
+# define BN_MP_SET_U32_C
+#endif
+
+#if defined(BN_MP_INIT_U64_C)
+# define BN_MP_INIT_C
+# define BN_MP_SET_U64_C
+#endif
+
#if defined(BN_MP_INVMOD_C)
# define BN_MP_CMP_D_C
# define BN_S_MP_INVMOD_FAST_C
@@ -504,14 +531,14 @@
#endif
#if defined(BN_MP_IS_SQUARE_C)
-# define BN_MP_MOD_D_C
+# define BN_MP_CLEAR_C
+# define BN_MP_CMP_MAG_C
+# define BN_MP_GET_I32_C
# define BN_MP_INIT_U32_C
# define BN_MP_MOD_C
-# define BN_MP_GET_U32_C
+# define BN_MP_MOD_D_C
# define BN_MP_SQRT_C
# define BN_MP_SQR_C
-# define BN_MP_CMP_MAG_C
-# define BN_MP_CLEAR_C
#endif
#if defined(BN_MP_ISEVEN_C)
@@ -521,22 +548,23 @@
#endif
#if defined(BN_MP_KRONECKER_C)
-# define BN_MP_INIT_COPY_C
-# define BN_MP_CNT_LSB_C
-# define BN_MP_DIV_2D_C
+# define BN_MP_CLEAR_C
# define BN_MP_CMP_D_C
+# define BN_MP_CNT_LSB_C
# define BN_MP_COPY_C
+# define BN_MP_DIV_2D_C
+# define BN_MP_INIT_C
+# define BN_MP_INIT_COPY_C
# define BN_MP_MOD_C
-# define BN_MP_CLEAR_C
#endif
#if defined(BN_MP_LCM_C)
-# define BN_MP_INIT_MULTI_C
-# define BN_MP_GCD_C
+# define BN_MP_CLEAR_MULTI_C
# define BN_MP_CMP_MAG_C
# define BN_MP_DIV_C
+# define BN_MP_GCD_C
+# define BN_MP_INIT_MULTI_C
# define BN_MP_MUL_C
-# define BN_MP_CLEAR_MULTI_C
#endif
#if defined(BN_MP_LSHD_C)
@@ -544,17 +572,17 @@
#endif
#if defined(BN_MP_MOD_C)
-# define BN_MP_INIT_SIZE_C
-# define BN_MP_DIV_C
+# define BN_MP_ADD_C
# define BN_MP_CLEAR_C
+# define BN_MP_DIV_C
# define BN_MP_EXCH_C
-# define BN_MP_ADD_C
+# define BN_MP_INIT_SIZE_C
#endif
#if defined(BN_MP_MOD_2D_C)
-# define BN_MP_ZERO_C
-# define BN_MP_COPY_C
# define BN_MP_CLAMP_C
+# define BN_MP_COPY_C
+# define BN_MP_ZERO_C
#endif
#if defined(BN_MP_MOD_D_C)
@@ -562,20 +590,20 @@
#endif
#if defined(BN_MP_MONTGOMERY_CALC_NORMALIZATION_C)
-# define BN_MP_COUNT_BITS_C
# define BN_MP_2EXPT_C
-# define BN_MP_SET_C
-# define BN_MP_MUL_2_C
# define BN_MP_CMP_MAG_C
+# define BN_MP_COUNT_BITS_C
+# define BN_MP_MUL_2_C
+# define BN_MP_SET_C
# define BN_S_MP_SUB_C
#endif
#if defined(BN_MP_MONTGOMERY_REDUCE_C)
-# define BN_S_MP_MONTGOMERY_REDUCE_FAST_C
-# define BN_MP_GROW_C
# define BN_MP_CLAMP_C
-# define BN_MP_RSHD_C
# define BN_MP_CMP_MAG_C
+# define BN_MP_GROW_C
+# define BN_MP_RSHD_C
+# define BN_S_MP_MONTGOMERY_REDUCE_FAST_C
# define BN_S_MP_SUB_C
#endif
@@ -584,10 +612,10 @@
#if defined(BN_MP_MUL_C)
# define BN_S_MP_BALANCE_MUL_C
-# define BN_S_MP_TOOM_MUL_C
# define BN_S_MP_KARATSUBA_MUL_C
-# define BN_S_MP_MUL_DIGS_FAST_C
# define BN_S_MP_MUL_DIGS_C
+# define BN_S_MP_MUL_DIGS_FAST_C
+# define BN_S_MP_TOOM_MUL_C
#endif
#if defined(BN_MP_MUL_2_C)
@@ -595,40 +623,40 @@
#endif
#if defined(BN_MP_MUL_2D_C)
+# define BN_MP_CLAMP_C
# define BN_MP_COPY_C
# define BN_MP_GROW_C
# define BN_MP_LSHD_C
-# define BN_MP_CLAMP_C
#endif
#if defined(BN_MP_MUL_D_C)
-# define BN_MP_GROW_C
# define BN_MP_CLAMP_C
+# define BN_MP_GROW_C
#endif
#if defined(BN_MP_MULMOD_C)
-# define BN_MP_INIT_SIZE_C
-# define BN_MP_MUL_C
# define BN_MP_CLEAR_C
+# define BN_MP_INIT_SIZE_C
# define BN_MP_MOD_C
+# define BN_MP_MUL_C
#endif
#if defined(BN_MP_N_ROOT_C)
-# define BN_MP_INIT_MULTI_C
-# define BN_MP_COUNT_BITS_C
-# define BN_MP_SET_C
# define BN_MP_2EXPT_C
+# define BN_MP_ADD_D_C
+# define BN_MP_CLEAR_MULTI_C
+# define BN_MP_CMP_C
# define BN_MP_COPY_C
+# define BN_MP_COUNT_BITS_C
+# define BN_MP_DIV_C
+# define BN_MP_EXCH_C
# define BN_MP_EXPT_D_C
+# define BN_MP_INIT_MULTI_C
# define BN_MP_MUL_C
-# define BN_MP_SUB_C
# define BN_MP_MUL_D_C
-# define BN_MP_DIV_C
-# define BN_MP_CMP_C
-# define BN_MP_ADD_D_C
+# define BN_MP_SET_C
+# define BN_MP_SUB_C
# define BN_MP_SUB_D_C
-# define BN_MP_EXCH_C
-# define BN_MP_CLEAR_MULTI_C
#endif
#if defined(BN_MP_NEG_C)
@@ -636,144 +664,144 @@
#endif
#if defined(BN_MP_OR_C)
-# define BN_MP_GROW_C
# define BN_MP_CLAMP_C
+# define BN_MP_GROW_C
#endif
#if defined(BN_MP_PRIME_FERMAT_C)
+# define BN_MP_CLEAR_C
+# define BN_MP_CMP_C
# define BN_MP_CMP_D_C
-# define BN_MP_INIT_C
# define BN_MP_EXPTMOD_C
-# define BN_MP_CMP_C
-# define BN_MP_CLEAR_C
+# define BN_MP_INIT_C
#endif
#if defined(BN_MP_PRIME_FROBENIUS_UNDERWOOD_C)
-# define BN_MP_INIT_MULTI_C
-# define BN_MP_SET_U32_C
-# define BN_MP_SQR_C
-# define BN_MP_SUB_D_C
-# define BN_MP_KRONECKER_C
-# define BN_MP_GCD_C
+# define BN_MP_ADD_C
# define BN_MP_ADD_D_C
-# define BN_MP_SET_C
+# define BN_MP_CLEAR_MULTI_C
+# define BN_MP_CMP_C
# define BN_MP_COUNT_BITS_C
+# define BN_MP_EXCH_C
+# define BN_MP_GCD_C
+# define BN_MP_INIT_MULTI_C
+# define BN_MP_KRONECKER_C
+# define BN_MP_MOD_C
# define BN_MP_MUL_2_C
-# define BN_MP_MUL_D_C
-# define BN_MP_ADD_C
# define BN_MP_MUL_C
+# define BN_MP_MUL_D_C
+# define BN_MP_SET_C
+# define BN_MP_SET_U32_C
+# define BN_MP_SQR_C
# define BN_MP_SUB_C
-# define BN_MP_MOD_C
+# define BN_MP_SUB_D_C
# define BN_S_MP_GET_BIT_C
-# define BN_MP_EXCH_C
-# define BN_MP_CMP_C
-# define BN_MP_CLEAR_MULTI_C
#endif
#if defined(BN_MP_PRIME_IS_PRIME_C)
-# define BN_MP_IS_SQUARE_C
+# define BN_MP_CLEAR_C
+# define BN_MP_CMP_C
# define BN_MP_CMP_D_C
-# define BN_S_MP_PRIME_IS_DIVISIBLE_C
+# define BN_MP_COUNT_BITS_C
+# define BN_MP_DIV_2D_C
# define BN_MP_INIT_SET_C
+# define BN_MP_IS_SQUARE_C
# define BN_MP_PRIME_MILLER_RABIN_C
-# define BN_MP_PRIME_FROBENIUS_UNDERWOOD_C
# define BN_MP_PRIME_STRONG_LUCAS_SELFRIDGE_C
+# define BN_MP_RAND_C
# define BN_MP_READ_RADIX_C
-# define BN_MP_CMP_C
# define BN_MP_SET_C
-# define BN_MP_COUNT_BITS_C
-# define BN_MP_RAND_C
-# define BN_MP_DIV_2D_C
-# define BN_MP_CLEAR_C
+# define BN_S_MP_PRIME_IS_DIVISIBLE_C
#endif
#if defined(BN_MP_PRIME_MILLER_RABIN_C)
+# define BN_MP_CLEAR_C
+# define BN_MP_CMP_C
# define BN_MP_CMP_D_C
-# define BN_MP_INIT_COPY_C
-# define BN_MP_SUB_D_C
# define BN_MP_CNT_LSB_C
# define BN_MP_DIV_2D_C
# define BN_MP_EXPTMOD_C
-# define BN_MP_CMP_C
+# define BN_MP_INIT_C
+# define BN_MP_INIT_COPY_C
# define BN_MP_SQRMOD_C
-# define BN_MP_CLEAR_C
+# define BN_MP_SUB_D_C
#endif
#if defined(BN_MP_PRIME_NEXT_PRIME_C)
+# define BN_MP_ADD_D_C
+# define BN_MP_CLEAR_C
# define BN_MP_CMP_D_C
-# define BN_MP_SET_C
-# define BN_MP_SUB_D_C
-# define BN_MP_MOD_D_C
# define BN_MP_INIT_C
-# define BN_MP_ADD_D_C
+# define BN_MP_MOD_D_C
# define BN_MP_PRIME_IS_PRIME_C
-# define BN_MP_CLEAR_C
+# define BN_MP_SET_C
+# define BN_MP_SUB_D_C
#endif
#if defined(BN_MP_PRIME_RABIN_MILLER_TRIALS_C)
#endif
#if defined(BN_MP_PRIME_RAND_C)
-# define BN_S_MP_PRIME_RANDOM_EX_C
-# define BN_MP_READ_UNSIGNED_BIN_C
-# define BN_MP_PRIME_IS_PRIME_C
-# define BN_MP_SUB_D_C
+# define BN_MP_ADD_D_C
# define BN_MP_DIV_2_C
# define BN_MP_MUL_2_C
-# define BN_MP_ADD_D_C
+# define BN_MP_PRIME_IS_PRIME_C
+# define BN_MP_READ_UNSIGNED_BIN_C
+# define BN_MP_SUB_D_C
+# define BN_S_MP_PRIME_RANDOM_EX_C
# define BN_S_MP_RAND_CB_C
# define BN_S_MP_RAND_SOURCE_C
#endif
#if defined(BN_MP_PRIME_STRONG_LUCAS_SELFRIDGE_C)
-# define BN_S_MP_MUL_SI_C
-# define BN_MP_INIT_C
-# define BN_MP_SET_I32_C
-# define BN_MP_MUL_C
+# define BN_MP_ADD_C
+# define BN_MP_ADD_D_C
# define BN_MP_CLEAR_C
-# define BN_MP_INIT_MULTI_C
-# define BN_MP_SET_U32_C
-# define BN_MP_GCD_C
-# define BN_MP_CMP_D_C
+# define BN_MP_CLEAR_MULTI_C
# define BN_MP_CMP_C
-# define BN_MP_KRONECKER_C
-# define BN_MP_ADD_D_C
+# define BN_MP_CMP_D_C
# define BN_MP_CNT_LSB_C
-# define BN_MP_DIV_2D_C
-# define BN_MP_SET_C
-# define BN_MP_MUL_2_C
# define BN_MP_COUNT_BITS_C
+# define BN_MP_DIV_2D_C
+# define BN_MP_DIV_2_C
+# define BN_MP_GCD_C
+# define BN_MP_INIT_C
+# define BN_MP_INIT_MULTI_C
+# define BN_MP_KRONECKER_C
# define BN_MP_MOD_C
+# define BN_MP_MUL_2_C
+# define BN_MP_MUL_C
+# define BN_MP_SET_C
+# define BN_MP_SET_I32_C
+# define BN_MP_SET_U32_C
# define BN_MP_SQR_C
# define BN_MP_SUB_C
-# define BN_S_MP_GET_BIT_C
-# define BN_MP_ADD_C
-# define BN_MP_DIV_2_C
# define BN_MP_SUB_D_C
-# define BN_MP_CLEAR_MULTI_C
+# define BN_S_MP_GET_BIT_C
+# define BN_S_MP_MUL_SI_C
#endif
#if defined(BN_MP_RADIX_SIZE_C)
+# define BN_MP_CLEAR_C
# define BN_MP_COUNT_BITS_C
-# define BN_MP_INIT_COPY_C
# define BN_MP_DIV_D_C
-# define BN_MP_CLEAR_C
+# define BN_MP_INIT_COPY_C
#endif
#if defined(BN_MP_RADIX_SMAP_C)
#endif
#if defined(BN_MP_RAND_C)
+# define BN_MP_GROW_C
# define BN_MP_RAND_SOURCE_C
# define BN_MP_ZERO_C
-# define BN_MP_GROW_C
# define BN_S_MP_RAND_SOURCE_C
#endif
#if defined(BN_MP_READ_RADIX_C)
-# define BN_MP_ZERO_C
-# define BN_MP_MUL_D_C
# define BN_MP_ADD_D_C
+# define BN_MP_MUL_D_C
+# define BN_MP_ZERO_C
#endif
#if defined(BN_MP_READ_SIGNED_BIN_C)
@@ -781,66 +809,65 @@
#endif
#if defined(BN_MP_READ_UNSIGNED_BIN_C)
+# define BN_MP_CLAMP_C
# define BN_MP_GROW_C
-# define BN_MP_ZERO_C
# define BN_MP_MUL_2D_C
-# define BN_MP_CLAMP_C
+# define BN_MP_ZERO_C
#endif
#if defined(BN_MP_REDUCE_C)
+# define BN_MP_ADD_C
+# define BN_MP_CLEAR_C
+# define BN_MP_CMP_C
+# define BN_MP_CMP_D_C
# define BN_MP_INIT_COPY_C
-# define BN_MP_RSHD_C
-# define BN_MP_MUL_C
-# define BN_S_MP_MUL_HIGH_DIGS_C
-# define BN_S_MP_MUL_HIGH_DIGS_FAST_C
+# define BN_MP_LSHD_C
# define BN_MP_MOD_2D_C
-# define BN_S_MP_MUL_DIGS_C
-# define BN_MP_SUB_C
-# define BN_MP_CMP_D_C
+# define BN_MP_MUL_C
+# define BN_MP_RSHD_C
# define BN_MP_SET_C
-# define BN_MP_LSHD_C
-# define BN_MP_ADD_C
-# define BN_MP_CMP_C
+# define BN_MP_SUB_C
+# define BN_S_MP_MUL_DIGS_C
+# define BN_S_MP_MUL_HIGH_DIGS_C
# define BN_S_MP_SUB_C
-# define BN_MP_CLEAR_C
#endif
#if defined(BN_MP_REDUCE_2K_C)
-# define BN_MP_INIT_C
+# define BN_MP_CLEAR_C
+# define BN_MP_CMP_MAG_C
# define BN_MP_COUNT_BITS_C
# define BN_MP_DIV_2D_C
+# define BN_MP_INIT_C
# define BN_MP_MUL_D_C
# define BN_S_MP_ADD_C
-# define BN_MP_CMP_MAG_C
# define BN_S_MP_SUB_C
-# define BN_MP_CLEAR_C
#endif
#if defined(BN_MP_REDUCE_2K_L_C)
-# define BN_MP_INIT_C
+# define BN_MP_CLEAR_C
+# define BN_MP_CMP_MAG_C
# define BN_MP_COUNT_BITS_C
# define BN_MP_DIV_2D_C
+# define BN_MP_INIT_C
# define BN_MP_MUL_C
# define BN_S_MP_ADD_C
-# define BN_MP_CMP_MAG_C
# define BN_S_MP_SUB_C
-# define BN_MP_CLEAR_C
#endif
#if defined(BN_MP_REDUCE_2K_SETUP_C)
-# define BN_MP_INIT_C
-# define BN_MP_COUNT_BITS_C
# define BN_MP_2EXPT_C
# define BN_MP_CLEAR_C
+# define BN_MP_COUNT_BITS_C
+# define BN_MP_INIT_C
# define BN_S_MP_SUB_C
#endif
#if defined(BN_MP_REDUCE_2K_SETUP_L_C)
-# define BN_MP_INIT_C
# define BN_MP_2EXPT_C
+# define BN_MP_CLEAR_C
# define BN_MP_COUNT_BITS_C
+# define BN_MP_INIT_C
# define BN_S_MP_SUB_C
-# define BN_MP_CLEAR_C
#endif
#if defined(BN_MP_REDUCE_IS_2K_C)
@@ -863,9 +890,23 @@
#endif
#if defined(BN_MP_SET_DOUBLE_C)
-# define BN_MP_SET_U64_C
# define BN_MP_DIV_2D_C
# define BN_MP_MUL_2D_C
+# define BN_MP_SET_U64_C
+#endif
+
+#if defined(BN_MP_SET_I32_C)
+# define BN_MP_SET_U32_C
+#endif
+
+#if defined(BN_MP_SET_I64_C)
+# define BN_MP_SET_U64_C
+#endif
+
+#if defined(BN_MP_SET_U32_C)
+#endif
+
+#if defined(BN_MP_SET_U64_C)
#endif
#if defined(BN_MP_SHRINK_C)
@@ -876,72 +917,73 @@
#endif
#if defined(BN_MP_SIGNED_RSH_C)
-# define BN_MP_DIV_2D_C
# define BN_MP_ADD_D_C
+# define BN_MP_DIV_2D_C
# define BN_MP_SUB_D_C
#endif
#if defined(BN_MP_SQR_C)
-# define BN_S_MP_TOOM_SQR_C
# define BN_S_MP_KARATSUBA_SQR_C
-# define BN_S_MP_SQR_FAST_C
# define BN_S_MP_SQR_C
+# define BN_S_MP_SQR_FAST_C
+# define BN_S_MP_TOOM_SQR_C
#endif
#if defined(BN_MP_SQRMOD_C)
-# define BN_MP_INIT_C
-# define BN_MP_SQR_C
# define BN_MP_CLEAR_C
+# define BN_MP_INIT_C
# define BN_MP_MOD_C
+# define BN_MP_SQR_C
#endif
#if defined(BN_MP_SQRT_C)
-# define BN_MP_ZERO_C
-# define BN_MP_INIT_COPY_C
-# define BN_MP_RSHD_C
-# define BN_MP_DIV_C
# define BN_MP_ADD_C
-# define BN_MP_DIV_2_C
+# define BN_MP_CLEAR_C
# define BN_MP_CMP_MAG_C
+# define BN_MP_DIV_2_C
+# define BN_MP_DIV_C
# define BN_MP_EXCH_C
-# define BN_MP_CLEAR_C
+# define BN_MP_INIT_C
+# define BN_MP_INIT_COPY_C
+# define BN_MP_RSHD_C
+# define BN_MP_ZERO_C
#endif
#if defined(BN_MP_SQRTMOD_PRIME_C)
-# define BN_MP_CMP_D_C
-# define BN_MP_ZERO_C
-# define BN_MP_KRONECKER_C
-# define BN_MP_INIT_MULTI_C
-# define BN_MP_MOD_D_C
# define BN_MP_ADD_D_C
+# define BN_MP_CLEAR_MULTI_C
+# define BN_MP_CMP_D_C
+# define BN_MP_COPY_C
# define BN_MP_DIV_2_C
# define BN_MP_EXPTMOD_C
-# define BN_MP_COPY_C
-# define BN_MP_SUB_D_C
-# define BN_MP_SET_U32_C
-# define BN_MP_SQRMOD_C
+# define BN_MP_INIT_MULTI_C
+# define BN_MP_KRONECKER_C
+# define BN_MP_MOD_D_C
# define BN_MP_MULMOD_C
# define BN_MP_SET_C
-# define BN_MP_CLEAR_MULTI_C
+# define BN_MP_SET_U32_C
+# define BN_MP_SQRMOD_C
+# define BN_MP_SUB_D_C
+# define BN_MP_ZERO_C
#endif
#if defined(BN_MP_SUB_C)
-# define BN_S_MP_ADD_C
# define BN_MP_CMP_MAG_C
+# define BN_S_MP_ADD_C
# define BN_S_MP_SUB_C
#endif
#if defined(BN_MP_SUB_D_C)
-# define BN_MP_GROW_C
# define BN_MP_ADD_D_C
# define BN_MP_CLAMP_C
+# define BN_MP_GROW_C
#endif
#if defined(BN_MP_SUBMOD_C)
-# define BN_MP_INIT_C
-# define BN_MP_SUB_C
# define BN_MP_CLEAR_C
+# define BN_MP_INIT_C
# define BN_MP_MOD_C
+# define BN_MP_SUB_C
#endif
#if defined(BN_MP_TO_SIGNED_BIN_C)
@@ -954,28 +996,28 @@
#endif
#if defined(BN_MP_TO_UNSIGNED_BIN_C)
-# define BN_MP_INIT_COPY_C
-# define BN_MP_DIV_2D_C
# define BN_MP_CLEAR_C
+# define BN_MP_DIV_2D_C
+# define BN_MP_INIT_COPY_C
# define BN_S_MP_REVERSE_C
#endif
#if defined(BN_MP_TO_UNSIGNED_BIN_N_C)
-# define BN_MP_UNSIGNED_BIN_SIZE_C
# define BN_MP_TO_UNSIGNED_BIN_C
+# define BN_MP_UNSIGNED_BIN_SIZE_C
#endif
#if defined(BN_MP_TORADIX_C)
-# define BN_MP_INIT_COPY_C
-# define BN_MP_DIV_D_C
# define BN_MP_CLEAR_C
+# define BN_MP_DIV_D_C
+# define BN_MP_INIT_COPY_C
# define BN_S_MP_REVERSE_C
#endif
#if defined(BN_MP_TORADIX_N_C)
-# define BN_MP_INIT_COPY_C
-# define BN_MP_DIV_D_C
# define BN_MP_CLEAR_C
+# define BN_MP_DIV_D_C
+# define BN_MP_INIT_COPY_C
# define BN_S_MP_REVERSE_C
#endif
@@ -984,8 +1026,8 @@
#endif
#if defined(BN_MP_XOR_C)
-# define BN_MP_GROW_C
# define BN_MP_CLAMP_C
+# define BN_MP_GROW_C
#endif
#if defined(BN_MP_ZERO_C)
@@ -995,138 +1037,138 @@
#endif
#if defined(BN_S_MP_ADD_C)
-# define BN_MP_GROW_C
# define BN_MP_CLAMP_C
+# define BN_MP_GROW_C
#endif
#if defined(BN_S_MP_BALANCE_MUL_C)
-# define BN_MP_INIT_SIZE_C
-# define BN_MP_INIT_MULTI_C
-# define BN_MP_CLEAR_C
-# define BN_MP_MUL_C
-# define BN_MP_LSHD_C
# define BN_MP_ADD_C
-# define BN_MP_EXCH_C
+# define BN_MP_CLEAR_C
# define BN_MP_CLEAR_MULTI_C
+# define BN_MP_EXCH_C
+# define BN_MP_INIT_MULTI_C
+# define BN_MP_INIT_SIZE_C
+# define BN_MP_LSHD_C
+# define BN_MP_MUL_C
#endif
#if defined(BN_S_MP_EXPTMOD_C)
+# define BN_MP_CLEAR_C
+# define BN_MP_COPY_C
# define BN_MP_COUNT_BITS_C
+# define BN_MP_EXCH_C
# define BN_MP_INIT_C
-# define BN_MP_CLEAR_C
-# define BN_MP_REDUCE_SETUP_C
-# define BN_MP_REDUCE_2K_SETUP_L_C
# define BN_MP_MOD_C
-# define BN_MP_COPY_C
-# define BN_MP_SQR_C
# define BN_MP_MUL_C
+# define BN_MP_REDUCE_2K_SETUP_L_C
+# define BN_MP_REDUCE_SETUP_C
# define BN_MP_SET_C
-# define BN_MP_EXCH_C
+# define BN_MP_SQR_C
#endif
#if defined(BN_S_MP_EXPTMOD_FAST_C)
-# define BN_MP_COUNT_BITS_C
-# define BN_MP_INIT_SIZE_C
# define BN_MP_CLEAR_C
-# define BN_MP_MONTGOMERY_SETUP_C
+# define BN_MP_COPY_C
+# define BN_MP_COUNT_BITS_C
# define BN_MP_DR_SETUP_C
-# define BN_MP_REDUCE_2K_SETUP_C
+# define BN_MP_EXCH_C
+# define BN_MP_INIT_SIZE_C
+# define BN_MP_MOD_C
# define BN_MP_MONTGOMERY_CALC_NORMALIZATION_C
+# define BN_MP_MONTGOMERY_SETUP_C
# define BN_MP_MULMOD_C
+# define BN_MP_MUL_C
+# define BN_MP_REDUCE_2K_SETUP_C
# define BN_MP_SET_C
-# define BN_MP_MOD_C
-# define BN_MP_COPY_C
# define BN_MP_SQR_C
-# define BN_MP_MUL_C
-# define BN_MP_EXCH_C
#endif
#if defined(BN_S_MP_GET_BIT_C)
#endif
#if defined(BN_S_MP_INVMOD_FAST_C)
-# define BN_MP_INIT_MULTI_C
-# define BN_MP_COPY_C
-# define BN_MP_MOD_C
-# define BN_MP_SET_C
-# define BN_MP_DIV_2_C
-# define BN_MP_SUB_C
+# define BN_MP_ADD_C
+# define BN_MP_CLEAR_MULTI_C
# define BN_MP_CMP_C
# define BN_MP_CMP_D_C
-# define BN_MP_ADD_C
# define BN_MP_CMP_MAG_C
+# define BN_MP_COPY_C
+# define BN_MP_DIV_2_C
# define BN_MP_EXCH_C
-# define BN_MP_CLEAR_MULTI_C
-#endif
-
-#if defined(BN_S_MP_INVMOD_SLOW_C)
# define BN_MP_INIT_MULTI_C
# define BN_MP_MOD_C
-# define BN_MP_COPY_C
# define BN_MP_SET_C
-# define BN_MP_DIV_2_C
-# define BN_MP_ADD_C
# define BN_MP_SUB_C
+#endif
+
+#if defined(BN_S_MP_INVMOD_SLOW_C)
+# define BN_MP_ADD_C
+# define BN_MP_CLEAR_MULTI_C
# define BN_MP_CMP_C
# define BN_MP_CMP_D_C
# define BN_MP_CMP_MAG_C
+# define BN_MP_COPY_C
+# define BN_MP_DIV_2_C
# define BN_MP_EXCH_C
-# define BN_MP_CLEAR_MULTI_C
+# define BN_MP_INIT_MULTI_C
+# define BN_MP_MOD_C
+# define BN_MP_SET_C
+# define BN_MP_SUB_C
#endif
#if defined(BN_S_MP_KARATSUBA_MUL_C)
-# define BN_MP_INIT_SIZE_C
+# define BN_MP_ADD_C
# define BN_MP_CLAMP_C
+# define BN_MP_CLEAR_C
+# define BN_MP_INIT_SIZE_C
+# define BN_MP_LSHD_C
# define BN_MP_MUL_C
# define BN_S_MP_ADD_C
-# define BN_MP_ADD_C
# define BN_S_MP_SUB_C
-# define BN_MP_LSHD_C
-# define BN_MP_CLEAR_C
#endif
#if defined(BN_S_MP_KARATSUBA_SQR_C)
-# define BN_MP_INIT_SIZE_C
+# define BN_MP_ADD_C
# define BN_MP_CLAMP_C
+# define BN_MP_CLEAR_C
+# define BN_MP_INIT_SIZE_C
+# define BN_MP_LSHD_C
# define BN_MP_SQR_C
# define BN_S_MP_ADD_C
# define BN_S_MP_SUB_C
-# define BN_MP_LSHD_C
-# define BN_MP_ADD_C
-# define BN_MP_CLEAR_C
#endif
#if defined(BN_S_MP_MONTGOMERY_REDUCE_FAST_C)
-# define BN_MP_GROW_C
# define BN_MP_CLAMP_C
# define BN_MP_CMP_MAG_C
+# define BN_MP_GROW_C
# define BN_S_MP_SUB_C
#endif
#if defined(BN_S_MP_MUL_DIGS_C)
-# define BN_S_MP_MUL_DIGS_FAST_C
-# define BN_MP_INIT_SIZE_C
# define BN_MP_CLAMP_C
-# define BN_MP_EXCH_C
# define BN_MP_CLEAR_C
+# define BN_MP_EXCH_C
+# define BN_MP_INIT_SIZE_C
+# define BN_S_MP_MUL_DIGS_FAST_C
#endif
#if defined(BN_S_MP_MUL_DIGS_FAST_C)
-# define BN_MP_GROW_C
# define BN_MP_CLAMP_C
+# define BN_MP_GROW_C
#endif
#if defined(BN_S_MP_MUL_HIGH_DIGS_C)
-# define BN_S_MP_MUL_HIGH_DIGS_FAST_C
-# define BN_MP_INIT_SIZE_C
# define BN_MP_CLAMP_C
-# define BN_MP_EXCH_C
# define BN_MP_CLEAR_C
+# define BN_MP_EXCH_C
+# define BN_MP_INIT_SIZE_C
+# define BN_S_MP_MUL_HIGH_DIGS_FAST_C
#endif
#if defined(BN_S_MP_MUL_HIGH_DIGS_FAST_C)
-# define BN_MP_GROW_C
# define BN_MP_CLAMP_C
+# define BN_MP_GROW_C
#endif
#if defined(BN_S_MP_PRIME_IS_DIVISIBLE_C)
@@ -1144,51 +1186,53 @@
#endif
#if defined(BN_S_MP_SQR_C)
-# define BN_MP_INIT_SIZE_C
# define BN_MP_CLAMP_C
-# define BN_MP_EXCH_C
# define BN_MP_CLEAR_C
+# define BN_MP_EXCH_C
+# define BN_MP_INIT_SIZE_C
#endif
#if defined(BN_S_MP_SQR_FAST_C)
-# define BN_MP_GROW_C
# define BN_MP_CLAMP_C
+# define BN_MP_GROW_C
#endif
#if defined(BN_S_MP_SUB_C)
-# define BN_MP_GROW_C
# define BN_MP_CLAMP_C
+# define BN_MP_GROW_C
#endif
#if defined(BN_S_MP_TOOM_MUL_C)
+# define BN_MP_ADD_C
+# define BN_MP_CLAMP_C
+# define BN_MP_CLEAR_C
+# define BN_MP_CLEAR_MULTI_C
+# define BN_MP_DIV_2_C
+# define BN_MP_DIV_3_C
# define BN_MP_INIT_MULTI_C
# define BN_MP_INIT_SIZE_C
-# define BN_MP_CLAMP_C
-# define BN_MP_ADD_C
-# define BN_MP_MUL_C
+# define BN_MP_LSHD_C
# define BN_MP_MUL_2_C
+# define BN_MP_MUL_C
# define BN_MP_SUB_C
-# define BN_MP_DIV_3_C
-# define BN_MP_DIV_2_C
-# define BN_MP_LSHD_C
-# define BN_MP_CLEAR_C
-# define BN_MP_CLEAR_MULTI_C
#endif
#if defined(BN_S_MP_TOOM_SQR_C)
+# define BN_MP_ADD_C
+# define BN_MP_CLAMP_C
+# define BN_MP_CLEAR_C
+# define BN_MP_DIV_2_C
# define BN_MP_INIT_C
# define BN_MP_INIT_SIZE_C
-# define BN_MP_CLAMP_C
+# define BN_MP_LSHD_C
+# define BN_MP_MUL_2_C
+# define BN_MP_MUL_C
# define BN_MP_SQR_C
-# define BN_MP_ADD_C
# define BN_MP_SUB_C
-# define BN_MP_MUL_C
-# define BN_MP_MUL_2_C
-# define BN_MP_DIV_2_C
-# define BN_MP_LSHD_C
-# define BN_MP_CLEAR_C
#endif
+#ifdef LTM_INSIDE
+#undef LTM_INSIDE
#ifdef LTM3
# define LTM_LAST
#endif
diff --git a/tommath_private.h b/tommath_private.h
index afe01de7b..ad59c0493 100644
--- a/tommath_private.h
+++ b/tommath_private.h
@@ -169,7 +169,7 @@ typedef private_mp_word mp_word;
#endif
/* Minimum number of available digits in mp_int, MP_PREC >= MP_MIN_PREC */
-#define MP_MIN_PREC ((((CHAR_BIT * (int)sizeof(long long)) + MP_DIGIT_BIT) - 1) / MP_DIGIT_BIT)
+#define MP_MIN_PREC ((((int)MP_SIZEOF_BITS(long long) + MP_DIGIT_BIT) - 1) / MP_DIGIT_BIT)
MP_STATIC_ASSERT(prec_geq_min_prec, MP_PREC >= MP_MIN_PREC)
@@ -231,4 +231,57 @@ MP_DEPRECATED(s_mp_toom_mul) mp_err mp_toom_mul(const mp_int *a, const mp_int *b
MP_DEPRECATED(s_mp_toom_sqr) mp_err mp_toom_sqr(const mp_int *a, mp_int *b);
MP_DEPRECATED(s_mp_reverse) void bn_reverse(unsigned char *s, int len);
+/* code-generating macros */
+#define MP_SET_UNSIGNED(name, type) \
+ void name(mp_int * a, type b) \
+ { \
+ int i = 0; \
+ while (b != 0u) { \
+ a->dp[i++] = ((mp_digit)b & MP_MASK); \
+ if (MP_SIZEOF_BITS(type) <= MP_DIGIT_BIT) { break; } \
+ b >>= ((MP_SIZEOF_BITS(type) <= MP_DIGIT_BIT) ? 0 : MP_DIGIT_BIT); \
+ } \
+ a->used = i; \
+ a->sign = MP_ZPOS; \
+ MP_ZERO_DIGITS(a->dp + a->used, a->alloc - a->used); \
+ }
+
+#define MP_SET_SIGNED(name, uname, type, utype) \
+ void name(mp_int * a, type b) \
+ { \
+ uname(a, (b < 0) ? -(utype)b : (utype)b); \
+ if (b < 0) { a->sign = MP_NEG; } \
+ }
+
+#define MP_INIT_INT(name , set, type) \
+ mp_err name(mp_int * a, type b) \
+ { \
+ mp_err err; \
+ if ((err = mp_init(a)) != MP_OKAY) { \
+ return err; \
+ } \
+ set(a, b); \
+ return MP_OKAY; \
+ }
+
+#define MP_GET_MAG(type, name) \
+ 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)); \
+ type res = 0u; \
+ while (i --> 0u) { \
+ res <<= ((MP_SIZEOF_BITS(type) <= MP_DIGIT_BIT) ? 0 : MP_DIGIT_BIT); \
+ res |= (type)a->dp[i]; \
+ if (MP_SIZEOF_BITS(type) <= MP_DIGIT_BIT) { break; } \
+ } \
+ return res; \
+ }
+
+#define MP_GET_SIGNED(type, name, mag) \
+ type name(const mp_int* a) \
+ { \
+ uint64_t res = mag(a); \
+ return (a->sign == MP_NEG) ? (type)-res : (type)res; \
+ }
+
#endif