aboutsummaryrefslogtreecommitdiffstats
path: root/src/powm_mnt.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/powm_mnt.cpp')
-rw-r--r--src/powm_mnt.cpp12
1 files changed, 12 insertions, 0 deletions
diff --git a/src/powm_mnt.cpp b/src/powm_mnt.cpp
index ad1ac312c..d28bfacfe 100644
--- a/src/powm_mnt.cpp
+++ b/src/powm_mnt.cpp
@@ -12,6 +12,18 @@ namespace Botan {
namespace {
/*************************************************
+* Montgomery Reduction *
+*************************************************/
+void montgomery_reduce(word z[], u32bit z_size,
+ const word x[], u32bit x_size, word u)
+ {
+ 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);
+ }
+
+/*************************************************
* Try to choose a good window size *
*************************************************/
u32bit choose_window_bits(u32bit exp_bits, u32bit,