diff options
author | David Hook <dgh@bouncycastle.org> | 2021-05-31 08:54:59 +1000 |
---|---|---|
committer | David Hook <dgh@bouncycastle.org> | 2021-05-31 08:54:59 +1000 |
commit | 1d0f6346030e5c01a69e6e3659c3238ab7e5e857 (patch) | |
tree | 9fb63c33eabcaeebcd790f1734a97f95b2fdded8 /crypto/test | |
parent | github #83 - correct digest name fetch to check enc oid (diff) | |
download | BouncyCastle.NET-ed25519-1d0f6346030e5c01a69e6e3659c3238ab7e5e857.tar.xz |
github #172 - added blowfish init check on key size
Diffstat (limited to 'crypto/test')
-rw-r--r-- | crypto/test/src/crypto/test/BlowfishTest.cs | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/crypto/test/src/crypto/test/BlowfishTest.cs b/crypto/test/src/crypto/test/BlowfishTest.cs index 780dd3abd..b940d13ac 100644 --- a/crypto/test/src/crypto/test/BlowfishTest.cs +++ b/crypto/test/src/crypto/test/BlowfishTest.cs @@ -40,6 +40,29 @@ namespace Org.BouncyCastle.Crypto.Tests { string resultText = Perform().ToString(); + BlowfishEngine blowfish = new BlowfishEngine(); + + // key range check + try + { + blowfish.Init(true, new KeyParameter(new byte[1])); + Fail("no exception"); + } + catch (ArgumentException e) + { + Assert.AreEqual("key length must be in range 32 to 448 bits", e.Message); + } + + try + { + blowfish.Init(true, new KeyParameter(new byte[59])); + Fail("no exception"); + } + catch (ArgumentException e) + { + Assert.AreEqual("key length must be in range 32 to 448 bits", e.Message); + } + Assert.AreEqual(Name + ": Okay", resultText); } |