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/nr | |
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/nr')
-rw-r--r-- | src/pubkey/nr/nr.cpp | 21 |
1 files changed, 12 insertions, 9 deletions
diff --git a/src/pubkey/nr/nr.cpp b/src/pubkey/nr/nr.cpp index 440fa22e4..50cf080fb 100644 --- a/src/pubkey/nr/nr.cpp +++ b/src/pubkey/nr/nr.cpp @@ -100,20 +100,23 @@ NR_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); - BigInt f(msg, msg_len); if(f >= q) throw Invalid_Argument("NR_Signature_Operation: Input is out of range"); - BigInt c = mod_q.reduce(powermod_g_p(k) + f); - if(c.is_zero()) - throw Internal_Error("NR_Signature_Operation: c was zero"); - BigInt d = mod_q.reduce(k - x * c); + BigInt c, d; + + while(c == 0) + { + BigInt k; + do + k.randomize(rng, q.bits()); + while(k >= q); + + c = mod_q.reduce(powermod_g_p(k) + f); + d = mod_q.reduce(k - x * c); + } SecureVector<byte> output(2*q.bytes()); c.binary_encode(output + (output.size() / 2 - c.bytes())); |