summary refs log tree commit diff
path: root/crypto
diff options
context:
space:
mode:
Diffstat (limited to 'crypto')
-rw-r--r--crypto/src/crypto/engines/SparkleEngine.cs2
-rw-r--r--crypto/test/src/crypto/test/AsconTest.cs6
-rw-r--r--crypto/test/src/crypto/test/SparkleTest.cs6
3 files changed, 13 insertions, 1 deletions
diff --git a/crypto/src/crypto/engines/SparkleEngine.cs b/crypto/src/crypto/engines/SparkleEngine.cs
index 4c558b70f..053ca3bb5 100644
--- a/crypto/src/crypto/engines/SparkleEngine.cs
+++ b/crypto/src/crypto/engines/SparkleEngine.cs
@@ -623,7 +623,7 @@ namespace Org.BouncyCastle.Crypto.Engines
         public int GetUpdateOutputSize(int len)
         {
             // The -1 is to account for the lazy processing of a full buffer
-            int total = System.Math.Max(0, len - 1);
+            int total = System.Math.Max(0, len) - 1;
 
             switch (m_state)
             {
diff --git a/crypto/test/src/crypto/test/AsconTest.cs b/crypto/test/src/crypto/test/AsconTest.cs
index 400767df0..8edaf9182 100644
--- a/crypto/test/src/crypto/test/AsconTest.cs
+++ b/crypto/test/src/crypto/test/AsconTest.cs
@@ -373,6 +373,9 @@ namespace Org.BouncyCastle.Crypto.Tests
                 random.NextBytes(output);
 
                 int length = ascon.ProcessBytes(plaintext, 0, split, output, 0);
+
+                Assert.AreEqual(0, ascon.GetUpdateOutputSize(0));
+
                 length += ascon.ProcessBytes(plaintext, split, plaintextLength - split, output, length);
                 length += ascon.DoFinal(output, length);
 
@@ -389,6 +392,9 @@ namespace Org.BouncyCastle.Crypto.Tests
                 random.NextBytes(output);
 
                 int length = ascon.ProcessBytes(ciphertext, 0, split, output, 0);
+
+                Assert.AreEqual(0, ascon.GetUpdateOutputSize(0));
+
                 length += ascon.ProcessBytes(ciphertext, split, ciphertextLength - split, output, length);
                 length += ascon.DoFinal(output, length);
 
diff --git a/crypto/test/src/crypto/test/SparkleTest.cs b/crypto/test/src/crypto/test/SparkleTest.cs
index ca6e7aa8b..712223a86 100644
--- a/crypto/test/src/crypto/test/SparkleTest.cs
+++ b/crypto/test/src/crypto/test/SparkleTest.cs
@@ -334,6 +334,9 @@ namespace Org.BouncyCastle.Crypto.Tests
                 random.NextBytes(output);
 
                 int length = sparkle.ProcessBytes(plaintext, 0, split, output, 0);
+
+                Assert.AreEqual(0, sparkle.GetUpdateOutputSize(0));
+
                 length += sparkle.ProcessBytes(plaintext, split, plaintextLength - split, output, length);
                 length += sparkle.DoFinal(output, length);
 
@@ -350,6 +353,9 @@ namespace Org.BouncyCastle.Crypto.Tests
                 random.NextBytes(output);
 
                 int length = sparkle.ProcessBytes(ciphertext, 0, split, output, 0);
+
+                Assert.AreEqual(0, sparkle.GetUpdateOutputSize(0));
+
                 length += sparkle.ProcessBytes(ciphertext, split, ciphertextLength - split, output, length);
                 length += sparkle.DoFinal(output, length);