aboutsummaryrefslogtreecommitdiffstats
path: root/src/pubkey/dh
diff options
context:
space:
mode:
authorlloyd <[email protected]>2012-07-17 18:44:31 +0000
committerlloyd <[email protected]>2012-07-17 18:44:31 +0000
commit803c19e7cf66972eb33f4293fbce37e7183fa64c (patch)
tree9306668df170102e273ab35b5a612088122a18ef /src/pubkey/dh
parent31ca086fbddc67a7ca00a6b292bdb382cfe9312f (diff)
Check for DH inputs out of range, was removed in the pk_op
refactoring.
Diffstat (limited to 'src/pubkey/dh')
-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 d58fece12..dacae5ab7 100644
--- a/src/pubkey/dh/dh.cpp
+++ b/src/pubkey/dh/dh.cpp
@@ -87,6 +87,9 @@ SecureVector<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());