summary refs log tree commit diff
path: root/crypto/test
diff options
context:
space:
mode:
authorPeter Dettman <peter.dettman@bouncycastle.org>2023-02-15 18:13:17 +0700
committerPeter Dettman <peter.dettman@bouncycastle.org>2023-02-15 18:13:17 +0700
commit9ebb5d67badc33b6acae4ee428345df97c43049d (patch)
tree95b749a0c1d271cc674ad87cbbdab0e457c01d62 /crypto/test
parentChaCha20Poly1305: improve OutputSize methods (diff)
downloadBouncyCastle.NET-ed25519-9ebb5d67badc33b6acae4ee428345df97c43049d.tar.xz
Rework AsconEngine
- efficient buffering
- AeadParameters support
- underflow check for decryption
improved OutputSize methods
Diffstat (limited to 'crypto/test')
-rw-r--r--crypto/test/src/crypto/test/AsconTest.cs54
1 files changed, 54 insertions, 0 deletions
diff --git a/crypto/test/src/crypto/test/AsconTest.cs b/crypto/test/src/crypto/test/AsconTest.cs
index 59e5aaa6d..5e426bbfe 100644
--- a/crypto/test/src/crypto/test/AsconTest.cs
+++ b/crypto/test/src/crypto/test/AsconTest.cs
@@ -19,6 +19,60 @@ namespace Org.BouncyCastle.Crypto.Tests
     {
         public override string Name => "ASCON";
 
+        [Test, Explicit]
+        public void BenchAuth80pq()
+        {
+            var parameters = new AeadParameters(new KeyParameter(new byte[20]), 128, new byte[16], null);
+            var engine = new AsconEngine(AsconEngine.AsconParameters.ascon80pq);
+            engine.Init(false, parameters);
+
+            byte[] data = new byte[1024];
+            for (int i = 0; i < 1024 * 1024; ++i)
+            {
+#if NET6_0_OR_GREATER
+                engine.ProcessAadBytes(data.AsSpan(0, 1024));
+#else
+                engine.ProcessAadBytes(data, 0, 1024);
+#endif
+            }
+        }
+
+        [Test, Explicit]
+        public void BenchDecrypt80pq()
+        {
+            var parameters = new AeadParameters(new KeyParameter(new byte[20]), 128, new byte[16], null);
+            var engine = new AsconEngine(AsconEngine.AsconParameters.ascon80pq);
+            engine.Init(false, parameters);
+
+            byte[] data = new byte[1024];
+            for (int i = 0; i < 1024 * 1024; ++i)
+            {
+#if NET6_0_OR_GREATER
+                engine.ProcessBytes(data.AsSpan(0, 1024), data);
+#else
+                engine.ProcessBytes(data, 0, 1024, data, 0);
+#endif
+            }
+        }
+
+        [Test, Explicit]
+        public void BenchEncrypt80pq()
+        {
+            var parameters = new AeadParameters(new KeyParameter(new byte[20]), 128, new byte[16], null);
+            var engine = new AsconEngine(AsconEngine.AsconParameters.ascon80pq);
+            engine.Init(true, parameters);
+
+            byte[] data = new byte[engine.GetUpdateOutputSize(1024)];
+            for (int i = 0; i < 1024 * 1024; ++i)
+            {
+#if NET6_0_OR_GREATER
+                engine.ProcessBytes(data.AsSpan(0, 1024), data);
+#else
+                engine.ProcessBytes(data, 0, 1024, data, 0);
+#endif
+            }
+        }
+
         [Test]
         public override void PerformTest()
         {