package org.bouncycastle.crypto.digests;

/* JADX INFO: loaded from: E:\ios\vf_dex\classes4.dex */
public class SHA224Digest extends org.bouncycastle.crypto.digests.GeneralDigest implements org.bouncycastle.crypto.digests.EncodableDigest {
    static final int[] o = {1116352408, 1899447441, -1245643825, -373957723, 961987163, 1508970993, -1841331548, -1424204075, -670586216, 310598401, 607225278, 1426881987, 1925078388, -2132889090, -1680079193, -1046744716, -459576895, -272742522, 264347078, 604807628, 770255983, 1249150122, 1555081692, 1996064986, -1740746414, -1473132947, -1341970488, -1084653625, -958395405, -710438585, 113926993, 338241895, 666307205, 773529912, 1294757372, 1396182291, 1695183700, 1986661051, -2117940946, -1838011259, -1564481375, -1474664885, -1035236496, -949202525, -778901479, -694614492, -200395387, 275423344, 430227734, 506948616, 659060556, 883997877, 958139571, 1322822218, 1537002063, 1747873779, 1955562222, 2024104815, -2067236844, -1933114872, -1866530822, -1538233109, -1090935817, -965641998};
    private int e;
    private int f;
    private int g;
    private int h;
    private int i;
    private int j;
    private int k;
    private int l;
    private int[] m;
    private int n;

    public SHA224Digest() {
        this(org.bouncycastle.crypto.CryptoServicePurpose.ANY);
    }

    private int j(int i, int i2, int i3) {
        return (i & i2) ^ ((~i) & i3);
    }

    private int k(int i, int i2, int i3) {
        return ((i & i2) ^ (i & i3)) ^ (i2 & i3);
    }

    private int l(int i) {
        return (((i >>> 2) | (i << 30)) ^ ((i >>> 13) | (i << 19))) ^ ((i << 10) | (i >>> 22));
    }

    private int m(int i) {
        return (((i >>> 6) | (i << 26)) ^ ((i >>> 11) | (i << 21))) ^ ((i << 7) | (i >>> 25));
    }

    private int n(int i) {
        return (((i >>> 7) | (i << 25)) ^ ((i >>> 18) | (i << 14))) ^ (i >>> 3);
    }

    private int o(int i) {
        return (((i >>> 17) | (i << 15)) ^ ((i >>> 19) | (i << 13))) ^ (i >>> 10);
    }

    private void q(org.bouncycastle.crypto.digests.SHA224Digest sHA224Digest) {
        super.e(sHA224Digest);
        this.e = sHA224Digest.e;
        this.f = sHA224Digest.f;
        this.g = sHA224Digest.g;
        this.h = sHA224Digest.h;
        this.i = sHA224Digest.i;
        this.j = sHA224Digest.j;
        this.k = sHA224Digest.k;
        this.l = sHA224Digest.l;
        int[] iArr = sHA224Digest.m;
        java.lang.System.arraycopy(iArr, 0, this.m, 0, iArr.length);
        this.n = sHA224Digest.n;
    }

    public org.bouncycastle.util.Memoable a() {
        return new org.bouncycastle.crypto.digests.SHA224Digest(this);
    }

    public void d(org.bouncycastle.util.Memoable memoable) {
        q((org.bouncycastle.crypto.digests.SHA224Digest) memoable);
    }

    @Override // org.bouncycastle.crypto.Digest
    public int doFinal(byte[] bArr, int i) {
        f();
        org.bouncycastle.util.Pack.h(this.e, bArr, i);
        org.bouncycastle.util.Pack.h(this.f, bArr, i + 4);
        org.bouncycastle.util.Pack.h(this.g, bArr, i + 8);
        org.bouncycastle.util.Pack.h(this.h, bArr, i + 12);
        org.bouncycastle.util.Pack.h(this.i, bArr, i + 16);
        org.bouncycastle.util.Pack.h(this.j, bArr, i + 20);
        org.bouncycastle.util.Pack.h(this.k, bArr, i + 24);
        reset();
        return 28;
    }

    @Override // org.bouncycastle.crypto.digests.GeneralDigest
    protected void g() {
        for (int i = 16; i <= 63; i++) {
            int[] iArr = this.m;
            int iO = o(iArr[i - 2]);
            int[] iArr2 = this.m;
            iArr[i] = iO + iArr2[i - 7] + n(iArr2[i - 15]) + this.m[i - 16];
        }
        int iL = this.e;
        int iL2 = this.f;
        int iL3 = this.g;
        int iL4 = this.h;
        int i2 = this.i;
        int i3 = this.j;
        int i4 = this.k;
        int i5 = this.l;
        int i6 = 0;
        for (int i7 = 0; i7 < 8; i7++) {
            int iM = m(i2) + j(i2, i3, i4);
            int[] iArr3 = o;
            int i8 = i5 + iM + iArr3[i6] + this.m[i6];
            int i9 = iL4 + i8;
            int iL5 = i8 + l(iL) + k(iL, iL2, iL3);
            int i10 = i6 + 1;
            int iM2 = i4 + m(i9) + j(i9, i2, i3) + iArr3[i10] + this.m[i10];
            int i11 = iL3 + iM2;
            int iL6 = iM2 + l(iL5) + k(iL5, iL, iL2);
            int i12 = i6 + 2;
            int iM3 = i3 + m(i11) + j(i11, i9, i2) + iArr3[i12] + this.m[i12];
            int i13 = iL2 + iM3;
            int iL7 = iM3 + l(iL6) + k(iL6, iL5, iL);
            int i14 = i6 + 3;
            int iM4 = i2 + m(i13) + j(i13, i11, i9) + iArr3[i14] + this.m[i14];
            int i15 = iL + iM4;
            int iL8 = iM4 + l(iL7) + k(iL7, iL6, iL5);
            int i16 = i6 + 4;
            int iM5 = i9 + m(i15) + j(i15, i13, i11) + iArr3[i16] + this.m[i16];
            i5 = iL5 + iM5;
            iL4 = iM5 + l(iL8) + k(iL8, iL7, iL6);
            int i17 = i6 + 5;
            int iM6 = i11 + m(i5) + j(i5, i15, i13) + iArr3[i17] + this.m[i17];
            i4 = iL6 + iM6;
            iL3 = iM6 + l(iL4) + k(iL4, iL8, iL7);
            int i18 = i6 + 6;
            int iM7 = i13 + m(i4) + j(i4, i5, i15) + iArr3[i18] + this.m[i18];
            i3 = iL7 + iM7;
            iL2 = iM7 + l(iL3) + k(iL3, iL4, iL8);
            int i19 = i6 + 7;
            int iM8 = i15 + m(i3) + j(i3, i4, i5) + iArr3[i19] + this.m[i19];
            i2 = iL8 + iM8;
            iL = iM8 + l(iL2) + k(iL2, iL3, iL4);
            i6 += 8;
        }
        this.e += iL;
        this.f += iL2;
        this.g += iL3;
        this.h += iL4;
        this.i += i2;
        this.j += i3;
        this.k += i4;
        this.l += i5;
        this.n = 0;
        for (int i20 = 0; i20 < 16; i20++) {
            this.m[i20] = 0;
        }
    }

    @Override // org.bouncycastle.crypto.Digest
    public java.lang.String getAlgorithmName() {
        return "SHA-224";
    }

    @Override // org.bouncycastle.crypto.Digest
    public int getDigestSize() {
        return 28;
    }

    @Override // org.bouncycastle.crypto.digests.GeneralDigest
    protected void h(long j) {
        if (this.n > 14) {
            g();
        }
        int[] iArr = this.m;
        iArr[14] = (int) (j >>> 32);
        iArr[15] = (int) j;
    }

    @Override // org.bouncycastle.crypto.digests.GeneralDigest
    protected void i(byte[] bArr, int i) {
        this.m[this.n] = org.bouncycastle.util.Pack.a(bArr, i);
        int i2 = this.n + 1;
        this.n = i2;
        if (i2 == 16) {
            g();
        }
    }

    protected org.bouncycastle.crypto.CryptoServiceProperties p() {
        return org.bouncycastle.crypto.digests.Utils.a(this, 192, this.a);
    }

    @Override // org.bouncycastle.crypto.digests.GeneralDigest, org.bouncycastle.crypto.Digest
    public void reset() {
        super.reset();
        this.e = -1056596264;
        this.f = 914150663;
        this.g = 812702999;
        this.h = -150054599;
        this.i = -4191439;
        this.j = 1750603025;
        this.k = 1694076839;
        this.l = -1090891868;
        this.n = 0;
        int i = 0;
        while (true) {
            int[] iArr = this.m;
            if (i == iArr.length) {
                return;
            }
            iArr[i] = 0;
            i++;
        }
    }

    public SHA224Digest(org.bouncycastle.crypto.CryptoServicePurpose cryptoServicePurpose) {
        super(cryptoServicePurpose);
        this.m = new int[64];
        org.bouncycastle.crypto.CryptoServicesRegistrar.a(p());
        reset();
    }

    public SHA224Digest(org.bouncycastle.crypto.digests.SHA224Digest sHA224Digest) {
        super(sHA224Digest);
        this.m = new int[64];
        org.bouncycastle.crypto.CryptoServicesRegistrar.a(p());
        q(sHA224Digest);
    }
}
