diff options
author | Peter Dettman <peter.dettman@bouncycastle.org> | 2022-12-01 00:58:27 +0700 |
---|---|---|
committer | Peter Dettman <peter.dettman@bouncycastle.org> | 2022-12-01 00:58:27 +0700 |
commit | f693a6cd892ea8a4747d5cff60ad2051458ad5f5 (patch) | |
tree | c26d517c68bb9969e2eeb099f814b6a6edc8d1a4 /crypto/src/util | |
parent | sect233r1 perf. opts. (diff) | |
download | BouncyCastle.NET-ed25519-f693a6cd892ea8a4747d5cff60ad2051458ad5f5.tar.xz |
Tnaf perf. opts.
Diffstat (limited to 'crypto/src/util')
-rw-r--r-- | crypto/src/util/BigIntegers.cs | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/crypto/src/util/BigIntegers.cs b/crypto/src/util/BigIntegers.cs index e63af7c7c..668d92246 100644 --- a/crypto/src/util/BigIntegers.cs +++ b/crypto/src/util/BigIntegers.cs @@ -16,6 +16,22 @@ namespace Org.BouncyCastle.Utilities private const int MaxIterations = 1000; +#if NETCOREAPP2_1_OR_GREATER || NETSTANDARD2_1_OR_GREATER + [CLSCompliant(false)] + public static void AsUint32ArrayLittleEndian(BigInteger n, Span<uint> buf) + { + int uintsLength = n.GetLengthofUInt32Array(); + + if (uintsLength > buf.Length) + throw new ArgumentException("standard length exceeded", nameof(n)); + + n.ToUInt32ArrayLittleEndian(buf); + + int sign = (int)buf[uintsLength - 1] >> 31; + buf[uintsLength..].Fill((uint)sign); + } +#endif + /** * Return the passed in value as an unsigned byte array. * |