diff options
author | Peter Dettman <peter.dettman@bouncycastle.org> | 2023-06-08 14:26:42 +0700 |
---|---|---|
committer | Peter Dettman <peter.dettman@bouncycastle.org> | 2023-06-08 14:26:42 +0700 |
commit | cd3c400f5cebd7a2f8af6538b745d22fe241a55e (patch) | |
tree | ce4ea4e6dab5e611840fd68d42df981991e872b7 | |
parent | Add more Pack method variants (diff) | |
download | BouncyCastle.NET-ed25519-cd3c400f5cebd7a2f8af6538b745d22fe241a55e.tar.xz |
Minor opt in Nat.ToBigInteger
-rw-r--r-- | crypto/src/math/raw/Nat.cs | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/crypto/src/math/raw/Nat.cs b/crypto/src/math/raw/Nat.cs index f4d91b180..d748e04c5 100644 --- a/crypto/src/math/raw/Nat.cs +++ b/crypto/src/math/raw/Nat.cs @@ -2,6 +2,7 @@ using System.Diagnostics; #if NETCOREAPP2_1_OR_GREATER || NETSTANDARD2_1_OR_GREATER using System.Numerics; +using System.Runtime.InteropServices; #endif using Org.BouncyCastle.Crypto.Utilities; @@ -2742,6 +2743,9 @@ namespace Org.BouncyCastle.Math.Raw #if NETCOREAPP2_1_OR_GREATER || NETSTANDARD2_1_OR_GREATER public static BigInteger ToBigInteger(int len, ReadOnlySpan<uint> x) { + if (BitConverter.IsLittleEndian) + return new BigInteger(1, MemoryMarshal.AsBytes(x), bigEndian: false); + int bsLen = len << 2; Span<byte> bs = bsLen <= 512 ? stackalloc byte[bsLen] |