diff options
author | lloyd <[email protected]> | 2012-05-25 20:35:47 +0000 |
---|---|---|
committer | lloyd <[email protected]> | 2012-05-25 20:35:47 +0000 |
commit | 29c337b2c7024d1b34aa3b578b5fc38b4d869fb0 (patch) | |
tree | ab69a5f6ade56e2406dae62453513b4545ff922b /src/pubkey | |
parent | d9ce2edc929218b5718b3f6747a17ecd3fdada7e (diff) |
Use std::async for parallel CRT in Rabin Williams signature generation.
Diffstat (limited to 'src/pubkey')
-rw-r--r-- | src/pubkey/rw/rw.cpp | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/src/pubkey/rw/rw.cpp b/src/pubkey/rw/rw.cpp index c41b18101..d57b967e9 100644 --- a/src/pubkey/rw/rw.cpp +++ b/src/pubkey/rw/rw.cpp @@ -10,6 +10,7 @@ #include <botan/keypair.h> #include <botan/parsing.h> #include <algorithm> +#include <future> namespace Botan { @@ -90,15 +91,15 @@ RW_Signature_Operation::sign(const byte msg[], size_t msg_len, i = blinder.blind(i); - BigInt j1 = powermod_d1_p(i); - BigInt j2 = powermod_d2_q(i); - j1 = mod_p.reduce(sub_mul(j1, j2, c)); + auto future_j1 = std::async(std::launch::async, powermod_d1_p, i); + const BigInt j2 = powermod_d2_q(i); + BigInt j1 = future_j1.get(); - BigInt r = blinder.unblind(mul_add(j1, q, j2)); + j1 = mod_p.reduce(sub_mul(j1, j2, c)); - r = std::min(r, n - r); + const BigInt r = blinder.unblind(mul_add(j1, q, j2)); - return BigInt::encode_1363(r, n.bytes()); + return BigInt::encode_1363(std::min(r, n - r), n.bytes()); } secure_vector<byte> |