package u2;

import F2.B;
import F2.C;
import F2.C0062h;
import F2.C0063i;
import F2.C0064j;
import F2.C0066l;
import F2.C0067m;
import F2.C0068n;
import F2.C0069o;
import F2.C0070p;
import F2.C0072s;
import F2.C0073t;
import F2.C0074u;
import F2.C0075v;
import F2.C0077x;
import F2.C0078y;
import F2.C0079z;
import F2.D;
import F2.F;
import F2.J;
import F2.O;
import F2.Q;
import F2.S;
import F2.T;
import F2.U;
import F2.V;
import F2.X;
import F2.m0;
import F2.p0;
import F2.u0;
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;
import java.security.InvalidKeyException;
import java.util.Collections;
import java.util.HashMap;

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

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

    /* JADX WARN: 'super' call moved to the top of the method (can break code semantics) */
    public /* synthetic */ f(Class cls, B2.d[] dVarArr, int i) {
        super(cls, dVarArr);
        this.f10317d = i;
    }

    public static A2.d h(int i, int i5) {
        C0072s c0072sA = C0073t.A();
        c0072sA.e();
        C0073t.x((C0073t) c0072sA.f5805l, i);
        C0074u c0074uZ = C0075v.z();
        c0074uZ.e();
        C0075v.w((C0075v) c0074uZ.f5805l);
        C0075v c0075v = (C0075v) c0074uZ.b();
        c0072sA.e();
        C0073t.w((C0073t) c0072sA.f5805l, c0075v);
        return new A2.d((C0073t) c0072sA.b(), i5);
    }

    public static A2.d i(int i, int i5, int i6) {
        O o5 = O.SHA256;
        C0067m c0067mB = C0068n.B();
        C0069o c0069oZ = C0070p.z();
        c0069oZ.e();
        C0070p.w((C0070p) c0069oZ.f5805l);
        C0070p c0070p = (C0070p) c0069oZ.b();
        c0067mB.e();
        C0068n.w((C0068n) c0067mB.f5805l, c0070p);
        c0067mB.e();
        C0068n.x((C0068n) c0067mB.f5805l, i);
        C0068n c0068n = (C0068n) c0067mB.b();
        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, 32);
        T t4 = (T) sB.b();
        C0063i c0063iA = C0064j.A();
        c0063iA.e();
        C0064j.w((C0064j) c0063iA.f5805l, c0068n);
        c0063iA.e();
        C0064j.x((C0064j) c0063iA.f5805l, t4);
        return new A2.d((C0064j) c0063iA.b(), i6);
    }

    public static A2.d j(int i, int i5) {
        C0078y c0078yY = C0079z.y();
        c0078yY.e();
        C0079z.w((C0079z) c0078yY.f5805l, i);
        return new A2.d((C0079z) c0078yY.b(), i5);
    }

    public static A2.d k(int i, int i5) {
        C cY = D.y();
        cY.e();
        D.w((D) cY.f5805l, i);
        return new A2.d((D) cY.b(), i5);
    }

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

    @Override // A2.f
    public final String b() {
        switch (this.f10317d) {
            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 // A2.f
    public final A2.e d() {
        switch (this.f10317d) {
            case 0:
                return new B2.n(this);
            case 1:
                return new B2.n(this, (byte) 0);
            case 2:
                return new B2.n(this, (char) 0);
            case 3:
                return new B2.n(this, 0);
            case 4:
                return new B2.n(this, (short) 0);
            case 5:
                return new B2.n(this, (byte) 0, false);
            case 6:
                return new B2.n(this, (byte) 0, (byte) 0);
            case 7:
                return new B2.n(this, (byte) 0, (char) 0);
            default:
                return new B2.n(this, (byte) 0, 0);
        }
    }

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

    @Override // A2.f
    public final AbstractC0472a f(AbstractC0479h abstractC0479h) {
        switch (this.f10317d) {
            case 0:
                return C0062h.D(abstractC0479h, C0485n.a());
            case 1:
                return F2.r.D(abstractC0479h, C0485n.a());
            case 2:
                return C0077x.B(abstractC0479h, C0485n.a());
            case 3:
                return B.B(abstractC0479h, C0485n.a());
            case 4:
                return J.B(abstractC0479h, C0485n.a());
            case 5:
                return m0.B(abstractC0479h, C0485n.a());
            case 6:
                return p0.B(abstractC0479h, C0485n.a());
            case 7:
                return u0.B(abstractC0479h, C0485n.a());
            default:
                return F.B(abstractC0479h, C0485n.a());
        }
    }

    @Override // A2.f
    public final void g(AbstractC0472a abstractC0472a) throws GeneralSecurityException {
        switch (this.f10317d) {
            case 0:
                C0062h c0062h = (C0062h) abstractC0472a;
                G2.o.c(c0062h.B());
                B2.d[] dVarArr = {new B2.d(3, G2.k.class)};
                HashMap map = new HashMap();
                for (int i = 0; i < 1; i++) {
                    B2.d dVar = dVarArr[i];
                    boolean zContainsKey = map.containsKey(dVar.f140a);
                    Class cls = dVar.f140a;
                    if (zContainsKey) {
                        throw new IllegalArgumentException("KeyTypeManager constructed with duplicate factories for primitive " + cls.getCanonicalName());
                    }
                    map.put(cls, dVar);
                }
                Class cls2 = dVarArr[0].f140a;
                Collections.unmodifiableMap(map);
                C0066l c0066lZ = c0062h.z();
                G2.o.c(c0066lZ.C());
                G2.o.a(c0066lZ.A().size());
                C0070p c0070pB = c0066lZ.B();
                if (c0070pB.y() < 12 || c0070pB.y() > 16) {
                    throw new GeneralSecurityException("invalid IV size");
                }
                B2.d[] dVarArr2 = {new B2.d(1, t2.j.class)};
                HashMap map2 = new HashMap();
                B2.d dVar2 = dVarArr2[0];
                boolean zContainsKey2 = map2.containsKey(dVar2.f140a);
                Class cls3 = dVar2.f140a;
                if (zContainsKey2) {
                    throw new IllegalArgumentException("KeyTypeManager constructed with duplicate factories for primitive " + cls3.getCanonicalName());
                }
                map2.put(cls3, dVar2);
                Class cls4 = dVarArr2[0].f140a;
                Collections.unmodifiableMap(map2);
                Q qA = c0062h.A();
                G2.o.c(qA.C());
                if (qA.A().size() < 16) {
                    throw new GeneralSecurityException("key too short");
                }
                B2.f.j(qA.B());
                return;
            case 1:
                F2.r rVar = (F2.r) abstractC0472a;
                G2.o.c(rVar.B());
                G2.o.a(rVar.z().size());
                if (rVar.A().y() != 12 && rVar.A().y() != 16) {
                    throw new GeneralSecurityException("invalid IV size; acceptable values have 12 or 16 bytes");
                }
                return;
            case 2:
                C0077x c0077x = (C0077x) abstractC0472a;
                G2.o.c(c0077x.z());
                G2.o.a(c0077x.y().size());
                return;
            case 3:
                B b2 = (B) abstractC0472a;
                G2.o.c(b2.z());
                G2.o.a(b2.y().size());
                return;
            case 4:
                J j5 = (J) abstractC0472a;
                G2.o.c(j5.z());
                if (j5.y().size() != 32) {
                    throw new GeneralSecurityException("invalid ChaCha20Poly1305Key: incorrect key length");
                }
                return;
            case 5:
                G2.o.c(((m0) abstractC0472a).z());
                return;
            case 6:
                G2.o.c(((p0) abstractC0472a).z());
                return;
            case 7:
                u0 u0Var = (u0) abstractC0472a;
                G2.o.c(u0Var.z());
                if (u0Var.y().size() != 32) {
                    throw new GeneralSecurityException("invalid XChaCha20Poly1305Key: incorrect key length");
                }
                return;
            default:
                F f6 = (F) abstractC0472a;
                G2.o.c(f6.z());
                if (f6.y().size() == 64) {
                    return;
                }
                throw new InvalidKeyException("invalid key size: " + f6.y().size() + ". Valid keys must have 64 bytes.");
        }
    }
}
