summary refs log tree commit diff
diff options
context:
space:
mode:
authorPeter Dettman <peter.dettman@bouncycastle.org>2022-08-26 12:14:09 +0700
committerPeter Dettman <peter.dettman@bouncycastle.org>2022-08-26 12:14:09 +0700
commit41707f4a3de253f97e5036075d9b5dd22a7d9af3 (patch)
treebfa56a1b819ba1b7dc5375015fb09e35fcb456bf
parentHandle zero-distance rotates correctly (diff)
downloadBouncyCastle.NET-ed25519-41707f4a3de253f97e5036075d9b5dd22a7d9af3.tar.xz
Don't use CLR span-based NextBytes
-rw-r--r--crypto/test/src/security/test/SecureRandomTest.cs17
-rw-r--r--crypto/test/src/util/test/FixedSecureRandom.cs8
2 files changed, 19 insertions, 6 deletions
diff --git a/crypto/test/src/security/test/SecureRandomTest.cs b/crypto/test/src/security/test/SecureRandomTest.cs
index f6d06201f..fb18f98e0 100644
--- a/crypto/test/src/security/test/SecureRandomTest.cs
+++ b/crypto/test/src/security/test/SecureRandomTest.cs
@@ -12,6 +12,7 @@ using Org.BouncyCastle.Utilities;
 namespace Org.BouncyCastle.Security.Tests
 {
     [TestFixture]
+    [Parallelizable(ParallelScope.All)]
     public class SecureRandomTest
     {
         [Test]
@@ -142,7 +143,9 @@ namespace Org.BouncyCastle.Security.Tests
                     return false;
             }
 
-#if NETCOREAPP2_1_OR_GREATER || NETSTANDARD2_1_OR_GREATER
+            // NOTE: .NET Core 2.1 has Span<T>, but is tested against our .NET Standard 2.0 assembly.
+//#if NETCOREAPP2_1_OR_GREATER || NETSTANDARD2_1_OR_GREATER
+#if NET6_0_OR_GREATER || NETSTANDARD2_1_OR_GREATER
             {
                 int passes = 0;
 
@@ -223,7 +226,9 @@ namespace Org.BouncyCastle.Security.Tests
             return chi2;
         }
 
-#if NETCOREAPP2_1_OR_GREATER || NETSTANDARD2_1_OR_GREATER
+        // NOTE: .NET Core 2.1 has Span<T>, but is tested against our .NET Standard 2.0 assembly.
+//#if NETCOREAPP2_1_OR_GREATER || NETSTANDARD2_1_OR_GREATER
+#if NET6_0_OR_GREATER || NETSTANDARD2_1_OR_GREATER
         private static double MeasureChiSquaredSpan(SecureRandom random, int rounds)
         {
             byte[] opts = random.GenerateSeed(2);
@@ -301,7 +306,9 @@ namespace Org.BouncyCastle.Security.Tests
 
             public abstract void NextBytes(byte[] bytes, int start, int len);
 
-#if NETCOREAPP2_1_OR_GREATER || NETSTANDARD2_1_OR_GREATER
+            // NOTE: .NET Core 2.1 has Span<T>, but is tested against our .NET Standard 2.0 assembly.
+//#if NETCOREAPP2_1_OR_GREATER || NETSTANDARD2_1_OR_GREATER
+#if NET6_0_OR_GREATER || NETSTANDARD2_1_OR_GREATER
             public abstract void NextBytes(Span<byte> bytes);
 #endif
         }
@@ -321,7 +328,9 @@ namespace Org.BouncyCastle.Security.Tests
                 Arrays.Fill(bytes, start, start + len, b);
             }
 
-#if NETCOREAPP2_1_OR_GREATER || NETSTANDARD2_1_OR_GREATER
+            // NOTE: .NET Core 2.1 has Span<T>, but is tested against our .NET Standard 2.0 assembly.
+//#if NETCOREAPP2_1_OR_GREATER || NETSTANDARD2_1_OR_GREATER
+#if NET6_0_OR_GREATER || NETSTANDARD2_1_OR_GREATER
             public override void NextBytes(Span<byte> bytes)
             {
                 bytes.Fill(b);
diff --git a/crypto/test/src/util/test/FixedSecureRandom.cs b/crypto/test/src/util/test/FixedSecureRandom.cs
index ab74145a4..d29159a62 100644
--- a/crypto/test/src/util/test/FixedSecureRandom.cs
+++ b/crypto/test/src/util/test/FixedSecureRandom.cs
@@ -226,7 +226,9 @@ namespace Org.BouncyCastle.Utilities.Test
 			_index += len;
 		}
 
-#if NETCOREAPP2_1_OR_GREATER || NETSTANDARD2_1_OR_GREATER
+        // NOTE: .NET Core 2.1 has Span<T>, but is tested against our .NET Standard 2.0 assembly.
+        //#if NETCOREAPP2_1_OR_GREATER || NETSTANDARD2_1_OR_GREATER
+#if NET6_0_OR_GREATER || NETSTANDARD2_1_OR_GREATER
         public override void NextBytes(Span<byte> buffer)
         {
             _data.AsSpan(_index, buffer.Length).CopyTo(buffer);
@@ -258,7 +260,9 @@ namespace Org.BouncyCastle.Utilities.Test
                 index += len;
             }
 
-#if NETCOREAPP2_1_OR_GREATER || NETSTANDARD2_1_OR_GREATER
+            // NOTE: .NET Core 2.1 has Span<T>, but is tested against our .NET Standard 2.0 assembly.
+//#if NETCOREAPP2_1_OR_GREATER || NETSTANDARD2_1_OR_GREATER
+#if NET6_0_OR_GREATER || NETSTANDARD2_1_OR_GREATER
             public override void NextBytes(Span<byte> buffer)
             {
                 data.AsSpan(index, buffer.Length).CopyTo(buffer);