diff options
author | Peter Dettman <peter.dettman@bouncycastle.org> | 2020-07-07 20:11:57 +0700 |
---|---|---|
committer | Peter Dettman <peter.dettman@bouncycastle.org> | 2020-07-07 20:11:57 +0700 |
commit | ffec0edf33e6772a330ce3f195886e2bf480e762 (patch) | |
tree | fb562a952a3dd19ebfe89d447a8fdadcde91dc28 /crypto | |
parent | Extract common expression (diff) | |
download | BouncyCastle.NET-ed25519-ffec0edf33e6772a330ce3f195886e2bf480e762.tar.xz |
Add some more variants
Diffstat (limited to 'crypto')
-rw-r--r-- | crypto/src/crypto/util/Pack.cs | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/crypto/src/crypto/util/Pack.cs b/crypto/src/crypto/util/Pack.cs index 1b94fee0e..2a3596772 100644 --- a/crypto/src/crypto/util/Pack.cs +++ b/crypto/src/crypto/util/Pack.cs @@ -73,6 +73,15 @@ namespace Org.BouncyCastle.Crypto.Utilities } } + public static void UInt32_To_BE(uint[] ns, int nsOff, int nsLen, byte[] bs, int bsOff) + { + for (int i = 0; i < nsLen; ++i) + { + UInt32_To_BE(ns[nsOff + i], bs, bsOff); + bsOff += 4; + } + } + internal static uint BE_To_UInt32(byte[] bs) { return (uint)bs[0] << 24 @@ -98,6 +107,15 @@ namespace Org.BouncyCastle.Crypto.Utilities } } + public static void BE_To_UInt32(byte[] bs, int bsOff, uint[] ns, int nsOff, int nsLen) + { + for (int i = 0; i < nsLen; ++i) + { + ns[nsOff + i] = BE_To_UInt32(bs, bsOff); + bsOff += 4; + } + } + internal static byte[] UInt64_To_BE(ulong n) { byte[] bs = new byte[8]; @@ -133,6 +151,15 @@ namespace Org.BouncyCastle.Crypto.Utilities } } + public static void UInt64_To_BE(ulong[] ns, int nsOff, int nsLen, byte[] bs, int bsOff) + { + for (int i = 0; i < nsLen; ++i) + { + UInt64_To_BE(ns[nsOff + i], bs, bsOff); + bsOff += 8; + } + } + internal static ulong BE_To_UInt64(byte[] bs) { uint hi = BE_To_UInt32(bs); @@ -156,6 +183,15 @@ namespace Org.BouncyCastle.Crypto.Utilities } } + public static void BE_To_UInt64(byte[] bs, int bsOff, ulong[] ns, int nsOff, int nsLen) + { + for (int i = 0; i < nsLen; ++i) + { + ns[nsOff + i] = BE_To_UInt64(bs, bsOff); + bsOff += 8; + } + } + internal static void UInt16_To_LE(ushort n, byte[] bs) { bs[0] = (byte)(n); |