summary refs log tree commit diff
path: root/crypto/src/util/BigIntegers.cs
diff options
context:
space:
mode:
Diffstat (limited to 'crypto/src/util/BigIntegers.cs')
-rw-r--r--crypto/src/util/BigIntegers.cs16
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.
         *