188 lines
5.9 KiB
Java
188 lines
5.9 KiB
Java
|
package org.bouncycastle.util;
|
||
|
|
||
|
import com.google.common.base.Ascii;
|
||
|
import com.google.common.primitives.UnsignedBytes;
|
||
|
import io.flutter.embedding.android.KeyboardMap;
|
||
|
|
||
|
/* loaded from: classes6.dex */
|
||
|
public abstract class Pack {
|
||
|
public static byte[] shortToLittleEndian(short s) {
|
||
|
byte[] bArr = new byte[2];
|
||
|
shortToLittleEndian(s, bArr, 0);
|
||
|
return bArr;
|
||
|
}
|
||
|
|
||
|
public static void shortToLittleEndian(short s, byte[] bArr, int i) {
|
||
|
bArr[i] = (byte) s;
|
||
|
bArr[i + 1] = (byte) (s >>> 8);
|
||
|
}
|
||
|
|
||
|
public static byte[] longToLittleEndian(long[] jArr) {
|
||
|
byte[] bArr = new byte[jArr.length << 3];
|
||
|
longToLittleEndian(jArr, bArr, 0);
|
||
|
return bArr;
|
||
|
}
|
||
|
|
||
|
public static byte[] longToLittleEndian(long j) {
|
||
|
byte[] bArr = new byte[8];
|
||
|
longToLittleEndian(j, bArr, 0);
|
||
|
return bArr;
|
||
|
}
|
||
|
|
||
|
public static void longToLittleEndian(long[] jArr, byte[] bArr, int i) {
|
||
|
for (long j : jArr) {
|
||
|
longToLittleEndian(j, bArr, i);
|
||
|
i += 8;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
public static void longToLittleEndian(long j, byte[] bArr, int i) {
|
||
|
intToLittleEndian((int) (KeyboardMap.kValueMask & j), bArr, i);
|
||
|
intToLittleEndian((int) (j >>> 32), bArr, i + 4);
|
||
|
}
|
||
|
|
||
|
public static byte[] longToBigEndian(long[] jArr) {
|
||
|
byte[] bArr = new byte[jArr.length << 3];
|
||
|
longToBigEndian(jArr, bArr, 0);
|
||
|
return bArr;
|
||
|
}
|
||
|
|
||
|
public static byte[] longToBigEndian(long j) {
|
||
|
byte[] bArr = new byte[8];
|
||
|
longToBigEndian(j, bArr, 0);
|
||
|
return bArr;
|
||
|
}
|
||
|
|
||
|
public static void longToBigEndian(long[] jArr, byte[] bArr, int i) {
|
||
|
for (long j : jArr) {
|
||
|
longToBigEndian(j, bArr, i);
|
||
|
i += 8;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
public static void longToBigEndian(long j, byte[] bArr, int i) {
|
||
|
intToBigEndian((int) (j >>> 32), bArr, i);
|
||
|
intToBigEndian((int) j, bArr, i + 4);
|
||
|
}
|
||
|
|
||
|
public static short littleEndianToShort(byte[] bArr, int i) {
|
||
|
return (short) (((bArr[i + 1] & UnsignedBytes.MAX_VALUE) << 8) | (bArr[i] & UnsignedBytes.MAX_VALUE));
|
||
|
}
|
||
|
|
||
|
public static void littleEndianToLong(byte[] bArr, int i, long[] jArr) {
|
||
|
for (int i2 = 0; i2 < jArr.length; i2++) {
|
||
|
jArr[i2] = littleEndianToLong(bArr, i);
|
||
|
i += 8;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
public static long littleEndianToLong(byte[] bArr, int i) {
|
||
|
return ((littleEndianToInt(bArr, i + 4) & KeyboardMap.kValueMask) << 32) | (littleEndianToInt(bArr, i) & KeyboardMap.kValueMask);
|
||
|
}
|
||
|
|
||
|
public static int[] littleEndianToInt(byte[] bArr, int i, int i2) {
|
||
|
int[] iArr = new int[i2];
|
||
|
for (int i3 = 0; i3 < i2; i3++) {
|
||
|
iArr[i3] = littleEndianToInt(bArr, i);
|
||
|
i += 4;
|
||
|
}
|
||
|
return iArr;
|
||
|
}
|
||
|
|
||
|
public static void littleEndianToInt(byte[] bArr, int i, int[] iArr, int i2, int i3) {
|
||
|
for (int i4 = 0; i4 < i3; i4++) {
|
||
|
iArr[i2 + i4] = littleEndianToInt(bArr, i);
|
||
|
i += 4;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
public static void littleEndianToInt(byte[] bArr, int i, int[] iArr) {
|
||
|
for (int i2 = 0; i2 < iArr.length; i2++) {
|
||
|
iArr[i2] = littleEndianToInt(bArr, i);
|
||
|
i += 4;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
public static int littleEndianToInt(byte[] bArr, int i) {
|
||
|
return (bArr[i + 3] << Ascii.CAN) | (bArr[i] & UnsignedBytes.MAX_VALUE) | ((bArr[i + 1] & UnsignedBytes.MAX_VALUE) << 8) | ((bArr[i + 2] & UnsignedBytes.MAX_VALUE) << 16);
|
||
|
}
|
||
|
|
||
|
public static byte[] intToLittleEndian(int[] iArr) {
|
||
|
byte[] bArr = new byte[iArr.length << 2];
|
||
|
intToLittleEndian(iArr, bArr, 0);
|
||
|
return bArr;
|
||
|
}
|
||
|
|
||
|
public static byte[] intToLittleEndian(int i) {
|
||
|
byte[] bArr = new byte[4];
|
||
|
intToLittleEndian(i, bArr, 0);
|
||
|
return bArr;
|
||
|
}
|
||
|
|
||
|
public static void intToLittleEndian(int[] iArr, byte[] bArr, int i) {
|
||
|
for (int i2 : iArr) {
|
||
|
intToLittleEndian(i2, bArr, i);
|
||
|
i += 4;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
public static void intToLittleEndian(int i, byte[] bArr, int i2) {
|
||
|
bArr[i2] = (byte) i;
|
||
|
bArr[i2 + 1] = (byte) (i >>> 8);
|
||
|
bArr[i2 + 2] = (byte) (i >>> 16);
|
||
|
bArr[i2 + 3] = (byte) (i >>> 24);
|
||
|
}
|
||
|
|
||
|
public static byte[] intToBigEndian(int[] iArr) {
|
||
|
byte[] bArr = new byte[iArr.length << 2];
|
||
|
intToBigEndian(iArr, bArr, 0);
|
||
|
return bArr;
|
||
|
}
|
||
|
|
||
|
public static byte[] intToBigEndian(int i) {
|
||
|
byte[] bArr = new byte[4];
|
||
|
intToBigEndian(i, bArr, 0);
|
||
|
return bArr;
|
||
|
}
|
||
|
|
||
|
public static void intToBigEndian(int[] iArr, byte[] bArr, int i) {
|
||
|
for (int i2 : iArr) {
|
||
|
intToBigEndian(i2, bArr, i);
|
||
|
i += 4;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
public static void intToBigEndian(int i, byte[] bArr, int i2) {
|
||
|
bArr[i2] = (byte) (i >>> 24);
|
||
|
bArr[i2 + 1] = (byte) (i >>> 16);
|
||
|
bArr[i2 + 2] = (byte) (i >>> 8);
|
||
|
bArr[i2 + 3] = (byte) i;
|
||
|
}
|
||
|
|
||
|
public static short bigEndianToShort(byte[] bArr, int i) {
|
||
|
return (short) ((bArr[i + 1] & UnsignedBytes.MAX_VALUE) | ((bArr[i] & UnsignedBytes.MAX_VALUE) << 8));
|
||
|
}
|
||
|
|
||
|
public static void bigEndianToLong(byte[] bArr, int i, long[] jArr) {
|
||
|
for (int i2 = 0; i2 < jArr.length; i2++) {
|
||
|
jArr[i2] = bigEndianToLong(bArr, i);
|
||
|
i += 8;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
public static long bigEndianToLong(byte[] bArr, int i) {
|
||
|
return (bigEndianToInt(bArr, i + 4) & KeyboardMap.kValueMask) | ((bigEndianToInt(bArr, i) & KeyboardMap.kValueMask) << 32);
|
||
|
}
|
||
|
|
||
|
public static void bigEndianToInt(byte[] bArr, int i, int[] iArr) {
|
||
|
for (int i2 = 0; i2 < iArr.length; i2++) {
|
||
|
iArr[i2] = bigEndianToInt(bArr, i);
|
||
|
i += 4;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
public static int bigEndianToInt(byte[] bArr, int i) {
|
||
|
return (bArr[i + 3] & UnsignedBytes.MAX_VALUE) | (bArr[i] << Ascii.CAN) | ((bArr[i + 1] & UnsignedBytes.MAX_VALUE) << 16) | ((bArr[i + 2] & UnsignedBytes.MAX_VALUE) << 8);
|
||
|
}
|
||
|
}
|