package kk;

import com.google.crypto.tink.shaded.protobuf.p;
import fk.h;
import fk.o;
import fk.r;
import java.security.GeneralSecurityException;
import javax.crypto.spec.SecretKeySpec;
import mk.u;
import mk.v;
import mk.w;
import mk.x;
import mk.y;
import nk.s;
import nk.t;

/* loaded from: classes3.dex */
public final class b extends h {

    /* loaded from: classes3.dex */
    class a extends h.b {
        a(Class cls) {
            super(cls);
        }

        @Override // fk.h.b
        /* renamed from: c, reason: merged with bridge method [inline-methods] */
        public o a(v vVar) {
            u H = vVar.L().H();
            SecretKeySpec secretKeySpec = new SecretKeySpec(vVar.K().C(), "HMAC");
            int I = vVar.L().I();
            int i10 = c.f25872a[H.ordinal()];
            if (i10 == 1) {
                return new t(new s("HMACSHA1", secretKeySpec), I);
            }
            if (i10 == 2) {
                return new t(new s("HMACSHA256", secretKeySpec), I);
            }
            if (i10 == 3) {
                return new t(new s("HMACSHA512", secretKeySpec), I);
            }
            throw new GeneralSecurityException("unknown hash");
        }
    }

    /* renamed from: kk.b$b, reason: collision with other inner class name */
    /* loaded from: classes3.dex */
    class C0550b extends h.a {
        C0550b(Class cls) {
            super(cls);
        }

        @Override // fk.h.a
        /* renamed from: e, reason: merged with bridge method [inline-methods] */
        public v a(w wVar) {
            return (v) v.N().v(b.this.k()).u(wVar.I()).t(com.google.crypto.tink.shaded.protobuf.h.l(nk.u.c(wVar.H()))).i();
        }

        @Override // fk.h.a
        /* renamed from: f, reason: merged with bridge method [inline-methods] */
        public w c(com.google.crypto.tink.shaded.protobuf.h hVar) {
            return w.J(hVar, p.b());
        }

        @Override // fk.h.a
        /* renamed from: g, reason: merged with bridge method [inline-methods] */
        public void d(w wVar) {
            if (wVar.H() < 16) {
                throw new GeneralSecurityException("key too short");
            }
            b.o(wVar.I());
        }
    }

    /* JADX INFO: Access modifiers changed from: package-private */
    /* loaded from: classes3.dex */
    public static /* synthetic */ class c {

        /* renamed from: a, reason: collision with root package name */
        static final /* synthetic */ int[] f25872a;

        static {
            int[] iArr = new int[u.values().length];
            f25872a = iArr;
            try {
                iArr[u.SHA1.ordinal()] = 1;
            } catch (NoSuchFieldError unused) {
            }
            try {
                f25872a[u.SHA256.ordinal()] = 2;
            } catch (NoSuchFieldError unused2) {
            }
            try {
                f25872a[u.SHA512.ordinal()] = 3;
            } catch (NoSuchFieldError unused3) {
            }
        }
    }

    public b() {
        super(v.class, new a(o.class));
    }

    public static void m(boolean z10) {
        r.q(new b(), z10);
    }

    /* JADX INFO: Access modifiers changed from: private */
    public static void o(x xVar) {
        if (xVar.I() < 10) {
            throw new GeneralSecurityException("tag size too small");
        }
        int i10 = c.f25872a[xVar.H().ordinal()];
        if (i10 == 1) {
            if (xVar.I() > 20) {
                throw new GeneralSecurityException("tag size too big");
            }
        } else if (i10 == 2) {
            if (xVar.I() > 32) {
                throw new GeneralSecurityException("tag size too big");
            }
        } else {
            if (i10 != 3) {
                throw new GeneralSecurityException("unknown hash type");
            }
            if (xVar.I() > 64) {
                throw new GeneralSecurityException("tag size too big");
            }
        }
    }

    @Override // fk.h
    public String c() {
        return "type.googleapis.com/google.crypto.tink.HmacKey";
    }

    @Override // fk.h
    public h.a e() {
        return new C0550b(w.class);
    }

    @Override // fk.h
    public y.c f() {
        return y.c.SYMMETRIC;
    }

    public int k() {
        return 0;
    }

    @Override // fk.h
    /* renamed from: l, reason: merged with bridge method [inline-methods] */
    public v g(com.google.crypto.tink.shaded.protobuf.h hVar) {
        return v.O(hVar, p.b());
    }

    @Override // fk.h
    /* renamed from: n, reason: merged with bridge method [inline-methods] */
    public void i(v vVar) {
        nk.w.c(vVar.M(), k());
        if (vVar.K().size() < 16) {
            throw new GeneralSecurityException("key too short");
        }
        o(vVar.L());
    }
}
