diff options
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); |