aboutsummaryrefslogtreecommitdiffstats
path: root/src/math/numbertheory/powm_mnt.cpp
diff options
context:
space:
mode:
authorlloyd <[email protected]>2010-03-09 01:29:12 +0000
committerlloyd <[email protected]>2010-03-09 01:29:12 +0000
commit56a19fb01f3b0651359f059b51eef26e408015b4 (patch)
tree6d7e100abf4792159227d88808e71e0803449a98 /src/math/numbertheory/powm_mnt.cpp
parentb98f0aa4ac768fb045e439915a8115434e5a91de (diff)
Consolidate code for choosing a window size for fixed width window
exponentiation algorithms.
Diffstat (limited to 'src/math/numbertheory/powm_mnt.cpp')
-rw-r--r--src/math/numbertheory/powm_mnt.cpp34
1 files changed, 1 insertions, 33 deletions
diff --git a/src/math/numbertheory/powm_mnt.cpp b/src/math/numbertheory/powm_mnt.cpp
index 2d18ccdef..cce142020 100644
--- a/src/math/numbertheory/powm_mnt.cpp
+++ b/src/math/numbertheory/powm_mnt.cpp
@@ -14,38 +14,6 @@ namespace Botan {
namespace {
/*
-* Try to choose a good window size
-*/
-u32bit montgomery_powm_window_bits(u32bit exp_bits, u32bit,
- Power_Mod::Usage_Hints hints)
- {
- static const u32bit wsize[][2] = {
- { 2048, 4 }, { 1024, 3 }, { 256, 2 }, { 128, 1 }, { 0, 0 }
- };
-
- u32bit window_bits = 1;
-
- if(exp_bits)
- {
- for(u32bit j = 0; wsize[j][0]; ++j)
- {
- if(exp_bits >= wsize[j][0])
- {
- window_bits += wsize[j][1];
- break;
- }
- }
- }
-
- if(hints & Power_Mod::BASE_IS_FIXED)
- window_bits += 2;
- if(hints & Power_Mod::EXP_IS_LARGE)
- ++window_bits;
-
- return window_bits;
- }
-
-/*
* Montgomery Reduction
*/
inline void montgomery_reduce(BigInt& out, MemoryRegion<word>& z_buf,
@@ -76,7 +44,7 @@ void Montgomery_Exponentiator::set_exponent(const BigInt& exp)
*/
void Montgomery_Exponentiator::set_base(const BigInt& base)
{
- window_bits = montgomery_powm_window_bits(exp.bits(), base.bits(), hints);
+ window_bits = Power_Mod::window_bits(exp.bits(), base.bits(), hints);
g.resize((1 << window_bits) - 1);