package P3;

import I3.y;
import T3.C0310b;
import T3.C0312d;
import T3.C0314f;
import T3.O;
import T3.Q;
import T3.S;
import T3.T;
import T3.U;
import T3.V;
import T3.X;
import com.google.crypto.tink.shaded.protobuf.AbstractC0735a;
import com.google.crypto.tink.shaded.protobuf.AbstractC0742h;
import com.google.crypto.tink.shaded.protobuf.C0748n;
import java.security.GeneralSecurityException;
import n4.u0;

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

    /* JADX INFO: renamed from: e, reason: collision with root package name */
    public static final O3.n f5449e = new O3.n(a.class, new y(12));

    /* JADX INFO: renamed from: f, reason: collision with root package name */
    public static final O3.n f5450f = new O3.n(j.class, new y(14));

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

    public /* synthetic */ c(Class cls, I3.f[] fVarArr) {
        super(cls, fVarArr);
    }

    public static O3.d n(int i, int i5, O o8, int i8) {
        S sB = T.B();
        U uB = V.B();
        uB.h();
        V.w((V) uB.f10543r, o8);
        uB.h();
        V.x((V) uB.f10543r, i5);
        V v7 = (V) uB.d();
        sB.h();
        T.w((T) sB.f10543r, v7);
        sB.h();
        T.x((T) sB.f10543r, i);
        return new O3.d((T) sB.d(), i8);
    }

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

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

    @Override // O3.f
    public int b() {
        switch (this.f5451d) {
            case 1:
                return 2;
            default:
                return super.b();
        }
    }

    @Override // O3.f
    public final String c() {
        switch (this.f5451d) {
            case u0.f15495q /* 0 */:
                return "type.googleapis.com/google.crypto.tink.AesCmacKey";
            default:
                return "type.googleapis.com/google.crypto.tink.HmacKey";
        }
    }

    @Override // O3.f
    public final O3.e f() {
        switch (this.f5451d) {
            case u0.f15495q /* 0 */:
                return new b(C0312d.class);
            default:
                return new I3.g(this);
        }
    }

    @Override // O3.f
    public final X g() {
        switch (this.f5451d) {
        }
        return X.f6572s;
    }

    @Override // O3.f
    public final AbstractC0735a h(AbstractC0742h abstractC0742h) {
        switch (this.f5451d) {
            case u0.f15495q /* 0 */:
                return C0310b.D(abstractC0742h, C0748n.a());
            default:
                return Q.E(abstractC0742h, C0748n.a());
        }
    }

    @Override // O3.f
    public final void m(AbstractC0735a abstractC0735a) throws GeneralSecurityException {
        switch (this.f5451d) {
            case u0.f15495q /* 0 */:
                C0310b c0310b = (C0310b) abstractC0735a;
                U3.o.c(c0310b.B());
                if (c0310b.z().size() != 32) {
                    throw new GeneralSecurityException("AesCmacKey size wrong, must be 32 bytes");
                }
                o(c0310b.A());
                return;
            default:
                Q q8 = (Q) abstractC0735a;
                U3.o.c(q8.C());
                if (q8.A().size() < 16) {
                    throw new GeneralSecurityException("key too short");
                }
                p(q8.B());
                return;
        }
    }

    public c() {
        super(Q.class, new I3.f(11, H3.j.class));
    }
}
