aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorlloyd <[email protected]>2009-11-17 17:50:30 +0000
committerlloyd <[email protected]>2009-11-17 17:50:30 +0000
commite25d4ec4612f74bfed1ffe34cc07a798c9e7a4ce (patch)
treebe17e65c33be842e57c301cfc9d3d3ba0ce2261b
parentaa361909f881b791cdce67993f3ab0d6af47c140 (diff)
Use a thread to compute half of the DSA verification. 20-90% faster depending
on key size on a Core2.
-rw-r--r--src/pubkey/dsa/dsa_op.cpp21
1 files changed, 19 insertions, 2 deletions
diff --git a/src/pubkey/dsa/dsa_op.cpp b/src/pubkey/dsa/dsa_op.cpp
index 5b921441d..114731eea 100644
--- a/src/pubkey/dsa/dsa_op.cpp
+++ b/src/pubkey/dsa/dsa_op.cpp
@@ -6,6 +6,8 @@
*/
#include <botan/dsa_op.h>
+#include <thread>
+#include <future>
namespace Botan {
@@ -40,8 +42,23 @@ bool Default_DSA_Op::verify(const byte msg[], u32bit msg_len,
return false;
s = inverse_mod(s, q);
- s = mod_p.multiply(powermod_g_p(mod_q.multiply(s, i)),
- powermod_y_p(mod_q.multiply(s, r)));
+
+ // Todo: use async()
+
+ std::packaged_task<BigInt ()> task_s_i(
+ [&]() { return powermod_g_p(mod_q.multiply(s, i)); });
+
+ auto future_s_i = task_s_i.get_future();
+
+ std::thread thr_s_i(std::move(task_s_i));
+
+ BigInt s_r = powermod_y_p(mod_q.multiply(s, r));
+
+ BigInt s_i = future_s_i.get();
+
+ thr_s_i.join();
+
+ s = mod_p.multiply(s_i, s_r);
return (mod_q.reduce(s) == r);
}