diff options
author | lloyd <[email protected]> | 2006-08-17 21:41:02 +0000 |
---|---|---|
committer | lloyd <[email protected]> | 2006-08-17 21:41:02 +0000 |
commit | 914a5c0c3200073c95d510e14150da81d2eac105 (patch) | |
tree | cc9c99f21473dafdb9ad91a1cb730e04891353df | |
parent | 23df9aa184130ea94a7708ba01ec2798c7d73426 (diff) |
Move montgomery_reduce to after choose_window_bits for better consistency
between the Montgomery and fixed-window exponentiators.
-rw-r--r-- | src/powm_mnt.cpp | 36 |
1 files changed, 18 insertions, 18 deletions
diff --git a/src/powm_mnt.cpp b/src/powm_mnt.cpp index f527927b5..747510d87 100644 --- a/src/powm_mnt.cpp +++ b/src/powm_mnt.cpp @@ -12,24 +12,6 @@ namespace Botan { namespace { /************************************************* -* Montgomery Reduction * -*************************************************/ -inline void montgomery_reduce(BigInt& out, MemoryRegion<word>& z_buf, - const BigInt& x_bn, u32bit x_size, word u) - { - const word* x = x_bn.data(); - word* z = z_buf.begin(); - u32bit z_size = z_buf.size(); - - bigint_monty_redc(z, z_size, x, x_size, u); - - if(bigint_cmp(z + x_size, x_size + 1, x, x_size) >= 0) - bigint_sub2(z + x_size, x_size + 1, x, x_size); - - out.get_reg().set(z + x_size, x_size + 1); - } - -/************************************************* * Try to choose a good window size * *************************************************/ u32bit choose_window_bits(u32bit exp_bits, u32bit, @@ -61,6 +43,24 @@ u32bit choose_window_bits(u32bit exp_bits, u32bit, return window_bits; } +/************************************************* +* Montgomery Reduction * +*************************************************/ +inline void montgomery_reduce(BigInt& out, MemoryRegion<word>& z_buf, + const BigInt& x_bn, u32bit x_size, word u) + { + const word* x = x_bn.data(); + word* z = z_buf.begin(); + u32bit z_size = z_buf.size(); + + bigint_monty_redc(z, z_size, x, x_size, u); + + if(bigint_cmp(z + x_size, x_size + 1, x, x_size) >= 0) + bigint_sub2(z + x_size, x_size + 1, x, x_size); + + out.get_reg().set(z + x_size, x_size + 1); + } + } /************************************************* |