package I3;

import T3.A;
import T3.B;
import T3.C0315g;
import T3.C0316h;
import T3.C0318j;
import T3.C0319k;
import T3.C0320l;
import T3.C0322n;
import T3.C0324p;
import T3.C0325q;
import T3.C0327t;
import T3.C0329v;
import T3.C0330w;
import T3.C0331x;
import T3.C0333z;
import T3.D;
import T3.E;
import T3.F;
import T3.G;
import T3.H;
import T3.I;
import T3.J;
import T3.L;
import T3.O;
import T3.P;
import T3.Q;
import T3.T;
import T3.V;
import T3.l0;
import T3.m0;
import T3.n0;
import T3.o0;
import T3.p0;
import T3.q0;
import T3.t0;
import T3.v0;
import com.google.crypto.tink.shaded.protobuf.AbstractC0735a;
import com.google.crypto.tink.shaded.protobuf.AbstractC0742h;
import com.google.crypto.tink.shaded.protobuf.C0741g;
import com.google.crypto.tink.shaded.protobuf.C0748n;
import java.security.GeneralSecurityException;
import java.security.InvalidAlgorithmParameterException;
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
import n4.u0;

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

    /* JADX INFO: renamed from: r, reason: collision with root package name */
    public final /* synthetic */ int f3322r = 0;

    /* JADX INFO: renamed from: s, reason: collision with root package name */
    public final /* synthetic */ O3.f f3323s;

    /* JADX WARN: 'super' call moved to the top of the method (can break code semantics) */
    public g(h hVar, byte b8, boolean z8) {
        super(n0.class);
        this.f3323s = hVar;
    }

    @Override // O3.e
    public final void D(AbstractC0735a abstractC0735a) throws GeneralSecurityException {
        switch (this.f3322r) {
            case u0.f15495q /* 0 */:
                C0318j c0318j = (C0318j) abstractC0735a;
                f[] fVarArr = {new f(1, U3.k.class)};
                HashMap map = new HashMap();
                for (f fVar : fVarArr) {
                    boolean zContainsKey = map.containsKey(fVar.f3320a);
                    Class cls = fVar.f3320a;
                    if (zContainsKey) {
                        throw new IllegalArgumentException(I1.a.m(cls, new StringBuilder("KeyTypeManager constructed with duplicate factories for primitive ")));
                    }
                    map.put(cls, fVar);
                }
                if (fVarArr.length > 0) {
                    Class cls2 = fVarArr[0].f3320a;
                }
                Collections.unmodifiableMap(map);
                C0322n c0322nY = c0318j.y();
                U3.o.a(c0322nY.z());
                C0324p c0324pA = c0322nY.A();
                if (c0324pA.y() < 12 || c0324pA.y() > 16) {
                    throw new GeneralSecurityException("invalid IV size");
                }
                f[] fVarArr2 = {new f(11, H3.j.class)};
                HashMap map2 = new HashMap();
                for (f fVar2 : fVarArr2) {
                    boolean zContainsKey2 = map2.containsKey(fVar2.f3320a);
                    Class cls3 = fVar2.f3320a;
                    if (zContainsKey2) {
                        throw new IllegalArgumentException(I1.a.m(cls3, new StringBuilder("KeyTypeManager constructed with duplicate factories for primitive ")));
                    }
                    map2.put(cls3, fVar2);
                }
                if (fVarArr2.length > 0) {
                    Class cls4 = fVarArr2[0].f3320a;
                }
                Collections.unmodifiableMap(map2);
                T tZ = c0318j.z();
                if (tZ.z() < 16) {
                    throw new GeneralSecurityException("key too short");
                }
                P3.c.p(tZ.A());
                U3.o.a(c0318j.y().z());
                return;
            case 1:
                C0327t c0327t = (C0327t) abstractC0735a;
                U3.o.a(c0327t.y());
                if (c0327t.z().y() != 12 && c0327t.z().y() != 16) {
                    throw new GeneralSecurityException("invalid IV size; acceptable values have 12 or 16 bytes");
                }
                return;
            case 2:
                U3.o.a(((C0333z) abstractC0735a).x());
                return;
            case 3:
                U3.o.a(((D) abstractC0735a).x());
                return;
            case 4:
                return;
            case 5:
                return;
            case Z.g.STRING_SET_FIELD_NUMBER /* 6 */:
                q0 q0Var = (q0) abstractC0735a;
                if (q0Var.y().isEmpty() || !q0Var.z()) {
                    throw new GeneralSecurityException("invalid key format: missing KEK URI or DEK template");
                }
                return;
            case Z.g.DOUBLE_FIELD_NUMBER /* 7 */:
                return;
            case Z.g.BYTES_FIELD_NUMBER /* 8 */:
                H h8 = (H) abstractC0735a;
                if (h8.x() == 64) {
                    return;
                }
                throw new InvalidAlgorithmParameterException("invalid key size: " + h8.x() + ". Valid keys must have 64 bytes.");
            default:
                T t6 = (T) abstractC0735a;
                if (t6.z() < 16) {
                    throw new GeneralSecurityException("key too short");
                }
                P3.c.p(t6.A());
                return;
        }
    }

    @Override // O3.e
    public final AbstractC0735a i(AbstractC0735a abstractC0735a) {
        O3.f fVar = this.f3323s;
        switch (this.f3322r) {
            case u0.f15495q /* 0 */:
                C0318j c0318j = (C0318j) abstractC0735a;
                f[] fVarArr = {new f(1, U3.k.class)};
                HashMap map = new HashMap();
                for (f fVar2 : fVarArr) {
                    boolean zContainsKey = map.containsKey(fVar2.f3320a);
                    Class cls = fVar2.f3320a;
                    if (zContainsKey) {
                        throw new IllegalArgumentException(I1.a.m(cls, new StringBuilder("KeyTypeManager constructed with duplicate factories for primitive ")));
                    }
                    map.put(cls, fVar2);
                }
                if (fVarArr.length > 0) {
                    Class cls2 = fVarArr[0].f3320a;
                }
                Collections.unmodifiableMap(map);
                C0322n c0322nY = c0318j.y();
                C0319k c0319kD = C0320l.D();
                C0324p c0324pA = c0322nY.A();
                c0319kD.h();
                C0320l.x((C0320l) c0319kD.f10543r, c0324pA);
                byte[] bArrA = U3.n.a(c0322nY.z());
                C0741g c0741gC = AbstractC0742h.c(bArrA, 0, bArrA.length);
                c0319kD.h();
                C0320l.y((C0320l) c0319kD.f10543r, c0741gC);
                c0319kD.h();
                C0320l.w((C0320l) c0319kD.f10543r);
                C0320l c0320l = (C0320l) c0319kD.d();
                f[] fVarArr2 = {new f(11, H3.j.class)};
                HashMap map2 = new HashMap();
                for (f fVar3 : fVarArr2) {
                    boolean zContainsKey2 = map2.containsKey(fVar3.f3320a);
                    Class cls3 = fVar3.f3320a;
                    if (zContainsKey2) {
                        throw new IllegalArgumentException(I1.a.m(cls3, new StringBuilder("KeyTypeManager constructed with duplicate factories for primitive ")));
                    }
                    map2.put(cls3, fVar3);
                }
                if (fVarArr2.length > 0) {
                    Class cls4 = fVarArr2[0].f3320a;
                }
                Collections.unmodifiableMap(map2);
                T tZ = c0318j.z();
                P pD = Q.D();
                pD.h();
                Q.w((Q) pD.f10543r);
                V vA = tZ.A();
                pD.h();
                Q.x((Q) pD.f10543r, vA);
                byte[] bArrA2 = U3.n.a(tZ.z());
                C0741g c0741gC2 = AbstractC0742h.c(bArrA2, 0, bArrA2.length);
                pD.h();
                Q.y((Q) pD.f10543r, c0741gC2);
                Q q8 = (Q) pD.d();
                C0315g c0315gC = C0316h.C();
                c0315gC.h();
                C0316h.x((C0316h) c0315gC.f10543r, c0320l);
                c0315gC.h();
                C0316h.y((C0316h) c0315gC.f10543r, q8);
                ((h) fVar).getClass();
                c0315gC.h();
                C0316h.w((C0316h) c0315gC.f10543r);
                return (C0316h) c0315gC.d();
            case 1:
                C0327t c0327t = (C0327t) abstractC0735a;
                C0325q c0325qC = T3.r.C();
                byte[] bArrA3 = U3.n.a(c0327t.y());
                C0741g c0741gC3 = AbstractC0742h.c(bArrA3, 0, bArrA3.length);
                c0325qC.h();
                T3.r.y((T3.r) c0325qC.f10543r, c0741gC3);
                C0329v c0329vZ = c0327t.z();
                c0325qC.h();
                T3.r.x((T3.r) c0325qC.f10543r, c0329vZ);
                ((h) fVar).getClass();
                c0325qC.h();
                T3.r.w((T3.r) c0325qC.f10543r);
                return (T3.r) c0325qC.d();
            case 2:
                C0330w c0330wA = C0331x.A();
                byte[] bArrA4 = U3.n.a(((C0333z) abstractC0735a).x());
                C0741g c0741gC4 = AbstractC0742h.c(bArrA4, 0, bArrA4.length);
                c0330wA.h();
                C0331x.x((C0331x) c0330wA.f10543r, c0741gC4);
                ((h) fVar).getClass();
                c0330wA.h();
                C0331x.w((C0331x) c0330wA.f10543r);
                return (C0331x) c0330wA.d();
            case 3:
                A A8 = B.A();
                byte[] bArrA5 = U3.n.a(((D) abstractC0735a).x());
                C0741g c0741gC5 = AbstractC0742h.c(bArrA5, 0, bArrA5.length);
                A8.h();
                B.x((B) A8.f10543r, c0741gC5);
                ((h) fVar).getClass();
                A8.h();
                B.w((B) A8.f10543r);
                return (B) A8.d();
            case 4:
                I iA = J.A();
                ((h) fVar).getClass();
                iA.h();
                J.w((J) iA.f10543r);
                byte[] bArrA6 = U3.n.a(32);
                C0741g c0741gC6 = AbstractC0742h.c(bArrA6, 0, bArrA6.length);
                iA.h();
                J.x((J) iA.f10543r, c0741gC6);
                return (J) iA.d();
            case 5:
                l0 l0VarA = m0.A();
                l0VarA.h();
                m0.x((m0) l0VarA.f10543r, (n0) abstractC0735a);
                ((h) fVar).getClass();
                l0VarA.h();
                m0.w((m0) l0VarA.f10543r);
                return (m0) l0VarA.d();
            case Z.g.STRING_SET_FIELD_NUMBER /* 6 */:
                o0 o0VarA = p0.A();
                o0VarA.h();
                p0.x((p0) o0VarA.f10543r, (q0) abstractC0735a);
                ((h) fVar).getClass();
                o0VarA.h();
                p0.w((p0) o0VarA.f10543r);
                return (p0) o0VarA.d();
            case Z.g.DOUBLE_FIELD_NUMBER /* 7 */:
                t0 t0VarA = T3.u0.A();
                ((h) fVar).getClass();
                t0VarA.h();
                T3.u0.w((T3.u0) t0VarA.f10543r);
                byte[] bArrA7 = U3.n.a(32);
                C0741g c0741gC7 = AbstractC0742h.c(bArrA7, 0, bArrA7.length);
                t0VarA.h();
                T3.u0.x((T3.u0) t0VarA.f10543r, c0741gC7);
                return (T3.u0) t0VarA.d();
            case Z.g.BYTES_FIELD_NUMBER /* 8 */:
                E eA = F.A();
                byte[] bArrA8 = U3.n.a(((H) abstractC0735a).x());
                C0741g c0741gC8 = AbstractC0742h.c(bArrA8, 0, bArrA8.length);
                eA.h();
                F.x((F) eA.f10543r, c0741gC8);
                ((h) fVar).getClass();
                eA.h();
                F.w((F) eA.f10543r);
                return (F) eA.d();
            default:
                T t6 = (T) abstractC0735a;
                P pD2 = Q.D();
                ((P3.c) fVar).getClass();
                pD2.h();
                Q.w((Q) pD2.f10543r);
                V vA2 = t6.A();
                pD2.h();
                Q.x((Q) pD2.f10543r, vA2);
                byte[] bArrA9 = U3.n.a(t6.z());
                C0741g c0741gC9 = AbstractC0742h.c(bArrA9, 0, bArrA9.length);
                pD2.h();
                Q.y((Q) pD2.f10543r, c0741gC9);
                return (Q) pD2.d();
        }
    }

    @Override // O3.e
    public Map u() {
        switch (this.f3322r) {
            case u0.f15495q /* 0 */:
                HashMap map = new HashMap();
                map.put("AES128_CTR_HMAC_SHA256", h.o(16, 16, 1));
                map.put("AES128_CTR_HMAC_SHA256_RAW", h.o(16, 16, 3));
                map.put("AES256_CTR_HMAC_SHA256", h.o(32, 32, 1));
                map.put("AES256_CTR_HMAC_SHA256_RAW", h.o(32, 32, 3));
                return Collections.unmodifiableMap(map);
            case 1:
                HashMap map2 = new HashMap();
                map2.put("AES128_EAX", h.n(16, 1));
                map2.put("AES128_EAX_RAW", h.n(16, 3));
                map2.put("AES256_EAX", h.n(32, 1));
                map2.put("AES256_EAX_RAW", h.n(32, 3));
                return Collections.unmodifiableMap(map2);
            case 2:
                HashMap map3 = new HashMap();
                map3.put("AES128_GCM", h.p(16, 1));
                map3.put("AES128_GCM_RAW", h.p(16, 3));
                map3.put("AES256_GCM", h.p(32, 1));
                map3.put("AES256_GCM_RAW", h.p(32, 3));
                return Collections.unmodifiableMap(map3);
            case 3:
                HashMap map4 = new HashMap();
                map4.put("AES128_GCM_SIV", h.q(16, 1));
                map4.put("AES128_GCM_SIV_RAW", h.q(16, 3));
                map4.put("AES256_GCM_SIV", h.q(32, 1));
                map4.put("AES256_GCM_SIV_RAW", h.q(32, 3));
                return Collections.unmodifiableMap(map4);
            case 4:
                HashMap map5 = new HashMap();
                map5.put("CHACHA20_POLY1305", new O3.d(L.w(), 1));
                map5.put("CHACHA20_POLY1305_RAW", new O3.d(L.w(), 3));
                return Collections.unmodifiableMap(map5);
            case 5:
            case Z.g.STRING_SET_FIELD_NUMBER /* 6 */:
            default:
                return super.u();
            case Z.g.DOUBLE_FIELD_NUMBER /* 7 */:
                HashMap map6 = new HashMap();
                map6.put("XCHACHA20_POLY1305", new O3.d(v0.w(), 1));
                map6.put("XCHACHA20_POLY1305_RAW", new O3.d(v0.w(), 3));
                return Collections.unmodifiableMap(map6);
            case Z.g.BYTES_FIELD_NUMBER /* 8 */:
                HashMap map7 = new HashMap();
                G gY = H.y();
                gY.h();
                H.w((H) gY.f10543r);
                map7.put("AES256_SIV", new O3.d((H) gY.d(), 1));
                G gY2 = H.y();
                gY2.h();
                H.w((H) gY2.f10543r);
                map7.put("AES256_SIV_RAW", new O3.d((H) gY2.d(), 3));
                return Collections.unmodifiableMap(map7);
            case 9:
                HashMap map8 = new HashMap();
                O o8 = O.f6565u;
                map8.put("HMAC_SHA256_128BITTAG", P3.c.n(32, 16, o8, 1));
                map8.put("HMAC_SHA256_128BITTAG_RAW", P3.c.n(32, 16, o8, 3));
                map8.put("HMAC_SHA256_256BITTAG", P3.c.n(32, 32, o8, 1));
                map8.put("HMAC_SHA256_256BITTAG_RAW", P3.c.n(32, 32, o8, 3));
                O o9 = O.f6566v;
                map8.put("HMAC_SHA512_128BITTAG", P3.c.n(64, 16, o9, 1));
                map8.put("HMAC_SHA512_128BITTAG_RAW", P3.c.n(64, 16, o9, 3));
                map8.put("HMAC_SHA512_256BITTAG", P3.c.n(64, 32, o9, 1));
                map8.put("HMAC_SHA512_256BITTAG_RAW", P3.c.n(64, 32, o9, 3));
                map8.put("HMAC_SHA512_512BITTAG", P3.c.n(64, 64, o9, 1));
                map8.put("HMAC_SHA512_512BITTAG_RAW", P3.c.n(64, 64, o9, 3));
                return Collections.unmodifiableMap(map8);
        }
    }

    @Override // O3.e
    public final AbstractC0735a v(AbstractC0742h abstractC0742h) {
        switch (this.f3322r) {
            case u0.f15495q /* 0 */:
                return C0318j.B(abstractC0742h, C0748n.a());
            case 1:
                return C0327t.B(abstractC0742h, C0748n.a());
            case 2:
                return C0333z.z(abstractC0742h, C0748n.a());
            case 3:
                return D.z(abstractC0742h, C0748n.a());
            case 4:
                return L.x(abstractC0742h, C0748n.a());
            case 5:
                return n0.y(abstractC0742h, C0748n.a());
            case Z.g.STRING_SET_FIELD_NUMBER /* 6 */:
                return q0.A(abstractC0742h, C0748n.a());
            case Z.g.DOUBLE_FIELD_NUMBER /* 7 */:
                return v0.x(abstractC0742h, C0748n.a());
            case Z.g.BYTES_FIELD_NUMBER /* 8 */:
                return H.z(abstractC0742h, C0748n.a());
            default:
                return T.C(abstractC0742h, C0748n.a());
        }
    }

    /* JADX WARN: 'super' call moved to the top of the method (can break code semantics) */
    public g(h hVar, byte b8, byte b9) {
        super(q0.class);
        this.f3323s = hVar;
    }

    /* JADX WARN: 'super' call moved to the top of the method (can break code semantics) */
    public g(h hVar, char c3) {
        super(C0333z.class);
        this.f3323s = hVar;
    }

    /* JADX WARN: 'super' call moved to the top of the method (can break code semantics) */
    public g(h hVar, byte b8) {
        super(C0327t.class);
        this.f3323s = hVar;
    }

    /* JADX WARN: 'super' call moved to the top of the method (can break code semantics) */
    public g(h hVar, int i) {
        super(D.class);
        this.f3323s = hVar;
    }

    /* JADX WARN: 'super' call moved to the top of the method (can break code semantics) */
    public g(h hVar, short s8) {
        super(L.class);
        this.f3323s = hVar;
    }

    /* JADX WARN: 'super' call moved to the top of the method (can break code semantics) */
    public g(h hVar, byte b8, char c3) {
        super(v0.class);
        this.f3323s = hVar;
    }

    /* JADX WARN: 'super' call moved to the top of the method (can break code semantics) */
    public g(h hVar, byte b8, int i) {
        super(H.class);
        this.f3323s = hVar;
    }

    /* JADX WARN: 'super' call moved to the top of the method (can break code semantics) */
    public g(h hVar) {
        super(C0318j.class);
        this.f3323s = hVar;
    }

    /* JADX WARN: 'super' call moved to the top of the method (can break code semantics) */
    public g(P3.c cVar) {
        super(T.class);
        this.f3323s = cVar;
    }
}
