diff options
author | Peter Dettman <peter.dettman@bouncycastle.org> | 2017-08-31 17:38:16 +0700 |
---|---|---|
committer | Peter Dettman <peter.dettman@bouncycastle.org> | 2017-08-31 17:38:16 +0700 |
commit | 16cb1559e6c7ef565d9d44a20b82d2e5f39dbd5b (patch) | |
tree | 69c3f1554a74a524178fbbc8dcaaa5b7f1e1f3f8 | |
parent | Fix the message in case of test failure (diff) | |
download | BouncyCastle.NET-ed25519-16cb1559e6c7ef565d9d44a20b82d2e5f39dbd5b.tar.xz |
Avoid integer overflow in argument checks
- see https://github.com/bcgit/bc-csharp/issues/91
-rw-r--r-- | crypto/src/crypto/parameters/KeyParameter.cs | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/crypto/src/crypto/parameters/KeyParameter.cs b/crypto/src/crypto/parameters/KeyParameter.cs index 33dff96d7..043adf276 100644 --- a/crypto/src/crypto/parameters/KeyParameter.cs +++ b/crypto/src/crypto/parameters/KeyParameter.cs @@ -27,7 +27,7 @@ namespace Org.BouncyCastle.Crypto.Parameters throw new ArgumentNullException("key"); if (keyOff < 0 || keyOff > key.Length) throw new ArgumentOutOfRangeException("keyOff"); - if (keyLen < 0 || (keyOff + keyLen) > key.Length) + if (keyLen < 0 || keyLen > (key.Length - keyOff)) throw new ArgumentOutOfRangeException("keyLen"); this.key = new byte[keyLen]; |