From 125f513592d39249341dc8f74f8cab6cee5489d2 Mon Sep 17 00:00:00 2001 From: Peter Dettman Date: Tue, 30 May 2023 11:27:54 +0700 Subject: TODO for stricter HC-256 key/IV --- crypto/src/crypto/engines/HC256Engine.cs | 1 + crypto/test/src/test/CipherStreamTest.cs | 9 +++++---- 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] -- cgit 1.4.1