79 lines
1.9 KiB
Java
79 lines
1.9 KiB
Java
|
package org.bouncycastle.math.raw;
|
||
|
|
||
|
import java.math.BigInteger;
|
||
|
import org.bouncycastle.util.Pack;
|
||
|
|
||
|
/* loaded from: classes6.dex */
|
||
|
public abstract class Nat320 {
|
||
|
public static BigInteger toBigInteger64(long[] jArr) {
|
||
|
byte[] bArr = new byte[40];
|
||
|
for (int i = 0; i < 5; i++) {
|
||
|
long j = jArr[i];
|
||
|
if (j != 0) {
|
||
|
Pack.longToBigEndian(j, bArr, (4 - i) << 3);
|
||
|
}
|
||
|
}
|
||
|
return new BigInteger(1, bArr);
|
||
|
}
|
||
|
|
||
|
public static boolean isZero64(long[] jArr) {
|
||
|
for (int i = 0; i < 5; i++) {
|
||
|
if (jArr[i] != 0) {
|
||
|
return false;
|
||
|
}
|
||
|
}
|
||
|
return true;
|
||
|
}
|
||
|
|
||
|
public static boolean isOne64(long[] jArr) {
|
||
|
if (jArr[0] != 1) {
|
||
|
return false;
|
||
|
}
|
||
|
for (int i = 1; i < 5; i++) {
|
||
|
if (jArr[i] != 0) {
|
||
|
return false;
|
||
|
}
|
||
|
}
|
||
|
return true;
|
||
|
}
|
||
|
|
||
|
public static long[] fromBigInteger64(BigInteger bigInteger) {
|
||
|
if (bigInteger.signum() < 0 || bigInteger.bitLength() > 320) {
|
||
|
throw new IllegalArgumentException();
|
||
|
}
|
||
|
long[] create64 = create64();
|
||
|
int i = 0;
|
||
|
while (bigInteger.signum() != 0) {
|
||
|
create64[i] = bigInteger.longValue();
|
||
|
bigInteger = bigInteger.shiftRight(64);
|
||
|
i++;
|
||
|
}
|
||
|
return create64;
|
||
|
}
|
||
|
|
||
|
public static boolean eq64(long[] jArr, long[] jArr2) {
|
||
|
for (int i = 4; i >= 0; i--) {
|
||
|
if (jArr[i] != jArr2[i]) {
|
||
|
return false;
|
||
|
}
|
||
|
}
|
||
|
return true;
|
||
|
}
|
||
|
|
||
|
public static long[] createExt64() {
|
||
|
return new long[10];
|
||
|
}
|
||
|
|
||
|
public static long[] create64() {
|
||
|
return new long[5];
|
||
|
}
|
||
|
|
||
|
public static void copy64(long[] jArr, long[] jArr2) {
|
||
|
jArr2[0] = jArr[0];
|
||
|
jArr2[1] = jArr[1];
|
||
|
jArr2[2] = jArr[2];
|
||
|
jArr2[3] = jArr[3];
|
||
|
jArr2[4] = jArr[4];
|
||
|
}
|
||
|
}
|