package p138.p176.p278.p279.p290;

import com.google.errorprone.annotations.Immutable;
import java.security.GeneralSecurityException;
import java.security.InvalidAlgorithmParameterException;
import java.security.InvalidKeyException;
import java.security.Key;
import java.security.NoSuchAlgorithmException;
import javax.crypto.Mac;
import p138.p139.p143.p144.C2803;
import p138.p176.p177.p242.p246.p251.C4303;
import p138.p176.p278.p279.InterfaceC5189;

/* JADX INFO: renamed from: ދ.ހ.ހ.֏.ޞ.ޝ, reason: contains not printable characters */
/* JADX INFO: loaded from: classes.dex */
@Immutable
public final class C5546 implements InterfaceC5189 {

    /* JADX INFO: renamed from: ֏, reason: contains not printable characters */
    public final Mac f15951;

    /* JADX INFO: renamed from: ؠ, reason: contains not printable characters */
    public final int f15952;

    /* JADX INFO: renamed from: ހ, reason: contains not printable characters */
    public final String f15953;

    /* JADX INFO: renamed from: ށ, reason: contains not printable characters */
    public final Key f15954;

    public C5546(String str, Key key, int i) throws NoSuchAlgorithmException, InvalidKeyException, InvalidAlgorithmParameterException {
        if (i < 10) {
            throw new InvalidAlgorithmParameterException("tag size too small, need at least 10 bytes");
        }
        if (key.getEncoded().length < 16) {
            throw new InvalidAlgorithmParameterException("key size too small, need at least 16 bytes");
        }
        byte b = -1;
        int iHashCode = str.hashCode();
        if (iHashCode != -1823053428) {
            if (iHashCode != 392315118) {
                if (iHashCode == 392317873 && str.equals("HMACSHA512")) {
                    b = 2;
                }
            } else if (str.equals("HMACSHA256")) {
                b = 1;
            }
        } else if (str.equals("HMACSHA1")) {
            b = 0;
        }
        if (b != 0) {
            if (b != 1) {
                if (b != 2) {
                    throw new NoSuchAlgorithmException(C2803.m4879("unknown Hmac algorithm: ", str));
                }
                if (i > 64) {
                    throw new InvalidAlgorithmParameterException("tag size too big");
                }
            } else if (i > 32) {
                throw new InvalidAlgorithmParameterException("tag size too big");
            }
        } else if (i > 20) {
            throw new InvalidAlgorithmParameterException("tag size too big");
        }
        this.f15953 = str;
        this.f15952 = i;
        this.f15954 = key;
        Mac macM8904 = C5534.f15934.m8904(str);
        this.f15951 = macM8904;
        macM8904.init(key);
    }

    @Override // p138.p176.p278.p279.InterfaceC5189
    /* JADX INFO: renamed from: ֏ */
    public void mo8679(byte[] bArr, byte[] bArr2) throws GeneralSecurityException {
        if (!C4303.m7172(mo8680(bArr2), bArr)) {
            throw new GeneralSecurityException("invalid MAC");
        }
    }

    @Override // p138.p176.p278.p279.InterfaceC5189
    /* JADX INFO: renamed from: ֏ */
    public byte[] mo8680(byte[] bArr) throws InvalidKeyException {
        Mac macM8904;
        try {
            macM8904 = (Mac) this.f15951.clone();
        } catch (CloneNotSupportedException unused) {
            macM8904 = C5534.f15934.m8904(this.f15953);
            macM8904.init(this.f15954);
        }
        macM8904.update(bArr);
        byte[] bArr2 = new byte[this.f15952];
        System.arraycopy(macM8904.doFinal(), 0, bArr2, 0, this.f15952);
        return bArr2;
    }
}
