aboutsummaryrefslogtreecommitdiffstats
path: root/src/pubkey
diff options
context:
space:
mode:
Diffstat (limited to 'src/pubkey')
-rw-r--r--src/pubkey/elgamal/elg_op.cpp6
-rw-r--r--src/pubkey/nr/nr_op.cpp8
2 files changed, 10 insertions, 4 deletions
diff --git a/src/pubkey/elgamal/elg_op.cpp b/src/pubkey/elgamal/elg_op.cpp
index 1e476ab7a..db828a300 100644
--- a/src/pubkey/elgamal/elg_op.cpp
+++ b/src/pubkey/elgamal/elg_op.cpp
@@ -1,11 +1,12 @@
/*
* ElGamal Operations
-* (C) 1999-2007 Jack Lloyd
+* (C) 1999-2009 Jack Lloyd
*
* Distributed under the terms of the Botan license
*/
#include <botan/elg_op.h>
+#include <botan/async.h>
namespace Botan {
@@ -33,8 +34,9 @@ SecureVector<byte> Default_ELG_Op::encrypt(const byte in[], u32bit length,
if(m >= p)
throw Invalid_Argument("Default_ELG_Op::encrypt: Input is too large");
- BigInt a = powermod_g_p(k);
+ auto future_a = std_async([&]() { return powermod_g_p(k); });
BigInt b = mod_p.multiply(m, powermod_y_p(k));
+ BigInt a = future_a.get();
SecureVector<byte> output(2*p.bytes());
a.binary_encode(output + (p.bytes() - a.bytes()));
diff --git a/src/pubkey/nr/nr_op.cpp b/src/pubkey/nr/nr_op.cpp
index b5efa3d37..49aa9fc00 100644
--- a/src/pubkey/nr/nr_op.cpp
+++ b/src/pubkey/nr/nr_op.cpp
@@ -1,11 +1,12 @@
/*
* NR Operations
-* (C) 1999-2007 Jack Lloyd
+* (C) 1999-2009 Jack Lloyd
*
* Distributed under the terms of the Botan license
*/
#include <botan/nr_op.h>
+#include <botan/async.h>
namespace Botan {
@@ -37,7 +38,10 @@ SecureVector<byte> Default_NR_Op::verify(const byte in[], u32bit length) const
if(c.is_zero() || c >= q || d >= q)
throw Invalid_Argument("Default_NR_Op::verify: Invalid signature");
- BigInt i = mod_p.multiply(powermod_g_p(d), powermod_y_p(c));
+ auto future_y_c = std_async([&]() { return powermod_y_p(c); });
+ BigInt g_d = powermod_g_p(d);
+
+ BigInt i = mod_p.multiply(g_d, future_y_c.get());
return BigInt::encode(mod_q.reduce(c - i));
}