package org.bouncycastle.crypto.digests;

/* JADX INFO: loaded from: E:\ios\vf_dex\classes4.dex */
public class SHAKEDigest extends org.bouncycastle.crypto.digests.KeccakDigest implements org.bouncycastle.crypto.Xof {
    public SHAKEDigest(int i) {
        super(n(i), org.bouncycastle.crypto.CryptoServicePurpose.ANY);
    }

    private static int n(int i) {
        if (i == 128 || i == 256) {
            return i;
        }
        throw new java.lang.IllegalArgumentException("'bitStrength' " + i + " not supported for SHAKE");
    }

    @Override // org.bouncycastle.crypto.Xof
    public int b(byte[] bArr, int i, int i2) {
        int iC = c(bArr, i, i2);
        reset();
        return iC;
    }

    public int c(byte[] bArr, int i, int i2) {
        if (!this.g) {
            h(15, 4);
        }
        m(bArr, i, ((long) i2) * 8);
        return i2;
    }

    @Override // org.bouncycastle.crypto.digests.KeccakDigest, org.bouncycastle.crypto.Digest
    public int doFinal(byte[] bArr, int i) {
        return b(bArr, i, getDigestSize());
    }

    @Override // org.bouncycastle.crypto.digests.KeccakDigest, org.bouncycastle.crypto.Digest
    public java.lang.String getAlgorithmName() {
        return "SHAKE" + this.f;
    }

    @Override // org.bouncycastle.crypto.digests.KeccakDigest, org.bouncycastle.crypto.Digest
    public int getDigestSize() {
        return this.f / 4;
    }

    @Override // org.bouncycastle.crypto.digests.KeccakDigest
    protected org.bouncycastle.crypto.CryptoServiceProperties i() {
        return org.bouncycastle.crypto.digests.Utils.b(this, this.a);
    }

    public SHAKEDigest(int i, org.bouncycastle.crypto.CryptoServicePurpose cryptoServicePurpose) {
        super(n(i), cryptoServicePurpose);
    }

    public SHAKEDigest(org.bouncycastle.crypto.digests.SHAKEDigest sHAKEDigest) {
        super(sHAKEDigest);
    }
}
