80 lines
2.4 KiB
Java
80 lines
2.4 KiB
Java
|
package org.bouncycastle.pqc.crypto.gmss.util;
|
||
|
|
||
|
import com.google.common.primitives.UnsignedBytes;
|
||
|
import java.io.PrintStream;
|
||
|
|
||
|
/* loaded from: classes6.dex */
|
||
|
public class GMSSUtil {
|
||
|
public int getLog(int i) {
|
||
|
int i2 = 1;
|
||
|
int i3 = 2;
|
||
|
while (i3 < i) {
|
||
|
i3 <<= 1;
|
||
|
i2++;
|
||
|
}
|
||
|
return i2;
|
||
|
}
|
||
|
|
||
|
public boolean testPowerOfTwo(int i) {
|
||
|
int i2 = 1;
|
||
|
while (i2 < i) {
|
||
|
i2 <<= 1;
|
||
|
}
|
||
|
return i == i2;
|
||
|
}
|
||
|
|
||
|
public void printArray(String str, byte[][] bArr) {
|
||
|
System.out.println(str);
|
||
|
int i = 0;
|
||
|
for (byte[] bArr2 : bArr) {
|
||
|
for (int i2 = 0; i2 < bArr[0].length; i2++) {
|
||
|
PrintStream printStream = System.out;
|
||
|
StringBuilder sb = new StringBuilder();
|
||
|
sb.append(i);
|
||
|
sb.append("; ");
|
||
|
sb.append((int) bArr2[i2]);
|
||
|
printStream.println(sb.toString());
|
||
|
i++;
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
|
||
|
public void printArray(String str, byte[] bArr) {
|
||
|
System.out.println(str);
|
||
|
int i = 0;
|
||
|
for (byte b : bArr) {
|
||
|
PrintStream printStream = System.out;
|
||
|
StringBuilder sb = new StringBuilder();
|
||
|
sb.append(i);
|
||
|
sb.append("; ");
|
||
|
sb.append((int) b);
|
||
|
printStream.println(sb.toString());
|
||
|
i++;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
public byte[] intToBytesLittleEndian(int i) {
|
||
|
return new byte[]{(byte) i, (byte) (i >> 8), (byte) (i >> 16), (byte) (i >>> 24)};
|
||
|
}
|
||
|
|
||
|
public byte[] concatenateArray(byte[][] bArr) {
|
||
|
byte[] bArr2 = new byte[bArr.length * bArr[0].length];
|
||
|
int i = 0;
|
||
|
for (int i2 = 0; i2 < bArr.length; i2++) {
|
||
|
byte[] bArr3 = bArr[i2];
|
||
|
System.arraycopy(bArr3, 0, bArr2, i, bArr3.length);
|
||
|
i += bArr[i2].length;
|
||
|
}
|
||
|
return bArr2;
|
||
|
}
|
||
|
|
||
|
public int bytesToIntLittleEndian(byte[] bArr, int i) {
|
||
|
byte b = bArr[i];
|
||
|
return ((bArr[i + 3] & UnsignedBytes.MAX_VALUE) << 24) | ((bArr[i + 1] & UnsignedBytes.MAX_VALUE) << 8) | (b & UnsignedBytes.MAX_VALUE) | ((bArr[i + 2] & UnsignedBytes.MAX_VALUE) << 16);
|
||
|
}
|
||
|
|
||
|
public int bytesToIntLittleEndian(byte[] bArr) {
|
||
|
return ((bArr[3] & UnsignedBytes.MAX_VALUE) << 24) | (bArr[0] & UnsignedBytes.MAX_VALUE) | ((bArr[1] & UnsignedBytes.MAX_VALUE) << 8) | ((bArr[2] & UnsignedBytes.MAX_VALUE) << 16);
|
||
|
}
|
||
|
}
|