package M3;

import F.I;
import X3.B;
import X3.C;
import X3.C0817h;
import X3.C0818i;
import X3.C0819j;
import X3.C0821l;
import X3.C0822m;
import X3.C0823n;
import X3.C0824o;
import X3.C0825p;
import X3.C0827s;
import X3.C0828t;
import X3.C0829u;
import X3.C0830v;
import X3.C0832x;
import X3.C0833y;
import X3.C0834z;
import X3.D;
import X3.F;
import X3.J;
import X3.O;
import X3.Q;
import X3.S;
import X3.T;
import X3.U;
import X3.V;
import X3.X;
import X3.m0;
import X3.p0;
import X3.u0;
import com.google.crypto.tink.shaded.protobuf.AbstractC1253a;
import com.google.crypto.tink.shaded.protobuf.AbstractC1261i;
import com.google.crypto.tink.shaded.protobuf.C1267o;
import java.security.GeneralSecurityException;
import java.security.InvalidKeyException;
import java.util.Collections;
import java.util.HashMap;

/* JADX INFO: loaded from: classes3.dex */
public final class h extends S3.d {

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

    /* JADX WARN: 'super' call moved to the top of the method (can break code semantics) */
    public /* synthetic */ h(Class cls, f[] fVarArr, int i6) {
        super(cls, fVarArr);
        this.f5061d = i6;
    }

    public static S3.c h(int i6, int i7) {
        C0827s c0827sZ = C0828t.z();
        c0827sZ.d();
        C0828t.w((C0828t) c0827sZ.f13838b, i6);
        C0829u c0829uY = C0830v.y();
        c0829uY.d();
        C0830v.v((C0830v) c0829uY.f13838b);
        C0830v c0830v = (C0830v) c0829uY.a();
        c0827sZ.d();
        C0828t.v((C0828t) c0827sZ.f13838b, c0830v);
        return new S3.c((C0828t) c0827sZ.a(), i7);
    }

    public static S3.c i(int i6, int i7, int i8) {
        O o6 = O.SHA256;
        C0822m c0822mA = C0823n.A();
        C0824o c0824oY = C0825p.y();
        c0824oY.d();
        C0825p.v((C0825p) c0824oY.f13838b);
        C0825p c0825p = (C0825p) c0824oY.a();
        c0822mA.d();
        C0823n.v((C0823n) c0822mA.f13838b, c0825p);
        c0822mA.d();
        C0823n.w((C0823n) c0822mA.f13838b, i6);
        C0823n c0823n = (C0823n) c0822mA.a();
        S sA = T.A();
        U uA = V.A();
        uA.d();
        V.v((V) uA.f13838b, o6);
        uA.d();
        V.w((V) uA.f13838b, i7);
        V v3 = (V) uA.a();
        sA.d();
        T.v((T) sA.f13838b, v3);
        sA.d();
        T.w((T) sA.f13838b, 32);
        T t6 = (T) sA.a();
        C0818i c0818iZ = C0819j.z();
        c0818iZ.d();
        C0819j.v((C0819j) c0818iZ.f13838b, c0823n);
        c0818iZ.d();
        C0819j.w((C0819j) c0818iZ.f13838b, t6);
        return new S3.c((C0819j) c0818iZ.a(), i8);
    }

    public static S3.c j(int i6, int i7) {
        C0833y c0833yX = C0834z.x();
        c0833yX.d();
        C0834z.v((C0834z) c0833yX.f13838b, i6);
        return new S3.c((C0834z) c0833yX.a(), i7);
    }

    public static S3.c k(int i6, int i7) {
        C cX = D.x();
        cX.d();
        D.v((D) cX.f13838b, i6);
        return new S3.c((D) cX.a(), i7);
    }

    @Override // S3.d
    public int a() {
        switch (this.f5061d) {
            case 0:
                return 2;
            case 1:
            default:
                return super.a();
            case 2:
                return 2;
        }
    }

    @Override // S3.d
    public final String b() {
        switch (this.f5061d) {
            case 0:
                return "type.googleapis.com/google.crypto.tink.AesCtrHmacAeadKey";
            case 1:
                return "type.googleapis.com/google.crypto.tink.AesEaxKey";
            case 2:
                return "type.googleapis.com/google.crypto.tink.AesGcmKey";
            case 3:
                return "type.googleapis.com/google.crypto.tink.AesGcmSivKey";
            case 4:
                return "type.googleapis.com/google.crypto.tink.ChaCha20Poly1305Key";
            case 5:
                return "type.googleapis.com/google.crypto.tink.KmsAeadKey";
            case 6:
                return "type.googleapis.com/google.crypto.tink.KmsEnvelopeAeadKey";
            case 7:
                return "type.googleapis.com/google.crypto.tink.XChaCha20Poly1305Key";
            default:
                return "type.googleapis.com/google.crypto.tink.AesSivKey";
        }
    }

    @Override // S3.d
    public final I d() {
        switch (this.f5061d) {
            case 0:
                return new g(this);
            case 1:
                return new g(this, (byte) 0);
            case 2:
                return new g(this, (char) 0);
            case 3:
                return new g(this, 0);
            case 4:
                return new g(this, (short) 0);
            case 5:
                return new g(this, (byte) 0, false);
            case 6:
                return new g(this, (byte) 0, (byte) 0);
            case 7:
                return new g(this, (byte) 0, (char) 0);
            default:
                return new g(this, (byte) 0, 0);
        }
    }

    @Override // S3.d
    public final X e() {
        switch (this.f5061d) {
        }
        return X.SYMMETRIC;
    }

    @Override // S3.d
    public final AbstractC1253a f(AbstractC1261i abstractC1261i) {
        switch (this.f5061d) {
            case 0:
                return C0817h.C(abstractC1261i, C1267o.a());
            case 1:
                return X3.r.C(abstractC1261i, C1267o.a());
            case 2:
                return C0832x.A(abstractC1261i, C1267o.a());
            case 3:
                return B.A(abstractC1261i, C1267o.a());
            case 4:
                return J.A(abstractC1261i, C1267o.a());
            case 5:
                return m0.A(abstractC1261i, C1267o.a());
            case 6:
                return p0.A(abstractC1261i, C1267o.a());
            case 7:
                return u0.A(abstractC1261i, C1267o.a());
            default:
                return F.A(abstractC1261i, C1267o.a());
        }
    }

    @Override // S3.d
    public final void g(AbstractC1253a abstractC1253a) throws GeneralSecurityException {
        switch (this.f5061d) {
            case 0:
                C0817h c0817h = (C0817h) abstractC1253a;
                Y3.t.c(c0817h.A());
                f[] fVarArr = {new f(Y3.p.class, 1)};
                HashMap map = new HashMap();
                for (int i6 = 0; i6 < 1; i6++) {
                    f fVar = fVarArr[i6];
                    boolean zContainsKey = map.containsKey(fVar.f5057a);
                    Class cls = fVar.f5057a;
                    if (zContainsKey) {
                        throw new IllegalArgumentException(A0.a.l(cls, new StringBuilder("KeyTypeManager constructed with duplicate factories for primitive ")));
                    }
                    map.put(cls, fVar);
                }
                Class cls2 = fVarArr[0].f5057a;
                Collections.unmodifiableMap(map);
                C0821l c0821lY = c0817h.y();
                Y3.t.c(c0821lY.B());
                Y3.t.a(c0821lY.z().size());
                C0825p c0825pA = c0821lY.A();
                if (c0825pA.x() < 12 || c0825pA.x() > 16) {
                    throw new GeneralSecurityException("invalid IV size");
                }
                f[] fVarArr2 = {new f(L3.j.class, 11)};
                HashMap map2 = new HashMap();
                f fVar2 = fVarArr2[0];
                boolean zContainsKey2 = map2.containsKey(fVar2.f5057a);
                Class cls3 = fVar2.f5057a;
                if (zContainsKey2) {
                    throw new IllegalArgumentException(A0.a.l(cls3, new StringBuilder("KeyTypeManager constructed with duplicate factories for primitive ")));
                }
                map2.put(cls3, fVar2);
                Class cls4 = fVarArr2[0].f5057a;
                Collections.unmodifiableMap(map2);
                Q qZ = c0817h.z();
                Y3.t.c(qZ.B());
                if (qZ.z().size() < 16) {
                    throw new GeneralSecurityException("key too short");
                }
                T3.c.j(qZ.A());
                return;
            case 1:
                X3.r rVar = (X3.r) abstractC1253a;
                Y3.t.c(rVar.A());
                Y3.t.a(rVar.y().size());
                if (rVar.z().x() != 12 && rVar.z().x() != 16) {
                    throw new GeneralSecurityException("invalid IV size; acceptable values have 12 or 16 bytes");
                }
                return;
            case 2:
                C0832x c0832x = (C0832x) abstractC1253a;
                Y3.t.c(c0832x.y());
                Y3.t.a(c0832x.x().size());
                return;
            case 3:
                B b5 = (B) abstractC1253a;
                Y3.t.c(b5.y());
                Y3.t.a(b5.x().size());
                return;
            case 4:
                J j4 = (J) abstractC1253a;
                Y3.t.c(j4.y());
                if (j4.x().size() != 32) {
                    throw new GeneralSecurityException("invalid ChaCha20Poly1305Key: incorrect key length");
                }
                return;
            case 5:
                Y3.t.c(((m0) abstractC1253a).y());
                return;
            case 6:
                Y3.t.c(((p0) abstractC1253a).y());
                return;
            case 7:
                u0 u0Var = (u0) abstractC1253a;
                Y3.t.c(u0Var.y());
                if (u0Var.x().size() != 32) {
                    throw new GeneralSecurityException("invalid XChaCha20Poly1305Key: incorrect key length");
                }
                return;
            default:
                F f6 = (F) abstractC1253a;
                Y3.t.c(f6.y());
                if (f6.x().size() == 64) {
                    return;
                }
                throw new InvalidKeyException("invalid key size: " + f6.x().size() + ". Valid keys must have 64 bytes.");
        }
    }
}
