diff options
author | lloyd <[email protected]> | 2011-06-13 17:06:08 +0000 |
---|---|---|
committer | lloyd <[email protected]> | 2011-06-13 17:06:08 +0000 |
commit | 5fcdf6953ed820a446862702311221c10ae0b91d (patch) | |
tree | 10354a54bb8ef5c8f9c6cdd9fa0142ab0037c635 /src/pubkey/dsa/dsa.cpp | |
parent | b145e593616e83a4c124bba70d451ef0f03c5f3f (diff) | |
parent | 1a28f7ef6064041955e7a662c5e087bbea03b6ad (diff) |
propagate from branch 'net.randombit.botan' (head 150bd11dd8090559ee1e83394b8283bf93a018de)
to branch 'net.randombit.botan.c++0x' (head 7480693bb3f1e8a4e039a3e7ba3d9a7007f9730e)
Diffstat (limited to 'src/pubkey/dsa/dsa.cpp')
-rw-r--r-- | src/pubkey/dsa/dsa.cpp | 20 |
1 files changed, 15 insertions, 5 deletions
diff --git a/src/pubkey/dsa/dsa.cpp b/src/pubkey/dsa/dsa.cpp index 5e511840f..c3b4f260b 100644 --- a/src/pubkey/dsa/dsa.cpp +++ b/src/pubkey/dsa/dsa.cpp @@ -8,7 +8,7 @@ #include <botan/dsa.h> #include <botan/numthry.h> #include <botan/keypair.h> - +#include <future> namespace Botan { /* @@ -89,8 +89,12 @@ DSA_Signature_Operation::sign(const byte msg[], size_t msg_len, k.randomize(rng, q.bits()); while(k >= q); - r = mod_q.reduce(powermod_g_p(k)); - s = mod_q.multiply(inverse_mod(k, q), mul_add(x, r, i)); + auto future_r = std::async(std::launch::async, + [&]() { return mod_q.reduce(powermod_g_p(k)); }); + + s = inverse_mod(k, q); + r = future_r.get(); + s = mod_q.multiply(s, mul_add(x, r, i)); } SecureVector<byte> output(2*q.bytes()); @@ -124,8 +128,14 @@ bool DSA_Verification_Operation::verify(const byte msg[], size_t 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))); + + auto future_s_i = std::async(std::launch::async, + [&]() { return powermod_g_p(mod_q.multiply(s, i)); }); + + BigInt s_r = powermod_y_p(mod_q.multiply(s, r)); + BigInt s_i = future_s_i.get(); + + s = mod_p.multiply(s_i, s_r); return (mod_q.reduce(s) == r); } |