121 lines
3.9 KiB
Java
121 lines
3.9 KiB
Java
|
package org.bouncycastle.pqc.crypto.rainbow.util;
|
||
|
|
||
|
import com.google.common.primitives.UnsignedBytes;
|
||
|
import java.lang.reflect.Array;
|
||
|
|
||
|
/* loaded from: classes6.dex */
|
||
|
public class RainbowUtil {
|
||
|
public static boolean equals(short[][][] sArr, short[][][] sArr2) {
|
||
|
if (sArr.length != sArr2.length) {
|
||
|
return false;
|
||
|
}
|
||
|
boolean z = true;
|
||
|
for (int length = sArr.length - 1; length >= 0; length--) {
|
||
|
z &= equals(sArr[length], sArr2[length]);
|
||
|
}
|
||
|
return z;
|
||
|
}
|
||
|
|
||
|
public static boolean equals(short[][] sArr, short[][] sArr2) {
|
||
|
if (sArr.length != sArr2.length) {
|
||
|
return false;
|
||
|
}
|
||
|
boolean z = true;
|
||
|
for (int length = sArr.length - 1; length >= 0; length--) {
|
||
|
z &= equals(sArr[length], sArr2[length]);
|
||
|
}
|
||
|
return z;
|
||
|
}
|
||
|
|
||
|
public static boolean equals(short[] sArr, short[] sArr2) {
|
||
|
if (sArr.length != sArr2.length) {
|
||
|
return false;
|
||
|
}
|
||
|
boolean z = true;
|
||
|
for (int length = sArr.length - 1; length >= 0; length--) {
|
||
|
z &= sArr[length] == sArr2[length];
|
||
|
}
|
||
|
return z;
|
||
|
}
|
||
|
|
||
|
public static byte[] convertIntArray(int[] iArr) {
|
||
|
byte[] bArr = new byte[iArr.length];
|
||
|
for (int i = 0; i < iArr.length; i++) {
|
||
|
bArr[i] = (byte) iArr[i];
|
||
|
}
|
||
|
return bArr;
|
||
|
}
|
||
|
|
||
|
public static int[] convertArraytoInt(byte[] bArr) {
|
||
|
int[] iArr = new int[bArr.length];
|
||
|
for (int i = 0; i < bArr.length; i++) {
|
||
|
iArr[i] = bArr[i] & UnsignedBytes.MAX_VALUE;
|
||
|
}
|
||
|
return iArr;
|
||
|
}
|
||
|
|
||
|
public static short[][][] convertArray(byte[][][] bArr) {
|
||
|
int length = bArr.length;
|
||
|
byte[][] bArr2 = bArr[0];
|
||
|
short[][][] sArr = (short[][][]) Array.newInstance((Class<?>) Short.TYPE, length, bArr2.length, bArr2[0].length);
|
||
|
for (int i = 0; i < bArr.length; i++) {
|
||
|
for (int i2 = 0; i2 < bArr[0].length; i2++) {
|
||
|
for (int i3 = 0; i3 < bArr[0][0].length; i3++) {
|
||
|
sArr[i][i2][i3] = (short) (bArr[i][i2][i3] & UnsignedBytes.MAX_VALUE);
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
return sArr;
|
||
|
}
|
||
|
|
||
|
public static byte[][][] convertArray(short[][][] sArr) {
|
||
|
int length = sArr.length;
|
||
|
short[][] sArr2 = sArr[0];
|
||
|
byte[][][] bArr = (byte[][][]) Array.newInstance((Class<?>) Byte.TYPE, length, sArr2.length, sArr2[0].length);
|
||
|
for (int i = 0; i < sArr.length; i++) {
|
||
|
for (int i2 = 0; i2 < sArr[0].length; i2++) {
|
||
|
for (int i3 = 0; i3 < sArr[0][0].length; i3++) {
|
||
|
bArr[i][i2][i3] = (byte) sArr[i][i2][i3];
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
return bArr;
|
||
|
}
|
||
|
|
||
|
public static short[][] convertArray(byte[][] bArr) {
|
||
|
short[][] sArr = (short[][]) Array.newInstance((Class<?>) Short.TYPE, bArr.length, bArr[0].length);
|
||
|
for (int i = 0; i < bArr.length; i++) {
|
||
|
for (int i2 = 0; i2 < bArr[0].length; i2++) {
|
||
|
sArr[i][i2] = (short) (bArr[i][i2] & UnsignedBytes.MAX_VALUE);
|
||
|
}
|
||
|
}
|
||
|
return sArr;
|
||
|
}
|
||
|
|
||
|
public static byte[][] convertArray(short[][] sArr) {
|
||
|
byte[][] bArr = (byte[][]) Array.newInstance((Class<?>) Byte.TYPE, sArr.length, sArr[0].length);
|
||
|
for (int i = 0; i < sArr.length; i++) {
|
||
|
for (int i2 = 0; i2 < sArr[0].length; i2++) {
|
||
|
bArr[i][i2] = (byte) sArr[i][i2];
|
||
|
}
|
||
|
}
|
||
|
return bArr;
|
||
|
}
|
||
|
|
||
|
public static short[] convertArray(byte[] bArr) {
|
||
|
short[] sArr = new short[bArr.length];
|
||
|
for (int i = 0; i < bArr.length; i++) {
|
||
|
sArr[i] = (short) (bArr[i] & UnsignedBytes.MAX_VALUE);
|
||
|
}
|
||
|
return sArr;
|
||
|
}
|
||
|
|
||
|
public static byte[] convertArray(short[] sArr) {
|
||
|
byte[] bArr = new byte[sArr.length];
|
||
|
for (int i = 0; i < sArr.length; i++) {
|
||
|
bArr[i] = (byte) sArr[i];
|
||
|
}
|
||
|
return bArr;
|
||
|
}
|
||
|
}
|