diff options
author | Peter Dettman <peter.dettman@bouncycastle.org> | 2023-06-08 14:26:10 +0700 |
---|---|---|
committer | Peter Dettman <peter.dettman@bouncycastle.org> | 2023-06-08 14:26:10 +0700 |
commit | 0ebde6504685c71c5aa4a5e2ad4be1a04a8a6ef1 (patch) | |
tree | d7d232f8a33fccaf2afc652eed6b429645ce4291 /crypto/src | |
parent | BIKE perf. opts. (diff) | |
download | BouncyCastle.NET-ed25519-0ebde6504685c71c5aa4a5e2ad4be1a04a8a6ef1.tar.xz |
Add more Pack method variants
Diffstat (limited to 'crypto/src')
-rw-r--r-- | crypto/src/crypto/util/Pack.cs | 20 |
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); |