package org.bouncycastle.crypto.macs;

/* JADX INFO: loaded from: E:\ios\vf_dex\classes4.dex */
public class GMac implements org.bouncycastle.crypto.Mac {
    private final org.bouncycastle.crypto.modes.GCMModeCipher a;
    private final int b = 128;

    public GMac(org.bouncycastle.crypto.modes.GCMModeCipher gCMModeCipher) {
        this.a = gCMModeCipher;
    }

    @Override // org.bouncycastle.crypto.Mac
    public int doFinal(byte[] bArr, int i) {
        try {
            return this.a.doFinal(bArr, i);
        } catch (org.bouncycastle.crypto.InvalidCipherTextException e) {
            throw new java.lang.IllegalStateException(e.toString());
        }
    }

    @Override // org.bouncycastle.crypto.Mac
    public java.lang.String getAlgorithmName() {
        return this.a.getUnderlyingCipher().getAlgorithmName() + "-GMAC";
    }

    @Override // org.bouncycastle.crypto.Mac
    public int getMacSize() {
        return this.b / 8;
    }

    @Override // org.bouncycastle.crypto.Mac
    public void init(org.bouncycastle.crypto.CipherParameters cipherParameters) {
        if (!(cipherParameters instanceof org.bouncycastle.crypto.params.ParametersWithIV)) {
            throw new java.lang.IllegalArgumentException("GMAC requires ParametersWithIV");
        }
        org.bouncycastle.crypto.params.ParametersWithIV parametersWithIV = (org.bouncycastle.crypto.params.ParametersWithIV) cipherParameters;
        byte[] bArrA = parametersWithIV.a();
        this.a.init(true, new org.bouncycastle.crypto.params.AEADParameters((org.bouncycastle.crypto.params.KeyParameter) parametersWithIV.b(), this.b, bArrA));
    }

    @Override // org.bouncycastle.crypto.Mac
    public void reset() {
        this.a.reset();
    }

    @Override // org.bouncycastle.crypto.Mac
    public void update(byte b) {
        this.a.d(b);
    }

    @Override // org.bouncycastle.crypto.Mac
    public void update(byte[] bArr, int i, int i2) {
        this.a.c(bArr, i, i2);
    }
}
