summary refs log tree commit diff
diff options
context:
space:
mode:
authorPeter Dettman <peter.dettman@bouncycastle.org>2022-07-25 15:30:30 +0700
committerPeter Dettman <peter.dettman@bouncycastle.org>2022-07-25 15:30:30 +0700
commit0cab5b16039e30069a934d3cc96f57212d510c77 (patch)
tree6dbaa3e1809461dd324f696a6fd972b87270f17a
parentImprove Pack usage (diff)
downloadBouncyCastle.NET-ed25519-0cab5b16039e30069a934d3cc96f57212d510c77.tar.xz
Fix Haraka API
-rw-r--r--crypto/src/crypto/digests/Haraka256Digest.cs2
-rw-r--r--crypto/src/crypto/digests/Haraka512Digest.cs2
-rw-r--r--crypto/src/crypto/digests/HarakaBase.cs6
-rw-r--r--crypto/test/src/crypto/test/Haraka256DigestTest.cs14
-rw-r--r--crypto/test/src/crypto/test/Haraka512DigestTest.cs14
5 files changed, 17 insertions, 21 deletions
diff --git a/crypto/src/crypto/digests/Haraka256Digest.cs b/crypto/src/crypto/digests/Haraka256Digest.cs
index b5b230e27..f7af4bf69 100644
--- a/crypto/src/crypto/digests/Haraka256Digest.cs
+++ b/crypto/src/crypto/digests/Haraka256Digest.cs
@@ -121,7 +121,7 @@ namespace Org.BouncyCastle.Crypto.Digests
             buffer[off++] = input;
         }
 
-        public void Update(byte[] input, int inOff, int len)
+        public override void BlockUpdate(byte[] input, int inOff, int len)
         {
             if (off + len > 32)
             {
diff --git a/crypto/src/crypto/digests/Haraka512Digest.cs b/crypto/src/crypto/digests/Haraka512Digest.cs
index ce48c81bc..36bdcbabe 100644
--- a/crypto/src/crypto/digests/Haraka512Digest.cs
+++ b/crypto/src/crypto/digests/Haraka512Digest.cs
@@ -182,7 +182,7 @@ namespace Org.BouncyCastle.Crypto.Digests
             buffer[off++] = input;
         }
 
-        public void Update(byte[] input, int inOff, int len)
+        public override void BlockUpdate(byte[] input, int inOff, int len)
         {
             if (off + len > 64)
             {
diff --git a/crypto/src/crypto/digests/HarakaBase.cs b/crypto/src/crypto/digests/HarakaBase.cs
index ef74204e9..6157198f1 100644
--- a/crypto/src/crypto/digests/HarakaBase.cs
+++ b/crypto/src/crypto/digests/HarakaBase.cs
@@ -138,11 +138,7 @@ namespace Org.BouncyCastle.Crypto.Digests
 
         public abstract void Update(byte input);
 
-
-        public void BlockUpdate(byte[] input, int inOff, int length)
-        {
-            throw new NotImplementedException();
-        }
+        public abstract void BlockUpdate(byte[] input, int inOff, int length);
 
         public abstract int DoFinal(byte[] output, int outOff);
 
diff --git a/crypto/test/src/crypto/test/Haraka256DigestTest.cs b/crypto/test/src/crypto/test/Haraka256DigestTest.cs
index 5d9ec6e9b..3f7706211 100644
--- a/crypto/test/src/crypto/test/Haraka256DigestTest.cs
+++ b/crypto/test/src/crypto/test/Haraka256DigestTest.cs
@@ -28,7 +28,7 @@ namespace Org.BouncyCastle.Crypto.Tests
             byte[] expected256 = Hex.Decode("8027ccb87949774b78d0545fb72bf70c695c2a0923cbd47bba1159efbf2b2c1c");
 
             Haraka256Digest haraka = new Haraka256Digest();
-            haraka.Update(input, 0, input.Length);
+            haraka.BlockUpdate(input, 0, input.Length);
             byte[] output = new byte[haraka.GetDigestSize()];
             haraka.DoFinal(output, 0);
             Assert.IsTrue(Arrays.AreEqual(expected256, output));
@@ -41,7 +41,7 @@ namespace Org.BouncyCastle.Crypto.Tests
             {
                 Haraka256Digest haraka = new Haraka256Digest();
                 byte[] input = new byte[31];
-                haraka.Update(input, 0, input.Length);
+                haraka.BlockUpdate(input, 0, input.Length);
                 haraka.DoFinal(null, 0);
                 Assert.Fail("fail on input not 32 bytes.");
             }
@@ -57,7 +57,7 @@ namespace Org.BouncyCastle.Crypto.Tests
             {
                 Haraka256Digest haraka = new Haraka256Digest();
                 byte[] input = new byte[33];
-                haraka.Update(input, 0, input.Length);
+                haraka.BlockUpdate(input, 0, input.Length);
                 haraka.DoFinal(null, 0);
                 Assert.Fail("fail on input not 32 bytes.");
             }
@@ -77,7 +77,7 @@ namespace Org.BouncyCastle.Crypto.Tests
             {
                 Haraka256Digest harakaCipher = new Haraka256Digest();
                 byte[] input = new byte[32];
-                harakaCipher.Update(input, 0, input.Length);
+                harakaCipher.BlockUpdate(input, 0, input.Length);
                 byte[] output = new byte[31];
                 harakaCipher.DoFinal(output, 0);
                 Assert.Fail("Output too short for digest result.");
@@ -94,7 +94,7 @@ namespace Org.BouncyCastle.Crypto.Tests
             {
                 Haraka256Digest harakaCipher = new Haraka256Digest();
                 byte[] input = new byte[32];
-                harakaCipher.Update(input, 0, input.Length);
+                harakaCipher.BlockUpdate(input, 0, input.Length);
                 byte[] output = new byte[48];
                 harakaCipher.DoFinal(output, 17);
                 Assert.Fail("Output too short for digest result.");
@@ -118,7 +118,7 @@ namespace Org.BouncyCastle.Crypto.Tests
                 byte[] expected256 = Hex.Decode("000000008027ccb87949774b78d0545fb72bf70c695c2a0923cbd47bba1159efbf2b2c1c");
 
                 Haraka256Digest harakaCipher = new Haraka256Digest();
-                harakaCipher.Update(input, 0, input.Length);
+                harakaCipher.BlockUpdate(input, 0, input.Length);
                 byte[] output = new byte[harakaCipher.GetDigestSize() + 4];
                 harakaCipher.DoFinal(output, 4);
                 Assert.IsTrue(Arrays.AreEqual(expected256, output));
@@ -158,7 +158,7 @@ namespace Org.BouncyCastle.Crypto.Tests
                 byte[] result = Hex.Decode(vector[0]);
                 for (int t = 0; t < 1000; t++)
                 {
-                    haraka.Update(result, 0, result.Length);
+                    haraka.BlockUpdate(result, 0, result.Length);
                     haraka.DoFinal(result, 0);
                 }
                 Assert.IsTrue(Arrays.AreEqual(expected, result));
diff --git a/crypto/test/src/crypto/test/Haraka512DigestTest.cs b/crypto/test/src/crypto/test/Haraka512DigestTest.cs
index 43a4beff2..11aa746af 100644
--- a/crypto/test/src/crypto/test/Haraka512DigestTest.cs
+++ b/crypto/test/src/crypto/test/Haraka512DigestTest.cs
@@ -28,7 +28,7 @@ namespace Org.BouncyCastle.Crypto.Tests
             byte[] expected512 = Hex.Decode("be7f723b4e80a99813b292287f306f625a6d57331cae5f34dd9277b0945be2aa");
 
             Haraka512Digest haraka = new Haraka512Digest();
-            haraka.Update(input, 0, input.Length);
+            haraka.BlockUpdate(input, 0, input.Length);
             byte[] output = new byte[haraka.GetDigestSize()];
             haraka.DoFinal(output, 0);
             Assert.IsTrue(Arrays.AreEqual(expected512, output));
@@ -40,7 +40,7 @@ namespace Org.BouncyCastle.Crypto.Tests
             {
                 Haraka512Digest haraka = new Haraka512Digest();
                 byte[] input = new byte[63];
-                haraka.Update(input, 0, input.Length);
+                haraka.BlockUpdate(input, 0, input.Length);
                 haraka.DoFinal(null, 0);
                 Assert.Fail("fail on input not 64 bytes.");
             }
@@ -56,7 +56,7 @@ namespace Org.BouncyCastle.Crypto.Tests
             {
                 Haraka512Digest haraka = new Haraka512Digest();
                 byte[] input = new byte[65];
-                haraka.Update(input, 0, input.Length);
+                haraka.BlockUpdate(input, 0, input.Length);
                 haraka.DoFinal(null, 0);
                 Assert.Fail("fail on input not 64 bytes.");
             }
@@ -75,7 +75,7 @@ namespace Org.BouncyCastle.Crypto.Tests
             {
                 Haraka512Digest haraka = new Haraka512Digest();
                 byte[] input = new byte[64];
-                haraka.Update(input, 0, input.Length);
+                haraka.BlockUpdate(input, 0, input.Length);
                 byte[] output = new byte[31];
                 haraka.DoFinal(output, 0);
                 Assert.Fail("Output too short for digest result.");
@@ -92,7 +92,7 @@ namespace Org.BouncyCastle.Crypto.Tests
             {
                 Haraka512Digest haraka = new Haraka512Digest();
                 byte[] input = new byte[64];
-                haraka.Update(input, 0, input.Length);
+                haraka.BlockUpdate(input, 0, input.Length);
                 byte[] output = new byte[48];
                 haraka.DoFinal(output, 17);
                 Assert.Fail("Output too short for digest result.");
@@ -115,7 +115,7 @@ namespace Org.BouncyCastle.Crypto.Tests
                 byte[] expected512 = Hex.Decode("00000000be7f723b4e80a99813b292287f306f625a6d57331cae5f34dd9277b0945be2aa");
 
                 Haraka512Digest haraka = new Haraka512Digest();
-                haraka.Update(input, 0, input.Length);
+                haraka.BlockUpdate(input, 0, input.Length);
                 byte[] output = new byte[haraka.GetDigestSize() + 4];
                 haraka.DoFinal(output, 4);
                 Assert.IsTrue(Arrays.AreEqual(expected512, output));
@@ -152,7 +152,7 @@ namespace Org.BouncyCastle.Crypto.Tests
                 byte[] result = new byte[haraka.GetDigestSize()];
                 for (int t = 0; t < 1000; t++)
                 {
-                    haraka.Update(input, 0, input.Length);
+                    haraka.BlockUpdate(input, 0, input.Length);
                     haraka.DoFinal(result, 0);
 
                     if ((t & 0x01) == 1)