summary refs log tree commit diff
path: root/crypto/test/src
diff options
context:
space:
mode:
authorDavid Hook <dgh@bouncycastle.org>2021-05-31 08:54:59 +1000
committerDavid Hook <dgh@bouncycastle.org>2021-05-31 08:54:59 +1000
commit1d0f6346030e5c01a69e6e3659c3238ab7e5e857 (patch)
tree9fb63c33eabcaeebcd790f1734a97f95b2fdded8 /crypto/test/src
parentgithub #83 - correct digest name fetch to check enc oid (diff)
downloadBouncyCastle.NET-ed25519-1d0f6346030e5c01a69e6e3659c3238ab7e5e857.tar.xz
github #172 - added blowfish init check on key size
Diffstat (limited to 'crypto/test/src')
-rw-r--r--crypto/test/src/crypto/test/BlowfishTest.cs23
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);
         }