diff options
author | lloyd <[email protected]> | 2010-01-21 16:36:12 +0000 |
---|---|---|
committer | lloyd <[email protected]> | 2010-01-21 16:36:12 +0000 |
commit | 412a13fc607a57bd9986155d247353ba8e5fb203 (patch) | |
tree | cbdf63aaa7e9f28a748dedda286e79a138573f74 /src/pubkey/dsa/dsa_op.cpp | |
parent | 41bed2fa0c4d96faf805cd33850166972dcac114 (diff) | |
parent | 9b82bb5a720f32e3e7878550310b1151cac188b8 (diff) |
propagate from branch 'net.randombit.botan' (head 12382647ef0a28fcb11c824c77b670cc88a4f721)
to branch 'net.randombit.botan.c++0x' (head b586a3286d2c4d547ad3add5af9df1455bf4b87b)
Diffstat (limited to 'src/pubkey/dsa/dsa_op.cpp')
-rw-r--r-- | src/pubkey/dsa/dsa_op.cpp | 21 |
1 files changed, 16 insertions, 5 deletions
diff --git a/src/pubkey/dsa/dsa_op.cpp b/src/pubkey/dsa/dsa_op.cpp index 5b921441d..5eb9e92be 100644 --- a/src/pubkey/dsa/dsa_op.cpp +++ b/src/pubkey/dsa/dsa_op.cpp @@ -1,11 +1,12 @@ /* * DSA Operations -* (C) 1999-2007 Jack Lloyd +* (C) 1999-2009 Jack Lloyd * * Distributed under the terms of the Botan license */ #include <botan/dsa_op.h> +#include <botan/internal/async.h> namespace Botan { @@ -40,8 +41,14 @@ 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))); + + auto future_s_i = std_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); } @@ -55,11 +62,15 @@ SecureVector<byte> Default_DSA_Op::sign(const byte in[], u32bit length, if(x == 0) throw Internal_Error("Default_DSA_Op::sign: No private key"); + auto future_r = std_async([&]() { return mod_q.reduce(powermod_g_p(k)); }); + 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)); + BigInt s = inverse_mod(k, q); + BigInt r = future_r.get(); + + 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"); |