summary refs log tree commit diff
diff options
context:
space:
mode:
authorPeter Dettman <peter.dettman@bouncycastle.org>2023-04-13 15:31:46 +0700
committerPeter Dettman <peter.dettman@bouncycastle.org>2023-04-13 15:31:46 +0700
commit4fac9a2bcbbc8622f0ca9823507ae7a56e6061b5 (patch)
tree1e0de5bbccae89d38375a5531c1a2296e9b3b9ed
parentAsn1OctetString constructor from Span<byte> (copying) (diff)
downloadBouncyCastle.NET-ed25519-4fac9a2bcbbc8622f0ca9823507ae7a56e6061b5.tar.xz
Round out Span-based Pack methods
-rw-r--r--crypto/src/crypto/util/Pack.cs18
1 files changed, 18 insertions, 0 deletions
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
@@ -710,6 +710,12 @@ namespace Org.BouncyCastle.Crypto.Utilities } [MethodImpl(MethodImplOptions.AggressiveInlining)] + internal static uint BE_To_UInt32(ReadOnlySpan<byte> bs, int off) + { + return BinaryPrimitives.ReadUInt32BigEndian(bs[off..]); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] internal static void BE_To_UInt32(ReadOnlySpan<byte> bs, Span<uint> ns) { for (int i = 0; i < ns.Length; ++i) @@ -746,6 +752,12 @@ namespace Org.BouncyCastle.Crypto.Utilities } [MethodImpl(MethodImplOptions.AggressiveInlining)] + internal static ulong BE_To_UInt64(ReadOnlySpan<byte> bs, int off) + { + return BinaryPrimitives.ReadUInt64BigEndian(bs[off..]); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] internal static void BE_To_UInt64(ReadOnlySpan<byte> bs, Span<ulong> ns) { for (int i = 0; i < ns.Length; ++i) @@ -820,6 +832,12 @@ namespace Org.BouncyCastle.Crypto.Utilities } [MethodImpl(MethodImplOptions.AggressiveInlining)] + internal static ulong LE_To_UInt64(ReadOnlySpan<byte> bs, int off) + { + return BinaryPrimitives.ReadUInt64LittleEndian(bs[off..]); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] internal static void LE_To_UInt64(ReadOnlySpan<byte> bs, Span<ulong> ns) { for (int i = 0; i < ns.Length; ++i)