aboutsummaryrefslogtreecommitdiffstats
path: root/src/lib/pubkey/dsa/dsa.cpp
diff options
context:
space:
mode:
authorJack Lloyd <[email protected]>2016-10-12 15:32:14 -0400
committerJack Lloyd <[email protected]>2016-10-12 15:32:14 -0400
commited9e147695e4c5e800e83654baf365a634f3a2a7 (patch)
tree59bad402cff7d7af9baa5fd79081d677b60afc83 /src/lib/pubkey/dsa/dsa.cpp
parentd59b164a2ad2bc2290265530ac1a5c7be7855975 (diff)
Abstract out mutex type. Make threads optional.
Diffstat (limited to 'src/lib/pubkey/dsa/dsa.cpp')
-rw-r--r--src/lib/pubkey/dsa/dsa.cpp15
1 files changed, 14 insertions, 1 deletions
diff --git a/src/lib/pubkey/dsa/dsa.cpp b/src/lib/pubkey/dsa/dsa.cpp
index 15dc45373..9c8ae0821 100644
--- a/src/lib/pubkey/dsa/dsa.cpp
+++ b/src/lib/pubkey/dsa/dsa.cpp
@@ -17,7 +17,9 @@
#include <botan/rfc6979.h>
#endif
-#include <future>
+#if defined(BOTAN_TARGET_OS_HAS_THREADS)
+ #include <future>
+#endif
namespace Botan {
@@ -124,11 +126,17 @@ DSA_Signature_Operation::raw_sign(const byte msg[], size_t msg_len,
const BigInt k = BigInt::random_integer(rng, 1, m_q);
#endif
+#if defined(BOTAN_TARGET_OS_HAS_THREADS)
auto future_r = std::async(std::launch::async,
[&]() { return m_mod_q.reduce(m_powermod_g_p(k)); });
BigInt s = inverse_mod(k, m_q);
const BigInt r = future_r.get();
+#else
+ BigInt s = inverse_mod(k, m_q);
+ const BigInt r = m_mod_q.reduce(m_powermod_g_p(k));
+#endif
+
s = m_mod_q.multiply(s, mul_add(m_x, r, i));
// With overwhelming probability, a bug rather than actual zero r/s
@@ -184,11 +192,16 @@ bool DSA_Verification_Operation::verify(const byte msg[], size_t msg_len,
s = inverse_mod(s, m_q);
+#if defined(BOTAN_TARGET_OS_HAS_THREADS)
auto future_s_i = std::async(std::launch::async,
[&]() { return m_powermod_g_p(m_mod_q.multiply(s, i)); });
BigInt s_r = m_powermod_y_p(m_mod_q.multiply(s, r));
BigInt s_i = future_s_i.get();
+#else
+ BigInt s_r = m_powermod_y_p(m_mod_q.multiply(s, r));
+ BigInt s_i = m_powermod_g_p(m_mod_q.multiply(s, i));
+#endif
s = m_mod_p.multiply(s_i, s_r);