summary refs log tree commit diff
diff options
context:
space:
mode:
authorgefeili <gli@keyfactor.com>2023-01-23 14:21:17 +1030
committergefeili <gli@keyfactor.com>2023-01-23 14:21:17 +1030
commit2372a4e7486c116f1c9e7a2ee2601f594d6f6874 (patch)
tree608d0737f6b6fa104503edc1219afe13ed419a6a
parentComplete tests for Ascon AEAD (diff)
parentComplete tests for Ascon AEAD (diff)
downloadBouncyCastle.NET-ed25519-2372a4e7486c116f1c9e7a2ee2601f594d6f6874.tar.xz
Remove tests on span<byte>
-rw-r--r--crypto/test/src/crypto/test/AsconTest.cs35
1 files changed, 35 insertions, 0 deletions
diff --git a/crypto/test/src/crypto/test/AsconTest.cs b/crypto/test/src/crypto/test/AsconTest.cs

index 1dc32ba4b..255cc2770 100644 --- a/crypto/test/src/crypto/test/AsconTest.cs +++ b/crypto/test/src/crypto/test/AsconTest.cs
@@ -373,6 +373,7 @@ namespace BouncyCastle.Crypto.Tests Assert.Fail("Splitting input of plaintext should output the same ciphertext"); } +<<<<<<< HEAD //#if NETCOREAPP2_1_OR_GREATER || NETSTANDARD2_1_OR_GREATER // Span<byte> c4_1 = new byte[c2.Length]; // Span<byte> c4_2 = new byte[c2.Length]; @@ -405,6 +406,40 @@ namespace BouncyCastle.Crypto.Tests // Assert.Fail("mac should match for the same AAD and message with different offset for both input and output"); // } //#endif +======= +#if NETCOREAPP2_1_OR_GREATER || NETSTANDARD2_1_OR_GREATER + Span<byte> c4_1 = new byte[c2.Length]; + Span<byte> c4_2 = new byte[c2.Length]; + ReadOnlySpan<byte> m5 = new ReadOnlySpan<byte>(m2); + ReadOnlySpan<byte> aad4 = new ReadOnlySpan<byte>(aad2); + aeadBlockCipher.Init(true, param); + aeadBlockCipher.ProcessAadBytes(aad4); + offset = aeadBlockCipher.ProcessBytes(m5, c4_1); + aeadBlockCipher.DoFinal(c4_2); + byte[] c5 = new byte[c2.Length]; + Array.Copy(c4_1.ToArray(), 0, c5, 0, offset); + Array.Copy(c4_2.ToArray(), 0, c5, offset, c5.Length - offset); + if (!Arrays.AreEqual(c2, c5)) + { + Assert.Fail("mac should match for the same AAD and message with different offset for both input and output"); + } + aeadBlockCipher.Reset(); + aeadBlockCipher.Init(false, param); + Span<byte> m6_1 = new byte[m2.Length]; + Span<byte> m6_2 = new byte[m2.Length]; + ReadOnlySpan<byte> c6 = new ReadOnlySpan<byte>(c2); + aeadBlockCipher.ProcessAadBytes(aad4); + offset = aeadBlockCipher.ProcessBytes(c6, m6_1); + aeadBlockCipher.DoFinal(m6_2); + byte[] m6 = new byte[m2.Length]; + Array.Copy(m6_1.ToArray(), 0, m6, 0, offset); + Array.Copy(m6_2.ToArray(), 0, m6, offset, m6.Length - offset); + if (!Arrays.AreEqual(m2, m6)) + { + Assert.Fail("mac should match for the same AAD and message with different offset for both input and output"); + } +#endif +>>>>>>> 50f605fdfafd4bcf2fff5f75b1ade5490e7710ab } private void testParameters(AsconEngine ascon, int keySize, int ivSize, int macSize, int blockSize)