package org.jmrtd.cert; import java.io.ByteArrayOutputStream; import java.io.IOException; import java.io.InputStream; import java.security.cert.CRL; import java.security.cert.CRLException; import java.security.cert.Certificate; import java.security.cert.CertificateException; import java.security.cert.CertificateFactorySpi; import java.util.Collection; import net.sf.scuba.tlv.TLVInputStream; import net.sf.scuba.tlv.TLVOutputStream; import o.glS; import o.glV; import org.ejbca.cvc.CVCertificate; import org.ejbca.cvc.exception.ConstructionException; import org.ejbca.cvc.exception.ParseException; /* loaded from: classes6.dex */ public class CVCertificateFactorySpi extends CertificateFactorySpi { private static final int CV_CERTIFICATE_TAG = 32545; @Override // java.security.cert.CertificateFactorySpi public CRL engineGenerateCRL(InputStream inputStream) throws CRLException { return null; } @Override // java.security.cert.CertificateFactorySpi public Collection engineGenerateCRLs(InputStream inputStream) throws CRLException { return null; } @Override // java.security.cert.CertificateFactorySpi public Collection engineGenerateCertificates(InputStream inputStream) throws CertificateException { return null; } @Override // java.security.cert.CertificateFactorySpi public Certificate engineGenerateCertificate(InputStream inputStream) throws CertificateException { try { TLVInputStream tLVInputStream = new TLVInputStream(inputStream); int b = tLVInputStream.b(); if (b != 32545) { StringBuilder sb = new StringBuilder("Expected CV_CERTIFICATE_TAG, found "); sb.append(Integer.toHexString(b)); throw new CertificateException(sb.toString()); } tLVInputStream.c(); byte[] d = tLVInputStream.d(); ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream(); TLVOutputStream tLVOutputStream = new TLVOutputStream(byteArrayOutputStream); tLVOutputStream.d(32545); tLVOutputStream.d(d); tLVOutputStream.close(); CVCertificate cVCertificate = (CVCertificate) glV.e(byteArrayOutputStream.toByteArray(), glS.CV_CERTIFICATE); CVCertificate cVCertificate2 = cVCertificate; return new CardVerifiableCertificate(cVCertificate); } catch (IOException e) { throw new CertificateException(e.getMessage()); } catch (ConstructionException e2) { throw new CertificateException(e2.getMessage()); } catch (ParseException e3) { throw new CertificateException(e3.getMessage()); } } }