diff options
author | lloyd <[email protected]> | 2012-07-17 20:47:24 +0000 |
---|---|---|
committer | lloyd <[email protected]> | 2012-07-17 20:47:24 +0000 |
commit | ed93f55a8dbbf7b8a2a6e0b5dd5ed390e30f34ec (patch) | |
tree | 6c5422181becc8ea4772c934671565e01d14f05c /src | |
parent | 45599ab2192863a2361c2dcca4a932419a7945cf (diff) |
Add check for out of range DH keys
Diffstat (limited to 'src')
-rw-r--r-- | src/pubkey/dh/dh.cpp | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/src/pubkey/dh/dh.cpp b/src/pubkey/dh/dh.cpp index 956a98ba4..956552c7d 100644 --- a/src/pubkey/dh/dh.cpp +++ b/src/pubkey/dh/dh.cpp @@ -87,6 +87,9 @@ secure_vector<byte> DH_KA_Operation::agree(const byte w[], size_t w_len) { BigInt input = BigInt::decode(w, w_len); + if(input <= 1 || input >= p - 1) + throw Invalid_Argument("DH agreement - invalid key provided"); + BigInt r = blinder.unblind(powermod_x_p(blinder.blind(input))); return BigInt::encode_1363(r, p.bytes()); |