summary refs log tree commit diff
path: root/crypto/src/crypto/util/Pack.cs
diff options
context:
space:
mode:
Diffstat (limited to 'crypto/src/crypto/util/Pack.cs')
-rw-r--r--crypto/src/crypto/util/Pack.cs30
1 files changed, 30 insertions, 0 deletions
diff --git a/crypto/src/crypto/util/Pack.cs b/crypto/src/crypto/util/Pack.cs

index e281f1818..7b9ce496f 100644 --- a/crypto/src/crypto/util/Pack.cs +++ b/crypto/src/crypto/util/Pack.cs
@@ -503,6 +503,21 @@ namespace Org.BouncyCastle.Crypto.Utilities } [MethodImpl(MethodImplOptions.AggressiveInlining)] + internal static uint BE_To_UInt32_Partial(ReadOnlySpan<byte> bs) + { + int len = bs.Length; + Debug.Assert(1 <= len && len <= 4); + + uint result = bs[0]; + for (int i = 1; i < len; ++i) + { + result <<= 8; + result |= bs[i]; + } + return result; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] internal static ulong BE_To_UInt64(ReadOnlySpan<byte> bs) { uint hi = BE_To_UInt32(bs); @@ -521,6 +536,21 @@ namespace Org.BouncyCastle.Crypto.Utilities } [MethodImpl(MethodImplOptions.AggressiveInlining)] + internal static ulong BE_To_UInt64_Partial(ReadOnlySpan<byte> bs) + { + int len = bs.Length; + Debug.Assert(1 <= len && len <= 8); + + ulong result = bs[0]; + for (int i = 1; i < len; ++i) + { + result <<= 8; + result |= bs[i]; + } + return result; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] internal static uint LE_To_UInt32(ReadOnlySpan<byte> bs) { return bs[0]