aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorlloyd <[email protected]>2012-07-17 20:47:24 +0000
committerlloyd <[email protected]>2012-07-17 20:47:24 +0000
commited93f55a8dbbf7b8a2a6e0b5dd5ed390e30f34ec (patch)
tree6c5422181becc8ea4772c934671565e01d14f05c
parent45599ab2192863a2361c2dcca4a932419a7945cf (diff)
Add check for out of range DH keys
-rw-r--r--src/pubkey/dh/dh.cpp3
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());