From 9111180cdbb9d26de2fac774a82dd7556d610c37 Mon Sep 17 00:00:00 2001 From: Peter Dettman Date: Wed, 26 Apr 2023 23:09:11 +0700 Subject: Add new Pack methods --- crypto/src/crypto/util/Pack.cs | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/crypto/src/crypto/util/Pack.cs b/crypto/src/crypto/util/Pack.cs index a4f8a834f..17bd3681f 100644 --- a/crypto/src/crypto/util/Pack.cs +++ b/crypto/src/crypto/util/Pack.cs @@ -925,6 +925,12 @@ namespace Org.BouncyCastle.Crypto.Utilities BinaryPrimitives.WriteUInt32BigEndian(bs, n); } + [MethodImpl(MethodImplOptions.AggressiveInlining)] + internal static void UInt32_To_BE(uint n, Span bs, int off) + { + BinaryPrimitives.WriteUInt32BigEndian(bs[off..], n); + } + internal static void UInt32_To_BE_High(uint n, Span bs) { int len = bs.Length; @@ -961,6 +967,12 @@ namespace Org.BouncyCastle.Crypto.Utilities BinaryPrimitives.WriteUInt32LittleEndian(bs, n); } + [MethodImpl(MethodImplOptions.AggressiveInlining)] + internal static void UInt32_To_LE(uint n, Span bs, int off) + { + BinaryPrimitives.WriteUInt32LittleEndian(bs[off..], n); + } + [MethodImpl(MethodImplOptions.AggressiveInlining)] internal static void UInt32_To_LE(ReadOnlySpan ns, Span bs) { @@ -977,6 +989,12 @@ namespace Org.BouncyCastle.Crypto.Utilities BinaryPrimitives.WriteUInt64BigEndian(bs, n); } + [MethodImpl(MethodImplOptions.AggressiveInlining)] + internal static void UInt64_To_BE(ulong n, Span bs, int off) + { + BinaryPrimitives.WriteUInt64BigEndian(bs[off..], n); + } + internal static void UInt64_To_BE_High(ulong n, Span bs) { int len = bs.Length; @@ -1013,6 +1031,12 @@ namespace Org.BouncyCastle.Crypto.Utilities BinaryPrimitives.WriteUInt64LittleEndian(bs, n); } + [MethodImpl(MethodImplOptions.AggressiveInlining)] + internal static void UInt64_To_LE(ulong n, Span bs, int off) + { + BinaryPrimitives.WriteUInt64LittleEndian(bs[off..], n); + } + [MethodImpl(MethodImplOptions.AggressiveInlining)] internal static void UInt64_To_LE(ReadOnlySpan ns, Span bs) { -- cgit 1.5.1