package B2;

import F2.C0056b;
import F2.C0058d;
import F2.C0060f;
import F2.O;
import F2.Q;
import F2.S;
import F2.T;
import F2.U;
import F2.V;
import F2.X;
import com.google.crypto.tink.shaded.protobuf.AbstractC0472a;
import com.google.crypto.tink.shaded.protobuf.AbstractC0479h;
import com.google.crypto.tink.shaded.protobuf.C0485n;
import java.security.GeneralSecurityException;

/* JADX INFO: loaded from: classes.dex */
public final class f extends A2.f {

    /* JADX INFO: renamed from: e, reason: collision with root package name */
    public static final A2.m f142e = new A2.m(b.class, new c(0));

    /* JADX INFO: renamed from: f, reason: collision with root package name */
    public static final A2.m f143f = new A2.m(m.class, new c(2));

    /* JADX INFO: renamed from: d, reason: collision with root package name */
    public final /* synthetic */ int f144d = 1;

    public /* synthetic */ f(Class cls, d[] dVarArr) {
        super(cls, dVarArr);
    }

    public static A2.d h(int i, int i5, O o5, int i6) {
        S sB = T.B();
        U uB = V.B();
        uB.e();
        V.w((V) uB.f5805l, o5);
        uB.e();
        V.x((V) uB.f5805l, i5);
        V v5 = (V) uB.b();
        sB.e();
        T.w((T) sB.f5805l, v5);
        sB.e();
        T.x((T) sB.f5805l, i);
        return new A2.d((T) sB.b(), i6);
    }

    public static void i(C0060f c0060f) {
        if (c0060f.y() < 10) {
            throw new GeneralSecurityException("tag size too short");
        }
        if (c0060f.y() > 16) {
            throw new GeneralSecurityException("tag size too long");
        }
    }

    public static void j(V v5) {
        if (v5.A() < 10) {
            throw new GeneralSecurityException("tag size too small");
        }
        int iOrdinal = v5.z().ordinal();
        if (iOrdinal == 1) {
            if (v5.A() > 20) {
                throw new GeneralSecurityException("tag size too big");
            }
            return;
        }
        if (iOrdinal == 2) {
            if (v5.A() > 48) {
                throw new GeneralSecurityException("tag size too big");
            }
            return;
        }
        if (iOrdinal == 3) {
            if (v5.A() > 32) {
                throw new GeneralSecurityException("tag size too big");
            }
        } else if (iOrdinal == 4) {
            if (v5.A() > 64) {
                throw new GeneralSecurityException("tag size too big");
            }
        } else {
            if (iOrdinal != 5) {
                throw new GeneralSecurityException("unknown hash type");
            }
            if (v5.A() > 28) {
                throw new GeneralSecurityException("tag size too big");
            }
        }
    }

    @Override // A2.f
    public int a() {
        switch (this.f144d) {
            case 1:
                return 2;
            default:
                return super.a();
        }
    }

    @Override // A2.f
    public final String b() {
        switch (this.f144d) {
            case 0:
                return "type.googleapis.com/google.crypto.tink.AesCmacKey";
            default:
                return "type.googleapis.com/google.crypto.tink.HmacKey";
        }
    }

    @Override // A2.f
    public final A2.e d() {
        switch (this.f144d) {
            case 0:
                return new e(C0058d.class);
            default:
                return new n(this);
        }
    }

    @Override // A2.f
    public final X e() {
        switch (this.f144d) {
        }
        return X.SYMMETRIC;
    }

    @Override // A2.f
    public final AbstractC0472a f(AbstractC0479h abstractC0479h) {
        switch (this.f144d) {
            case 0:
                return C0056b.D(abstractC0479h, C0485n.a());
            default:
                return Q.E(abstractC0479h, C0485n.a());
        }
    }

    @Override // A2.f
    public final void g(AbstractC0472a abstractC0472a) throws GeneralSecurityException {
        switch (this.f144d) {
            case 0:
                C0056b c0056b = (C0056b) abstractC0472a;
                G2.o.c(c0056b.B());
                if (c0056b.z().size() != 32) {
                    throw new GeneralSecurityException("AesCmacKey size wrong, must be 32 bytes");
                }
                i(c0056b.A());
                return;
            default:
                Q q = (Q) abstractC0472a;
                G2.o.c(q.C());
                if (q.A().size() < 16) {
                    throw new GeneralSecurityException("key too short");
                }
                j(q.B());
                return;
        }
    }

    public f() {
        super(Q.class, new d(1, t2.j.class));
    }
}
