aboutsummaryrefslogtreecommitdiffstats
path: root/src/libs/3rdparty/botan/src/lib/math/numbertheory/powm_mnt.cpp
diff options
context:
space:
mode:
authorEike Ziller <eike.ziller@qt.io>2018-08-15 13:53:28 +0200
committerEike Ziller <eike.ziller@qt.io>2018-08-15 13:53:28 +0200
commitdb9837fa6c9401e898ac8e7492081a6e21c71790 (patch)
treed542a089711257402ac4fe70813fa0e7de825f2e /src/libs/3rdparty/botan/src/lib/math/numbertheory/powm_mnt.cpp
parent7bc14bf3498ea6b1c19abacf85a5103772da26bc (diff)
parent58747b2de107e8f6ac00daeb431ecbf3e603fd34 (diff)
Merge remote-tracking branch 'origin/4.7'
Conflicts: src/plugins/clangtools/clangtoolruncontrol.cpp src/plugins/cpptools/compileroptionsbuilder.cpp Change-Id: Ib1e8abf066898b50c90fc1ccba4697fe983e8a8f
Diffstat (limited to 'src/libs/3rdparty/botan/src/lib/math/numbertheory/powm_mnt.cpp')
-rw-r--r--src/libs/3rdparty/botan/src/lib/math/numbertheory/powm_mnt.cpp46
1 files changed, 46 insertions, 0 deletions
diff --git a/src/libs/3rdparty/botan/src/lib/math/numbertheory/powm_mnt.cpp b/src/libs/3rdparty/botan/src/lib/math/numbertheory/powm_mnt.cpp
new file mode 100644
index 00000000000..8cb3f6a08ea
--- /dev/null
+++ b/src/libs/3rdparty/botan/src/lib/math/numbertheory/powm_mnt.cpp
@@ -0,0 +1,46 @@
+/*
+* Montgomery Exponentiation
+* (C) 1999-2010,2012,2018 Jack Lloyd
+* 2016 Matthias Gierlings
+*
+* Botan is released under the Simplified BSD License (see license.txt)
+*/
+
+#include <botan/internal/def_powm.h>
+#include <botan/numthry.h>
+#include <botan/monty.h>
+#include <botan/internal/monty_exp.h>
+#include <botan/internal/rounding.h>
+
+namespace Botan {
+
+void Montgomery_Exponentiator::set_exponent(const BigInt& exp)
+ {
+ m_e = exp;
+ }
+
+void Montgomery_Exponentiator::set_base(const BigInt& base)
+ {
+ size_t window_bits = Power_Mod::window_bits(m_e.bits(), base.bits(), m_hints);
+ m_monty = monty_precompute(m_monty_params, base, window_bits);
+ }
+
+BigInt Montgomery_Exponentiator::execute() const
+ {
+ /*
+ This leaks size of e via loop iterations, not possible to fix without
+ breaking this API. Round up to avoid leaking fine details.
+ */
+ return monty_execute(*m_monty, m_e, round_up(m_e.bits(), 8));
+ }
+
+Montgomery_Exponentiator::Montgomery_Exponentiator(const BigInt& mod,
+ Power_Mod::Usage_Hints hints) :
+ m_p(mod),
+ m_mod_p(mod),
+ m_monty_params(std::make_shared<Montgomery_Params>(m_p, m_mod_p)),
+ m_hints(hints)
+ {
+ }
+
+}