diff options
author | Peter Dettman <peter.dettman@bouncycastle.org> | 2022-10-07 23:27:37 +0700 |
---|---|---|
committer | Peter Dettman <peter.dettman@bouncycastle.org> | 2022-10-07 23:27:37 +0700 |
commit | 15105e796c6cd0c23357aa54ac5a0a05af20c2a0 (patch) | |
tree | 435794f619138df8aa7358afb3b9af4fc4c2e372 /crypto/src/tls/AbstractTlsContext.cs | |
parent | Span usage in encoders (diff) | |
download | BouncyCastle.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.cs | 6 |
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); |