< Summary

Information
Class: Renci.SshNet.Security.Org.BouncyCastle.Crypto.Utilities.Pack
Assembly: Renci.SshNet
File(s): \home\appveyor\projects\ssh-net\src\Renci.SshNet\Security\BouncyCastle\crypto\util\Pack.cs
Line coverage
11%
Covered lines: 28
Uncovered lines: 221
Coverable lines: 249
Total lines: 345
Line coverage: 11.2%
Branch coverage
0%
Covered branches: 0
Total branches: 24
Branch coverage: 0%
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

File(s)

\home\appveyor\projects\ssh-net\src\Renci.SshNet\Security\BouncyCastle\crypto\util\Pack.cs

#LineLine coverage
 1using System;
 2
 3namespace Renci.SshNet.Security.Org.BouncyCastle.Crypto.Utilities
 4{
 5    internal sealed class Pack
 6    {
 07        private Pack()
 08        {
 09        }
 10
 11        internal static void UInt16_To_BE(ushort n, byte[] bs)
 012        {
 013            bs[0] = (byte)(n >> 8);
 014            bs[1] = (byte)(n);
 015        }
 16
 17        internal static void UInt16_To_BE(ushort n, byte[] bs, int off)
 018        {
 019            bs[off] = (byte)(n >> 8);
 020            bs[off + 1] = (byte)(n);
 021        }
 22
 23        internal static ushort BE_To_UInt16(byte[] bs)
 024        {
 025            uint n = (uint)bs[0] << 8
 026                | (uint)bs[1];
 027            return (ushort)n;
 028        }
 29
 30        internal static ushort BE_To_UInt16(byte[] bs, int off)
 031        {
 032            uint n = (uint)bs[off] << 8
 033                | (uint)bs[off + 1];
 034            return (ushort)n;
 035        }
 36
 37        internal static byte[] UInt32_To_BE(uint n)
 038        {
 039            byte[] bs = new byte[4];
 040            UInt32_To_BE(n, bs, 0);
 041            return bs;
 042        }
 43
 44        internal static void UInt32_To_BE(uint n, byte[] bs)
 045        {
 046            bs[0] = (byte)(n >> 24);
 047            bs[1] = (byte)(n >> 16);
 048            bs[2] = (byte)(n >> 8);
 049            bs[3] = (byte)(n);
 050        }
 51
 52        internal static void UInt32_To_BE(uint n, byte[] bs, int off)
 71153        {
 71154            bs[off] = (byte)(n >> 24);
 71155            bs[off + 1] = (byte)(n >> 16);
 71156            bs[off + 2] = (byte)(n >> 8);
 71157            bs[off + 3] = (byte)(n);
 71158        }
 59
 60        internal static byte[] UInt32_To_BE(uint[] ns)
 061        {
 062            byte[] bs = new byte[4 * ns.Length];
 063            UInt32_To_BE(ns, bs, 0);
 064            return bs;
 065        }
 66
 67        internal static void UInt32_To_BE(uint[] ns, byte[] bs, int off)
 068        {
 069            for (int i = 0; i < ns.Length; ++i)
 070            {
 071                UInt32_To_BE(ns[i], bs, off);
 072                off += 4;
 073            }
 074        }
 75
 76        internal static uint BE_To_UInt32(byte[] bs)
 077        {
 078            return (uint)bs[0] << 24
 079                | (uint)bs[1] << 16
 080                | (uint)bs[2] << 8
 081                | (uint)bs[3];
 082        }
 83
 84        internal static uint BE_To_UInt32(byte[] bs, int off)
 62285        {
 62286            return (uint)bs[off] << 24
 62287                | (uint)bs[off + 1] << 16
 62288                | (uint)bs[off + 2] << 8
 62289                | (uint)bs[off + 3];
 62290        }
 91
 92        internal static void BE_To_UInt32(byte[] bs, int off, uint[] ns)
 093        {
 094            for (int i = 0; i < ns.Length; ++i)
 095            {
 096                ns[i] = BE_To_UInt32(bs, off);
 097                off += 4;
 098            }
 099        }
 100
 101        internal static byte[] UInt64_To_BE(ulong n)
 0102        {
 0103            byte[] bs = new byte[8];
 0104            UInt64_To_BE(n, bs, 0);
 0105            return bs;
 0106        }
 107
 108        internal static void UInt64_To_BE(ulong n, byte[] bs)
 0109        {
 0110            UInt32_To_BE((uint)(n >> 32), bs);
 0111            UInt32_To_BE((uint)(n), bs, 4);
 0112        }
 113
 114        internal static void UInt64_To_BE(ulong n, byte[] bs, int off)
 0115        {
 0116            UInt32_To_BE((uint)(n >> 32), bs, off);
 0117            UInt32_To_BE((uint)(n), bs, off + 4);
 0118        }
 119
 120        internal static byte[] UInt64_To_BE(ulong[] ns)
 0121        {
 0122            byte[] bs = new byte[8 * ns.Length];
 0123            UInt64_To_BE(ns, bs, 0);
 0124            return bs;
 0125        }
 126
 127        internal static void UInt64_To_BE(ulong[] ns, byte[] bs, int off)
 0128        {
 0129            for (int i = 0; i < ns.Length; ++i)
 0130            {
 0131                UInt64_To_BE(ns[i], bs, off);
 0132                off += 8;
 0133            }
 0134        }
 135
 136        internal static ulong BE_To_UInt64(byte[] bs)
 0137        {
 0138            uint hi = BE_To_UInt32(bs);
 0139            uint lo = BE_To_UInt32(bs, 4);
 0140            return ((ulong)hi << 32) | (ulong)lo;
 0141        }
 142
 143        internal static ulong BE_To_UInt64(byte[] bs, int off)
 0144        {
 0145            uint hi = BE_To_UInt32(bs, off);
 0146            uint lo = BE_To_UInt32(bs, off + 4);
 0147            return ((ulong)hi << 32) | (ulong)lo;
 0148        }
 149
 150        internal static void BE_To_UInt64(byte[] bs, int off, ulong[] ns)
 0151        {
 0152            for (int i = 0; i < ns.Length; ++i)
 0153            {
 0154                ns[i] = BE_To_UInt64(bs, off);
 0155                off += 8;
 0156            }
 0157        }
 158
 159        internal static void UInt16_To_LE(ushort n, byte[] bs)
 0160        {
 0161            bs[0] = (byte)(n);
 0162            bs[1] = (byte)(n >> 8);
 0163        }
 164
 165        internal static void UInt16_To_LE(ushort n, byte[] bs, int off)
 0166        {
 0167            bs[off] = (byte)(n);
 0168            bs[off + 1] = (byte)(n >> 8);
 0169        }
 170
 171        internal static ushort LE_To_UInt16(byte[] bs)
 0172        {
 0173            uint n = (uint)bs[0]
 0174                | (uint)bs[1] << 8;
 0175            return (ushort)n;
 0176        }
 177
 178        internal static ushort LE_To_UInt16(byte[] bs, int off)
 0179        {
 0180            uint n = (uint)bs[off]
 0181                | (uint)bs[off + 1] << 8;
 0182            return (ushort)n;
 0183        }
 184
 185        internal static byte[] UInt32_To_LE(uint n)
 0186        {
 0187            byte[] bs = new byte[4];
 0188            UInt32_To_LE(n, bs, 0);
 0189            return bs;
 0190        }
 191
 192        internal static void UInt32_To_LE(uint n, byte[] bs)
 28193        {
 28194            bs[0] = (byte)(n);
 28195            bs[1] = (byte)(n >> 8);
 28196            bs[2] = (byte)(n >> 16);
 28197            bs[3] = (byte)(n >> 24);
 28198        }
 199
 200        internal static void UInt32_To_LE(uint n, byte[] bs, int off)
 28201        {
 28202            bs[off] = (byte)(n);
 28203            bs[off + 1] = (byte)(n >> 8);
 28204            bs[off + 2] = (byte)(n >> 16);
 28205            bs[off + 3] = (byte)(n >> 24);
 28206        }
 207
 208        internal static byte[] UInt32_To_LE(uint[] ns)
 0209        {
 0210            byte[] bs = new byte[4 * ns.Length];
 0211            UInt32_To_LE(ns, bs, 0);
 0212            return bs;
 0213        }
 214
 215        internal static void UInt32_To_LE(uint[] ns, byte[] bs, int off)
 0216        {
 0217            for (int i = 0; i < ns.Length; ++i)
 0218            {
 0219                UInt32_To_LE(ns[i], bs, off);
 0220                off += 4;
 0221            }
 0222        }
 223
 224        internal static uint LE_To_UInt32(byte[] bs)
 0225        {
 0226            return (uint)bs[0]
 0227                | (uint)bs[1] << 8
 0228                | (uint)bs[2] << 16
 0229                | (uint)bs[3] << 24;
 0230        }
 231
 232        internal static uint LE_To_UInt32(byte[] bs, int off)
 0233        {
 0234            return (uint)bs[off]
 0235                | (uint)bs[off + 1] << 8
 0236                | (uint)bs[off + 2] << 16
 0237                | (uint)bs[off + 3] << 24;
 0238        }
 239
 240        internal static void LE_To_UInt32(byte[] bs, int off, uint[] ns)
 0241        {
 0242            for (int i = 0; i < ns.Length; ++i)
 0243            {
 0244                ns[i] = LE_To_UInt32(bs, off);
 0245                off += 4;
 0246            }
 0247        }
 248
 249        internal static void LE_To_UInt32(byte[] bs, int bOff, uint[] ns, int nOff, int count)
 0250        {
 0251            for (int i = 0; i < count; ++i)
 0252            {
 0253                ns[nOff + i] = LE_To_UInt32(bs, bOff);
 0254                bOff += 4;
 0255            }
 0256        }
 257
 258        internal static uint[] LE_To_UInt32(byte[] bs, int off, int count)
 0259        {
 0260            uint[] ns = new uint[count];
 0261            for (int i = 0; i < ns.Length; ++i)
 0262            {
 0263                ns[i] = LE_To_UInt32(bs, off);
 0264                off += 4;
 0265            }
 0266            return ns;
 0267        }
 268
 269        internal static byte[] UInt64_To_LE(ulong n)
 0270        {
 0271            byte[] bs = new byte[8];
 0272            UInt64_To_LE(n, bs, 0);
 0273            return bs;
 0274        }
 275
 276        internal static void UInt64_To_LE(ulong n, byte[] bs)
 28277        {
 28278            UInt32_To_LE((uint)(n), bs);
 28279            UInt32_To_LE((uint)(n >> 32), bs, 4);
 28280        }
 281
 282        internal static void UInt64_To_LE(ulong n, byte[] bs, int off)
 0283        {
 0284            UInt32_To_LE((uint)(n), bs, off);
 0285            UInt32_To_LE((uint)(n >> 32), bs, off + 4);
 0286        }
 287
 288        internal static byte[] UInt64_To_LE(ulong[] ns)
 0289        {
 0290            byte[] bs = new byte[8 * ns.Length];
 0291            UInt64_To_LE(ns, bs, 0);
 0292            return bs;
 0293        }
 294
 295        internal static void UInt64_To_LE(ulong[] ns, byte[] bs, int off)
 0296        {
 0297            for (int i = 0; i < ns.Length; ++i)
 0298            {
 0299                UInt64_To_LE(ns[i], bs, off);
 0300                off += 8;
 0301            }
 0302        }
 303
 304        internal static void UInt64_To_LE(ulong[] ns, int nsOff, int nsLen, byte[] bs, int bsOff)
 0305        {
 0306            for (int i = 0; i < nsLen; ++i)
 0307            {
 0308                UInt64_To_LE(ns[nsOff + i], bs, bsOff);
 0309                bsOff += 8;
 0310            }
 0311        }
 312
 313        internal static ulong LE_To_UInt64(byte[] bs)
 0314        {
 0315            uint lo = LE_To_UInt32(bs);
 0316            uint hi = LE_To_UInt32(bs, 4);
 0317            return ((ulong)hi << 32) | (ulong)lo;
 0318        }
 319
 320        internal static ulong LE_To_UInt64(byte[] bs, int off)
 0321        {
 0322            uint lo = LE_To_UInt32(bs, off);
 0323            uint hi = LE_To_UInt32(bs, off + 4);
 0324            return ((ulong)hi << 32) | (ulong)lo;
 0325        }
 326
 327        internal static void LE_To_UInt64(byte[] bs, int off, ulong[] ns)
 0328        {
 0329            for (int i = 0; i < ns.Length; ++i)
 0330            {
 0331                ns[i] = LE_To_UInt64(bs, off);
 0332                off += 8;
 0333            }
 0334        }
 335
 336        internal static void LE_To_UInt64(byte[] bs, int bsOff, ulong[] ns, int nsOff, int nsLen)
 0337        {
 0338            for (int i = 0; i < nsLen; ++i)
 0339            {
 0340                ns[nsOff + i] = LE_To_UInt64(bs, bsOff);
 0341                bsOff += 8;
 0342            }
 0343        }
 344    }
 345}

Methods/Properties

.ctor()
UInt16_To_BE(System.UInt16,System.Byte[])
UInt16_To_BE(System.UInt16,System.Byte[],System.Int32)
BE_To_UInt16(System.Byte[])
BE_To_UInt16(System.Byte[],System.Int32)
UInt32_To_BE(System.UInt32)
UInt32_To_BE(System.UInt32,System.Byte[])
UInt32_To_BE(System.UInt32,System.Byte[],System.Int32)
UInt32_To_BE(System.UInt32[])
UInt32_To_BE(System.UInt32[],System.Byte[],System.Int32)
BE_To_UInt32(System.Byte[])
BE_To_UInt32(System.Byte[],System.Int32)
BE_To_UInt32(System.Byte[],System.Int32,System.UInt32[])
UInt64_To_BE(System.UInt64)
UInt64_To_BE(System.UInt64,System.Byte[])
UInt64_To_BE(System.UInt64,System.Byte[],System.Int32)
UInt64_To_BE(System.UInt64[])
UInt64_To_BE(System.UInt64[],System.Byte[],System.Int32)
BE_To_UInt64(System.Byte[])
BE_To_UInt64(System.Byte[],System.Int32)
BE_To_UInt64(System.Byte[],System.Int32,System.UInt64[])
UInt16_To_LE(System.UInt16,System.Byte[])
UInt16_To_LE(System.UInt16,System.Byte[],System.Int32)
LE_To_UInt16(System.Byte[])
LE_To_UInt16(System.Byte[],System.Int32)
UInt32_To_LE(System.UInt32)
UInt32_To_LE(System.UInt32,System.Byte[])
UInt32_To_LE(System.UInt32,System.Byte[],System.Int32)
UInt32_To_LE(System.UInt32[])
UInt32_To_LE(System.UInt32[],System.Byte[],System.Int32)
LE_To_UInt32(System.Byte[])
LE_To_UInt32(System.Byte[],System.Int32)
LE_To_UInt32(System.Byte[],System.Int32,System.UInt32[])
LE_To_UInt32(System.Byte[],System.Int32,System.UInt32[],System.Int32,System.Int32)
LE_To_UInt32(System.Byte[],System.Int32,System.Int32)
UInt64_To_LE(System.UInt64)
UInt64_To_LE(System.UInt64,System.Byte[])
UInt64_To_LE(System.UInt64,System.Byte[],System.Int32)
UInt64_To_LE(System.UInt64[])
UInt64_To_LE(System.UInt64[],System.Byte[],System.Int32)
UInt64_To_LE(System.UInt64[],System.Int32,System.Int32,System.Byte[],System.Int32)
LE_To_UInt64(System.Byte[])
LE_To_UInt64(System.Byte[],System.Int32)
LE_To_UInt64(System.Byte[],System.Int32,System.UInt64[])
LE_To_UInt64(System.Byte[],System.Int32,System.UInt64[],System.Int32,System.Int32)