aboutsummaryrefslogtreecommitdiffstats
path: root/modules/alg_ia32
diff options
context:
space:
mode:
authorlloyd <[email protected]>2006-08-19 12:23:50 +0000
committerlloyd <[email protected]>2006-08-19 12:23:50 +0000
commitd6ff613df191d078ecb3175a20710d013bcfd3a5 (patch)
treef6a8e546068141298b71470a4fcaaced3e7b12fc /modules/alg_ia32
parent3dbff1820b79f8bf2a9ade41d2f30e73ce8d9f90 (diff)
Move Montgomery reduction algorithm into mp_asm.cpp
Move the inner-most loop of Montgomery into bigint_mul_add_words, in mp_muladd.cpp Use bigint_mul_add_words for the inner loop of bigint_simple_multiply Move the compare/subtract at the end of the Montomgery algorithm into bigint_monty_redc
Diffstat (limited to 'modules/alg_ia32')
-rw-r--r--modules/alg_ia32/modinfo.txt2
-rw-r--r--modules/alg_ia32/mp_monty.cpp44
2 files changed, 1 insertions, 45 deletions
diff --git a/modules/alg_ia32/modinfo.txt b/modules/alg_ia32/modinfo.txt
index 285137fda..ccba743e3 100644
--- a/modules/alg_ia32/modinfo.txt
+++ b/modules/alg_ia32/modinfo.txt
@@ -4,7 +4,7 @@ replace_file md4.cpp
replace_file md5.cpp
replace_file sha160.cpp
replace_file serpent.cpp
-replace_file mp_monty.cpp
+ignore_file mp_mulladd.cpp
add_file asm_macr.h
diff --git a/modules/alg_ia32/mp_monty.cpp b/modules/alg_ia32/mp_monty.cpp
deleted file mode 100644
index 90bf71e56..000000000
--- a/modules/alg_ia32/mp_monty.cpp
+++ /dev/null
@@ -1,44 +0,0 @@
-/*************************************************
-* Montgomery Reduction Source File *
-* (C) 1999-2006 The Botan Project *
-*************************************************/
-
-#include <botan/mp_asm.h>
-#include <botan/mp_asmi.h>
-#include <botan/mp_core.h>
-
-namespace Botan {
-
-extern "C" word bigint_mul_add_words(word[], const word[], u32bit, word);
-
-extern "C" {
-
-/*************************************************
-* Montgomery Reduction Algorithm *
-*************************************************/
-void bigint_monty_redc(word z[], u32bit z_size,
- const word x[], u32bit x_size, word u)
- {
- for(u32bit j = 0; j != x_size; ++j)
- {
- word* z_j = z + j;
-
- const word y = z_j[0] * u;
-
- word carry = bigint_mul_add_words(z_j, x, x_size, y);
-
- word z_sum = z_j[x_size] + carry;
- carry = (z_sum < z_j[x_size]);
- z_j[x_size] = z_sum;
-
- for(u32bit k = x_size + 1; carry && k != z_size - j; ++k)
- {
- ++z_j[k];
- carry = !z_j[k];
- }
- }
- }
-
-}
-
-}