1417 lines
62 KiB
Java
1417 lines
62 KiB
Java
|
package org.bouncycastle.crypto.engines;
|
||
|
|
||
|
import org.bouncycastle.crypto.BlockCipher;
|
||
|
import org.bouncycastle.crypto.CipherParameters;
|
||
|
import org.bouncycastle.crypto.DataLengthException;
|
||
|
import org.bouncycastle.crypto.params.KeyParameter;
|
||
|
import org.bouncycastle.crypto.params.TweakableBlockCipherParameters;
|
||
|
|
||
|
/* loaded from: classes6.dex */
|
||
|
public class ThreefishEngine implements BlockCipher {
|
||
|
public static final int BLOCKSIZE_1024 = 1024;
|
||
|
public static final int BLOCKSIZE_256 = 256;
|
||
|
public static final int BLOCKSIZE_512 = 512;
|
||
|
private static final long C_240 = 2004413935125273122L;
|
||
|
private static final int MAX_ROUNDS = 80;
|
||
|
private static final int ROUNDS_1024 = 80;
|
||
|
private static final int ROUNDS_256 = 72;
|
||
|
private static final int ROUNDS_512 = 72;
|
||
|
private static final int TWEAK_SIZE_BYTES = 16;
|
||
|
private static final int TWEAK_SIZE_WORDS = 2;
|
||
|
private int blocksizeBytes;
|
||
|
private int blocksizeWords;
|
||
|
private ThreefishCipher cipher;
|
||
|
private long[] currentBlock;
|
||
|
private boolean forEncryption;
|
||
|
private long[] kw;
|
||
|
private long[] t;
|
||
|
private static int[] MOD9 = new int[80];
|
||
|
private static int[] MOD17 = new int[80];
|
||
|
private static int[] MOD5 = new int[80];
|
||
|
private static int[] MOD3 = new int[80];
|
||
|
|
||
|
static long rotlXor(long j, int i, long j2) {
|
||
|
return ((j << i) | (j >>> (-i))) ^ j2;
|
||
|
}
|
||
|
|
||
|
static long xorRotr(long j, int i, long j2) {
|
||
|
long j3 = j ^ j2;
|
||
|
return (j3 >>> i) | (j3 << (-i));
|
||
|
}
|
||
|
|
||
|
@Override // org.bouncycastle.crypto.BlockCipher
|
||
|
public void reset() {
|
||
|
}
|
||
|
|
||
|
public int processBlock(long[] jArr, long[] jArr2) throws DataLengthException, IllegalStateException {
|
||
|
long[] jArr3 = this.kw;
|
||
|
int i = this.blocksizeWords;
|
||
|
if (jArr3[i] == 0) {
|
||
|
throw new IllegalStateException("Threefish engine not initialised");
|
||
|
}
|
||
|
if (jArr.length != i) {
|
||
|
throw new DataLengthException("Input buffer too short");
|
||
|
}
|
||
|
if (jArr2.length != i) {
|
||
|
throw new DataLengthException("Output buffer too short");
|
||
|
}
|
||
|
if (this.forEncryption) {
|
||
|
this.cipher.encryptBlock(jArr, jArr2);
|
||
|
} else {
|
||
|
this.cipher.decryptBlock(jArr, jArr2);
|
||
|
}
|
||
|
return this.blocksizeWords;
|
||
|
}
|
||
|
|
||
|
@Override // org.bouncycastle.crypto.BlockCipher
|
||
|
public int processBlock(byte[] bArr, int i, byte[] bArr2, int i2) throws DataLengthException, IllegalStateException {
|
||
|
int i3 = this.blocksizeBytes;
|
||
|
if (i2 + i3 > bArr2.length) {
|
||
|
throw new DataLengthException("Output buffer too short");
|
||
|
}
|
||
|
if (i3 + i > bArr.length) {
|
||
|
throw new DataLengthException("Input buffer too short");
|
||
|
}
|
||
|
int i4 = 0;
|
||
|
for (int i5 = 0; i5 < this.blocksizeBytes; i5 += 8) {
|
||
|
this.currentBlock[i5 >> 3] = bytesToWord(bArr, i + i5);
|
||
|
}
|
||
|
long[] jArr = this.currentBlock;
|
||
|
processBlock(jArr, jArr);
|
||
|
while (true) {
|
||
|
int i6 = this.blocksizeBytes;
|
||
|
if (i4 >= i6) {
|
||
|
return i6;
|
||
|
}
|
||
|
wordToBytes(this.currentBlock[i4 >> 3], bArr2, i2 + i4);
|
||
|
i4 += 8;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
public void init(boolean z, long[] jArr, long[] jArr2) {
|
||
|
this.forEncryption = z;
|
||
|
if (jArr != null) {
|
||
|
setKey(jArr);
|
||
|
}
|
||
|
if (jArr2 != null) {
|
||
|
setTweak(jArr2);
|
||
|
}
|
||
|
}
|
||
|
|
||
|
@Override // org.bouncycastle.crypto.BlockCipher
|
||
|
public void init(boolean z, CipherParameters cipherParameters) throws IllegalArgumentException {
|
||
|
byte[] key;
|
||
|
byte[] bArr;
|
||
|
long[] jArr;
|
||
|
long[] jArr2 = null;
|
||
|
if (cipherParameters instanceof TweakableBlockCipherParameters) {
|
||
|
TweakableBlockCipherParameters tweakableBlockCipherParameters = (TweakableBlockCipherParameters) cipherParameters;
|
||
|
key = tweakableBlockCipherParameters.getKey().getKey();
|
||
|
bArr = tweakableBlockCipherParameters.getTweak();
|
||
|
} else {
|
||
|
if (!(cipherParameters instanceof KeyParameter)) {
|
||
|
StringBuilder sb = new StringBuilder("Invalid parameter passed to Threefish init - ");
|
||
|
sb.append(cipherParameters.getClass().getName());
|
||
|
throw new IllegalArgumentException(sb.toString());
|
||
|
}
|
||
|
key = ((KeyParameter) cipherParameters).getKey();
|
||
|
bArr = null;
|
||
|
}
|
||
|
if (key == null) {
|
||
|
jArr = null;
|
||
|
} else {
|
||
|
if (key.length != this.blocksizeBytes) {
|
||
|
StringBuilder sb2 = new StringBuilder("Threefish key must be same size as block (");
|
||
|
sb2.append(this.blocksizeBytes);
|
||
|
sb2.append(" bytes)");
|
||
|
throw new IllegalArgumentException(sb2.toString());
|
||
|
}
|
||
|
int i = this.blocksizeWords;
|
||
|
jArr = new long[i];
|
||
|
for (int i2 = 0; i2 < i; i2++) {
|
||
|
jArr[i2] = bytesToWord(key, i2 << 3);
|
||
|
}
|
||
|
}
|
||
|
if (bArr != null) {
|
||
|
if (bArr.length != 16) {
|
||
|
throw new IllegalArgumentException("Threefish tweak must be 16 bytes");
|
||
|
}
|
||
|
jArr2 = new long[]{bytesToWord(bArr, 0), bytesToWord(bArr, 8)};
|
||
|
}
|
||
|
init(z, jArr, jArr2);
|
||
|
}
|
||
|
|
||
|
@Override // org.bouncycastle.crypto.BlockCipher
|
||
|
public int getBlockSize() {
|
||
|
return this.blocksizeBytes;
|
||
|
}
|
||
|
|
||
|
@Override // org.bouncycastle.crypto.BlockCipher
|
||
|
public String getAlgorithmName() {
|
||
|
StringBuilder sb = new StringBuilder("Threefish-");
|
||
|
sb.append(this.blocksizeBytes << 3);
|
||
|
return sb.toString();
|
||
|
}
|
||
|
|
||
|
public static void wordToBytes(long j, byte[] bArr, int i) {
|
||
|
if (i + 8 > bArr.length) {
|
||
|
throw new IllegalArgumentException();
|
||
|
}
|
||
|
bArr[i] = (byte) j;
|
||
|
bArr[i + 1] = (byte) (j >> 8);
|
||
|
bArr[i + 2] = (byte) (j >> 16);
|
||
|
bArr[i + 3] = (byte) (j >> 24);
|
||
|
bArr[i + 4] = (byte) (j >> 32);
|
||
|
bArr[i + 5] = (byte) (j >> 40);
|
||
|
bArr[i + 6] = (byte) (j >> 48);
|
||
|
bArr[i + 7] = (byte) (j >> 56);
|
||
|
}
|
||
|
|
||
|
private void setTweak(long[] jArr) {
|
||
|
if (jArr.length != 2) {
|
||
|
throw new IllegalArgumentException("Tweak must be 2 words.");
|
||
|
}
|
||
|
long[] jArr2 = this.t;
|
||
|
long j = jArr[0];
|
||
|
jArr2[0] = j;
|
||
|
long j2 = jArr[1];
|
||
|
jArr2[1] = j2;
|
||
|
jArr2[2] = j ^ j2;
|
||
|
jArr2[3] = j;
|
||
|
jArr2[4] = j2;
|
||
|
}
|
||
|
|
||
|
private void setKey(long[] jArr) {
|
||
|
if (jArr.length != this.blocksizeWords) {
|
||
|
StringBuilder sb = new StringBuilder("Threefish key must be same size as block (");
|
||
|
sb.append(this.blocksizeWords);
|
||
|
sb.append(" words)");
|
||
|
throw new IllegalArgumentException(sb.toString());
|
||
|
}
|
||
|
long j = C_240;
|
||
|
int i = 0;
|
||
|
while (true) {
|
||
|
int i2 = this.blocksizeWords;
|
||
|
if (i >= i2) {
|
||
|
long[] jArr2 = this.kw;
|
||
|
jArr2[i2] = j;
|
||
|
System.arraycopy(jArr2, 0, jArr2, i2 + 1, i2);
|
||
|
return;
|
||
|
} else {
|
||
|
long[] jArr3 = this.kw;
|
||
|
long j2 = jArr[i];
|
||
|
jArr3[i] = j2;
|
||
|
j ^= j2;
|
||
|
i++;
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
|
||
|
public static long bytesToWord(byte[] bArr, int i) {
|
||
|
if (i + 8 > bArr.length) {
|
||
|
throw new IllegalArgumentException();
|
||
|
}
|
||
|
return (bArr[i] & 255) | ((bArr[i + 1] & 255) << 8) | ((bArr[i + 2] & 255) << 16) | ((bArr[i + 3] & 255) << 24) | ((bArr[i + 4] & 255) << 32) | ((bArr[i + 5] & 255) << 40) | ((bArr[i + 6] & 255) << 48) | ((bArr[i + 7] & 255) << 56);
|
||
|
}
|
||
|
|
||
|
/* loaded from: classes6.dex */
|
||
|
static final class Threefish1024Cipher extends ThreefishCipher {
|
||
|
private static final int ROTATION_0_0 = 24;
|
||
|
private static final int ROTATION_0_1 = 13;
|
||
|
private static final int ROTATION_0_2 = 8;
|
||
|
private static final int ROTATION_0_3 = 47;
|
||
|
private static final int ROTATION_0_4 = 8;
|
||
|
private static final int ROTATION_0_5 = 17;
|
||
|
private static final int ROTATION_0_6 = 22;
|
||
|
private static final int ROTATION_0_7 = 37;
|
||
|
private static final int ROTATION_1_0 = 38;
|
||
|
private static final int ROTATION_1_1 = 19;
|
||
|
private static final int ROTATION_1_2 = 10;
|
||
|
private static final int ROTATION_1_3 = 55;
|
||
|
private static final int ROTATION_1_4 = 49;
|
||
|
private static final int ROTATION_1_5 = 18;
|
||
|
private static final int ROTATION_1_6 = 23;
|
||
|
private static final int ROTATION_1_7 = 52;
|
||
|
private static final int ROTATION_2_0 = 33;
|
||
|
private static final int ROTATION_2_1 = 4;
|
||
|
private static final int ROTATION_2_2 = 51;
|
||
|
private static final int ROTATION_2_3 = 13;
|
||
|
private static final int ROTATION_2_4 = 34;
|
||
|
private static final int ROTATION_2_5 = 41;
|
||
|
private static final int ROTATION_2_6 = 59;
|
||
|
private static final int ROTATION_2_7 = 17;
|
||
|
private static final int ROTATION_3_0 = 5;
|
||
|
private static final int ROTATION_3_1 = 20;
|
||
|
private static final int ROTATION_3_2 = 48;
|
||
|
private static final int ROTATION_3_3 = 41;
|
||
|
private static final int ROTATION_3_4 = 47;
|
||
|
private static final int ROTATION_3_5 = 28;
|
||
|
private static final int ROTATION_3_6 = 16;
|
||
|
private static final int ROTATION_3_7 = 25;
|
||
|
private static final int ROTATION_4_0 = 41;
|
||
|
private static final int ROTATION_4_1 = 9;
|
||
|
private static final int ROTATION_4_2 = 37;
|
||
|
private static final int ROTATION_4_3 = 31;
|
||
|
private static final int ROTATION_4_4 = 12;
|
||
|
private static final int ROTATION_4_5 = 47;
|
||
|
private static final int ROTATION_4_6 = 44;
|
||
|
private static final int ROTATION_4_7 = 30;
|
||
|
private static final int ROTATION_5_0 = 16;
|
||
|
private static final int ROTATION_5_1 = 34;
|
||
|
private static final int ROTATION_5_2 = 56;
|
||
|
private static final int ROTATION_5_3 = 51;
|
||
|
private static final int ROTATION_5_4 = 4;
|
||
|
private static final int ROTATION_5_5 = 53;
|
||
|
private static final int ROTATION_5_6 = 42;
|
||
|
private static final int ROTATION_5_7 = 41;
|
||
|
private static final int ROTATION_6_0 = 31;
|
||
|
private static final int ROTATION_6_1 = 44;
|
||
|
private static final int ROTATION_6_2 = 47;
|
||
|
private static final int ROTATION_6_3 = 46;
|
||
|
private static final int ROTATION_6_4 = 19;
|
||
|
private static final int ROTATION_6_5 = 42;
|
||
|
private static final int ROTATION_6_6 = 44;
|
||
|
private static final int ROTATION_6_7 = 25;
|
||
|
private static final int ROTATION_7_0 = 9;
|
||
|
private static final int ROTATION_7_1 = 48;
|
||
|
private static final int ROTATION_7_2 = 35;
|
||
|
private static final int ROTATION_7_3 = 52;
|
||
|
private static final int ROTATION_7_4 = 23;
|
||
|
private static final int ROTATION_7_5 = 31;
|
||
|
private static final int ROTATION_7_6 = 37;
|
||
|
private static final int ROTATION_7_7 = 20;
|
||
|
|
||
|
@Override // org.bouncycastle.crypto.engines.ThreefishEngine.ThreefishCipher
|
||
|
final void encryptBlock(long[] jArr, long[] jArr2) {
|
||
|
long[] jArr3 = this.kw;
|
||
|
long[] jArr4 = this.t;
|
||
|
int[] iArr = ThreefishEngine.MOD17;
|
||
|
int[] iArr2 = ThreefishEngine.MOD3;
|
||
|
if (jArr3.length != 33) {
|
||
|
throw new IllegalArgumentException();
|
||
|
}
|
||
|
if (jArr4.length != 5) {
|
||
|
throw new IllegalArgumentException();
|
||
|
}
|
||
|
long j = jArr[0];
|
||
|
int i = 1;
|
||
|
long j2 = jArr[1];
|
||
|
long j3 = jArr[2];
|
||
|
long j4 = jArr[3];
|
||
|
long j5 = jArr[4];
|
||
|
long j6 = jArr[5];
|
||
|
long j7 = jArr[6];
|
||
|
long j8 = jArr[7];
|
||
|
long j9 = jArr[8];
|
||
|
long j10 = jArr[9];
|
||
|
long j11 = jArr[10];
|
||
|
long j12 = jArr[11];
|
||
|
long j13 = jArr[12];
|
||
|
long j14 = jArr[13];
|
||
|
long j15 = jArr[14];
|
||
|
long j16 = jArr[15];
|
||
|
long j17 = j + jArr3[0];
|
||
|
long j18 = j2 + jArr3[1];
|
||
|
long j19 = j3 + jArr3[2];
|
||
|
long j20 = jArr3[3];
|
||
|
long j21 = j5 + jArr3[4];
|
||
|
long j22 = jArr3[5];
|
||
|
long j23 = j7 + jArr3[6];
|
||
|
long j24 = jArr3[7];
|
||
|
long j25 = j9 + jArr3[8];
|
||
|
long j26 = jArr3[9];
|
||
|
long j27 = j11 + jArr3[10];
|
||
|
long j28 = jArr3[11];
|
||
|
long j29 = j13 + jArr3[12];
|
||
|
long j30 = jArr3[13];
|
||
|
long j31 = jArr4[0];
|
||
|
long j32 = j15 + jArr3[14] + jArr4[1];
|
||
|
long j33 = j4 + j20;
|
||
|
long j34 = j6 + j22;
|
||
|
long j35 = j8 + j24;
|
||
|
long j36 = j10 + j26;
|
||
|
long j37 = j12 + j28;
|
||
|
long j38 = j14 + j30 + j31;
|
||
|
long j39 = j16 + jArr3[15];
|
||
|
while (i < 20) {
|
||
|
int i2 = iArr[i];
|
||
|
int i3 = iArr2[i];
|
||
|
long j40 = j17 + j18;
|
||
|
long rotlXor = ThreefishEngine.rotlXor(j18, 24, j40);
|
||
|
long j41 = j19 + j33;
|
||
|
long rotlXor2 = ThreefishEngine.rotlXor(j33, 13, j41);
|
||
|
long[] jArr5 = jArr3;
|
||
|
int[] iArr3 = iArr;
|
||
|
int[] iArr4 = iArr2;
|
||
|
long j42 = j34;
|
||
|
long j43 = j21 + j42;
|
||
|
long rotlXor3 = ThreefishEngine.rotlXor(j42, 8, j43);
|
||
|
int i4 = i;
|
||
|
long j44 = j35;
|
||
|
long j45 = j23 + j44;
|
||
|
long rotlXor4 = ThreefishEngine.rotlXor(j44, 47, j45);
|
||
|
long[] jArr6 = jArr4;
|
||
|
long j46 = j36;
|
||
|
long j47 = j25 + j46;
|
||
|
long rotlXor5 = ThreefishEngine.rotlXor(j46, 8, j47);
|
||
|
long j48 = j37;
|
||
|
long j49 = j27 + j48;
|
||
|
long rotlXor6 = ThreefishEngine.rotlXor(j48, 17, j49);
|
||
|
long j50 = j38;
|
||
|
long j51 = j29 + j50;
|
||
|
long rotlXor7 = ThreefishEngine.rotlXor(j50, 22, j51);
|
||
|
long j52 = j39;
|
||
|
long j53 = j32 + j52;
|
||
|
long rotlXor8 = ThreefishEngine.rotlXor(j52, 37, j53);
|
||
|
long j54 = j40 + rotlXor5;
|
||
|
long rotlXor9 = ThreefishEngine.rotlXor(rotlXor5, 38, j54);
|
||
|
long j55 = j41 + rotlXor7;
|
||
|
long rotlXor10 = ThreefishEngine.rotlXor(rotlXor7, 19, j55);
|
||
|
long j56 = j45 + rotlXor6;
|
||
|
long rotlXor11 = ThreefishEngine.rotlXor(rotlXor6, 10, j56);
|
||
|
long j57 = j43 + rotlXor8;
|
||
|
long rotlXor12 = ThreefishEngine.rotlXor(rotlXor8, 55, j57);
|
||
|
long j58 = j49 + rotlXor4;
|
||
|
long rotlXor13 = ThreefishEngine.rotlXor(rotlXor4, 49, j58);
|
||
|
long j59 = j51 + rotlXor2;
|
||
|
long rotlXor14 = ThreefishEngine.rotlXor(rotlXor2, 18, j59);
|
||
|
long j60 = j53 + rotlXor3;
|
||
|
long rotlXor15 = ThreefishEngine.rotlXor(rotlXor3, 23, j60);
|
||
|
long j61 = j47 + rotlXor;
|
||
|
long rotlXor16 = ThreefishEngine.rotlXor(rotlXor, 52, j61);
|
||
|
long j62 = j54 + rotlXor13;
|
||
|
long rotlXor17 = ThreefishEngine.rotlXor(rotlXor13, 33, j62);
|
||
|
long j63 = j55 + rotlXor15;
|
||
|
long rotlXor18 = ThreefishEngine.rotlXor(rotlXor15, 4, j63);
|
||
|
long j64 = j57 + rotlXor14;
|
||
|
long rotlXor19 = ThreefishEngine.rotlXor(rotlXor14, 51, j64);
|
||
|
long j65 = j56 + rotlXor16;
|
||
|
long rotlXor20 = ThreefishEngine.rotlXor(rotlXor16, 13, j65);
|
||
|
long j66 = j59 + rotlXor12;
|
||
|
long rotlXor21 = ThreefishEngine.rotlXor(rotlXor12, 34, j66);
|
||
|
long j67 = j60 + rotlXor10;
|
||
|
long rotlXor22 = ThreefishEngine.rotlXor(rotlXor10, 41, j67);
|
||
|
long j68 = j61 + rotlXor11;
|
||
|
long rotlXor23 = ThreefishEngine.rotlXor(rotlXor11, 59, j68);
|
||
|
long j69 = j58 + rotlXor9;
|
||
|
long rotlXor24 = ThreefishEngine.rotlXor(rotlXor9, 17, j69);
|
||
|
long j70 = j62 + rotlXor21;
|
||
|
long rotlXor25 = ThreefishEngine.rotlXor(rotlXor21, 5, j70);
|
||
|
long j71 = j63 + rotlXor23;
|
||
|
long rotlXor26 = ThreefishEngine.rotlXor(rotlXor23, 20, j71);
|
||
|
long j72 = j65 + rotlXor22;
|
||
|
long rotlXor27 = ThreefishEngine.rotlXor(rotlXor22, 48, j72);
|
||
|
long j73 = j64 + rotlXor24;
|
||
|
long rotlXor28 = ThreefishEngine.rotlXor(rotlXor24, 41, j73);
|
||
|
long j74 = j67 + rotlXor20;
|
||
|
long rotlXor29 = ThreefishEngine.rotlXor(rotlXor20, 47, j74);
|
||
|
long j75 = j68 + rotlXor18;
|
||
|
long rotlXor30 = ThreefishEngine.rotlXor(rotlXor18, 28, j75);
|
||
|
long j76 = j69 + rotlXor19;
|
||
|
long rotlXor31 = ThreefishEngine.rotlXor(rotlXor19, 16, j76);
|
||
|
long j77 = j66 + rotlXor17;
|
||
|
long rotlXor32 = ThreefishEngine.rotlXor(rotlXor17, 25, j77);
|
||
|
long j78 = jArr5[i2];
|
||
|
int i5 = i2 + 1;
|
||
|
long j79 = rotlXor29 + jArr5[i5];
|
||
|
int i6 = i2 + 2;
|
||
|
long j80 = jArr5[i6];
|
||
|
int i7 = i2 + 3;
|
||
|
long j81 = rotlXor31 + jArr5[i7];
|
||
|
int i8 = i2 + 4;
|
||
|
long j82 = jArr5[i8];
|
||
|
int i9 = i2 + 5;
|
||
|
long j83 = rotlXor30 + jArr5[i9];
|
||
|
int i10 = i2 + 6;
|
||
|
long j84 = jArr5[i10];
|
||
|
int i11 = i2 + 7;
|
||
|
long j85 = rotlXor32 + jArr5[i11];
|
||
|
int i12 = i2 + 8;
|
||
|
long j86 = jArr5[i12];
|
||
|
int i13 = i2 + 9;
|
||
|
long j87 = rotlXor28 + jArr5[i13];
|
||
|
int i14 = i2 + 10;
|
||
|
long j88 = jArr5[i14];
|
||
|
int i15 = i2 + 11;
|
||
|
long j89 = rotlXor26 + jArr5[i15];
|
||
|
int i16 = i2 + 12;
|
||
|
long j90 = jArr5[i16];
|
||
|
int i17 = i2 + 13;
|
||
|
long j91 = rotlXor27 + jArr5[i17] + jArr6[i3];
|
||
|
int i18 = i2 + 14;
|
||
|
long j92 = jArr5[i18];
|
||
|
int i19 = i3 + 1;
|
||
|
long j93 = jArr6[i19];
|
||
|
int i20 = i2 + 15;
|
||
|
long j94 = i4;
|
||
|
long j95 = rotlXor25 + jArr5[i20] + j94;
|
||
|
long j96 = j70 + j78 + j79;
|
||
|
long rotlXor33 = ThreefishEngine.rotlXor(j79, 41, j96);
|
||
|
long j97 = j71 + j80 + j81;
|
||
|
long rotlXor34 = ThreefishEngine.rotlXor(j81, 9, j97);
|
||
|
long j98 = j73 + j82 + j83;
|
||
|
long rotlXor35 = ThreefishEngine.rotlXor(j83, 37, j98);
|
||
|
long j99 = j72 + j84 + j85;
|
||
|
long rotlXor36 = ThreefishEngine.rotlXor(j85, 31, j99);
|
||
|
long j100 = j75 + j86 + j87;
|
||
|
long rotlXor37 = ThreefishEngine.rotlXor(j87, 12, j100);
|
||
|
long j101 = j76 + j88 + j89;
|
||
|
long rotlXor38 = ThreefishEngine.rotlXor(j89, 47, j101);
|
||
|
long j102 = j77 + j90 + j91;
|
||
|
long rotlXor39 = ThreefishEngine.rotlXor(j91, 44, j102);
|
||
|
long j103 = j74 + j92 + j93 + j95;
|
||
|
long rotlXor40 = ThreefishEngine.rotlXor(j95, 30, j103);
|
||
|
long j104 = j96 + rotlXor37;
|
||
|
long rotlXor41 = ThreefishEngine.rotlXor(rotlXor37, 16, j104);
|
||
|
long j105 = j97 + rotlXor39;
|
||
|
long rotlXor42 = ThreefishEngine.rotlXor(rotlXor39, 34, j105);
|
||
|
long j106 = j99 + rotlXor38;
|
||
|
long rotlXor43 = ThreefishEngine.rotlXor(rotlXor38, 56, j106);
|
||
|
long j107 = j98 + rotlXor40;
|
||
|
long rotlXor44 = ThreefishEngine.rotlXor(rotlXor40, 51, j107);
|
||
|
long j108 = j101 + rotlXor36;
|
||
|
long rotlXor45 = ThreefishEngine.rotlXor(rotlXor36, 4, j108);
|
||
|
long j109 = j102 + rotlXor34;
|
||
|
long rotlXor46 = ThreefishEngine.rotlXor(rotlXor34, 53, j109);
|
||
|
long j110 = j103 + rotlXor35;
|
||
|
long rotlXor47 = ThreefishEngine.rotlXor(rotlXor35, 42, j110);
|
||
|
long j111 = j100 + rotlXor33;
|
||
|
long rotlXor48 = ThreefishEngine.rotlXor(rotlXor33, 41, j111);
|
||
|
long j112 = j104 + rotlXor45;
|
||
|
long rotlXor49 = ThreefishEngine.rotlXor(rotlXor45, 31, j112);
|
||
|
long j113 = j105 + rotlXor47;
|
||
|
long rotlXor50 = ThreefishEngine.rotlXor(rotlXor47, 44, j113);
|
||
|
long j114 = j107 + rotlXor46;
|
||
|
long rotlXor51 = ThreefishEngine.rotlXor(rotlXor46, 47, j114);
|
||
|
long j115 = j106 + rotlXor48;
|
||
|
long rotlXor52 = ThreefishEngine.rotlXor(rotlXor48, 46, j115);
|
||
|
long j116 = j109 + rotlXor44;
|
||
|
long rotlXor53 = ThreefishEngine.rotlXor(rotlXor44, 19, j116);
|
||
|
long j117 = j110 + rotlXor42;
|
||
|
long rotlXor54 = ThreefishEngine.rotlXor(rotlXor42, 42, j117);
|
||
|
long j118 = j111 + rotlXor43;
|
||
|
long rotlXor55 = ThreefishEngine.rotlXor(rotlXor43, 44, j118);
|
||
|
long j119 = j108 + rotlXor41;
|
||
|
long rotlXor56 = ThreefishEngine.rotlXor(rotlXor41, 25, j119);
|
||
|
long j120 = j112 + rotlXor53;
|
||
|
long rotlXor57 = ThreefishEngine.rotlXor(rotlXor53, 9, j120);
|
||
|
long j121 = j113 + rotlXor55;
|
||
|
long rotlXor58 = ThreefishEngine.rotlXor(rotlXor55, 48, j121);
|
||
|
long j122 = j115 + rotlXor54;
|
||
|
long rotlXor59 = ThreefishEngine.rotlXor(rotlXor54, 35, j122);
|
||
|
long j123 = j114 + rotlXor56;
|
||
|
long rotlXor60 = ThreefishEngine.rotlXor(rotlXor56, 52, j123);
|
||
|
long j124 = j117 + rotlXor52;
|
||
|
long rotlXor61 = ThreefishEngine.rotlXor(rotlXor52, 23, j124);
|
||
|
long j125 = j118 + rotlXor50;
|
||
|
long rotlXor62 = ThreefishEngine.rotlXor(rotlXor50, 31, j125);
|
||
|
long j126 = j119 + rotlXor51;
|
||
|
long rotlXor63 = ThreefishEngine.rotlXor(rotlXor51, 37, j126);
|
||
|
long j127 = j116 + rotlXor49;
|
||
|
long rotlXor64 = ThreefishEngine.rotlXor(rotlXor49, 20, j127);
|
||
|
long j128 = jArr5[i5];
|
||
|
long j129 = jArr5[i6];
|
||
|
long j130 = jArr5[i7];
|
||
|
long j131 = jArr5[i8];
|
||
|
long j132 = jArr5[i9];
|
||
|
long j133 = jArr5[i10];
|
||
|
long j134 = jArr5[i11];
|
||
|
j35 = rotlXor64 + jArr5[i12];
|
||
|
long j135 = jArr5[i13];
|
||
|
long j136 = rotlXor60 + jArr5[i14];
|
||
|
long j137 = j126 + jArr5[i15];
|
||
|
j37 = rotlXor58 + jArr5[i16];
|
||
|
long j138 = jArr5[i17] + j127;
|
||
|
long j139 = rotlXor59 + jArr5[i18] + jArr6[i19];
|
||
|
long j140 = jArr5[i20] + jArr6[i3 + 2] + j124;
|
||
|
j39 = rotlXor57 + jArr5[i2 + 16] + j94 + 1;
|
||
|
j23 = j122 + j134;
|
||
|
long j141 = j132 + j123;
|
||
|
long j142 = rotlXor63 + j131;
|
||
|
j38 = j139;
|
||
|
j32 = j140;
|
||
|
j36 = j136;
|
||
|
j34 = rotlXor62 + j133;
|
||
|
i = i4 + 2;
|
||
|
j17 = j128 + j120;
|
||
|
jArr3 = jArr5;
|
||
|
j29 = j138;
|
||
|
iArr = iArr3;
|
||
|
jArr4 = jArr6;
|
||
|
iArr2 = iArr4;
|
||
|
j33 = j142;
|
||
|
j25 = j125 + j135;
|
||
|
j18 = rotlXor61 + j129;
|
||
|
j27 = j137;
|
||
|
j19 = j121 + j130;
|
||
|
j21 = j141;
|
||
|
}
|
||
|
jArr2[0] = j17;
|
||
|
jArr2[1] = j18;
|
||
|
jArr2[2] = j19;
|
||
|
jArr2[3] = j33;
|
||
|
jArr2[4] = j21;
|
||
|
jArr2[5] = j34;
|
||
|
jArr2[6] = j23;
|
||
|
jArr2[7] = j35;
|
||
|
jArr2[8] = j25;
|
||
|
jArr2[9] = j36;
|
||
|
jArr2[10] = j27;
|
||
|
jArr2[11] = j37;
|
||
|
jArr2[12] = j29;
|
||
|
jArr2[13] = j38;
|
||
|
jArr2[14] = j32;
|
||
|
jArr2[15] = j39;
|
||
|
}
|
||
|
|
||
|
@Override // org.bouncycastle.crypto.engines.ThreefishEngine.ThreefishCipher
|
||
|
final void decryptBlock(long[] jArr, long[] jArr2) {
|
||
|
long[] jArr3 = this.kw;
|
||
|
long[] jArr4 = this.t;
|
||
|
int[] iArr = ThreefishEngine.MOD17;
|
||
|
int[] iArr2 = ThreefishEngine.MOD3;
|
||
|
if (jArr3.length != 33) {
|
||
|
throw new IllegalArgumentException();
|
||
|
}
|
||
|
if (jArr4.length != 5) {
|
||
|
throw new IllegalArgumentException();
|
||
|
}
|
||
|
long j = jArr[0];
|
||
|
long j2 = jArr[1];
|
||
|
long j3 = jArr[2];
|
||
|
long j4 = jArr[3];
|
||
|
long j5 = jArr[4];
|
||
|
long j6 = jArr[5];
|
||
|
long j7 = jArr[6];
|
||
|
long j8 = jArr[7];
|
||
|
long j9 = jArr[8];
|
||
|
long j10 = jArr[9];
|
||
|
long j11 = jArr[10];
|
||
|
long j12 = jArr[11];
|
||
|
long j13 = jArr[12];
|
||
|
long j14 = jArr[13];
|
||
|
long j15 = jArr[14];
|
||
|
long j16 = jArr[15];
|
||
|
int i = 19;
|
||
|
while (i > 0) {
|
||
|
int i2 = iArr[i];
|
||
|
int i3 = iArr2[i];
|
||
|
int i4 = i2 + 1;
|
||
|
long j17 = j - jArr3[i4];
|
||
|
int i5 = i2 + 2;
|
||
|
long j18 = jArr3[i5];
|
||
|
int i6 = i2 + 3;
|
||
|
long j19 = j3 - jArr3[i6];
|
||
|
int i7 = i2 + 4;
|
||
|
long j20 = jArr3[i7];
|
||
|
int i8 = i2 + 5;
|
||
|
long j21 = j5 - jArr3[i8];
|
||
|
int i9 = i2 + 6;
|
||
|
long j22 = jArr3[i9];
|
||
|
int i10 = i2 + 7;
|
||
|
long j23 = j7 - jArr3[i10];
|
||
|
int i11 = i2 + 8;
|
||
|
long j24 = jArr3[i11];
|
||
|
int i12 = i2 + 9;
|
||
|
int i13 = i;
|
||
|
long j25 = j9 - jArr3[i12];
|
||
|
int i14 = i2 + 10;
|
||
|
long j26 = jArr3[i14];
|
||
|
int i15 = i2 + 11;
|
||
|
int[] iArr3 = iArr;
|
||
|
int[] iArr4 = iArr2;
|
||
|
long j27 = j11 - jArr3[i15];
|
||
|
int i16 = i2 + 12;
|
||
|
long j28 = jArr3[i16];
|
||
|
int i17 = i2 + 13;
|
||
|
long j29 = j13 - jArr3[i17];
|
||
|
int i18 = i2 + 14;
|
||
|
long j30 = jArr3[i18];
|
||
|
int i19 = i3 + 1;
|
||
|
long j31 = jArr4[i19];
|
||
|
int i20 = i2 + 15;
|
||
|
long j32 = j15 - (jArr3[i20] + jArr4[i3 + 2]);
|
||
|
long j33 = jArr3[i2 + 16];
|
||
|
long[] jArr5 = jArr4;
|
||
|
long[] jArr6 = jArr3;
|
||
|
long j34 = i13;
|
||
|
long xorRotr = ThreefishEngine.xorRotr(j16 - ((j33 + j34) + 1), 9, j17);
|
||
|
long j35 = j17 - xorRotr;
|
||
|
long xorRotr2 = ThreefishEngine.xorRotr(j12 - j28, 48, j19);
|
||
|
long j36 = j19 - xorRotr2;
|
||
|
long xorRotr3 = ThreefishEngine.xorRotr(j14 - (j30 + j31), 35, j23);
|
||
|
long j37 = j23 - xorRotr3;
|
||
|
long xorRotr4 = ThreefishEngine.xorRotr(j10 - j26, 52, j21);
|
||
|
long j38 = j21 - xorRotr4;
|
||
|
long xorRotr5 = ThreefishEngine.xorRotr(j2 - j18, 23, j32);
|
||
|
long j39 = j32 - xorRotr5;
|
||
|
long xorRotr6 = ThreefishEngine.xorRotr(j6 - j22, 31, j25);
|
||
|
long j40 = j25 - xorRotr6;
|
||
|
long xorRotr7 = ThreefishEngine.xorRotr(j4 - j20, 37, j27);
|
||
|
long j41 = j27 - xorRotr7;
|
||
|
long xorRotr8 = ThreefishEngine.xorRotr(j8 - j24, 20, j29);
|
||
|
long j42 = j29 - xorRotr8;
|
||
|
long xorRotr9 = ThreefishEngine.xorRotr(xorRotr8, 31, j35);
|
||
|
long j43 = j35 - xorRotr9;
|
||
|
long xorRotr10 = ThreefishEngine.xorRotr(xorRotr6, 44, j36);
|
||
|
long j44 = j36 - xorRotr10;
|
||
|
long xorRotr11 = ThreefishEngine.xorRotr(xorRotr7, 47, j38);
|
||
|
long j45 = j38 - xorRotr11;
|
||
|
long xorRotr12 = ThreefishEngine.xorRotr(xorRotr5, 46, j37);
|
||
|
long j46 = j37 - xorRotr12;
|
||
|
long xorRotr13 = ThreefishEngine.xorRotr(xorRotr, 19, j42);
|
||
|
long j47 = j42 - xorRotr13;
|
||
|
long xorRotr14 = ThreefishEngine.xorRotr(xorRotr3, 42, j39);
|
||
|
long j48 = j39 - xorRotr14;
|
||
|
long xorRotr15 = ThreefishEngine.xorRotr(xorRotr2, 44, j40);
|
||
|
long j49 = j40 - xorRotr15;
|
||
|
long xorRotr16 = ThreefishEngine.xorRotr(xorRotr4, 25, j41);
|
||
|
long j50 = j41 - xorRotr16;
|
||
|
long xorRotr17 = ThreefishEngine.xorRotr(xorRotr16, 16, j43);
|
||
|
long j51 = j43 - xorRotr17;
|
||
|
long xorRotr18 = ThreefishEngine.xorRotr(xorRotr14, 34, j44);
|
||
|
long j52 = j44 - xorRotr18;
|
||
|
long xorRotr19 = ThreefishEngine.xorRotr(xorRotr15, 56, j46);
|
||
|
long j53 = j46 - xorRotr19;
|
||
|
long xorRotr20 = ThreefishEngine.xorRotr(xorRotr13, 51, j45);
|
||
|
long j54 = j45 - xorRotr20;
|
||
|
long xorRotr21 = ThreefishEngine.xorRotr(xorRotr9, 4, j50);
|
||
|
long j55 = j50 - xorRotr21;
|
||
|
long xorRotr22 = ThreefishEngine.xorRotr(xorRotr11, 53, j47);
|
||
|
long j56 = j47 - xorRotr22;
|
||
|
long xorRotr23 = ThreefishEngine.xorRotr(xorRotr10, 42, j48);
|
||
|
long j57 = j48 - xorRotr23;
|
||
|
long xorRotr24 = ThreefishEngine.xorRotr(xorRotr12, 41, j49);
|
||
|
long j58 = j49 - xorRotr24;
|
||
|
long xorRotr25 = ThreefishEngine.xorRotr(xorRotr24, 41, j51);
|
||
|
long xorRotr26 = ThreefishEngine.xorRotr(xorRotr22, 9, j52);
|
||
|
long xorRotr27 = ThreefishEngine.xorRotr(xorRotr23, 37, j54);
|
||
|
long xorRotr28 = ThreefishEngine.xorRotr(xorRotr21, 31, j53);
|
||
|
long xorRotr29 = ThreefishEngine.xorRotr(xorRotr17, 12, j58);
|
||
|
long xorRotr30 = ThreefishEngine.xorRotr(xorRotr19, 47, j55);
|
||
|
long xorRotr31 = ThreefishEngine.xorRotr(xorRotr18, 44, j56);
|
||
|
long xorRotr32 = ThreefishEngine.xorRotr(xorRotr20, 30, j57);
|
||
|
long j59 = (j51 - xorRotr25) - jArr6[i2];
|
||
|
long j60 = jArr6[i4];
|
||
|
long j61 = (j52 - xorRotr26) - jArr6[i5];
|
||
|
long j62 = jArr6[i6];
|
||
|
long j63 = (j54 - xorRotr27) - jArr6[i7];
|
||
|
long j64 = jArr6[i8];
|
||
|
long j65 = (j53 - xorRotr28) - jArr6[i9];
|
||
|
long j66 = jArr6[i10];
|
||
|
long j67 = (j58 - xorRotr29) - jArr6[i11];
|
||
|
long j68 = jArr6[i12];
|
||
|
long j69 = (j55 - xorRotr30) - jArr6[i14];
|
||
|
long j70 = jArr6[i15];
|
||
|
long j71 = (j56 - xorRotr31) - jArr6[i16];
|
||
|
long j72 = jArr6[i17];
|
||
|
long j73 = jArr5[i3];
|
||
|
long j74 = (j57 - xorRotr32) - (jArr6[i18] + jArr5[i19]);
|
||
|
long xorRotr33 = ThreefishEngine.xorRotr(xorRotr32 - (jArr6[i20] + j34), 5, j59);
|
||
|
long j75 = j59 - xorRotr33;
|
||
|
long xorRotr34 = ThreefishEngine.xorRotr(xorRotr30 - j70, 20, j61);
|
||
|
long j76 = j61 - xorRotr34;
|
||
|
long xorRotr35 = ThreefishEngine.xorRotr(xorRotr31 - (j72 + j73), 48, j65);
|
||
|
long j77 = j65 - xorRotr35;
|
||
|
long xorRotr36 = ThreefishEngine.xorRotr(xorRotr29 - j68, 41, j63);
|
||
|
long j78 = j63 - xorRotr36;
|
||
|
long xorRotr37 = ThreefishEngine.xorRotr(xorRotr25 - j60, 47, j74);
|
||
|
long j79 = j74 - xorRotr37;
|
||
|
long xorRotr38 = ThreefishEngine.xorRotr(xorRotr27 - j64, 28, j67);
|
||
|
long j80 = j67 - xorRotr38;
|
||
|
long xorRotr39 = ThreefishEngine.xorRotr(xorRotr26 - j62, 16, j69);
|
||
|
long j81 = j69 - xorRotr39;
|
||
|
long xorRotr40 = ThreefishEngine.xorRotr(xorRotr28 - j66, 25, j71);
|
||
|
long j82 = j71 - xorRotr40;
|
||
|
long xorRotr41 = ThreefishEngine.xorRotr(xorRotr40, 33, j75);
|
||
|
long j83 = j75 - xorRotr41;
|
||
|
long xorRotr42 = ThreefishEngine.xorRotr(xorRotr38, 4, j76);
|
||
|
long j84 = j76 - xorRotr42;
|
||
|
long xorRotr43 = ThreefishEngine.xorRotr(xorRotr39, 51, j78);
|
||
|
long j85 = j78 - xorRotr43;
|
||
|
long xorRotr44 = ThreefishEngine.xorRotr(xorRotr37, 13, j77);
|
||
|
long j86 = j77 - xorRotr44;
|
||
|
long xorRotr45 = ThreefishEngine.xorRotr(xorRotr33, 34, j82);
|
||
|
long j87 = j82 - xorRotr45;
|
||
|
long xorRotr46 = ThreefishEngine.xorRotr(xorRotr35, 41, j79);
|
||
|
long j88 = j79 - xorRotr46;
|
||
|
long xorRotr47 = ThreefishEngine.xorRotr(xorRotr34, 59, j80);
|
||
|
long j89 = j80 - xorRotr47;
|
||
|
long xorRotr48 = ThreefishEngine.xorRotr(xorRotr36, 17, j81);
|
||
|
long j90 = j81 - xorRotr48;
|
||
|
long xorRotr49 = ThreefishEngine.xorRotr(xorRotr48, 38, j83);
|
||
|
long j91 = j83 - xorRotr49;
|
||
|
long xorRotr50 = ThreefishEngine.xorRotr(xorRotr46, 19, j84);
|
||
|
long j92 = j84 - xorRotr50;
|
||
|
long xorRotr51 = ThreefishEngine.xorRotr(xorRotr47, 10, j86);
|
||
|
long j93 = j86 - xorRotr51;
|
||
|
long xorRotr52 = ThreefishEngine.xorRotr(xorRotr45, 55, j85);
|
||
|
long j94 = j85 - xorRotr52;
|
||
|
long xorRotr53 = ThreefishEngine.xorRotr(xorRotr41, 49, j90);
|
||
|
long j95 = j90 - xorRotr53;
|
||
|
long xorRotr54 = ThreefishEngine.xorRotr(xorRotr43, 18, j87);
|
||
|
long j96 = j87 - xorRotr54;
|
||
|
long xorRotr55 = ThreefishEngine.xorRotr(xorRotr42, 23, j88);
|
||
|
long j97 = j88 - xorRotr55;
|
||
|
long xorRotr56 = ThreefishEngine.xorRotr(xorRotr44, 52, j89);
|
||
|
long j98 = j89 - xorRotr56;
|
||
|
long xorRotr57 = ThreefishEngine.xorRotr(xorRotr56, 24, j91);
|
||
|
long xorRotr58 = ThreefishEngine.xorRotr(xorRotr54, 13, j92);
|
||
|
long j99 = j92 - xorRotr58;
|
||
|
long xorRotr59 = ThreefishEngine.xorRotr(xorRotr55, 8, j94);
|
||
|
long xorRotr60 = ThreefishEngine.xorRotr(xorRotr53, 47, j93);
|
||
|
long xorRotr61 = ThreefishEngine.xorRotr(xorRotr49, 8, j98);
|
||
|
j12 = ThreefishEngine.xorRotr(xorRotr51, 17, j95);
|
||
|
long xorRotr62 = ThreefishEngine.xorRotr(xorRotr50, 22, j96);
|
||
|
j16 = ThreefishEngine.xorRotr(xorRotr52, 37, j97);
|
||
|
j15 = j97 - j16;
|
||
|
j13 = j96 - xorRotr62;
|
||
|
i = i13 - 2;
|
||
|
j11 = j95 - j12;
|
||
|
j7 = j93 - xorRotr60;
|
||
|
j10 = xorRotr61;
|
||
|
j3 = j99;
|
||
|
j4 = xorRotr58;
|
||
|
jArr3 = jArr6;
|
||
|
j5 = j94 - xorRotr59;
|
||
|
j14 = xorRotr62;
|
||
|
j = j91 - xorRotr57;
|
||
|
j2 = xorRotr57;
|
||
|
j6 = xorRotr59;
|
||
|
j8 = xorRotr60;
|
||
|
iArr2 = iArr4;
|
||
|
j9 = j98 - xorRotr61;
|
||
|
iArr = iArr3;
|
||
|
jArr4 = jArr5;
|
||
|
}
|
||
|
long[] jArr7 = jArr3;
|
||
|
long[] jArr8 = jArr4;
|
||
|
long j100 = jArr7[0];
|
||
|
long j101 = jArr7[1];
|
||
|
long j102 = jArr7[2];
|
||
|
long j103 = jArr7[3];
|
||
|
long j104 = jArr7[4];
|
||
|
long j105 = jArr7[5];
|
||
|
long j106 = jArr7[6];
|
||
|
long j107 = jArr7[7];
|
||
|
long j108 = jArr7[8];
|
||
|
long j109 = jArr7[9];
|
||
|
long j110 = jArr7[10];
|
||
|
long j111 = jArr7[11];
|
||
|
long j112 = jArr7[12];
|
||
|
long j113 = jArr7[13];
|
||
|
long j114 = jArr8[0];
|
||
|
long j115 = jArr7[14];
|
||
|
long j116 = jArr8[1];
|
||
|
long j117 = jArr7[15];
|
||
|
jArr2[0] = j - j100;
|
||
|
jArr2[1] = j2 - j101;
|
||
|
jArr2[2] = j3 - j102;
|
||
|
jArr2[3] = j4 - j103;
|
||
|
jArr2[4] = j5 - j104;
|
||
|
jArr2[5] = j6 - j105;
|
||
|
jArr2[6] = j7 - j106;
|
||
|
jArr2[7] = j8 - j107;
|
||
|
jArr2[8] = j9 - j108;
|
||
|
jArr2[9] = j10 - j109;
|
||
|
jArr2[10] = j11 - j110;
|
||
|
jArr2[11] = j12 - j111;
|
||
|
jArr2[12] = j13 - j112;
|
||
|
jArr2[13] = j14 - (j113 + j114);
|
||
|
jArr2[14] = j15 - (j115 + j116);
|
||
|
jArr2[15] = j16 - j117;
|
||
|
}
|
||
|
|
||
|
public Threefish1024Cipher(long[] jArr, long[] jArr2) {
|
||
|
super(jArr, jArr2);
|
||
|
}
|
||
|
}
|
||
|
|
||
|
/* loaded from: classes6.dex */
|
||
|
static final class Threefish256Cipher extends ThreefishCipher {
|
||
|
private static final int ROTATION_0_0 = 14;
|
||
|
private static final int ROTATION_0_1 = 16;
|
||
|
private static final int ROTATION_1_0 = 52;
|
||
|
private static final int ROTATION_1_1 = 57;
|
||
|
private static final int ROTATION_2_0 = 23;
|
||
|
private static final int ROTATION_2_1 = 40;
|
||
|
private static final int ROTATION_3_0 = 5;
|
||
|
private static final int ROTATION_3_1 = 37;
|
||
|
private static final int ROTATION_4_0 = 25;
|
||
|
private static final int ROTATION_4_1 = 33;
|
||
|
private static final int ROTATION_5_0 = 46;
|
||
|
private static final int ROTATION_5_1 = 12;
|
||
|
private static final int ROTATION_6_0 = 58;
|
||
|
private static final int ROTATION_6_1 = 22;
|
||
|
private static final int ROTATION_7_0 = 32;
|
||
|
private static final int ROTATION_7_1 = 32;
|
||
|
|
||
|
@Override // org.bouncycastle.crypto.engines.ThreefishEngine.ThreefishCipher
|
||
|
final void encryptBlock(long[] jArr, long[] jArr2) {
|
||
|
long[] jArr3 = this.kw;
|
||
|
long[] jArr4 = this.t;
|
||
|
int[] iArr = ThreefishEngine.MOD5;
|
||
|
int[] iArr2 = ThreefishEngine.MOD3;
|
||
|
if (jArr3.length != 9) {
|
||
|
throw new IllegalArgumentException();
|
||
|
}
|
||
|
if (jArr4.length != 5) {
|
||
|
throw new IllegalArgumentException();
|
||
|
}
|
||
|
long j = jArr[0];
|
||
|
long j2 = jArr[1];
|
||
|
long j3 = jArr[2];
|
||
|
long j4 = jArr[3];
|
||
|
long j5 = j + jArr3[0];
|
||
|
long j6 = j2 + jArr3[1] + jArr4[0];
|
||
|
long j7 = j3 + jArr3[2] + jArr4[1];
|
||
|
int i = 1;
|
||
|
long j8 = j4 + jArr3[3];
|
||
|
while (i < 18) {
|
||
|
int i2 = iArr[i];
|
||
|
int i3 = iArr2[i];
|
||
|
long j9 = j5 + j6;
|
||
|
long rotlXor = ThreefishEngine.rotlXor(j6, 14, j9);
|
||
|
long j10 = j7 + j8;
|
||
|
long rotlXor2 = ThreefishEngine.rotlXor(j8, 16, j10);
|
||
|
long j11 = j9 + rotlXor2;
|
||
|
long rotlXor3 = ThreefishEngine.rotlXor(rotlXor2, 52, j11);
|
||
|
long j12 = j10 + rotlXor;
|
||
|
long rotlXor4 = ThreefishEngine.rotlXor(rotlXor, 57, j12);
|
||
|
long j13 = j11 + rotlXor4;
|
||
|
long rotlXor5 = ThreefishEngine.rotlXor(rotlXor4, 23, j13);
|
||
|
long j14 = j12 + rotlXor3;
|
||
|
long rotlXor6 = ThreefishEngine.rotlXor(rotlXor3, 40, j14);
|
||
|
long j15 = j13 + rotlXor6;
|
||
|
long rotlXor7 = ThreefishEngine.rotlXor(rotlXor6, 5, j15);
|
||
|
long j16 = j14 + rotlXor5;
|
||
|
long rotlXor8 = ThreefishEngine.rotlXor(rotlXor5, 37, j16);
|
||
|
long j17 = jArr3[i2];
|
||
|
int i4 = i2 + 1;
|
||
|
long j18 = rotlXor8 + jArr3[i4] + jArr4[i3];
|
||
|
int i5 = i2 + 2;
|
||
|
long j19 = jArr3[i5];
|
||
|
int i6 = i3 + 1;
|
||
|
long j20 = jArr4[i6];
|
||
|
int i7 = i2 + 3;
|
||
|
int[] iArr3 = iArr;
|
||
|
long j21 = i;
|
||
|
long j22 = rotlXor7 + jArr3[i7] + j21;
|
||
|
long j23 = j15 + j17 + j18;
|
||
|
long rotlXor9 = ThreefishEngine.rotlXor(j18, 25, j23);
|
||
|
long j24 = j16 + j19 + j20 + j22;
|
||
|
long rotlXor10 = ThreefishEngine.rotlXor(j22, 33, j24);
|
||
|
long j25 = j23 + rotlXor10;
|
||
|
long rotlXor11 = ThreefishEngine.rotlXor(rotlXor10, 46, j25);
|
||
|
long j26 = j24 + rotlXor9;
|
||
|
long rotlXor12 = ThreefishEngine.rotlXor(rotlXor9, 12, j26);
|
||
|
long j27 = j25 + rotlXor12;
|
||
|
long rotlXor13 = ThreefishEngine.rotlXor(rotlXor12, 58, j27);
|
||
|
long j28 = j26 + rotlXor11;
|
||
|
long rotlXor14 = ThreefishEngine.rotlXor(rotlXor11, 22, j28);
|
||
|
long j29 = j27 + rotlXor14;
|
||
|
long rotlXor15 = ThreefishEngine.rotlXor(rotlXor14, 32, j29);
|
||
|
long j30 = j28 + rotlXor13;
|
||
|
long rotlXor16 = ThreefishEngine.rotlXor(rotlXor13, 32, j30);
|
||
|
j5 = j29 + jArr3[i4];
|
||
|
j6 = rotlXor16 + jArr3[i5] + jArr4[i6];
|
||
|
j7 = j30 + jArr3[i7] + jArr4[i3 + 2];
|
||
|
j8 = rotlXor15 + jArr3[i2 + 4] + j21 + 1;
|
||
|
i += 2;
|
||
|
iArr = iArr3;
|
||
|
iArr2 = iArr2;
|
||
|
}
|
||
|
jArr2[0] = j5;
|
||
|
jArr2[1] = j6;
|
||
|
jArr2[2] = j7;
|
||
|
jArr2[3] = j8;
|
||
|
}
|
||
|
|
||
|
@Override // org.bouncycastle.crypto.engines.ThreefishEngine.ThreefishCipher
|
||
|
final void decryptBlock(long[] jArr, long[] jArr2) {
|
||
|
long[] jArr3 = this.kw;
|
||
|
long[] jArr4 = this.t;
|
||
|
int[] iArr = ThreefishEngine.MOD5;
|
||
|
int[] iArr2 = ThreefishEngine.MOD3;
|
||
|
if (jArr3.length != 9) {
|
||
|
throw new IllegalArgumentException();
|
||
|
}
|
||
|
if (jArr4.length != 5) {
|
||
|
throw new IllegalArgumentException();
|
||
|
}
|
||
|
boolean z = false;
|
||
|
long j = jArr[0];
|
||
|
long j2 = jArr[1];
|
||
|
long j3 = jArr[2];
|
||
|
long j4 = jArr[3];
|
||
|
int i = 17;
|
||
|
while (i > 0) {
|
||
|
int i2 = iArr[i];
|
||
|
int i3 = iArr2[i];
|
||
|
int i4 = i2 + 1;
|
||
|
long j5 = j - jArr3[i4];
|
||
|
int i5 = i2 + 2;
|
||
|
long j6 = jArr3[i5];
|
||
|
int i6 = i3 + 1;
|
||
|
long j7 = jArr4[i6];
|
||
|
int i7 = i2 + 3;
|
||
|
long j8 = j3 - (jArr3[i7] + jArr4[i3 + 2]);
|
||
|
long j9 = i;
|
||
|
long xorRotr = ThreefishEngine.xorRotr(j4 - ((jArr3[i2 + 4] + j9) + 1), 32, j5);
|
||
|
long j10 = j5 - xorRotr;
|
||
|
long j11 = j2 - (j6 + j7);
|
||
|
int[] iArr3 = iArr;
|
||
|
long xorRotr2 = ThreefishEngine.xorRotr(j11, 32, j8);
|
||
|
long j12 = j8 - xorRotr2;
|
||
|
long xorRotr3 = ThreefishEngine.xorRotr(xorRotr2, 58, j10);
|
||
|
long j13 = j10 - xorRotr3;
|
||
|
long xorRotr4 = ThreefishEngine.xorRotr(xorRotr, 22, j12);
|
||
|
long j14 = j12 - xorRotr4;
|
||
|
long xorRotr5 = ThreefishEngine.xorRotr(xorRotr4, 46, j13);
|
||
|
long j15 = j13 - xorRotr5;
|
||
|
long xorRotr6 = ThreefishEngine.xorRotr(xorRotr3, 12, j14);
|
||
|
long j16 = j14 - xorRotr6;
|
||
|
long xorRotr7 = ThreefishEngine.xorRotr(xorRotr6, 25, j15);
|
||
|
long xorRotr8 = ThreefishEngine.xorRotr(xorRotr5, 33, j16);
|
||
|
long j17 = (j15 - xorRotr7) - jArr3[i2];
|
||
|
long j18 = jArr3[i4];
|
||
|
long j19 = jArr4[i3];
|
||
|
long j20 = (j16 - xorRotr8) - (jArr3[i5] + jArr4[i6]);
|
||
|
long xorRotr9 = ThreefishEngine.xorRotr(xorRotr8 - (jArr3[i7] + j9), 5, j17);
|
||
|
long j21 = j17 - xorRotr9;
|
||
|
long xorRotr10 = ThreefishEngine.xorRotr(xorRotr7 - (j18 + j19), 37, j20);
|
||
|
long j22 = j20 - xorRotr10;
|
||
|
long xorRotr11 = ThreefishEngine.xorRotr(xorRotr10, 23, j21);
|
||
|
long j23 = j21 - xorRotr11;
|
||
|
long xorRotr12 = ThreefishEngine.xorRotr(xorRotr9, 40, j22);
|
||
|
long j24 = j22 - xorRotr12;
|
||
|
long xorRotr13 = ThreefishEngine.xorRotr(xorRotr12, 52, j23);
|
||
|
long j25 = j23 - xorRotr13;
|
||
|
long xorRotr14 = ThreefishEngine.xorRotr(xorRotr11, 57, j24);
|
||
|
long j26 = j24 - xorRotr14;
|
||
|
j2 = ThreefishEngine.xorRotr(xorRotr14, 14, j25);
|
||
|
j = j25 - j2;
|
||
|
j4 = ThreefishEngine.xorRotr(xorRotr13, 16, j26);
|
||
|
j3 = j26 - j4;
|
||
|
i -= 2;
|
||
|
iArr = iArr3;
|
||
|
iArr2 = iArr2;
|
||
|
z = false;
|
||
|
}
|
||
|
boolean z2 = z;
|
||
|
long j27 = jArr3[z2 ? 1 : 0];
|
||
|
long j28 = jArr3[1];
|
||
|
long j29 = jArr4[z2 ? 1 : 0];
|
||
|
long j30 = jArr3[2];
|
||
|
long j31 = jArr4[1];
|
||
|
long j32 = jArr3[3];
|
||
|
jArr2[z2 ? 1 : 0] = j - j27;
|
||
|
jArr2[1] = j2 - (j28 + j29);
|
||
|
jArr2[2] = j3 - (j30 + j31);
|
||
|
jArr2[3] = j4 - j32;
|
||
|
}
|
||
|
|
||
|
public Threefish256Cipher(long[] jArr, long[] jArr2) {
|
||
|
super(jArr, jArr2);
|
||
|
}
|
||
|
}
|
||
|
|
||
|
/* loaded from: classes6.dex */
|
||
|
static final class Threefish512Cipher extends ThreefishCipher {
|
||
|
private static final int ROTATION_0_0 = 46;
|
||
|
private static final int ROTATION_0_1 = 36;
|
||
|
private static final int ROTATION_0_2 = 19;
|
||
|
private static final int ROTATION_0_3 = 37;
|
||
|
private static final int ROTATION_1_0 = 33;
|
||
|
private static final int ROTATION_1_1 = 27;
|
||
|
private static final int ROTATION_1_2 = 14;
|
||
|
private static final int ROTATION_1_3 = 42;
|
||
|
private static final int ROTATION_2_0 = 17;
|
||
|
private static final int ROTATION_2_1 = 49;
|
||
|
private static final int ROTATION_2_2 = 36;
|
||
|
private static final int ROTATION_2_3 = 39;
|
||
|
private static final int ROTATION_3_0 = 44;
|
||
|
private static final int ROTATION_3_1 = 9;
|
||
|
private static final int ROTATION_3_2 = 54;
|
||
|
private static final int ROTATION_3_3 = 56;
|
||
|
private static final int ROTATION_4_0 = 39;
|
||
|
private static final int ROTATION_4_1 = 30;
|
||
|
private static final int ROTATION_4_2 = 34;
|
||
|
private static final int ROTATION_4_3 = 24;
|
||
|
private static final int ROTATION_5_0 = 13;
|
||
|
private static final int ROTATION_5_1 = 50;
|
||
|
private static final int ROTATION_5_2 = 10;
|
||
|
private static final int ROTATION_5_3 = 17;
|
||
|
private static final int ROTATION_6_0 = 25;
|
||
|
private static final int ROTATION_6_1 = 29;
|
||
|
private static final int ROTATION_6_2 = 39;
|
||
|
private static final int ROTATION_6_3 = 43;
|
||
|
private static final int ROTATION_7_0 = 8;
|
||
|
private static final int ROTATION_7_1 = 35;
|
||
|
private static final int ROTATION_7_2 = 56;
|
||
|
private static final int ROTATION_7_3 = 22;
|
||
|
|
||
|
@Override // org.bouncycastle.crypto.engines.ThreefishEngine.ThreefishCipher
|
||
|
public final void encryptBlock(long[] jArr, long[] jArr2) {
|
||
|
long[] jArr3 = this.kw;
|
||
|
long[] jArr4 = this.t;
|
||
|
int[] iArr = ThreefishEngine.MOD9;
|
||
|
int[] iArr2 = ThreefishEngine.MOD3;
|
||
|
if (jArr3.length != 17) {
|
||
|
throw new IllegalArgumentException();
|
||
|
}
|
||
|
if (jArr4.length != 5) {
|
||
|
throw new IllegalArgumentException();
|
||
|
}
|
||
|
long j = jArr[0];
|
||
|
long j2 = jArr[1];
|
||
|
long j3 = jArr[2];
|
||
|
long j4 = jArr[3];
|
||
|
long j5 = jArr[4];
|
||
|
long j6 = jArr[5];
|
||
|
long j7 = jArr[6];
|
||
|
long j8 = jArr[7];
|
||
|
long j9 = j + jArr3[0];
|
||
|
long j10 = j2 + jArr3[1];
|
||
|
long j11 = j3 + jArr3[2];
|
||
|
long j12 = jArr3[3];
|
||
|
long j13 = j5 + jArr3[4];
|
||
|
long j14 = jArr3[5];
|
||
|
long j15 = jArr4[0];
|
||
|
long j16 = j7 + jArr3[6] + jArr4[1];
|
||
|
int i = 1;
|
||
|
long j17 = j4 + j12;
|
||
|
long j18 = j6 + j14 + j15;
|
||
|
long j19 = j8 + jArr3[7];
|
||
|
while (i < 18) {
|
||
|
int i2 = iArr[i];
|
||
|
int i3 = iArr2[i];
|
||
|
long j20 = j9 + j10;
|
||
|
long rotlXor = ThreefishEngine.rotlXor(j10, 46, j20);
|
||
|
long j21 = j11 + j17;
|
||
|
long rotlXor2 = ThreefishEngine.rotlXor(j17, 36, j21);
|
||
|
long j22 = j18;
|
||
|
int[] iArr3 = iArr;
|
||
|
long j23 = j13 + j22;
|
||
|
long rotlXor3 = ThreefishEngine.rotlXor(j22, 19, j23);
|
||
|
long[] jArr5 = jArr3;
|
||
|
long j24 = j19;
|
||
|
long j25 = j16 + j24;
|
||
|
long rotlXor4 = ThreefishEngine.rotlXor(j24, 37, j25);
|
||
|
int i4 = i;
|
||
|
long j26 = j21 + rotlXor;
|
||
|
long rotlXor5 = ThreefishEngine.rotlXor(rotlXor, 33, j26);
|
||
|
long j27 = j23 + rotlXor4;
|
||
|
long rotlXor6 = ThreefishEngine.rotlXor(rotlXor4, 27, j27);
|
||
|
long j28 = j25 + rotlXor3;
|
||
|
long rotlXor7 = ThreefishEngine.rotlXor(rotlXor3, 14, j28);
|
||
|
long j29 = j20 + rotlXor2;
|
||
|
long rotlXor8 = ThreefishEngine.rotlXor(rotlXor2, 42, j29);
|
||
|
long j30 = j27 + rotlXor5;
|
||
|
long rotlXor9 = ThreefishEngine.rotlXor(rotlXor5, 17, j30);
|
||
|
long j31 = j28 + rotlXor8;
|
||
|
long rotlXor10 = ThreefishEngine.rotlXor(rotlXor8, 49, j31);
|
||
|
long j32 = j29 + rotlXor7;
|
||
|
long rotlXor11 = ThreefishEngine.rotlXor(rotlXor7, 36, j32);
|
||
|
long j33 = j26 + rotlXor6;
|
||
|
long rotlXor12 = ThreefishEngine.rotlXor(rotlXor6, 39, j33);
|
||
|
long j34 = j31 + rotlXor9;
|
||
|
long rotlXor13 = ThreefishEngine.rotlXor(rotlXor9, 44, j34);
|
||
|
long j35 = j32 + rotlXor12;
|
||
|
long rotlXor14 = ThreefishEngine.rotlXor(rotlXor12, 9, j35);
|
||
|
long j36 = j33 + rotlXor11;
|
||
|
long rotlXor15 = ThreefishEngine.rotlXor(rotlXor11, 54, j36);
|
||
|
long j37 = j30 + rotlXor10;
|
||
|
long rotlXor16 = ThreefishEngine.rotlXor(rotlXor10, 56, j37);
|
||
|
long j38 = jArr5[i2];
|
||
|
int i5 = i2 + 1;
|
||
|
long j39 = rotlXor13 + jArr5[i5];
|
||
|
int i6 = i2 + 2;
|
||
|
long j40 = jArr5[i6];
|
||
|
int i7 = i2 + 3;
|
||
|
long j41 = rotlXor16 + jArr5[i7];
|
||
|
int i8 = i2 + 4;
|
||
|
long j42 = jArr5[i8];
|
||
|
int i9 = i2 + 5;
|
||
|
long j43 = rotlXor15 + jArr5[i9] + jArr4[i3];
|
||
|
int i10 = i2 + 6;
|
||
|
long j44 = jArr5[i10];
|
||
|
int i11 = i3 + 1;
|
||
|
long j45 = jArr4[i11];
|
||
|
int i12 = i2 + 7;
|
||
|
long j46 = i4;
|
||
|
long j47 = rotlXor14 + jArr5[i12] + j46;
|
||
|
long j48 = j35 + j38 + j39;
|
||
|
long rotlXor17 = ThreefishEngine.rotlXor(j39, 39, j48);
|
||
|
long j49 = j36 + j40 + j41;
|
||
|
long rotlXor18 = ThreefishEngine.rotlXor(j41, 30, j49);
|
||
|
long j50 = j37 + j42 + j43;
|
||
|
long rotlXor19 = ThreefishEngine.rotlXor(j43, 34, j50);
|
||
|
long j51 = j34 + j44 + j45 + j47;
|
||
|
long rotlXor20 = ThreefishEngine.rotlXor(j47, 24, j51);
|
||
|
long j52 = j49 + rotlXor17;
|
||
|
long rotlXor21 = ThreefishEngine.rotlXor(rotlXor17, 13, j52);
|
||
|
long j53 = j50 + rotlXor20;
|
||
|
long rotlXor22 = ThreefishEngine.rotlXor(rotlXor20, 50, j53);
|
||
|
long j54 = j51 + rotlXor19;
|
||
|
long rotlXor23 = ThreefishEngine.rotlXor(rotlXor19, 10, j54);
|
||
|
long j55 = j48 + rotlXor18;
|
||
|
long rotlXor24 = ThreefishEngine.rotlXor(rotlXor18, 17, j55);
|
||
|
long j56 = j53 + rotlXor21;
|
||
|
long rotlXor25 = ThreefishEngine.rotlXor(rotlXor21, 25, j56);
|
||
|
long j57 = j54 + rotlXor24;
|
||
|
long rotlXor26 = ThreefishEngine.rotlXor(rotlXor24, 29, j57);
|
||
|
long j58 = j55 + rotlXor23;
|
||
|
long rotlXor27 = ThreefishEngine.rotlXor(rotlXor23, 39, j58);
|
||
|
long j59 = j52 + rotlXor22;
|
||
|
long rotlXor28 = ThreefishEngine.rotlXor(rotlXor22, 43, j59);
|
||
|
long j60 = j57 + rotlXor25;
|
||
|
long rotlXor29 = ThreefishEngine.rotlXor(rotlXor25, 8, j60);
|
||
|
long j61 = j58 + rotlXor28;
|
||
|
long rotlXor30 = ThreefishEngine.rotlXor(rotlXor28, 35, j61);
|
||
|
long j62 = j59 + rotlXor27;
|
||
|
long rotlXor31 = ThreefishEngine.rotlXor(rotlXor27, 56, j62);
|
||
|
long j63 = j56 + rotlXor26;
|
||
|
long rotlXor32 = ThreefishEngine.rotlXor(rotlXor26, 22, j63);
|
||
|
long j64 = jArr5[i5];
|
||
|
j10 = rotlXor29 + jArr5[i6];
|
||
|
long j65 = jArr5[i7];
|
||
|
long j66 = rotlXor32 + jArr5[i8];
|
||
|
long j67 = jArr5[i9];
|
||
|
long j68 = rotlXor31 + jArr5[i10] + jArr4[i11];
|
||
|
long j69 = j60 + jArr5[i12] + jArr4[i3 + 2];
|
||
|
long j70 = j62 + j65;
|
||
|
j19 = rotlXor30 + jArr5[i2 + 8] + j46 + 1;
|
||
|
j13 = j63 + j67;
|
||
|
j16 = j69;
|
||
|
j18 = j68;
|
||
|
iArr2 = iArr2;
|
||
|
iArr = iArr3;
|
||
|
j17 = j66;
|
||
|
jArr3 = jArr5;
|
||
|
i = i4 + 2;
|
||
|
j11 = j70;
|
||
|
j9 = j61 + j64;
|
||
|
}
|
||
|
jArr2[0] = j9;
|
||
|
jArr2[1] = j10;
|
||
|
jArr2[2] = j11;
|
||
|
jArr2[3] = j17;
|
||
|
jArr2[4] = j13;
|
||
|
jArr2[5] = j18;
|
||
|
jArr2[6] = j16;
|
||
|
jArr2[7] = j19;
|
||
|
}
|
||
|
|
||
|
@Override // org.bouncycastle.crypto.engines.ThreefishEngine.ThreefishCipher
|
||
|
public final void decryptBlock(long[] jArr, long[] jArr2) {
|
||
|
long[] jArr3 = this.kw;
|
||
|
long[] jArr4 = this.t;
|
||
|
int[] iArr = ThreefishEngine.MOD9;
|
||
|
int[] iArr2 = ThreefishEngine.MOD3;
|
||
|
if (jArr3.length != 17) {
|
||
|
throw new IllegalArgumentException();
|
||
|
}
|
||
|
if (jArr4.length != 5) {
|
||
|
throw new IllegalArgumentException();
|
||
|
}
|
||
|
boolean z = false;
|
||
|
long j = jArr[0];
|
||
|
long j2 = jArr[1];
|
||
|
long j3 = jArr[2];
|
||
|
long j4 = jArr[3];
|
||
|
long j5 = jArr[4];
|
||
|
long j6 = jArr[5];
|
||
|
long j7 = jArr[6];
|
||
|
long j8 = jArr[7];
|
||
|
int i = 17;
|
||
|
while (i > 0) {
|
||
|
int i2 = iArr[i];
|
||
|
int i3 = iArr2[i];
|
||
|
int i4 = i2 + 1;
|
||
|
long j9 = j - jArr3[i4];
|
||
|
int i5 = i2 + 2;
|
||
|
long j10 = jArr3[i5];
|
||
|
int i6 = i2 + 3;
|
||
|
long j11 = j3 - jArr3[i6];
|
||
|
int i7 = i2 + 4;
|
||
|
long j12 = jArr3[i7];
|
||
|
int i8 = i2 + 5;
|
||
|
long j13 = j5 - jArr3[i8];
|
||
|
int i9 = i2 + 6;
|
||
|
long j14 = jArr3[i9];
|
||
|
int i10 = i3 + 1;
|
||
|
long j15 = jArr4[i10];
|
||
|
int i11 = i2 + 7;
|
||
|
long j16 = j7 - (jArr3[i11] + jArr4[i3 + 2]);
|
||
|
long j17 = jArr3[i2 + 8];
|
||
|
int[] iArr3 = iArr;
|
||
|
int[] iArr4 = iArr2;
|
||
|
long j18 = i;
|
||
|
long xorRotr = ThreefishEngine.xorRotr(j2 - j10, 8, j16);
|
||
|
long j19 = j16 - xorRotr;
|
||
|
long xorRotr2 = ThreefishEngine.xorRotr(j8 - ((j17 + j18) + 1), 35, j9);
|
||
|
long j20 = j9 - xorRotr2;
|
||
|
long[] jArr5 = jArr3;
|
||
|
long xorRotr3 = ThreefishEngine.xorRotr(j6 - (j14 + j15), 56, j11);
|
||
|
long j21 = j11 - xorRotr3;
|
||
|
long xorRotr4 = ThreefishEngine.xorRotr(j4 - j12, 22, j13);
|
||
|
long j22 = j13 - xorRotr4;
|
||
|
long xorRotr5 = ThreefishEngine.xorRotr(xorRotr, 25, j22);
|
||
|
long j23 = j22 - xorRotr5;
|
||
|
long xorRotr6 = ThreefishEngine.xorRotr(xorRotr4, 29, j19);
|
||
|
long j24 = j19 - xorRotr6;
|
||
|
long xorRotr7 = ThreefishEngine.xorRotr(xorRotr3, 39, j20);
|
||
|
long j25 = j20 - xorRotr7;
|
||
|
int i12 = i;
|
||
|
long xorRotr8 = ThreefishEngine.xorRotr(xorRotr2, 43, j21);
|
||
|
long j26 = j21 - xorRotr8;
|
||
|
long xorRotr9 = ThreefishEngine.xorRotr(xorRotr5, 13, j26);
|
||
|
long j27 = j26 - xorRotr9;
|
||
|
long xorRotr10 = ThreefishEngine.xorRotr(xorRotr8, 50, j23);
|
||
|
long j28 = j23 - xorRotr10;
|
||
|
long xorRotr11 = ThreefishEngine.xorRotr(xorRotr7, 10, j24);
|
||
|
long j29 = j24 - xorRotr11;
|
||
|
long xorRotr12 = ThreefishEngine.xorRotr(xorRotr6, 17, j25);
|
||
|
long j30 = j25 - xorRotr12;
|
||
|
long xorRotr13 = ThreefishEngine.xorRotr(xorRotr9, 39, j30);
|
||
|
long xorRotr14 = ThreefishEngine.xorRotr(xorRotr12, 30, j27);
|
||
|
long xorRotr15 = ThreefishEngine.xorRotr(xorRotr11, 34, j28);
|
||
|
long[] jArr6 = jArr4;
|
||
|
long xorRotr16 = ThreefishEngine.xorRotr(xorRotr10, 24, j29);
|
||
|
long j31 = (j30 - xorRotr13) - jArr5[i2];
|
||
|
long j32 = jArr5[i4];
|
||
|
long j33 = (j27 - xorRotr14) - jArr5[i5];
|
||
|
long j34 = jArr5[i6];
|
||
|
long j35 = (j28 - xorRotr15) - jArr5[i7];
|
||
|
long j36 = jArr5[i8];
|
||
|
long j37 = jArr6[i3];
|
||
|
long j38 = (j29 - xorRotr16) - (jArr5[i9] + jArr6[i10]);
|
||
|
long j39 = jArr5[i11];
|
||
|
long xorRotr17 = ThreefishEngine.xorRotr(xorRotr13 - j32, 44, j38);
|
||
|
long j40 = j38 - xorRotr17;
|
||
|
long xorRotr18 = ThreefishEngine.xorRotr(xorRotr16 - (j39 + j18), 9, j31);
|
||
|
long j41 = j31 - xorRotr18;
|
||
|
long xorRotr19 = ThreefishEngine.xorRotr(xorRotr15 - (j36 + j37), 54, j33);
|
||
|
long j42 = j33 - xorRotr19;
|
||
|
long xorRotr20 = ThreefishEngine.xorRotr(xorRotr14 - j34, 56, j35);
|
||
|
long j43 = j35 - xorRotr20;
|
||
|
long xorRotr21 = ThreefishEngine.xorRotr(xorRotr17, 17, j43);
|
||
|
long j44 = j43 - xorRotr21;
|
||
|
long xorRotr22 = ThreefishEngine.xorRotr(xorRotr20, 49, j40);
|
||
|
long j45 = j40 - xorRotr22;
|
||
|
long xorRotr23 = ThreefishEngine.xorRotr(xorRotr19, 36, j41);
|
||
|
long j46 = j41 - xorRotr23;
|
||
|
long xorRotr24 = ThreefishEngine.xorRotr(xorRotr18, 39, j42);
|
||
|
long j47 = j42 - xorRotr24;
|
||
|
long xorRotr25 = ThreefishEngine.xorRotr(xorRotr21, 33, j47);
|
||
|
long j48 = j47 - xorRotr25;
|
||
|
long xorRotr26 = ThreefishEngine.xorRotr(xorRotr24, 27, j44);
|
||
|
long j49 = j44 - xorRotr26;
|
||
|
long xorRotr27 = ThreefishEngine.xorRotr(xorRotr23, 14, j45);
|
||
|
long j50 = j45 - xorRotr27;
|
||
|
long xorRotr28 = ThreefishEngine.xorRotr(xorRotr22, 42, j46);
|
||
|
long j51 = j46 - xorRotr28;
|
||
|
long xorRotr29 = ThreefishEngine.xorRotr(xorRotr25, 46, j51);
|
||
|
long xorRotr30 = ThreefishEngine.xorRotr(xorRotr28, 36, j48);
|
||
|
j6 = ThreefishEngine.xorRotr(xorRotr27, 19, j49);
|
||
|
long j52 = j49 - j6;
|
||
|
j8 = ThreefishEngine.xorRotr(xorRotr26, 37, j50);
|
||
|
j7 = j50 - j8;
|
||
|
long j53 = j48 - xorRotr30;
|
||
|
i = i12 - 2;
|
||
|
j = j51 - xorRotr29;
|
||
|
j3 = j53;
|
||
|
j4 = xorRotr30;
|
||
|
j2 = xorRotr29;
|
||
|
jArr4 = jArr6;
|
||
|
iArr = iArr3;
|
||
|
iArr2 = iArr4;
|
||
|
z = false;
|
||
|
j5 = j52;
|
||
|
jArr3 = jArr5;
|
||
|
}
|
||
|
long[] jArr7 = jArr3;
|
||
|
long[] jArr8 = jArr4;
|
||
|
boolean z2 = z;
|
||
|
long j54 = jArr7[z2 ? 1 : 0];
|
||
|
long j55 = jArr7[1];
|
||
|
long j56 = jArr7[2];
|
||
|
long j57 = jArr7[3];
|
||
|
long j58 = jArr7[4];
|
||
|
long j59 = jArr7[5];
|
||
|
long j60 = jArr8[z2 ? 1 : 0];
|
||
|
long j61 = jArr7[6];
|
||
|
long j62 = jArr8[1];
|
||
|
long j63 = jArr7[7];
|
||
|
jArr2[z2 ? 1 : 0] = j - j54;
|
||
|
jArr2[1] = j2 - j55;
|
||
|
jArr2[2] = j3 - j56;
|
||
|
jArr2[3] = j4 - j57;
|
||
|
jArr2[4] = j5 - j58;
|
||
|
jArr2[5] = j6 - (j59 + j60);
|
||
|
jArr2[6] = j7 - (j61 + j62);
|
||
|
jArr2[7] = j8 - j63;
|
||
|
}
|
||
|
|
||
|
protected Threefish512Cipher(long[] jArr, long[] jArr2) {
|
||
|
super(jArr, jArr2);
|
||
|
}
|
||
|
}
|
||
|
|
||
|
/* JADX INFO: Access modifiers changed from: package-private */
|
||
|
/* loaded from: classes6.dex */
|
||
|
public static abstract class ThreefishCipher {
|
||
|
protected final long[] kw;
|
||
|
protected final long[] t;
|
||
|
|
||
|
abstract void decryptBlock(long[] jArr, long[] jArr2);
|
||
|
|
||
|
abstract void encryptBlock(long[] jArr, long[] jArr2);
|
||
|
|
||
|
protected ThreefishCipher(long[] jArr, long[] jArr2) {
|
||
|
this.kw = jArr;
|
||
|
this.t = jArr2;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
public ThreefishEngine(int i) {
|
||
|
ThreefishCipher threefish256Cipher;
|
||
|
long[] jArr = new long[5];
|
||
|
this.t = jArr;
|
||
|
int i2 = i / 8;
|
||
|
this.blocksizeBytes = i2;
|
||
|
int i3 = i2 / 8;
|
||
|
this.blocksizeWords = i3;
|
||
|
this.currentBlock = new long[i3];
|
||
|
long[] jArr2 = new long[(i3 << 1) + 1];
|
||
|
this.kw = jArr2;
|
||
|
if (i == 256) {
|
||
|
threefish256Cipher = new Threefish256Cipher(jArr2, jArr);
|
||
|
} else if (i == 512) {
|
||
|
threefish256Cipher = new Threefish512Cipher(jArr2, jArr);
|
||
|
} else {
|
||
|
if (i != 1024) {
|
||
|
throw new IllegalArgumentException("Invalid blocksize - Threefish is defined with block size of 256, 512, or 1024 bits");
|
||
|
}
|
||
|
threefish256Cipher = new Threefish1024Cipher(jArr2, jArr);
|
||
|
}
|
||
|
this.cipher = threefish256Cipher;
|
||
|
}
|
||
|
|
||
|
static {
|
||
|
int i = 0;
|
||
|
while (true) {
|
||
|
int[] iArr = MOD9;
|
||
|
if (i >= iArr.length) {
|
||
|
return;
|
||
|
}
|
||
|
MOD17[i] = i % 17;
|
||
|
iArr[i] = i % 9;
|
||
|
MOD5[i] = i % 5;
|
||
|
MOD3[i] = i % 3;
|
||
|
i++;
|
||
|
}
|
||
|
}
|
||
|
}
|