290 lines
63 KiB
Java
290 lines
63 KiB
Java
|
package org.bouncycastle.crypto.digests;
|
||
|
|
||
|
import com.google.common.base.Ascii;
|
||
|
import com.google.common.primitives.SignedBytes;
|
||
|
import com.google.common.primitives.UnsignedBytes;
|
||
|
import net.sf.scuba.smartcards.ISO7816;
|
||
|
import net.sf.scuba.smartcards.ISOFileInfo;
|
||
|
import org.bouncycastle.crypto.ExtendedDigest;
|
||
|
import org.bouncycastle.crypto.signers.PSSSigner;
|
||
|
import org.bouncycastle.util.Arrays;
|
||
|
import org.bouncycastle.util.Memoable;
|
||
|
import org.jmrtd.lds.CVCAFile;
|
||
|
|
||
|
/* loaded from: classes6.dex */
|
||
|
public abstract class GOST3411_2012Digest implements ExtendedDigest, Memoable {
|
||
|
private final byte[] IV;
|
||
|
private final byte[] h;
|
||
|
private static final byte[][] C = {new byte[]{ISO7816.INS_READ_BINARY2, 8, 91, ISO7816.INS_PUT_DATA, 30, ISO7816.INS_GET_DATA, ISO7816.INS_PUT_DATA, -23, -21, -53, 47, ISOFileInfo.DATA_BYTES2, ISO7816.INS_GET_RESPONSE, 101, 124, Ascii.US, 47, 106, 118, 67, 46, 69, ISO7816.INS_WRITE_BINARY, Ascii.SYN, 113, 78, -72, ISOFileInfo.ENV_TEMP_EF, 117, ISOFileInfo.PROP_INFO, -60, -4, 75, 124, ISO7816.INS_CREATE_FILE, -111, -110, 103, 105, 1, -94, CVCAFile.CAR_TAG, ISO7816.INS_PSO, 8, -92, 96, -45, Ascii.NAK, 5, 118, 116, 54, -52, 116, 77, 35, -35, Byte.MIN_VALUE, 101, 89, -14, -90, 69, 7}, new byte[]{ISOFileInfo.FCI_BYTE, -93, -75, ISOFileInfo.LCS_BYTE, -87, -99, 47, Ascii.SUB, 79, -29, -99, 70, 15, ISO7816.INS_MANAGE_CHANNEL, -75, -41, -13, -2, -22, 114, 10, 35, 43, -104, 97, -43, 94, 15, Ascii.SYN, -75, 1, 49, -102, -75, Ascii.ETB, 107, Ascii.DC2, ISO7816.INS_UPDATE_BINARY, -103, 88, 92, -75, 97, ISO7816.INS_ENVELOPE, -37, 10, -89, ISO7816.INS_GET_DATA, 85, -35, -94, Ascii.ESC, -41, -53, -51, 86, -26, 121, 4, ISO7816.INS_MANAGE_CHANNEL, 33, ISO7816.INS_READ_BINARY2, -101, -73}, new byte[]{-11, 116, ISO7816.INS_UPDATE_RECORD, -84, 43, -50, 47, -57, 10, 57, -4, 40, 106, 61, -124, 53, 6, -15, 94, 95, 82, -100, Ascii.US, ISOFileInfo.SECURITY_ATTR_EXP, -14, -22, 117, Ascii.DC4, ISO7816.INS_READ_BINARY2, 41, 123, 123, -45, ISO7816.INS_APPEND_RECORD, 15, ISO7816.INS_DELETE_FILE, -112, 53, -98, ISO7816.INS_READ_BINARY2, -63, -55, 58, 55, 96, ISOFileInfo.FCP_BYTE, -37, 9, ISO7816.INS_ENVELOPE, ISO7816.INS_READ_RECORD_STAMPED, -12, 67, -122, 122, -37, 49, -103, 30, -106, -11, 10, -70, 10, -78}, new byte[]{-17, Ascii.US, -33, ISO7816.INS_READ_RECORD2, -24, Ascii.NAK, 102, ISO7816.INS_WRITE_RECORD, -7, 72, -31, ISOFileInfo.A0, 93, 113, ISO7816.INS_DELETE_FILE, -35, 72, ISOFileInfo.CHANNEL_SECURITY, ISOFileInfo.PROP_INFO, 126, 51, 92, 60, 125, -99, 114, 28, -83, 104, 94, 53, 63, -87, -41, ISO7816.INS_UNBLOCK_CHV, -126, -19, 3, ISO7816.INS_UPDATE_BINARY, 117, ISO7816.INS_LOAD_KEY_FILE, -73, 19, 51, -109, 82, 3, -66, ISO7816.INS_DECREASE_STAMPED, 83, -22, ISOFileInfo.A1, -109, -24, 55, -15, ISO7816.INS_MSE, 12, -66, PSSSigner.TRAILER_IMPLICIT, -124, -29, -47, 46}, new byte[]{75, -22, 107, -84, -83, 71, 71, -103, -102, 63, 65, 12, 108, -87, 35, 99, Ascii.DEL, Ascii.NAK, 28, Ascii.US, Ascii.SYN, -122, 16, 74, 53, -98, 53, -41, Byte.MIN_VALUE, 15, -1, -67, -65, -51, Ascii.ETB, 71, 37, 58, -11, -93, -33, -1, 0, -73, 35, 39, Ascii.SUB, Ascii.SYN, 122, 86, -94, 126, -87, -22, 99, -11, 96, Ascii.ETB, 88, -3, 124, 108, -2, 87}, new byte[]{-82, 79, -82, -82, 29, 58, -45, -39, ISOFileInfo.FCI_BYTE, -92, -61, 59, 122, ISO7816.INS_DECREASE, 57, ISO7816.INS_GET_RESPONSE, 45, 102, -60, -7, 81, CVCAFile.CAR_TAG, -92, 108, Ascii.CAN, Ascii.DEL, -102, ISO7816.INS_READ_BINARY_STAMPED, -102, -16, ISOFileInfo.CHANNEL_SECURITY, -58, -49, -6, -90, -73, 28, -102, -73, ISO7816.INS_READ_BINARY_STAMPED, 10, -14, Ascii.US, 102, ISO7816.INS_ENVELOPE, -66, -58, ISO7816.INS_READ_RECORD_STAMPED, -65, 113, -59, 114, 54, -112, 79, 53, -6, 104, SignedBytes.MAX_POWER_OF_TWO, 122, 70, ISOFileInfo.FMD_BYTE, 125, 110}, new byte[]{-12, -57, 14, Ascii.SYN, -18, -86, -59, -20, 81, -84, -122, -2, -65, ISO7816.INS_CHANGE_CHV, 9, 84, 57, -98, -58, -57, -26, -65, ISOFileInfo.FCI_EXT, -55, -45, 71, 62, 51, Ascii.EM, 122, -109, -55, 9, -110, ISOFileInfo.AB, -59, 45, -126, ISO7816.INS_UNBLOCK_CHV, 55, 6, 71, 105, ISOFileInfo.FILE_IDENTIFIER, 40, 74, 5, 4, 53, Ascii.ETB, 69, 76, -94, 60, 74, -13, -120, -122, 86, 77, 58, Ascii.DC4, -44, -109}, new byte[]{-101, Ascii.US, 91, CVCAFile.CAR_TAG, 77, -109, -55, -89, 3, -25, -86, 2, 12, 110, 65, 65, 78, -73, -8, 113, -100, 54, -34, 30, -119, ISO7816.INS_READ_BINARY_STAMPED, ISO7816.INS_REHABILITATE_CHV, 59, 77, -37, -60, -102, -12, -119, 43, -53, -110, -101, 6, -112, 105, -47, ISOFileInfo.ENV_TEMP_EF, 43, -47, ISOFileInfo.A5, -60, 47, 54, -84, ISO7816.INS_ENVELOPE, 53, 89, 81, -88, -39, -92, Ascii.DEL, 13, -44, -65, 2, -25, 30}, new byte[]{55, -113, 90, 84, Ascii.SYN, 49, ISO7816.INS_MSE, -101, -108, 76, -102, ISO7816.INS_LOAD_KEY_FILE, -20,
|
||
|
private static final byte[] Zero = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
|
||
|
private static final long[][] T = {new long[]{-1803552715625652272L, 2703135593145367062L, -4014430758819158872L, 6577092334268629354L, 806964168861892974L, -6063472769050256282L, -713936367173212554L, -730696462206134965L, 5215999108449717233L, -46053480858810939L, -3782322580877781099L, 7409386412115095689L, 3849627103271945136L, 8988319201874450849L, 3938119337751376013L, -7010230157848027178L, -8423426398366749129L, -7147294794814685941L, -4896405975937806502L, -1930949658557223699L, -3548053845353340974L, -1407348811753517218L, -5094482946371975395L, -8349570678062906195L, 8519831221648263471L, 6380786457702773335L, 4606327678483665726L, 1135139788101916873L, -1296744055254569597L, 1220450159802546598L, 6759235690777098768L, 5340123591806085420L, 6034809048673841977L, -5407401691594998519L, 6896344311240562893L, -1690488634981198087L, 9184934662348565148L, -4183792988264456516L, -6457042926775703950L, 3364644269219363704L, 989048157634869780L, -9056160079784030844L, 3387584785362250392L, 6665082552186727408L, 8806730920978768603L, -8943992543361557404L, -3499218176542634446L, -8832779848047991010L, -5384180315986760471L, -5116578973163071747L, 2007762480278943944L, 7071029175581714734L, -245446995445778696L, -7098459127742649109L, 5517131305049330262L, 2524355749569298796L, 3276936053954857029L, -833575805165058901L, -4774104785891107142L, 4227838725751020409L, -1108816769305830132L, 2880731531503622347L, -8547577275558851350L, 1904883134495025448L, -8015005427386181889L, 4850405589464713887L, -602049820529576042L, 2081972218582700626L, 1379356218675464859L, -6509842815274707633L, 3166351970529817407L, -2925410023548009017L, -6354163580723349614L, -2675396450584002605L, -8745932894798146525L, 4095269026725968292L, 7284836791436182452L, 178206167350026973L, -8587687698711814902L, -7849942517349325374L, 5686309239594266763L, 3626867272058218794L, 4695292606739097666L, -5584978786571663757L, 7805587275216445447L, 6553870956925915274L, 2247080073069027695L, -4360880972299377210L, 4136504802722867268L, 2992705483290644962L, 4655464135170259362L, -1641371007467190503L, 867873424238963700L, 6139766898342725699L, 5048711494641582808L, 2360957084007330385L, 7917754814463914471L, -6851982712723858168L, 8900603062938514235L, 4819584321579539327L, -2835569523292644082L, -4162535888497939071L, 2409792751347803057L, 7449496838093054313L, 2608138101170875382L, -3089532541034338534L, 6775169570724432173L, 2898833334747545602L, -8076149933667584112L, 1717647244194337596L, -2273374492424215382L, 8669102231478190086L, 7938185699155198682L, -8713704321949088317L, 3969222566346957165L, -5988784469396818180L, 9134972545477524348L, -4561983676892834053L, -443809933158089025L, 8321595681021526376L, 3740161260836255946L, -6223083854011302213L, -1981192628965753587L, -8189443922177186192L, 5892660270079857124L, 2502541675832561804L, -2804466300730962706L, 3575476887658224151L, -3200685872914850720L, 669897467106812851L, -7208553650918336623L, -3694119084499141361L, 3809516679850545744L, 5718256960103440747L, -2332953186743126124L, 2758712437335984427L, -4627477833875620761L, -2457079737070004919L, 4334551115747581955L, -7965043308780665057L, 7539375937215052192L, -5292836362296451116L, 1449546416188301313L, -7476662035618257748L, 7253733569142936148L, -4410843088901983194L, 4494160142329627358L, 5797380680492875780L, 5033684639528710629L, 6942380200648117235L, -311213848885666718L, -6820034994775438104L, 5452010138718157004L, 646676091767009875L, -4539043153625528549L, -6988416084379726282L, 471514214048988026L, -1312069221898101058L, 8614828720478738639L, 3471190102295415799L, -8245283892968532659L, -547814629229383841L, -1516815754241838044L, -6167477462292361850L, -7381664543912200884L, 0, -1067861853971886868L, 8143953700710785973L, -5825391166404688447L, -7494732077575095195L, 1847633384726895125L, -7672935903076573512L, -2570373723287288663L, -7766808051888107688L, -9211246677606207655L, -4304686731880476836L, -424225740051214974L, -944158789619597359L, 7698943044753169277L, 5558086220651709366L, 273485755470967613L, -243723997786
|
||
|
private final byte[] N = new byte[64];
|
||
|
private final byte[] Sigma = new byte[64];
|
||
|
private final byte[] Ki = new byte[64];
|
||
|
private final byte[] m = new byte[64];
|
||
|
private final byte[] tmp = new byte[64];
|
||
|
private final byte[] block = new byte[64];
|
||
|
private int bOff = 64;
|
||
|
|
||
|
@Override // org.bouncycastle.util.Memoable
|
||
|
public abstract Memoable copy();
|
||
|
|
||
|
@Override // org.bouncycastle.crypto.Digest
|
||
|
public abstract String getAlgorithmName();
|
||
|
|
||
|
@Override // org.bouncycastle.crypto.ExtendedDigest
|
||
|
public int getByteLength() {
|
||
|
return 64;
|
||
|
}
|
||
|
|
||
|
@Override // org.bouncycastle.crypto.Digest
|
||
|
public abstract int getDigestSize();
|
||
|
|
||
|
@Override // org.bouncycastle.crypto.Digest
|
||
|
public void update(byte[] bArr, int i, int i2) {
|
||
|
while (this.bOff != 64 && i2 > 0) {
|
||
|
update(bArr[i]);
|
||
|
i2--;
|
||
|
i++;
|
||
|
}
|
||
|
while (i2 >= 64) {
|
||
|
System.arraycopy(bArr, i, this.tmp, 0, 64);
|
||
|
reverse(this.tmp, this.block);
|
||
|
g_N(this.h, this.N, this.block);
|
||
|
addMod512(this.N, 512);
|
||
|
addMod512(this.Sigma, this.block);
|
||
|
i2 -= 64;
|
||
|
i += 64;
|
||
|
}
|
||
|
while (i2 > 0) {
|
||
|
update(bArr[i]);
|
||
|
i2--;
|
||
|
i++;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
@Override // org.bouncycastle.crypto.Digest
|
||
|
public void update(byte b) {
|
||
|
byte[] bArr = this.block;
|
||
|
int i = this.bOff - 1;
|
||
|
this.bOff = i;
|
||
|
bArr[i] = b;
|
||
|
if (i == 0) {
|
||
|
g_N(this.h, this.N, bArr);
|
||
|
addMod512(this.N, 512);
|
||
|
addMod512(this.Sigma, this.block);
|
||
|
this.bOff = 64;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
@Override // org.bouncycastle.util.Memoable
|
||
|
public void reset(Memoable memoable) {
|
||
|
GOST3411_2012Digest gOST3411_2012Digest = (GOST3411_2012Digest) memoable;
|
||
|
System.arraycopy(gOST3411_2012Digest.IV, 0, this.IV, 0, 64);
|
||
|
System.arraycopy(gOST3411_2012Digest.N, 0, this.N, 0, 64);
|
||
|
System.arraycopy(gOST3411_2012Digest.Sigma, 0, this.Sigma, 0, 64);
|
||
|
System.arraycopy(gOST3411_2012Digest.Ki, 0, this.Ki, 0, 64);
|
||
|
System.arraycopy(gOST3411_2012Digest.m, 0, this.m, 0, 64);
|
||
|
System.arraycopy(gOST3411_2012Digest.h, 0, this.h, 0, 64);
|
||
|
System.arraycopy(gOST3411_2012Digest.block, 0, this.block, 0, 64);
|
||
|
this.bOff = gOST3411_2012Digest.bOff;
|
||
|
}
|
||
|
|
||
|
@Override // org.bouncycastle.crypto.Digest
|
||
|
public void reset() {
|
||
|
this.bOff = 64;
|
||
|
Arrays.fill(this.N, (byte) 0);
|
||
|
Arrays.fill(this.Sigma, (byte) 0);
|
||
|
System.arraycopy(this.IV, 0, this.h, 0, 64);
|
||
|
Arrays.fill(this.block, (byte) 0);
|
||
|
}
|
||
|
|
||
|
@Override // org.bouncycastle.crypto.Digest
|
||
|
public int doFinal(byte[] bArr, int i) {
|
||
|
int i2;
|
||
|
int i3 = 64 - this.bOff;
|
||
|
int i4 = 0;
|
||
|
while (true) {
|
||
|
i2 = 64 - i3;
|
||
|
if (i4 == i2) {
|
||
|
break;
|
||
|
}
|
||
|
this.m[i4] = 0;
|
||
|
i4++;
|
||
|
}
|
||
|
byte[] bArr2 = this.m;
|
||
|
bArr2[63 - i3] = 1;
|
||
|
int i5 = this.bOff;
|
||
|
if (i5 != 64) {
|
||
|
System.arraycopy(this.block, i5, bArr2, i2, i3);
|
||
|
}
|
||
|
g_N(this.h, this.N, this.m);
|
||
|
addMod512(this.N, i3 << 3);
|
||
|
addMod512(this.Sigma, this.m);
|
||
|
byte[] bArr3 = this.h;
|
||
|
byte[] bArr4 = Zero;
|
||
|
g_N(bArr3, bArr4, this.N);
|
||
|
g_N(this.h, bArr4, this.Sigma);
|
||
|
reverse(this.h, this.tmp);
|
||
|
System.arraycopy(this.tmp, 0, bArr, i, 64);
|
||
|
reset();
|
||
|
return 64;
|
||
|
}
|
||
|
|
||
|
private void xor512(byte[] bArr, byte[] bArr2) {
|
||
|
for (int i = 0; i < 64; i++) {
|
||
|
bArr[i] = (byte) (bArr[i] ^ bArr2[i]);
|
||
|
}
|
||
|
}
|
||
|
|
||
|
private void reverse(byte[] bArr, byte[] bArr2) {
|
||
|
int length = bArr.length;
|
||
|
for (int i = 0; i < length; i++) {
|
||
|
bArr2[(length - 1) - i] = bArr[i];
|
||
|
}
|
||
|
}
|
||
|
|
||
|
private void g_N(byte[] bArr, byte[] bArr2, byte[] bArr3) {
|
||
|
System.arraycopy(bArr, 0, this.tmp, 0, 64);
|
||
|
xor512(bArr, bArr2);
|
||
|
F(bArr);
|
||
|
E(bArr, bArr3);
|
||
|
xor512(bArr, this.tmp);
|
||
|
xor512(bArr, bArr3);
|
||
|
}
|
||
|
|
||
|
private void addMod512(byte[] bArr, byte[] bArr2) {
|
||
|
int i = 0;
|
||
|
for (int i2 = 63; i2 >= 0; i2--) {
|
||
|
i = (i >> 8) + (bArr[i2] & UnsignedBytes.MAX_VALUE) + (bArr2[i2] & UnsignedBytes.MAX_VALUE);
|
||
|
bArr[i2] = (byte) i;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
private void addMod512(byte[] bArr, int i) {
|
||
|
int i2 = (bArr[63] & 255) + (i & 255);
|
||
|
bArr[63] = (byte) i2;
|
||
|
int i3 = (bArr[62] & 255) + ((i >> 8) & 255) + (i2 >> 8);
|
||
|
bArr[62] = (byte) i3;
|
||
|
for (int i4 = 61; i4 >= 0 && i3 > 0; i4--) {
|
||
|
i3 = (bArr[i4] & 255) + (i3 >> 8);
|
||
|
bArr[i4] = (byte) i3;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
private void F(byte[] bArr) {
|
||
|
long[][] jArr = T;
|
||
|
long[] jArr2 = jArr[0];
|
||
|
long j = jArr2[bArr[56] & UnsignedBytes.MAX_VALUE];
|
||
|
long[] jArr3 = jArr[1];
|
||
|
long j2 = jArr3[bArr[48] & UnsignedBytes.MAX_VALUE];
|
||
|
long[] jArr4 = jArr[2];
|
||
|
long j3 = jArr4[bArr[40] & UnsignedBytes.MAX_VALUE];
|
||
|
long[] jArr5 = jArr[3];
|
||
|
long j4 = jArr5[bArr[32] & UnsignedBytes.MAX_VALUE];
|
||
|
long[] jArr6 = jArr[4];
|
||
|
long j5 = jArr6[bArr[24] & UnsignedBytes.MAX_VALUE];
|
||
|
long[] jArr7 = jArr[5];
|
||
|
long j6 = jArr7[bArr[16] & UnsignedBytes.MAX_VALUE];
|
||
|
long[] jArr8 = jArr[6];
|
||
|
long j7 = jArr8[bArr[8] & UnsignedBytes.MAX_VALUE];
|
||
|
long[] jArr9 = jArr[7];
|
||
|
long j8 = ((((((j ^ j2) ^ j3) ^ j4) ^ j5) ^ j6) ^ j7) ^ jArr9[bArr[0] & UnsignedBytes.MAX_VALUE];
|
||
|
long j9 = ((((((jArr2[bArr[57] & UnsignedBytes.MAX_VALUE] ^ jArr3[bArr[49] & UnsignedBytes.MAX_VALUE]) ^ jArr4[bArr[41] & UnsignedBytes.MAX_VALUE]) ^ jArr5[bArr[33] & UnsignedBytes.MAX_VALUE]) ^ jArr6[bArr[25] & UnsignedBytes.MAX_VALUE]) ^ jArr7[bArr[17] & UnsignedBytes.MAX_VALUE]) ^ jArr8[bArr[9] & UnsignedBytes.MAX_VALUE]) ^ jArr9[bArr[1] & UnsignedBytes.MAX_VALUE];
|
||
|
long j10 = ((((((jArr2[bArr[58] & UnsignedBytes.MAX_VALUE] ^ jArr3[bArr[50] & UnsignedBytes.MAX_VALUE]) ^ jArr4[bArr[42] & UnsignedBytes.MAX_VALUE]) ^ jArr5[bArr[34] & UnsignedBytes.MAX_VALUE]) ^ jArr6[bArr[26] & UnsignedBytes.MAX_VALUE]) ^ jArr7[bArr[18] & UnsignedBytes.MAX_VALUE]) ^ jArr8[bArr[10] & UnsignedBytes.MAX_VALUE]) ^ jArr9[bArr[2] & UnsignedBytes.MAX_VALUE];
|
||
|
long j11 = ((((((jArr2[bArr[59] & UnsignedBytes.MAX_VALUE] ^ jArr3[bArr[51] & UnsignedBytes.MAX_VALUE]) ^ jArr4[bArr[43] & UnsignedBytes.MAX_VALUE]) ^ jArr5[bArr[35] & UnsignedBytes.MAX_VALUE]) ^ jArr6[bArr[27] & UnsignedBytes.MAX_VALUE]) ^ jArr7[bArr[19] & UnsignedBytes.MAX_VALUE]) ^ jArr8[bArr[11] & UnsignedBytes.MAX_VALUE]) ^ jArr9[bArr[3] & UnsignedBytes.MAX_VALUE];
|
||
|
long j12 = ((((((jArr2[bArr[60] & UnsignedBytes.MAX_VALUE] ^ jArr3[bArr[52] & UnsignedBytes.MAX_VALUE]) ^ jArr4[bArr[44] & UnsignedBytes.MAX_VALUE]) ^ jArr5[bArr[36] & UnsignedBytes.MAX_VALUE]) ^ jArr6[bArr[28] & UnsignedBytes.MAX_VALUE]) ^ jArr7[bArr[20] & UnsignedBytes.MAX_VALUE]) ^ jArr8[bArr[12] & UnsignedBytes.MAX_VALUE]) ^ jArr9[bArr[4] & UnsignedBytes.MAX_VALUE];
|
||
|
long j13 = ((((((jArr2[bArr[61] & UnsignedBytes.MAX_VALUE] ^ jArr3[bArr[53] & UnsignedBytes.MAX_VALUE]) ^ jArr4[bArr[45] & UnsignedBytes.MAX_VALUE]) ^ jArr5[bArr[37] & UnsignedBytes.MAX_VALUE]) ^ jArr6[bArr[29] & UnsignedBytes.MAX_VALUE]) ^ jArr7[bArr[21] & UnsignedBytes.MAX_VALUE]) ^ jArr8[bArr[13] & UnsignedBytes.MAX_VALUE]) ^ jArr9[bArr[5] & UnsignedBytes.MAX_VALUE];
|
||
|
long j14 = ((((((jArr2[bArr[62] & UnsignedBytes.MAX_VALUE] ^ jArr3[bArr[54] & UnsignedBytes.MAX_VALUE]) ^ jArr4[bArr[46] & UnsignedBytes.MAX_VALUE]) ^ jArr5[bArr[38] & UnsignedBytes.MAX_VALUE]) ^ jArr6[bArr[30] & UnsignedBytes.MAX_VALUE]) ^ jArr7[bArr[22] & UnsignedBytes.MAX_VALUE]) ^ jArr8[bArr[14] & UnsignedBytes.MAX_VALUE]) ^ jArr9[bArr[6] & UnsignedBytes.MAX_VALUE];
|
||
|
long j15 = ((((((jArr2[bArr[63] & UnsignedBytes.MAX_VALUE] ^ jArr3[bArr[55] & UnsignedBytes.MAX_VALUE]) ^ jArr4[bArr[47] & UnsignedBytes.MAX_VALUE]) ^ jArr5[bArr[39] & UnsignedBytes.MAX_VALUE]) ^ jArr6[bArr[31] & UnsignedBytes.MAX_VALUE]) ^ jArr7[bArr[23] & UnsignedBytes.MAX_VALUE]) ^ jArr8[bArr[15] & UnsignedBytes.MAX_VALUE]) ^ jArr9[bArr[7] & UnsignedBytes.MAX_VALUE];
|
||
|
bArr[7] = (byte) (j8 >> 56);
|
||
|
bArr[6] = (byte) (j8 >> 48);
|
||
|
bArr[5] = (byte) (j8 >> 40);
|
||
|
bArr[4] = (byte) (j8 >> 32);
|
||
|
bArr[3] = (byte) (j8 >> 24);
|
||
|
bArr[2] = (byte) (j8 >> 16);
|
||
|
bArr[1] = (byte) (j8 >> 8);
|
||
|
bArr[0] = (byte) j8;
|
||
|
bArr[15] = (byte) (j9 >> 56);
|
||
|
bArr[14] = (byte) (j9 >> 48);
|
||
|
bArr[13] = (byte) (j9 >> 40);
|
||
|
bArr[12] = (byte) (j9 >> 32);
|
||
|
bArr[11] = (byte) (j9 >> 24);
|
||
|
bArr[10] = (byte) (j9 >> 16);
|
||
|
bArr[9] = (byte) (j9 >> 8);
|
||
|
bArr[8] = (byte) j9;
|
||
|
bArr[23] = (byte) (j10 >> 56);
|
||
|
bArr[22] = (byte) (j10 >> 48);
|
||
|
bArr[21] = (byte) (j10 >> 40);
|
||
|
bArr[20] = (byte) (j10 >> 32);
|
||
|
bArr[19] = (byte) (j10 >> 24);
|
||
|
bArr[18] = (byte) (j10 >> 16);
|
||
|
bArr[17] = (byte) (j10 >> 8);
|
||
|
bArr[16] = (byte) j10;
|
||
|
bArr[31] = (byte) (j11 >> 56);
|
||
|
bArr[30] = (byte) (j11 >> 48);
|
||
|
bArr[29] = (byte) (j11 >> 40);
|
||
|
bArr[28] = (byte) (j11 >> 32);
|
||
|
bArr[27] = (byte) (j11 >> 24);
|
||
|
bArr[26] = (byte) (j11 >> 16);
|
||
|
bArr[25] = (byte) (j11 >> 8);
|
||
|
bArr[24] = (byte) j11;
|
||
|
bArr[39] = (byte) (j12 >> 56);
|
||
|
bArr[38] = (byte) (j12 >> 48);
|
||
|
bArr[37] = (byte) (j12 >> 40);
|
||
|
bArr[36] = (byte) (j12 >> 32);
|
||
|
bArr[35] = (byte) (j12 >> 24);
|
||
|
bArr[34] = (byte) (j12 >> 16);
|
||
|
bArr[33] = (byte) (j12 >> 8);
|
||
|
bArr[32] = (byte) j12;
|
||
|
bArr[47] = (byte) (j13 >> 56);
|
||
|
bArr[46] = (byte) (j13 >> 48);
|
||
|
bArr[45] = (byte) (j13 >> 40);
|
||
|
bArr[44] = (byte) (j13 >> 32);
|
||
|
bArr[43] = (byte) (j13 >> 24);
|
||
|
bArr[42] = (byte) (j13 >> 16);
|
||
|
bArr[41] = (byte) (j13 >> 8);
|
||
|
bArr[40] = (byte) j13;
|
||
|
bArr[55] = (byte) (j14 >> 56);
|
||
|
bArr[54] = (byte) (j14 >> 48);
|
||
|
bArr[53] = (byte) (j14 >> 40);
|
||
|
bArr[52] = (byte) (j14 >> 32);
|
||
|
bArr[51] = (byte) (j14 >> 24);
|
||
|
bArr[50] = (byte) (j14 >> 16);
|
||
|
bArr[49] = (byte) (j14 >> 8);
|
||
|
bArr[48] = (byte) j14;
|
||
|
bArr[63] = (byte) (j15 >> 56);
|
||
|
bArr[62] = (byte) (j15 >> 48);
|
||
|
bArr[61] = (byte) (j15 >> 40);
|
||
|
bArr[60] = (byte) (j15 >> 32);
|
||
|
bArr[59] = (byte) (j15 >> 24);
|
||
|
bArr[58] = (byte) (j15 >> 16);
|
||
|
bArr[57] = (byte) (j15 >> 8);
|
||
|
bArr[56] = (byte) j15;
|
||
|
}
|
||
|
|
||
|
private void E(byte[] bArr, byte[] bArr2) {
|
||
|
System.arraycopy(bArr, 0, this.Ki, 0, 64);
|
||
|
xor512(bArr, bArr2);
|
||
|
F(bArr);
|
||
|
for (int i = 0; i < 11; i++) {
|
||
|
xor512(this.Ki, C[i]);
|
||
|
F(this.Ki);
|
||
|
xor512(bArr, this.Ki);
|
||
|
F(bArr);
|
||
|
}
|
||
|
xor512(this.Ki, C[11]);
|
||
|
F(this.Ki);
|
||
|
xor512(bArr, this.Ki);
|
||
|
}
|
||
|
|
||
|
public GOST3411_2012Digest(byte[] bArr) {
|
||
|
byte[] bArr2 = new byte[64];
|
||
|
this.IV = bArr2;
|
||
|
byte[] bArr3 = new byte[64];
|
||
|
this.h = bArr3;
|
||
|
System.arraycopy(bArr, 0, bArr2, 0, 64);
|
||
|
System.arraycopy(bArr, 0, bArr3, 0, 64);
|
||
|
}
|
||
|
}
|