aboutsummaryrefslogtreecommitdiffstats
path: root/src/pubkey
diff options
context:
space:
mode:
authorlloyd <[email protected]>2009-11-17 18:17:47 +0000
committerlloyd <[email protected]>2009-11-17 18:17:47 +0000
commit0467bf03eae3ace3412b5218210eb15b6c6bd30b (patch)
tree10cabd4c0382aa771977ad38d0ef0432698b52b2 /src/pubkey
parente25d4ec4612f74bfed1ffe34cc07a798c9e7a4ce (diff)
Also parallelize DSA signature generation, though due to critical path
constraints there isn't that much parallelization to extract. Slightly faster; better for smaller key sizes as once a certain point is reached one thread is doing a lot more work than the other.
Diffstat (limited to 'src/pubkey')
-rw-r--r--src/pubkey/dsa/dsa_op.cpp15
1 files changed, 13 insertions, 2 deletions
diff --git a/src/pubkey/dsa/dsa_op.cpp b/src/pubkey/dsa/dsa_op.cpp
index 114731eea..4c84667eb 100644
--- a/src/pubkey/dsa/dsa_op.cpp
+++ b/src/pubkey/dsa/dsa_op.cpp
@@ -75,8 +75,19 @@ SecureVector<byte> Default_DSA_Op::sign(const byte in[], u32bit length,
const BigInt& q = group.get_q();
BigInt i(in, length);
- BigInt r = mod_q.reduce(powermod_g_p(k));
- BigInt s = mod_q.multiply(inverse_mod(k, q), mul_add(x, r, i));
+ std::packaged_task<BigInt ()> task_r(
+ [&]() { return mod_q.reduce(powermod_g_p(k)); });
+
+ auto future_r = task_r.get_future();
+
+ std::thread thr_r(std::move(task_r));
+
+ BigInt s = inverse_mod(k, q);
+
+ BigInt r = future_r.get();
+ thr_r.join();
+
+ s = mod_q.multiply(s, mul_add(x, r, i));
if(r.is_zero() || s.is_zero())
throw Internal_Error("Default_DSA_Op::sign: r or s was zero");