aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorlloyd <[email protected]>2006-08-19 12:42:23 +0000
committerlloyd <[email protected]>2006-08-19 12:42:23 +0000
commit70db176e715f4fc143ccd1ff75984fdf7c0845cd (patch)
tree792d75d784f60de69e0013856289630c0833a19b
parentf119968c6465a0d1b953e209f6e3db180a46883c (diff)
Move bigint_simple_mul into mp_mul.cpp, since that is the only place it
was used. Make a variant of bigint_simple_mul, bigint_simple_sqr, for mp_sqr.cpp
-rw-r--r--include/mp_core.h2
-rw-r--r--src/mp_asm.cpp12
-rw-r--r--src/mp_mul.cpp12
-rw-r--r--src/mp_sqr.cpp17
4 files changed, 26 insertions, 17 deletions
diff --git a/include/mp_core.h b/include/mp_core.h
index d5e9cbe1b..8062ba845 100644
--- a/include/mp_core.h
+++ b/include/mp_core.h
@@ -44,8 +44,6 @@ word bigint_mul_add_words(word[], const word[], u32bit, word);
void bigint_linmul2(word[], u32bit, word);
void bigint_linmul3(word[], const word[], u32bit, word);
-
-void bigint_simple_mul(word[], const word[], u32bit, const word[], u32bit);
void bigint_linmul_add(word[], u32bit, const word[], u32bit, word);
/*************************************************
diff --git a/src/mp_asm.cpp b/src/mp_asm.cpp
index 88cc8b6e1..64605bb48 100644
--- a/src/mp_asm.cpp
+++ b/src/mp_asm.cpp
@@ -172,18 +172,6 @@ void bigint_linmul3(word z[], const word x[], u32bit x_size, word y)
}
/*************************************************
-* Simple O(N^2) Multiplication *
-*************************************************/
-void bigint_simple_mul(word z[], const word x[], u32bit x_size,
- const word y[], u32bit y_size)
- {
- clear_mem(z, x_size + y_size);
-
- for(u32bit j = 0; j != x_size; ++j)
- z[j+y_size] = bigint_mul_add_words(z + j, y, y_size, x[j]);
- }
-
-/*************************************************
* Montgomery Reduction Algorithm *
*************************************************/
void bigint_monty_redc(word z[], u32bit z_size,
diff --git a/src/mp_mul.cpp b/src/mp_mul.cpp
index ecebf823a..2870846fb 100644
--- a/src/mp_mul.cpp
+++ b/src/mp_mul.cpp
@@ -11,6 +11,18 @@ namespace Botan {
namespace {
/*************************************************
+* Simple O(N^2) Multiplication *
+*************************************************/
+void bigint_simple_mul(word z[], const word x[], u32bit x_size,
+ const word y[], u32bit y_size)
+ {
+ clear_mem(z, x_size + y_size);
+
+ for(u32bit j = 0; j != x_size; ++j)
+ z[j+y_size] = bigint_mul_add_words(z + j, y, y_size, x[j]);
+ }
+
+/*************************************************
* Karatsuba Multiplication Operation *
*************************************************/
void karatsuba_mul(word z[], const word x[], const word y[], u32bit N,
diff --git a/src/mp_sqr.cpp b/src/mp_sqr.cpp
index 934a90c5a..57b4695ee 100644
--- a/src/mp_sqr.cpp
+++ b/src/mp_sqr.cpp
@@ -11,6 +11,17 @@ namespace Botan {
namespace {
/*************************************************
+* Simple O(N^2) Squaring *
+*************************************************/
+void bigint_simple_sqr(word z[], const word x[], u32bit x_size)
+ {
+ clear_mem(z, 2*x_size);
+
+ for(u32bit j = 0; j != x_size; ++j)
+ z[j+x_size] = bigint_mul_add_words(z + j, x, x_size, x[j]);
+ }
+
+/*************************************************
* Karatsuba Squaring Operation *
*************************************************/
void karatsuba_sqr(word z[], const word x[], u32bit N, word workspace[])
@@ -22,7 +33,7 @@ void karatsuba_sqr(word z[], const word x[], u32bit N, word workspace[])
else if(N == 8)
bigint_comba_sqr8(z, x);
else if(N < KARATSUBA_SQR_LOWER_SIZE || N % 2)
- bigint_simple_mul(z, x, N, x, N);
+ bigint_simple_sqr(z, x, N);
else
{
const u32bit N2 = N / 2;
@@ -103,7 +114,7 @@ void handle_small_sqr(word z[], u32bit z_size,
else if(x_sw <= 8 && x_size >= 8 && z_size >= 16)
bigint_comba_sqr8(z, x);
else
- bigint_simple_mul(z, x, x_sw, x, x_sw);
+ bigint_simple_sqr(z, x, x_sw);
}
}
@@ -128,7 +139,7 @@ void bigint_sqr(word z[], u32bit z_size, word workspace[],
karatsuba_sqr(z, x, N, workspace);
}
else
- bigint_simple_mul(z, x, x_sw, x, x_sw);
+ bigint_simple_sqr(z, x, x_sw);
}
}