summary refs log tree commit diff
path: root/crypto/test
diff options
context:
space:
mode:
authorDavid Hook <dgh@bouncycastle.org>2016-02-07 22:46:57 +1100
committerDavid Hook <dgh@bouncycastle.org>2016-02-07 22:46:57 +1100
commitea14fe42f35364f2785f9baf979366ed4aae6118 (patch)
treef75806b3413b68c0a4ba23ac0c40dcf42512b8bb /crypto/test
parentAdd bcrypt classes to mobile projects (diff)
downloadBouncyCastle.NET-ed25519-ea14fe42f35364f2785f9baf979366ed4aae6118.tar.xz
Added support for repeated requests for output to Xof.
Diffstat (limited to 'crypto/test')
-rw-r--r--crypto/test/src/crypto/test/ShakeDigestTest.cs44
1 files changed, 44 insertions, 0 deletions
diff --git a/crypto/test/src/crypto/test/ShakeDigestTest.cs b/crypto/test/src/crypto/test/ShakeDigestTest.cs
index ef4696739..d8b2d55d6 100644
--- a/crypto/test/src/crypto/test/ShakeDigestTest.cs
+++ b/crypto/test/src/crypto/test/ShakeDigestTest.cs
@@ -199,6 +199,50 @@ namespace Org.BouncyCastle.Crypto.Tests
                 //Console.Error.WriteLine(v.Algorithm + " " + v.Bits + "-bit test vector hash mismatch");
                 //Console.Error.WriteLine(Hex.ToHexString(output).ToUpper());
             }
+
+            if (partialBits == 0)
+            {
+                d = CreateDigest(v.Algorithm);
+
+                m = v.Message;
+
+                d.BlockUpdate(m, 0, m.Length);
+                d.DoOutput(output, 0, outLen / 2);
+                d.DoOutput(output, outLen / 2, output.Length - outLen / 2);
+
+                if (!Arrays.AreEqual(expected, output))
+                {
+                    Fail(v.Algorithm + " " + v.Bits + "-bit test vector extended hash mismatch");
+                }
+
+                try
+                {
+                    d.Update((byte)0x01);
+                    Fail("no exception");
+                }
+                catch (InvalidOperationException e)
+                {
+                    if (!"attempt to absorb while squeezing".Equals(e.Message))
+                    {
+                        Fail("wrong exception");
+                    }
+                }
+
+                d = CreateDigest(v.Algorithm);
+
+                m = v.Message;
+
+                d.BlockUpdate(m, 0, m.Length);
+                d.DoOutput(output, 0, outLen / 2);
+                d.DoFinal(output, outLen / 2, output.Length - outLen / 2);
+
+                if (!Arrays.AreEqual(expected, output))
+                {
+                    Fail(v.Algorithm + " " + v.Bits + "-bit test vector extended doFinal hash mismatch");
+                }
+
+                d.Update((byte)0x01); // this should be okay as we've reset on DoFinal()
+            }
         }
 
         private void SkipUntil(StreamReader r, string header)