From 4fac9a2bcbbc8622f0ca9823507ae7a56e6061b5 Mon Sep 17 00:00:00 2001 From: Peter Dettman Date: Thu, 13 Apr 2023 15:31:46 +0700 Subject: Round out Span-based Pack methods --- crypto/src/crypto/util/Pack.cs | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'crypto/src') diff --git a/crypto/src/crypto/util/Pack.cs b/crypto/src/crypto/util/Pack.cs index dc87cf7d8..99c15484c 100644 --- a/crypto/src/crypto/util/Pack.cs +++ b/crypto/src/crypto/util/Pack.cs @@ -709,6 +709,12 @@ namespace Org.BouncyCastle.Crypto.Utilities return BinaryPrimitives.ReadUInt32BigEndian(bs); } + [MethodImpl(MethodImplOptions.AggressiveInlining)] + internal static uint BE_To_UInt32(ReadOnlySpan bs, int off) + { + return BinaryPrimitives.ReadUInt32BigEndian(bs[off..]); + } + [MethodImpl(MethodImplOptions.AggressiveInlining)] internal static void BE_To_UInt32(ReadOnlySpan bs, Span ns) { @@ -745,6 +751,12 @@ namespace Org.BouncyCastle.Crypto.Utilities return BinaryPrimitives.ReadUInt64BigEndian(bs); } + [MethodImpl(MethodImplOptions.AggressiveInlining)] + internal static ulong BE_To_UInt64(ReadOnlySpan bs, int off) + { + return BinaryPrimitives.ReadUInt64BigEndian(bs[off..]); + } + [MethodImpl(MethodImplOptions.AggressiveInlining)] internal static void BE_To_UInt64(ReadOnlySpan bs, Span ns) { @@ -819,6 +831,12 @@ namespace Org.BouncyCastle.Crypto.Utilities return BinaryPrimitives.ReadUInt64LittleEndian(bs); } + [MethodImpl(MethodImplOptions.AggressiveInlining)] + internal static ulong LE_To_UInt64(ReadOnlySpan bs, int off) + { + return BinaryPrimitives.ReadUInt64LittleEndian(bs[off..]); + } + [MethodImpl(MethodImplOptions.AggressiveInlining)] internal static void LE_To_UInt64(ReadOnlySpan bs, Span ns) { -- cgit 1.5.1