package com.google.android.gms.internal.ads;

import android.content.Context;
import android.os.RemoteException;
import androidx.media3.exoplayer.upstream.CmcdData;
import java.math.BigInteger;
import java.security.GeneralSecurityException;

/* JADX INFO: loaded from: classes2.dex */
public final class xu0 {

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

    /* JADX INFO: renamed from: b, reason: collision with root package name */
    public Object f18584b;

    /* JADX INFO: renamed from: c, reason: collision with root package name */
    public Object f18585c;

    /* JADX INFO: renamed from: d, reason: collision with root package name */
    public Object f18586d;

    /* JADX INFO: renamed from: e, reason: collision with root package name */
    public Object f18587e;

    /* JADX INFO: renamed from: f, reason: collision with root package name */
    public Object f18588f;

    /* JADX INFO: renamed from: g, reason: collision with root package name */
    public Object f18589g;

    /* JADX INFO: renamed from: h, reason: collision with root package name */
    public Object f18590h;

    public /* synthetic */ xu0(int i10) {
        this.f18583a = i10;
        this.f18584b = null;
        this.f18585c = null;
        this.f18586d = null;
        this.f18587e = null;
        this.f18588f = null;
        this.f18589g = null;
        this.f18590h = null;
    }

    public final void a() {
        switch (this.f18583a) {
            case 0:
                p7.r0 r0Var = m7.n.C.f30464c;
                if (!p7.r0.c(((Context) this.f18584b).getPackageName())) {
                    wu0 wu0Var = new wu0(this);
                    eb ebVar = (eb) this.f18589g;
                    vu0 vu0Var = new vu0((a80) ebVar.f10742c, (eb) ebVar.f10741b);
                    vu0Var.f17780d = wu0Var;
                    zv1 zv1Var = new zv1((a80) vu0Var.f17778b, wu0Var);
                    j70 j70Var = ((a80) zv1Var.f19405c).f8523b;
                    Context context = j70Var.f12750b;
                    vj1.i(context);
                    q7.a aVar = j70Var.f12749a;
                    vj1.i(aVar);
                    zt0 zt0Var = new zt0(context, aVar, (wu0) zv1Var.f19404b);
                    ((a30) ((dv1) this.f18585c)).execute(new z80(zt0Var, 20));
                } else {
                    ((a30) ((dv1) this.f18586d)).execute(new z80(this, 19));
                }
                break;
            default:
                try {
                    long jCurrentTimeMillis = System.currentTimeMillis();
                    n7.f4 f4VarX = n7.f4.x();
                    n7.u uVar = n7.x.f31085g.f31087b;
                    Context context2 = (Context) this.f18584b;
                    String str = (String) this.f18586d;
                    uv uvVar = (uv) this.f18589g;
                    uVar.getClass();
                    n7.r0 r0Var2 = (n7.r0) new n7.j(uVar, context2, f4VarX, str, uvVar).a(context2, false);
                    this.f18585c = r0Var2;
                    if (r0Var2 != null) {
                        n7.u2 u2Var = (n7.u2) this.f18587e;
                        u2Var.f31062n = jCurrentTimeMillis;
                        r0Var2.N0(new ek((i7.a) this.f18588f, str));
                        n7.r0 r0Var3 = (n7.r0) this.f18585c;
                        ((n7.e4) this.f18590h).getClass();
                        r0Var3.z(n7.e4.a(context2, u2Var));
                    }
                } catch (RemoteException e10) {
                    q7.j.zzl("#007 Could not call remote method.", e10);
                    return;
                }
                break;
        }
    }

    public final void b() {
        try {
            ((ev0) ((gg2) this.f18587e).zzb()).zzi(((q7.a) this.f18588f).f32212a);
            if (((Boolean) n7.y.f31093e.f31096c.b(ao.f9026pf)).booleanValue()) {
                br0 br0VarA = ((cr0) this.f18590h).a();
                br0VarA.zzc("action", "ptard");
                br0VarA.zzc("ptard", CmcdData.STREAM_TYPE_LIVE);
                br0VarA.b();
            }
        } catch (RemoteException | NullPointerException e10) {
            if (((Boolean) n7.y.f31093e.f31096c.b(ao.f9043qf)).booleanValue()) {
                m7.n.C.f30469h.d("Preconnect Local", e10);
            }
        }
    }

    public final o72 c() throws GeneralSecurityException {
        jc1 jc1Var;
        jc1 jc1Var2;
        p72 p72Var = (p72) this.f18584b;
        if (p72Var == null) {
            throw new GeneralSecurityException("Cannot build without a RSA SSA PKCS1 public key");
        }
        jc1 jc1Var3 = (jc1) this.f18586d;
        if (jc1Var3 == null || (jc1Var = (jc1) this.f18587e) == null) {
            throw new GeneralSecurityException("Cannot build without prime factors");
        }
        jc1 jc1Var4 = (jc1) this.f18585c;
        if (jc1Var4 == null) {
            throw new GeneralSecurityException("Cannot build without private exponent");
        }
        jc1 jc1Var5 = (jc1) this.f18588f;
        if (jc1Var5 == null || (jc1Var2 = (jc1) this.f18589g) == null) {
            throw new GeneralSecurityException("Cannot build without prime exponents");
        }
        jc1 jc1Var6 = (jc1) this.f18590h;
        if (jc1Var6 == null) {
            throw new GeneralSecurityException("Cannot build without CRT coefficient");
        }
        BigInteger bigInteger = p72Var.f15286b.f13998b;
        BigInteger bigInteger2 = p72Var.f15287c;
        BigInteger bigInteger3 = (BigInteger) jc1Var3.f12808b;
        BigInteger bigInteger4 = (BigInteger) jc1Var.f12808b;
        BigInteger bigInteger5 = (BigInteger) jc1Var4.f12808b;
        BigInteger bigInteger6 = (BigInteger) jc1Var5.f12808b;
        BigInteger bigInteger7 = (BigInteger) jc1Var2.f12808b;
        BigInteger bigInteger8 = (BigInteger) jc1Var6.f12808b;
        if (!bigInteger3.isProbablePrime(10)) {
            throw new GeneralSecurityException("p is not a prime");
        }
        if (!bigInteger4.isProbablePrime(10)) {
            throw new GeneralSecurityException("q is not a prime");
        }
        if (!bigInteger3.multiply(bigInteger4).equals(bigInteger2)) {
            throw new GeneralSecurityException("Prime p times prime q is not equal to the public key's modulus");
        }
        BigInteger bigInteger9 = BigInteger.ONE;
        BigInteger bigIntegerSubtract = bigInteger3.subtract(bigInteger9);
        BigInteger bigIntegerSubtract2 = bigInteger4.subtract(bigInteger9);
        if (!bigInteger.multiply(bigInteger5).mod(bigIntegerSubtract.divide(bigIntegerSubtract.gcd(bigIntegerSubtract2)).multiply(bigIntegerSubtract2)).equals(bigInteger9)) {
            throw new GeneralSecurityException("D is invalid.");
        }
        if (!bigInteger.multiply(bigInteger6).mod(bigIntegerSubtract).equals(bigInteger9)) {
            throw new GeneralSecurityException("dP is invalid.");
        }
        if (!bigInteger.multiply(bigInteger7).mod(bigIntegerSubtract2).equals(bigInteger9)) {
            throw new GeneralSecurityException("dQ is invalid.");
        }
        if (bigInteger4.multiply(bigInteger8).mod(bigInteger3).equals(bigInteger9)) {
            return new o72((p72) this.f18584b, (jc1) this.f18586d, (jc1) this.f18587e, (jc1) this.f18585c, (jc1) this.f18588f, (jc1) this.f18589g, (jc1) this.f18590h);
        }
        throw new GeneralSecurityException("qInv is invalid.");
    }

    public final w72 d() throws GeneralSecurityException {
        jc1 jc1Var;
        jc1 jc1Var2;
        x72 x72Var = (x72) this.f18584b;
        if (x72Var == null) {
            throw new GeneralSecurityException("Cannot build without a RSA SSA PKCS1 public key");
        }
        jc1 jc1Var3 = (jc1) this.f18586d;
        if (jc1Var3 == null || (jc1Var = (jc1) this.f18587e) == null) {
            throw new GeneralSecurityException("Cannot build without prime factors");
        }
        jc1 jc1Var4 = (jc1) this.f18585c;
        if (jc1Var4 == null) {
            throw new GeneralSecurityException("Cannot build without private exponent");
        }
        jc1 jc1Var5 = (jc1) this.f18588f;
        if (jc1Var5 == null || (jc1Var2 = (jc1) this.f18589g) == null) {
            throw new GeneralSecurityException("Cannot build without prime exponents");
        }
        jc1 jc1Var6 = (jc1) this.f18590h;
        if (jc1Var6 == null) {
            throw new GeneralSecurityException("Cannot build without CRT coefficient");
        }
        BigInteger bigInteger = x72Var.f18344b.f17534b;
        BigInteger bigInteger2 = x72Var.f18345c;
        BigInteger bigInteger3 = (BigInteger) jc1Var3.f12808b;
        BigInteger bigInteger4 = (BigInteger) jc1Var.f12808b;
        BigInteger bigInteger5 = (BigInteger) jc1Var4.f12808b;
        BigInteger bigInteger6 = (BigInteger) jc1Var5.f12808b;
        BigInteger bigInteger7 = (BigInteger) jc1Var2.f12808b;
        BigInteger bigInteger8 = (BigInteger) jc1Var6.f12808b;
        if (!bigInteger3.isProbablePrime(10)) {
            throw new GeneralSecurityException("p is not a prime");
        }
        if (!bigInteger4.isProbablePrime(10)) {
            throw new GeneralSecurityException("q is not a prime");
        }
        if (!bigInteger3.multiply(bigInteger4).equals(bigInteger2)) {
            throw new GeneralSecurityException("Prime p times prime q is not equal to the public key's modulus");
        }
        BigInteger bigInteger9 = BigInteger.ONE;
        BigInteger bigIntegerSubtract = bigInteger3.subtract(bigInteger9);
        BigInteger bigIntegerSubtract2 = bigInteger4.subtract(bigInteger9);
        if (!bigInteger.multiply(bigInteger5).mod(bigIntegerSubtract.divide(bigIntegerSubtract.gcd(bigIntegerSubtract2)).multiply(bigIntegerSubtract2)).equals(bigInteger9)) {
            throw new GeneralSecurityException("D is invalid.");
        }
        if (!bigInteger.multiply(bigInteger6).mod(bigIntegerSubtract).equals(bigInteger9)) {
            throw new GeneralSecurityException("dP is invalid.");
        }
        if (!bigInteger.multiply(bigInteger7).mod(bigIntegerSubtract2).equals(bigInteger9)) {
            throw new GeneralSecurityException("dQ is invalid.");
        }
        if (bigInteger4.multiply(bigInteger8).mod(bigInteger3).equals(bigInteger9)) {
            return new w72((x72) this.f18584b, (jc1) this.f18586d, (jc1) this.f18587e, (jc1) this.f18585c, (jc1) this.f18588f, (jc1) this.f18589g, (jc1) this.f18590h);
        }
        throw new GeneralSecurityException("qInv is invalid.");
    }

    public xu0(Context context, a30 a30Var, a30 a30Var2, gg2 gg2Var, q7.a aVar, eb ebVar, cr0 cr0Var) {
        this.f18583a = 0;
        this.f18584b = context;
        this.f18585c = a30Var;
        this.f18586d = a30Var2;
        this.f18587e = gg2Var;
        this.f18588f = aVar;
        this.f18589g = ebVar;
        this.f18590h = cr0Var;
    }

    public xu0(Context context, String str, n7.u2 u2Var, i7.a aVar) {
        this.f18583a = 1;
        this.f18589g = new uv();
        this.f18584b = context;
        this.f18586d = str;
        this.f18587e = u2Var;
        this.f18588f = aVar;
        this.f18590h = n7.e4.f30941a;
    }

    public xu0(a80 a80Var, Context context, String str) {
        this.f18583a = 2;
        this.f18584b = a80Var;
        this.f18585c = lg2.a(context);
        this.f18586d = lg2.a(str);
        og2 og2Var = (og2) this.f18585c;
        a80 a80Var2 = (a80) this.f18584b;
        og2 og2Var2 = a80Var2.M0;
        this.f18587e = new q91(og2Var, og2Var2, a80Var2.N0);
        og2 og2VarA = jg2.a(new ot0(og2Var2, 17));
        this.f18588f = og2VarA;
        og2 og2Var3 = a80Var2.f8527d;
        lg2 lg2Var = a80Var2.J;
        og2 og2Var4 = (og2) this.f18587e;
        u70 u70Var = a80Var2.f8539j;
        og2 og2VarA2 = jg2.a(new z90(og2Var, og2Var3, lg2Var, og2Var4, og2VarA, (og2) u70Var, 9));
        this.f18589g = og2VarA2;
        this.f18590h = jg2.a(new pd0(lg2Var, og2Var, (og2) this.f18586d, og2VarA2, og2VarA, u70Var, a80Var2.f8543l, 4));
    }

    public xu0(ek1 ek1Var) {
        this.f18583a = 3;
        this.f18585c = this;
        this.f18584b = ek1Var;
        og2 og2VarA = jg2.a(vj1.f17654b);
        this.f18586d = og2VarA;
        ek1 ek1Var2 = (ek1) this.f18584b;
        this.f18587e = jg2.a(new pd0(ek1Var2.f10817b, ek1Var2.f10819d, ek1Var2.f10827l, og2VarA, ek1Var2.f10829n, ek1Var2.f10824i, ek1Var2.f10820e, vj1.f17655c, 9));
        this.f18588f = jg2.a(ih1.f12510b);
        dk1 dk1Var = new dk1(this);
        this.f18589g = dk1Var;
        ek1 ek1Var3 = (ek1) this.f18584b;
        this.f18590h = jg2.a(new pd0(ek1Var3.f10819d, (og2) this.f18587e, ek1Var3.f10827l, ek1Var3.f10826k, (og2) this.f18588f, dk1Var, ek1Var3.f10820e, 8));
    }
}
