aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJack Lloyd <[email protected]>2021-05-02 08:53:35 -0400
committerJack Lloyd <[email protected]>2021-05-02 08:53:35 -0400
commitaa4045eb8f45c47a1bc95b9f03e686e4b19b8b5d (patch)
tree0911726d169d1be57556c9bac762bc221ee049c8
parent3e7f9c7c77fb8b2e1bc0bc8fa8a577b20257ce3c (diff)
parent6a50c72370c209fd79d72f22b4304d584a76b1bd (diff)
Merge GH #2734 Some MP header cleanups
-rw-r--r--src/lib/math/bigint/divide.cpp1
-rw-r--r--src/lib/math/mp/info.txt2
-rw-r--r--src/lib/math/mp/mp_asmi.h130
-rw-r--r--src/lib/math/mp/mp_comba.cpp3
-rw-r--r--src/lib/math/mp/mp_core.h55
-rw-r--r--src/lib/math/mp/mp_karat.cpp1
-rw-r--r--src/lib/math/mp/mp_madd.h146
-rw-r--r--src/lib/math/mp/mp_monty.cpp37
-rw-r--r--src/lib/math/mp/mp_monty.h31
-rw-r--r--src/lib/math/mp/mp_monty_n.cpp31
-rw-r--r--src/lib/math/numbertheory/nistp_redc.cpp1
-rw-r--r--src/lib/pubkey/ec_group/curve_gfp.cpp1
-rwxr-xr-xsrc/scripts/comba.py1
-rwxr-xr-xsrc/scripts/monty.py6
14 files changed, 186 insertions, 260 deletions
diff --git a/src/lib/math/bigint/divide.cpp b/src/lib/math/bigint/divide.cpp
index 9b92c9e39..7b7184c0b 100644
--- a/src/lib/math/bigint/divide.cpp
+++ b/src/lib/math/bigint/divide.cpp
@@ -7,7 +7,6 @@
#include <botan/internal/divide.h>
#include <botan/internal/mp_core.h>
-#include <botan/internal/mp_madd.h>
#include <botan/internal/ct_utils.h>
#include <botan/internal/bit_ops.h>
diff --git a/src/lib/math/mp/info.txt b/src/lib/math/mp/info.txt
index cee4325ed..b63fd354e 100644
--- a/src/lib/math/mp/info.txt
+++ b/src/lib/math/mp/info.txt
@@ -4,7 +4,5 @@ BIGINT_MP -> 20151225
<header:internal>
mp_core.h
-mp_madd.h
mp_asmi.h
-mp_monty.h
</header:internal>
diff --git a/src/lib/math/mp/mp_asmi.h b/src/lib/math/mp/mp_asmi.h
index e1518d51c..55a300f60 100644
--- a/src/lib/math/mp/mp_asmi.h
+++ b/src/lib/math/mp/mp_asmi.h
@@ -9,10 +9,138 @@
#ifndef BOTAN_MP_ASM_INTERNAL_H_
#define BOTAN_MP_ASM_INTERNAL_H_
-#include <botan/internal/mp_madd.h>
+#include <botan/types.h>
+#include <botan/internal/mul128.h>
namespace Botan {
+#if (BOTAN_MP_WORD_BITS == 32)
+ typedef uint64_t dword;
+ #define BOTAN_HAS_MP_DWORD
+
+#elif (BOTAN_MP_WORD_BITS == 64)
+ #if defined(BOTAN_TARGET_HAS_NATIVE_UINT128)
+ typedef uint128_t dword;
+ #define BOTAN_HAS_MP_DWORD
+ #else
+ // No native 128 bit integer type; use mul64x64_128 instead
+ #endif
+
+#else
+ #error BOTAN_MP_WORD_BITS must be 32 or 64
+#endif
+
+#if defined(BOTAN_USE_GCC_INLINE_ASM)
+
+ #if defined(BOTAN_TARGET_ARCH_IS_X86_32) && (BOTAN_MP_WORD_BITS == 32)
+ #define BOTAN_MP_USE_X86_32_ASM
+ #elif defined(BOTAN_TARGET_ARCH_IS_X86_64) && (BOTAN_MP_WORD_BITS == 64)
+ #define BOTAN_MP_USE_X86_64_ASM
+ #endif
+
+#endif
+
+/*
+* Word Multiply/Add
+*/
+inline word word_madd2(word a, word b, word* c)
+ {
+#if defined(BOTAN_MP_USE_X86_32_ASM)
+ asm(R"(
+ mull %[b]
+ addl %[c],%[a]
+ adcl $0,%[carry]
+ )"
+ : [a]"=a"(a), [b]"=rm"(b), [carry]"=&d"(*c)
+ : "0"(a), "1"(b), [c]"g"(*c) : "cc");
+
+ return a;
+
+#elif defined(BOTAN_MP_USE_X86_64_ASM)
+ asm(R"(
+ mulq %[b]
+ addq %[c],%[a]
+ adcq $0,%[carry]
+ )"
+ : [a]"=a"(a), [b]"=rm"(b), [carry]"=&d"(*c)
+ : "0"(a), "1"(b), [c]"g"(*c) : "cc");
+
+ return a;
+
+#elif defined(BOTAN_HAS_MP_DWORD)
+ const dword s = static_cast<dword>(a) * b + *c;
+ *c = static_cast<word>(s >> BOTAN_MP_WORD_BITS);
+ return static_cast<word>(s);
+#else
+ static_assert(BOTAN_MP_WORD_BITS == 64, "Unexpected word size");
+
+ word hi = 0, lo = 0;
+
+ mul64x64_128(a, b, &lo, &hi);
+
+ lo += *c;
+ hi += (lo < *c); // carry?
+
+ *c = hi;
+ return lo;
+#endif
+ }
+
+/*
+* Word Multiply/Add
+*/
+inline word word_madd3(word a, word b, word c, word* d)
+ {
+#if defined(BOTAN_MP_USE_X86_32_ASM)
+ asm(R"(
+ mull %[b]
+
+ addl %[c],%[a]
+ adcl $0,%[carry]
+
+ addl %[d],%[a]
+ adcl $0,%[carry]
+ )"
+ : [a]"=a"(a), [b]"=rm"(b), [carry]"=&d"(*d)
+ : "0"(a), "1"(b), [c]"g"(c), [d]"g"(*d) : "cc");
+
+ return a;
+
+#elif defined(BOTAN_MP_USE_X86_64_ASM)
+ asm(R"(
+ mulq %[b]
+ addq %[c],%[a]
+ adcq $0,%[carry]
+ addq %[d],%[a]
+ adcq $0,%[carry]
+ )"
+ : [a]"=a"(a), [b]"=rm"(b), [carry]"=&d"(*d)
+ : "0"(a), "1"(b), [c]"g"(c), [d]"g"(*d) : "cc");
+
+ return a;
+
+#elif defined(BOTAN_HAS_MP_DWORD)
+ const dword s = static_cast<dword>(a) * b + c + *d;
+ *d = static_cast<word>(s >> BOTAN_MP_WORD_BITS);
+ return static_cast<word>(s);
+#else
+ static_assert(BOTAN_MP_WORD_BITS == 64, "Unexpected word size");
+
+ word hi = 0, lo = 0;
+
+ mul64x64_128(a, b, &lo, &hi);
+
+ lo += c;
+ hi += (lo < c); // carry?
+
+ lo += *d;
+ hi += (lo < *d); // carry?
+
+ *d = hi;
+ return lo;
+#endif
+ }
+
#if defined(BOTAN_MP_USE_X86_32_ASM)
#define ADDSUB2_OP(OPERATION, INDEX) \
diff --git a/src/lib/math/mp/mp_comba.cpp b/src/lib/math/mp/mp_comba.cpp
index ec527224c..ff5f3000d 100644
--- a/src/lib/math/mp/mp_comba.cpp
+++ b/src/lib/math/mp/mp_comba.cpp
@@ -1,13 +1,12 @@
/*
* Comba Multiplication and Squaring
*
-* This file was automatically generated by ./src/scripts/comba.py on 2018-05-08
+* This file was automatically generated by ./src/scripts/comba.py on 2021-05-01
*
* Botan is released under the Simplified BSD License (see license.txt)
*/
#include <botan/internal/mp_core.h>
-#include <botan/internal/mp_asmi.h>
namespace Botan {
diff --git a/src/lib/math/mp/mp_core.h b/src/lib/math/mp/mp_core.h
index ad9d19524..0f22a08de 100644
--- a/src/lib/math/mp/mp_core.h
+++ b/src/lib/math/mp/mp_core.h
@@ -784,6 +784,26 @@ void bigint_comba_sqr9(word out[18], const word in[9]);
void bigint_comba_sqr16(word out[32], const word in[16]);
void bigint_comba_sqr24(word out[48], const word in[24]);
+/*
+* Montgomery reduction
+*
+* Each of these functions makes the following assumptions:
+*
+* z_size >= 2*(p_size + 1)
+* ws_size >= z_size
+*/
+void bigint_monty_redc_4(word z[], const word p[], word p_dash, word ws[]);
+void bigint_monty_redc_6(word z[], const word p[], word p_dash, word ws[]);
+void bigint_monty_redc_8(word z[], const word p[], word p_dash, word ws[]);
+void bigint_monty_redc_16(word z[], const word p[], word p_dash, word ws[]);
+void bigint_monty_redc_24(word z[], const word p[], word p_dash, word ws[]);
+void bigint_monty_redc_32(word z[], const word p[], word p_dash, word ws[]);
+
+void bigint_monty_redc_generic(word z[], size_t z_size,
+ const word p[], size_t p_size, word p_dash,
+ word ws[]);
+
+
/**
* Montgomery Reduction
* @param z integer to reduce, of size exactly 2*(p_size+1).
@@ -792,14 +812,35 @@ void bigint_comba_sqr24(word out[48], const word in[24]);
* @param p modulus
* @param p_size size of p
* @param p_dash Montgomery value
-* @param workspace array of at least 2*(p_size+1) words
-* @param ws_size size of workspace in words
+* @param ws array of at least 2*(p_size+1) words
+* @param ws_size size of ws in words
*/
-void bigint_monty_redc(word z[],
- const word p[], size_t p_size,
- word p_dash,
- word workspace[],
- size_t ws_size);
+inline void bigint_monty_redc(word z[],
+ const word p[], size_t p_size,
+ word p_dash,
+ word ws[],
+ size_t ws_size)
+ {
+ const size_t z_size = 2*(p_size+1);
+
+ BOTAN_ARG_CHECK(ws_size >= z_size, "ws too small");
+
+ if(p_size == 4)
+ bigint_monty_redc_4(z, p, p_dash, ws);
+ else if(p_size == 6)
+ bigint_monty_redc_6(z, p, p_dash, ws);
+ else if(p_size == 8)
+ bigint_monty_redc_8(z, p, p_dash, ws);
+ else if(p_size == 16)
+ bigint_monty_redc_16(z, p, p_dash, ws);
+ else if(p_size == 24)
+ bigint_monty_redc_24(z, p, p_dash, ws);
+ else if(p_size == 32)
+ bigint_monty_redc_32(z, p, p_dash, ws);
+ else
+ bigint_monty_redc_generic(z, z_size, p, p_size, p_dash, ws);
+ }
+
/*
* High Level Multiplication/Squaring Interfaces
diff --git a/src/lib/math/mp/mp_karat.cpp b/src/lib/math/mp/mp_karat.cpp
index 15fcafa5b..63885db17 100644
--- a/src/lib/math/mp/mp_karat.cpp
+++ b/src/lib/math/mp/mp_karat.cpp
@@ -7,7 +7,6 @@
*/
#include <botan/internal/mp_core.h>
-#include <botan/internal/mp_asmi.h>
#include <botan/internal/ct_utils.h>
#include <botan/mem_ops.h>
#include <botan/exceptn.h>
diff --git a/src/lib/math/mp/mp_madd.h b/src/lib/math/mp/mp_madd.h
deleted file mode 100644
index b530b74f1..000000000
--- a/src/lib/math/mp/mp_madd.h
+++ /dev/null
@@ -1,146 +0,0 @@
-/*
-* Lowest Level MPI Algorithms
-* (C) 1999-2008,2013 Jack Lloyd
-* 2006 Luca Piccarreta
-*
-* Botan is released under the Simplified BSD License (see license.txt)
-*/
-
-#ifndef BOTAN_MP_WORD_MULADD_H_
-#define BOTAN_MP_WORD_MULADD_H_
-
-#include <botan/types.h>
-#include <botan/internal/mul128.h>
-
-namespace Botan {
-
-#if (BOTAN_MP_WORD_BITS == 32)
- typedef uint64_t dword;
- #define BOTAN_HAS_MP_DWORD
-
-#elif (BOTAN_MP_WORD_BITS == 64)
- #if defined(BOTAN_TARGET_HAS_NATIVE_UINT128)
- typedef uint128_t dword;
- #define BOTAN_HAS_MP_DWORD
- #else
- // No native 128 bit integer type; use mul64x64_128 instead
- #endif
-
-#else
- #error BOTAN_MP_WORD_BITS must be 32 or 64
-#endif
-
-#if defined(BOTAN_USE_GCC_INLINE_ASM)
-
- #if defined(BOTAN_TARGET_ARCH_IS_X86_32) && (BOTAN_MP_WORD_BITS == 32)
- #define BOTAN_MP_USE_X86_32_ASM
- #elif defined(BOTAN_TARGET_ARCH_IS_X86_64) && (BOTAN_MP_WORD_BITS == 64)
- #define BOTAN_MP_USE_X86_64_ASM
- #endif
-
-#endif
-
-/*
-* Word Multiply/Add
-*/
-inline word word_madd2(word a, word b, word* c)
- {
-#if defined(BOTAN_MP_USE_X86_32_ASM)
- asm(R"(
- mull %[b]
- addl %[c],%[a]
- adcl $0,%[carry]
- )"
- : [a]"=a"(a), [b]"=rm"(b), [carry]"=&d"(*c)
- : "0"(a), "1"(b), [c]"g"(*c) : "cc");
-
- return a;
-
-#elif defined(BOTAN_MP_USE_X86_64_ASM)
- asm(R"(
- mulq %[b]
- addq %[c],%[a]
- adcq $0,%[carry]
- )"
- : [a]"=a"(a), [b]"=rm"(b), [carry]"=&d"(*c)
- : "0"(a), "1"(b), [c]"g"(*c) : "cc");
-
- return a;
-
-#elif defined(BOTAN_HAS_MP_DWORD)
- const dword s = static_cast<dword>(a) * b + *c;
- *c = static_cast<word>(s >> BOTAN_MP_WORD_BITS);
- return static_cast<word>(s);
-#else
- static_assert(BOTAN_MP_WORD_BITS == 64, "Unexpected word size");
-
- word hi = 0, lo = 0;
-
- mul64x64_128(a, b, &lo, &hi);
-
- lo += *c;
- hi += (lo < *c); // carry?
-
- *c = hi;
- return lo;
-#endif
- }
-
-/*
-* Word Multiply/Add
-*/
-inline word word_madd3(word a, word b, word c, word* d)
- {
-#if defined(BOTAN_MP_USE_X86_32_ASM)
- asm(R"(
- mull %[b]
-
- addl %[c],%[a]
- adcl $0,%[carry]
-
- addl %[d],%[a]
- adcl $0,%[carry]
- )"
- : [a]"=a"(a), [b]"=rm"(b), [carry]"=&d"(*d)
- : "0"(a), "1"(b), [c]"g"(c), [d]"g"(*d) : "cc");
-
- return a;
-
-#elif defined(BOTAN_MP_USE_X86_64_ASM)
- asm(R"(
- mulq %[b]
- addq %[c],%[a]
- adcq $0,%[carry]
- addq %[d],%[a]
- adcq $0,%[carry]
- )"
- : [a]"=a"(a), [b]"=rm"(b), [carry]"=&d"(*d)
- : "0"(a), "1"(b), [c]"g"(c), [d]"g"(*d) : "cc");
-
- return a;
-
-#elif defined(BOTAN_HAS_MP_DWORD)
- const dword s = static_cast<dword>(a) * b + c + *d;
- *d = static_cast<word>(s >> BOTAN_MP_WORD_BITS);
- return static_cast<word>(s);
-#else
- static_assert(BOTAN_MP_WORD_BITS == 64, "Unexpected word size");
-
- word hi = 0, lo = 0;
-
- mul64x64_128(a, b, &lo, &hi);
-
- lo += c;
- hi += (lo < c); // carry?
-
- lo += *d;
- hi += (lo < *d); // carry?
-
- *d = hi;
- return lo;
-#endif
- }
-
-}
-
-#endif
diff --git a/src/lib/math/mp/mp_monty.cpp b/src/lib/math/mp/mp_monty.cpp
index 433d3ff35..69edc1f22 100644
--- a/src/lib/math/mp/mp_monty.cpp
+++ b/src/lib/math/mp/mp_monty.cpp
@@ -8,17 +8,12 @@
*/
#include <botan/internal/mp_core.h>
-#include <botan/internal/mp_monty.h>
-#include <botan/internal/mp_madd.h>
-#include <botan/internal/mp_asmi.h>
#include <botan/internal/ct_utils.h>
#include <botan/mem_ops.h>
#include <botan/exceptn.h>
namespace Botan {
-namespace {
-
/*
* Montgomery reduction - product scanning form
*
@@ -92,11 +87,7 @@ void bigint_monty_redc_generic(word z[], size_t z_size,
* borrow.
*/
- // word borrow = bigint_sub3(ws + p_size + 1, ws, p_size + 1, p, p_size);
- word borrow = 0;
- for(size_t i = 0; i != p_size; ++i)
- ws[p_size + 1 + i] = word_sub(ws[i], p[i], &borrow);
- ws[2*p_size+1] = word_sub(ws[p_size], 0, &borrow);
+ word borrow = bigint_sub3(ws + p_size + 1, ws, p_size + 1, p, p_size);
BOTAN_DEBUG_ASSERT(borrow == 0 || borrow == 1);
@@ -105,29 +96,3 @@ void bigint_monty_redc_generic(word z[], size_t z_size,
}
}
-
-void bigint_monty_redc(word z[],
- const word p[], size_t p_size, word p_dash,
- word ws[], size_t ws_size)
- {
- const size_t z_size = 2*(p_size+1);
-
- BOTAN_ARG_CHECK(ws_size >= z_size, "workspace too small");
-
- if(p_size == 4)
- bigint_monty_redc_4(z, p, p_dash, ws);
- else if(p_size == 6)
- bigint_monty_redc_6(z, p, p_dash, ws);
- else if(p_size == 8)
- bigint_monty_redc_8(z, p, p_dash, ws);
- else if(p_size == 16)
- bigint_monty_redc_16(z, p, p_dash, ws);
- else if(p_size == 24)
- bigint_monty_redc_24(z, p, p_dash, ws);
- else if(p_size == 32)
- bigint_monty_redc_32(z, p, p_dash, ws);
- else
- bigint_monty_redc_generic(z, z_size, p, p_size, p_dash, ws);
- }
-
-}
diff --git a/src/lib/math/mp/mp_monty.h b/src/lib/math/mp/mp_monty.h
deleted file mode 100644
index 7462272d5..000000000
--- a/src/lib/math/mp/mp_monty.h
+++ /dev/null
@@ -1,31 +0,0 @@
-/*
-* (C) 2018 Jack Lloyd
-*
-* Botan is released under the Simplified BSD License (see license.txt)
-*/
-
-#ifndef BOTAN_MP_MONTY_H_
-#define BOTAN_MP_MONTY_H_
-
-#include <botan/types.h>
-
-namespace Botan {
-
-/*
-* Each of these functions makes the following assumptions:
-*
-* z_size >= 2*(p_size + 1)
-* ws_size >= z_size
-*/
-
-void bigint_monty_redc_4(word z[], const word p[], word p_dash, word ws[]);
-void bigint_monty_redc_6(word z[], const word p[], word p_dash, word ws[]);
-void bigint_monty_redc_8(word z[], const word p[], word p_dash, word ws[]);
-void bigint_monty_redc_16(word z[], const word p[], word p_dash, word ws[]);
-void bigint_monty_redc_24(word z[], const word p[], word p_dash, word ws[]);
-void bigint_monty_redc_32(word z[], const word p[], word p_dash, word ws[]);
-
-
-}
-
-#endif
diff --git a/src/lib/math/mp/mp_monty_n.cpp b/src/lib/math/mp/mp_monty_n.cpp
index 0331d4a07..d58889112 100644
--- a/src/lib/math/mp/mp_monty_n.cpp
+++ b/src/lib/math/mp/mp_monty_n.cpp
@@ -1,13 +1,11 @@
/*
-* This file was automatically generated by ./src/scripts/monty.py on 2018-06-11
+* This file was automatically generated by ./src/scripts/monty.py on 2021-05-01
* All manual changes will be lost. Edit the script instead.
*
* Botan is released under the Simplified BSD License (see license.txt)
*/
-#include <botan/internal/mp_monty.h>
#include <botan/internal/mp_core.h>
-#include <botan/internal/mp_asmi.h>
#include <botan/internal/ct_utils.h>
namespace Botan {
@@ -58,12 +56,7 @@ void bigint_monty_redc_4(word z[], const word p[4], word p_dash, word ws[])
word3_add(&w2, &w1, &w0, z[9]);
ws[4] = w0;
ws[5] = w1;
- word borrow = 0;
- ws[5] = word_sub(ws[0], p[0], &borrow);
- ws[6] = word_sub(ws[1], p[1], &borrow);
- ws[7] = word_sub(ws[2], p[2], &borrow);
- ws[8] = word_sub(ws[3], p[3], &borrow);
- ws[9] = word_sub(ws[4], 0, &borrow);
+ word borrow = bigint_sub3(ws + 4 + 1, ws, 4 + 1, p, 4);
CT::conditional_copy_mem(borrow, z, ws, ws + 5, 5);
clear_mem(z + 4, 2*(4+1) - 4);
}
@@ -146,14 +139,7 @@ void bigint_monty_redc_6(word z[], const word p[6], word p_dash, word ws[])
word3_add(&w2, &w1, &w0, z[13]);
ws[6] = w0;
ws[7] = w1;
- word borrow = 0;
- ws[7] = word_sub(ws[0], p[0], &borrow);
- ws[8] = word_sub(ws[1], p[1], &borrow);
- ws[9] = word_sub(ws[2], p[2], &borrow);
- ws[10] = word_sub(ws[3], p[3], &borrow);
- ws[11] = word_sub(ws[4], p[4], &borrow);
- ws[12] = word_sub(ws[5], p[5], &borrow);
- ws[13] = word_sub(ws[6], 0, &borrow);
+ word borrow = bigint_sub3(ws + 6 + 1, ws, 6 + 1, p, 6);
CT::conditional_copy_mem(borrow, z, ws, ws + 7, 7);
clear_mem(z + 6, 2*(6+1) - 6);
}
@@ -276,16 +262,7 @@ void bigint_monty_redc_8(word z[], const word p[8], word p_dash, word ws[])
word3_add(&w2, &w1, &w0, z[17]);
ws[8] = w0;
ws[9] = w1;
- word borrow = 0;
- ws[9] = word_sub(ws[0], p[0], &borrow);
- ws[10] = word_sub(ws[1], p[1], &borrow);
- ws[11] = word_sub(ws[2], p[2], &borrow);
- ws[12] = word_sub(ws[3], p[3], &borrow);
- ws[13] = word_sub(ws[4], p[4], &borrow);
- ws[14] = word_sub(ws[5], p[5], &borrow);
- ws[15] = word_sub(ws[6], p[6], &borrow);
- ws[16] = word_sub(ws[7], p[7], &borrow);
- ws[17] = word_sub(ws[8], 0, &borrow);
+ word borrow = bigint_sub3(ws + 8 + 1, ws, 8 + 1, p, 8);
CT::conditional_copy_mem(borrow, z, ws, ws + 9, 9);
clear_mem(z + 8, 2*(8+1) - 8);
}
diff --git a/src/lib/math/numbertheory/nistp_redc.cpp b/src/lib/math/numbertheory/nistp_redc.cpp
index 0f570d763..4ebe88250 100644
--- a/src/lib/math/numbertheory/nistp_redc.cpp
+++ b/src/lib/math/numbertheory/nistp_redc.cpp
@@ -7,7 +7,6 @@
#include <botan/internal/curve_nistp.h>
#include <botan/internal/mp_core.h>
-#include <botan/internal/mp_asmi.h>
#include <botan/internal/ct_utils.h>
namespace Botan {
diff --git a/src/lib/pubkey/ec_group/curve_gfp.cpp b/src/lib/pubkey/ec_group/curve_gfp.cpp
index e2409ba43..44bd69fe6 100644
--- a/src/lib/pubkey/ec_group/curve_gfp.cpp
+++ b/src/lib/pubkey/ec_group/curve_gfp.cpp
@@ -11,7 +11,6 @@
#include <botan/numthry.h>
#include <botan/reducer.h>
#include <botan/internal/mp_core.h>
-#include <botan/internal/mp_asmi.h>
#include <botan/internal/monty.h>
namespace Botan {
diff --git a/src/scripts/comba.py b/src/scripts/comba.py
index 309dca082..c139b8464 100755
--- a/src/scripts/comba.py
+++ b/src/scripts/comba.py
@@ -94,7 +94,6 @@ def main(args = None):
*/
#include <botan/internal/mp_core.h>
-#include <botan/internal/mp_asmi.h>
namespace Botan {
""" % (sys.argv[0], datetime.date.today().strftime("%Y-%m-%d")))
diff --git a/src/scripts/monty.py b/src/scripts/monty.py
index f253da3f6..e08b7203c 100755
--- a/src/scripts/monty.py
+++ b/src/scripts/monty.py
@@ -42,7 +42,9 @@ def monty_redc_code(n):
lines.append("ws[%d] = w0;" % (n))
lines.append("ws[%d] = w1;" % (n+1))
- if n < 16:
+ sub3_bound = 0
+
+ if n >= sub3_bound:
lines.append("word borrow = 0;")
for i in range(n):
lines.append("ws[%d] = word_sub(ws[%d], p[%d], &borrow);" % (n + 1 + i, i, i))
@@ -72,9 +74,7 @@ def main(args = None):
* Botan is released under the Simplified BSD License (see license.txt)
*/
-#include <botan/internal/mp_monty.h>
#include <botan/internal/mp_core.h>
-#include <botan/internal/mp_asmi.h>
#include <botan/internal/ct_utils.h>
namespace Botan {