summary refs log tree commit diff
diff options
context:
space:
mode:
authorPeter Dettman <peter.dettman@bouncycastle.org>2023-05-30 11:27:54 +0700
committerPeter Dettman <peter.dettman@bouncycastle.org>2023-05-30 11:27:54 +0700
commit125f513592d39249341dc8f74f8cab6cee5489d2 (patch)
tree26a98769dde097eb891b6158d67be42ff8abd415
parentAdd entry for DTLS bugfix (diff)
downloadBouncyCastle.NET-ed25519-125f513592d39249341dc8f74f8cab6cee5489d2.tar.xz
TODO for stricter HC-256 key/IV
-rw-r--r--crypto/src/crypto/engines/HC256Engine.cs1
-rw-r--r--crypto/test/src/test/CipherStreamTest.cs9
2 files changed, 6 insertions, 4 deletions
diff --git a/crypto/src/crypto/engines/HC256Engine.cs b/crypto/src/crypto/engines/HC256Engine.cs
index 1ace7bbc0..635a3912f 100644
--- a/crypto/src/crypto/engines/HC256Engine.cs
+++ b/crypto/src/crypto/engines/HC256Engine.cs
@@ -66,6 +66,7 @@ namespace Org.BouncyCastle.Crypto.Engines
 
 		private void Init()
 		{
+			// TODO[api] Strictly require 32 bytes for both key and IV
 			if (key.Length != 32 && key.Length != 16)
 				throw new ArgumentException("The key must be 128/256 bits long");
 			if (iv.Length < 16)
diff --git a/crypto/test/src/test/CipherStreamTest.cs b/crypto/test/src/test/CipherStreamTest.cs
index d51234649..2ede0e13e 100644
--- a/crypto/test/src/test/CipherStreamTest.cs
+++ b/crypto/test/src/test/CipherStreamTest.cs
@@ -36,9 +36,10 @@ namespace Org.BouncyCastle.Tests
 			+ "F9E460BC65EF95DA58F740B7D1DBB0AA");
 
 		private static readonly byte[] HCIN = new byte[64];
-		private static readonly byte[] HCIV = new byte[16];
+		private static readonly byte[] HCIV128 = new byte[16];
+        private static readonly byte[] HCIV256 = new byte[32];
 
-		private static readonly byte[] HCK256A = new byte[32];
+        private static readonly byte[] HCK256A = new byte[32];
 		private static readonly byte[] HC256A = Hex.Decode(
 			  "5B078985D8F6F30D42C5C02FA6B67951"
 			+ "53F06534801F89F24E74248B720B4818"
@@ -342,7 +343,7 @@ namespace Org.BouncyCastle.Tests
 		[Test]
 		public void TestHC128Algorithm()
 		{
-			doTestAlgorithm("HC128", HCK128A, HCIV, HCIN, HC128A);
+			doTestAlgorithm("HC128", HCK128A, HCIV128, HCIN, HC128A);
 		}
 
 		[Test]
@@ -360,7 +361,7 @@ namespace Org.BouncyCastle.Tests
 		[Test]
 		public void TestHC256Algorithm()
 		{
-			doTestAlgorithm("HC256", HCK256A, HCIV, HCIN, HC256A);
+			doTestAlgorithm("HC256", HCK256A, HCIV256, HCIN, HC256A);
 		}
 
 		[Test]