summary refs log tree commit diff
diff options
context:
space:
mode:
authorPeter Dettman <peter.dettman@bouncycastle.org>2023-06-08 14:26:10 +0700
committerPeter Dettman <peter.dettman@bouncycastle.org>2023-06-08 14:26:10 +0700
commit0ebde6504685c71c5aa4a5e2ad4be1a04a8a6ef1 (patch)
treed7d232f8a33fccaf2afc652eed6b429645ce4291
parentBIKE perf. opts. (diff)
downloadBouncyCastle.NET-ed25519-0ebde6504685c71c5aa4a5e2ad4be1a04a8a6ef1.tar.xz
Add more Pack method variants
-rw-r--r--crypto/src/crypto/util/Pack.cs20
1 files changed, 20 insertions, 0 deletions
diff --git a/crypto/src/crypto/util/Pack.cs b/crypto/src/crypto/util/Pack.cs
index 3977d221e..dc0e93b7d 100644
--- a/crypto/src/crypto/util/Pack.cs
+++ b/crypto/src/crypto/util/Pack.cs
@@ -1037,6 +1037,26 @@ namespace Org.BouncyCastle.Crypto.Utilities
         }
 
         [MethodImpl(MethodImplOptions.AggressiveInlining)]
+        internal static void UInt32_To_LE_High(uint n, Span<byte> bs)
+        {
+            UInt32_To_LE_Low(n >> ((4 - bs.Length) << 3), bs);
+        }
+
+        [MethodImpl(MethodImplOptions.AggressiveInlining)]
+        internal static void UInt32_To_LE_Low(uint n, Span<byte> bs)
+        {
+            int len = bs.Length;
+            Debug.Assert(1 <= len && len <= 4);
+
+            bs[0] = (byte)n;
+            for (int i = 1; i < len; ++i)
+            {
+                n >>= 8;
+                bs[i] = (byte)n;
+            }
+        }
+
+        [MethodImpl(MethodImplOptions.AggressiveInlining)]
         internal static void UInt64_To_BE(ulong n, Span<byte> bs)
         {
             BinaryPrimitives.WriteUInt64BigEndian(bs, n);