diff options
author | Peter Dettman <peter.dettman@bouncycastle.org> | 2023-02-28 12:09:51 +0700 |
---|---|---|
committer | Peter Dettman <peter.dettman@bouncycastle.org> | 2023-02-28 12:09:51 +0700 |
commit | d67160cc62739b62d852820c015e3af57f9f4736 (patch) | |
tree | 97f0b63f00c602f7e703cd03df48852d1fded90c /crypto/src/crypto/util/Pack.cs | |
parent | Exception on malformed checksum (diff) | |
download | BouncyCastle.NET-ed25519-d67160cc62739b62d852820c015e3af57f9f4736.tar.xz |
CRC24 perf. opts.
Diffstat (limited to '')
-rw-r--r-- | crypto/src/crypto/util/Pack.cs | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/crypto/src/crypto/util/Pack.cs b/crypto/src/crypto/util/Pack.cs index e00ba39fa..cd8010f5a 100644 --- a/crypto/src/crypto/util/Pack.cs +++ b/crypto/src/crypto/util/Pack.cs @@ -102,6 +102,34 @@ namespace Org.BouncyCastle.Crypto.Utilities return ns; } + internal static void UInt24_To_BE(uint n, byte[] bs) + { + bs[0] = (byte)(n >> 16); + bs[1] = (byte)(n >> 8); + bs[2] = (byte)n; + } + + internal static void UInt24_To_BE(uint n, byte[] bs, int off) + { + bs[off + 0] = (byte)(n >> 16); + bs[off + 1] = (byte)(n >> 8); + bs[off + 2] = (byte)n; + } + + internal static uint BE_To_UInt24(byte[] bs) + { + return (uint)bs[0] << 16 + | (uint)bs[1] << 8 + | bs[2]; + } + + internal static uint BE_To_UInt24(byte[] bs, int off) + { + return (uint)bs[off] << 16 + | (uint)bs[off + 1] << 8 + | bs[off + 2]; + } + internal static void UInt32_To_BE(uint n, byte[] bs) { #if NETCOREAPP2_1_OR_GREATER || NETSTANDARD2_1_OR_GREATER |