package o; import java.io.InputStream; import java.io.PushbackInputStream; import java.security.cert.CRL; import java.security.cert.CRLException; import java.security.cert.CertPath; import java.security.cert.Certificate; import java.security.cert.CertificateException; import java.security.cert.CertificateFactorySpi; import java.security.cert.X509Certificate; import java.util.ArrayList; import java.util.Collection; import java.util.Iterator; import java.util.List; /* loaded from: classes6.dex */ public final class gqC extends CertificateFactorySpi { private static final C15428gqH c = new C15428gqH("CERTIFICATE"); private static final C15428gqH b = new C15428gqH("CRL"); private final gqQ a = new gqR(); private AbstractC15318gnI i = null; private int g = 0; private InputStream e = null; private AbstractC15318gnI f = null; private int j = 0; private InputStream d = null; /* JADX WARN: Code restructure failed: missing block: B:10:0x002d, code lost: r1 = (o.C15389gpD) r0; */ /* JADX WARN: Code restructure failed: missing block: B:12:0x003f, code lost: return new o.gqK(r2, r1); */ /* JADX WARN: Code restructure failed: missing block: B:14:0x0031, code lost: if (r0 == null) goto L13; */ /* JADX WARN: Code restructure failed: missing block: B:15:0x0033, code lost: r1 = new o.C15389gpD(o.AbstractC15317gnH.a(r0)); */ /* JADX WARN: Code restructure failed: missing block: B:18:0x0040, code lost: return null; */ /* JADX WARN: Code restructure failed: missing block: B:2:0x0003, code lost: if (r5.i != null) goto L4; */ /* JADX WARN: Code restructure failed: missing block: B:4:0x000f, code lost: if (r5.g >= r5.i.d.size()) goto L17; */ /* JADX WARN: Code restructure failed: missing block: B:5:0x0011, code lost: r0 = r5.i; r2 = r5.g; r5.g = r2 + 1; r0 = (o.InterfaceC15342gnr) r0.d.elementAt(r2); */ /* JADX WARN: Code restructure failed: missing block: B:6:0x0023, code lost: if ((r0 instanceof o.AbstractC15317gnH) == false) goto L18; */ /* JADX WARN: Code restructure failed: missing block: B:8:0x0025, code lost: r2 = r5.a; */ /* JADX WARN: Code restructure failed: missing block: B:9:0x002b, code lost: if ((r0 instanceof o.C15389gpD) == false) goto L11; */ /* Code decompiled incorrectly, please refer to instructions dump. To view partially-correct add '--show-bad-code' argument */ private java.security.cert.Certificate d() throws java.security.cert.CertificateParsingException { /* r5 = this; o.gnI r0 = r5.i r1 = 0 if (r0 == 0) goto L40 L5: int r0 = r5.g o.gnI r2 = r5.i java.util.Vector r2 = r2.d int r2 = r2.size() if (r0 >= r2) goto L40 o.gnI r0 = r5.i int r2 = r5.g int r3 = r2 + 1 r5.g = r3 java.util.Vector r0 = r0.d java.lang.Object r0 = r0.elementAt(r2) o.gnr r0 = (o.InterfaceC15342gnr) r0 boolean r2 = r0 instanceof o.AbstractC15317gnH if (r2 == 0) goto L5 o.gqQ r2 = r5.a o.gqK r3 = new o.gqK boolean r4 = r0 instanceof o.C15389gpD if (r4 == 0) goto L31 r1 = r0 o.gpD r1 = (o.C15389gpD) r1 goto L3c L31: if (r0 == 0) goto L3c o.gpD r1 = new o.gpD o.gnH r0 = o.AbstractC15317gnH.a(r0) r1.(r0) L3c: r3.(r2, r1) return r3 L40: return r1 */ throw new UnsupportedOperationException("Method not decompiled: o.gqC.d():java.security.cert.Certificate"); } private CRL b() throws CRLException { AbstractC15318gnI abstractC15318gnI = this.f; gpA gpa = null; if (abstractC15318gnI == null || this.j >= abstractC15318gnI.d.size()) { return null; } AbstractC15318gnI abstractC15318gnI2 = this.f; int i = this.j; this.j = i + 1; InterfaceC15342gnr interfaceC15342gnr = (InterfaceC15342gnr) abstractC15318gnI2.d.elementAt(i); if (interfaceC15342gnr instanceof gpA) { gpa = (gpA) interfaceC15342gnr; } else if (interfaceC15342gnr != null) { gpa = new gpA(AbstractC15317gnH.a(interfaceC15342gnr)); } return new gqF(this.a, gpa); } @Override // java.security.cert.CertificateFactorySpi public final Certificate engineGenerateCertificate(InputStream inputStream) throws CertificateException { InputStream inputStream2 = this.e; if (inputStream2 == null || inputStream2 != inputStream) { this.e = inputStream; this.i = null; this.g = 0; } try { AbstractC15318gnI abstractC15318gnI = this.i; if (abstractC15318gnI == null) { PushbackInputStream pushbackInputStream = new PushbackInputStream(inputStream); int read = pushbackInputStream.read(); if (read == -1) { return null; } pushbackInputStream.unread(read); if (read != 48) { AbstractC15317gnH c2 = c.c(pushbackInputStream); if (c2 != null) { return new gqK(this.a, c2 != null ? new C15389gpD(AbstractC15317gnH.a(c2)) : null); } return null; } AbstractC15317gnH abstractC15317gnH = (AbstractC15317gnH) new C15348gnx(pushbackInputStream).b(); if (abstractC15317gnH.e() > 1 && (abstractC15317gnH.d(0) instanceof C15314gnC) && abstractC15317gnH.d(0).equals(InterfaceC15405gph.j)) { this.i = C15409gpl.a(AbstractC15317gnH.b((AbstractC15321gnP) abstractC15317gnH.d(1), true)).g; return d(); } return new gqK(this.a, abstractC15317gnH != null ? new C15389gpD(AbstractC15317gnH.a(abstractC15317gnH)) : null); } if (this.g != abstractC15318gnI.d.size()) { return d(); } this.i = null; this.g = 0; return null; } catch (Exception e) { throw new HBt(this, e); } } @Override // java.security.cert.CertificateFactorySpi public final Collection engineGenerateCertificates(InputStream inputStream) throws CertificateException { ArrayList arrayList = new ArrayList(); while (true) { Certificate engineGenerateCertificate = engineGenerateCertificate(inputStream); if (engineGenerateCertificate == null) { return arrayList; } arrayList.add(engineGenerateCertificate); } } @Override // java.security.cert.CertificateFactorySpi public final CRL engineGenerateCRL(InputStream inputStream) throws CRLException { InputStream inputStream2 = this.d; if (inputStream2 == null || inputStream2 != inputStream) { this.d = inputStream; this.f = null; this.j = 0; } try { AbstractC15318gnI abstractC15318gnI = this.f; if (abstractC15318gnI == null) { PushbackInputStream pushbackInputStream = new PushbackInputStream(inputStream); int read = pushbackInputStream.read(); if (read == -1) { return null; } pushbackInputStream.unread(read); if (read != 48) { AbstractC15317gnH c2 = b.c(pushbackInputStream); if (c2 != null) { return new gqF(this.a, c2 != null ? new gpA(AbstractC15317gnH.a(c2)) : null); } return null; } AbstractC15317gnH abstractC15317gnH = (AbstractC15317gnH) new C15348gnx((InputStream) pushbackInputStream, (byte) 0).b(); if (abstractC15317gnH.e() > 1 && (abstractC15317gnH.d(0) instanceof C15314gnC) && abstractC15317gnH.d(0).equals(InterfaceC15405gph.j)) { this.f = C15409gpl.a(AbstractC15317gnH.b((AbstractC15321gnP) abstractC15317gnH.d(1), true)).f; return b(); } return new gqF(this.a, abstractC15317gnH != null ? new gpA(AbstractC15317gnH.a(abstractC15317gnH)) : null); } if (this.j != abstractC15318gnI.d.size()) { return b(); } this.f = null; this.j = 0; return null; } catch (CRLException e) { throw e; } catch (Exception e2) { throw new CRLException(e2.toString()); } } @Override // java.security.cert.CertificateFactorySpi public final Collection engineGenerateCRLs(InputStream inputStream) throws CRLException { ArrayList arrayList = new ArrayList(); while (true) { CRL engineGenerateCRL = engineGenerateCRL(inputStream); if (engineGenerateCRL == null) { return arrayList; } arrayList.add(engineGenerateCRL); } } @Override // java.security.cert.CertificateFactorySpi public final Iterator engineGetCertPathEncodings() { return C15427gqG.c.iterator(); } @Override // java.security.cert.CertificateFactorySpi public final CertPath engineGenerateCertPath(InputStream inputStream) throws CertificateException { return engineGenerateCertPath(inputStream, "PkiPath"); } @Override // java.security.cert.CertificateFactorySpi public final CertPath engineGenerateCertPath(InputStream inputStream, String str) throws CertificateException { return new C15427gqG(inputStream, str); } @Override // java.security.cert.CertificateFactorySpi public final CertPath engineGenerateCertPath(List list) throws CertificateException { for (Object obj : list) { if (obj != null && !(obj instanceof X509Certificate)) { StringBuilder sb = new StringBuilder("list contains non X509Certificate object while creating CertPath\n"); sb.append(obj.toString()); throw new CertificateException(sb.toString()); } } return new C15427gqG(list); } /* loaded from: classes6.dex */ class HBt extends CertificateException { private gqC a; private Throwable e; public HBt(gqC gqc, Throwable th) { this.a = gqc; this.e = th; } @Override // java.lang.Throwable public final Throwable getCause() { return this.e; } } }