diff options
author | Peter Dettman <peter.dettman@bouncycastle.org> | 2017-07-19 18:15:23 +0700 |
---|---|---|
committer | Peter Dettman <peter.dettman@bouncycastle.org> | 2017-07-19 18:15:23 +0700 |
commit | 22af70a2b1f47c4a2d27e09126d17e2db225ba24 (patch) | |
tree | 46240249b34466de429d6d47959cceb8b0f67386 /crypto/src | |
parent | Fix GetValidSeconds for multi-sigs (port from Java version) (diff) | |
download | BouncyCastle.NET-ed25519-22af70a2b1f47c4a2d27e09126d17e2db225ba24.tar.xz |
Add a few method variations to Pack class
Diffstat (limited to 'crypto/src')
-rw-r--r-- | crypto/src/crypto/util/Pack.cs | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/crypto/src/crypto/util/Pack.cs b/crypto/src/crypto/util/Pack.cs index ebe5b7af1..1b94fee0e 100644 --- a/crypto/src/crypto/util/Pack.cs +++ b/crypto/src/crypto/util/Pack.cs @@ -285,6 +285,31 @@ namespace Org.BouncyCastle.Crypto.Utilities UInt32_To_LE((uint)(n >> 32), bs, off + 4); } + internal static byte[] UInt64_To_LE(ulong[] ns) + { + byte[] bs = new byte[8 * ns.Length]; + UInt64_To_LE(ns, bs, 0); + return bs; + } + + internal static void UInt64_To_LE(ulong[] ns, byte[] bs, int off) + { + for (int i = 0; i < ns.Length; ++i) + { + UInt64_To_LE(ns[i], bs, off); + off += 8; + } + } + + internal static void UInt64_To_LE(ulong[] ns, int nsOff, int nsLen, byte[] bs, int bsOff) + { + for (int i = 0; i < nsLen; ++i) + { + UInt64_To_LE(ns[nsOff + i], bs, bsOff); + bsOff += 8; + } + } + internal static ulong LE_To_UInt64(byte[] bs) { uint lo = LE_To_UInt32(bs); @@ -307,5 +332,14 @@ namespace Org.BouncyCastle.Crypto.Utilities off += 8; } } + + internal static void LE_To_UInt64(byte[] bs, int bsOff, ulong[] ns, int nsOff, int nsLen) + { + for (int i = 0; i < nsLen; ++i) + { + ns[nsOff + i] = LE_To_UInt64(bs, bsOff); + bsOff += 8; + } + } } } |