summary refs log tree commit diff
path: root/crypto/src/tls/AbstractTlsContext.cs
diff options
context:
space:
mode:
authorPeter Dettman <peter.dettman@bouncycastle.org>2022-10-07 23:27:37 +0700
committerPeter Dettman <peter.dettman@bouncycastle.org>2022-10-07 23:27:37 +0700
commit15105e796c6cd0c23357aa54ac5a0a05af20c2a0 (patch)
tree435794f619138df8aa7358afb3b9af4fc4c2e372 /crypto/src/tls/AbstractTlsContext.cs
parentSpan usage in encoders (diff)
downloadBouncyCastle.NET-ed25519-15105e796c6cd0c23357aa54ac5a0a05af20c2a0.tar.xz
More span variants in randomness classes
Diffstat (limited to 'crypto/src/tls/AbstractTlsContext.cs')
-rw-r--r--crypto/src/tls/AbstractTlsContext.cs6
1 files changed, 6 insertions, 0 deletions
diff --git a/crypto/src/tls/AbstractTlsContext.cs b/crypto/src/tls/AbstractTlsContext.cs
index 40a8e8f75..fa9bc80cd 100644
--- a/crypto/src/tls/AbstractTlsContext.cs
+++ b/crypto/src/tls/AbstractTlsContext.cs
@@ -20,9 +20,15 @@ namespace Org.BouncyCastle.Tls
 
         private static TlsNonceGenerator CreateNonceGenerator(TlsCrypto crypto, int connectionEnd)
         {
+#if NETCOREAPP2_1_OR_GREATER || NETSTANDARD2_1_OR_GREATER
+            Span<byte> additionalSeedMaterial = stackalloc byte[16];
+            Pack.UInt64_To_BE((ulong)NextCounterValue(), additionalSeedMaterial);
+            Pack.UInt64_To_BE((ulong)DateTime.UtcNow.Ticks, additionalSeedMaterial[8..]);
+#else
             byte[] additionalSeedMaterial = new byte[16];
             Pack.UInt64_To_BE((ulong)NextCounterValue(), additionalSeedMaterial, 0);
             Pack.UInt64_To_BE((ulong)DateTime.UtcNow.Ticks, additionalSeedMaterial, 8);
+#endif
             additionalSeedMaterial[0] &= 0x7F;
             additionalSeedMaterial[0] |= (byte)(connectionEnd << 7);