diff options
author | lloyd <[email protected]> | 2010-03-10 16:35:12 +0000 |
---|---|---|
committer | lloyd <[email protected]> | 2010-03-10 16:35:12 +0000 |
commit | ffebc65a41fbe22934830203cfa4ee791804796b (patch) | |
tree | 8ce04eba960bd524f58e096ac979e7f639696c6a /src/pubkey/dsa | |
parent | d3e279ec353133e9f80f13a536aae15e49c2a206 (diff) | |
parent | fd79f63a44ad0b59507ac67bdb3eccbe4d45adbc (diff) |
propagate from branch 'net.randombit.botan' (head 74e9e8642943d126a5e5efa5be1da8351f0fb6d7)
to branch 'net.randombit.botan.c++0x' (head 24371f742c2a1c7e5f3aace364fbb21e01c94657)
Diffstat (limited to 'src/pubkey/dsa')
-rw-r--r-- | src/pubkey/dsa/dsa.cpp | 27 |
1 files changed, 14 insertions, 13 deletions
diff --git a/src/pubkey/dsa/dsa.cpp b/src/pubkey/dsa/dsa.cpp index 2b9a73015..ca396204a 100644 --- a/src/pubkey/dsa/dsa.cpp +++ b/src/pubkey/dsa/dsa.cpp @@ -91,22 +91,23 @@ DSA_Signature_Operation::sign(const byte msg[], u32bit msg_len, { rng.add_entropy(msg, msg_len); - BigInt k; - do - k.randomize(rng, q.bits()); - while(k >= q); - - auto future_r = std::async(std::launch::async, - [&]() { return mod_q.reduce(powermod_g_p(k)); }); - BigInt i(msg, msg_len); + BigInt r = 0, s = 0; - BigInt s = inverse_mod(k, q); - BigInt r = future_r.get(); - s = mod_q.multiply(s, mul_add(x, r, i)); + while(r == 0 || s == 0) + { + BigInt k; + do + k.randomize(rng, q.bits()); + while(k >= q); - if(r.is_zero() || s.is_zero()) - throw Internal_Error("DSA signature gen failure: r or s was zero"); + 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()); r.binary_encode(output + (output.size() / 2 - r.bytes())); |