package org.bouncycastle.crypto.util;

public abstract class Pack
{
    public static int bigEndianToInt(byte[] bs, int off)
    {
        int n = bs[off++] << 24;
        n |= (bs[off++] & 0xff) << 16;
        n |= (bs[off++] & 0xff) << 8;
        n |= (bs[off++] & 0xff);
        return n;
    }

    public static void intToBigEndian(int n, byte[] bs, int off)
    {
        bs[off++] = (byte)(n >>> 24);
        bs[off++] = (byte)(n >>> 16);
        bs[off++] = (byte)(n >>>  8);
        bs[off  ] = (byte)(n       );
    }
}

@@ -143,21 +143,21 @@
  n = bs%5B
+  
 off
-++
 %5D %3C%3C 24;
@@ -166,37 +166,37 @@
        n %7C= (bs%5B
+++
 off
-++
 %5D & 0xff) %3C%3C 16;
@@ -205,37 +205,37 @@
        n %7C= (bs%5B
+++
 off
-++
 %5D & 0xff) %3C%3C 8;%0A
@@ -251,21 +251,21 @@
  %7C= (bs%5B
+++
 off
-++
 %5D & 0xff
@@ -366,37 +366,37 @@
    %7B%0A        bs%5B
+  
 off
-++
 %5D = (byte)(n %3E%3E%3E
@@ -404,37 +404,37 @@
 24);%0A        bs%5B
+++
 off
-++
 %5D = (byte)(n %3E%3E%3E
@@ -454,13 +454,13 @@
  bs%5B
+++
 off
-++
 %5D = 
@@ -492,13 +492,13 @@
  bs%5B
+++
 off
-  
 %5D = 
@@ -512,16 +512,443 @@
 n       
+);%0A    %7D%0A%0A    public static long bigEndianToLong(byte%5B%5D bs, int off)%0A    %7B%0A        int hi = bigEndianToInt(bs, off);%0A        int lo = bigEndianToInt(bs, off + 4);%0A        return ((long)(hi & 0xffffffffL) %3C%3C 32) %7C (long)(lo & 0xffffffffL);%0A    %7D%0A%0A    public static void longToBigEndian(long n, byte%5B%5D bs, int off)%0A    %7B%0A        intToBigEndian((int)(n %3E%3E%3E 32), bs, off);%0A        intToBigEndian((int)(n & 0xffffffffL), bs, off + 4
 );%0A    %7D

Improve existing methods, add new ones for packing longs