what-the-bank/sources/org/bouncycastle/x509/PKIXCertPathReviewer.java

563 lines
37 KiB
Java
Raw Permalink Normal View History

2024-07-27 18:17:47 +07:00
package org.bouncycastle.x509;
import com.google.common.primitives.UnsignedBytes;
import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.math.BigInteger;
import java.net.HttpURLConnection;
import java.net.InetAddress;
import java.net.URL;
import java.security.PublicKey;
import java.security.cert.CertPath;
import java.security.cert.CertPathValidatorException;
import java.security.cert.Certificate;
import java.security.cert.CertificateFactory;
import java.security.cert.PKIXCertPathChecker;
import java.security.cert.PKIXParameters;
import java.security.cert.PolicyNode;
import java.security.cert.TrustAnchor;
import java.security.cert.X509CRL;
import java.security.cert.X509CertSelector;
import java.security.cert.X509Certificate;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Date;
import java.util.Iterator;
import java.util.List;
import java.util.Set;
import java.util.Vector;
import javax.security.auth.x500.X500Principal;
import org.bouncycastle.asn1.ASN1InputStream;
import org.bouncycastle.asn1.ASN1ObjectIdentifier;
import org.bouncycastle.asn1.ASN1OctetString;
import org.bouncycastle.asn1.ASN1Primitive;
import org.bouncycastle.asn1.ASN1Sequence;
import org.bouncycastle.asn1.DERIA5String;
import org.bouncycastle.asn1.DEROctetString;
import org.bouncycastle.asn1.x509.AccessDescription;
import org.bouncycastle.asn1.x509.AuthorityInformationAccess;
import org.bouncycastle.asn1.x509.AuthorityKeyIdentifier;
import org.bouncycastle.asn1.x509.BasicConstraints;
import org.bouncycastle.asn1.x509.CRLDistPoint;
import org.bouncycastle.asn1.x509.DistributionPoint;
import org.bouncycastle.asn1.x509.DistributionPointName;
import org.bouncycastle.asn1.x509.GeneralName;
import org.bouncycastle.asn1.x509.GeneralNames;
import org.bouncycastle.asn1.x509.GeneralSubtree;
import org.bouncycastle.asn1.x509.NameConstraints;
import org.bouncycastle.asn1.x509.X509Extensions;
import org.bouncycastle.asn1.x509.qualified.MonetaryValue;
import org.bouncycastle.asn1.x509.qualified.QCStatement;
import org.bouncycastle.i18n.ErrorBundle;
import org.bouncycastle.i18n.filter.TrustedInput;
import org.bouncycastle.i18n.filter.UntrustedInput;
import org.bouncycastle.jce.provider.AnnotatedException;
import org.bouncycastle.jce.provider.BouncyCastleProvider;
import org.bouncycastle.jce.provider.PKIXNameConstraintValidator;
import org.bouncycastle.jce.provider.PKIXNameConstraintValidatorException;
import org.bouncycastle.util.Integers;
/* loaded from: classes6.dex */
public class PKIXCertPathReviewer extends CertPathValidatorUtilities {
private static final String RESOURCE_NAME = "org.bouncycastle.x509.CertPathReviewerMessages";
protected CertPath certPath;
protected List certs;
protected List[] errors;
private boolean initialized;
protected int n;
protected List[] notifications;
protected PKIXParameters pkixParams;
protected PolicyNode policyTree;
protected PublicKey subjectPublicKey;
protected TrustAnchor trustAnchor;
protected Date validDate;
private static final String QC_STATEMENT = X509Extensions.QCStatements.getId();
private static final String CRL_DIST_POINTS = X509Extensions.CRLDistributionPoints.getId();
private static final String AUTH_INFO_ACCESS = X509Extensions.AuthorityInfoAccess.getId();
public boolean isValidCertPath() {
doChecks();
int i = 0;
while (true) {
List[] listArr = this.errors;
if (i >= listArr.length) {
return true;
}
if (!listArr[i].isEmpty()) {
return false;
}
i++;
}
}
public void init(CertPath certPath, PKIXParameters pKIXParameters) throws CertPathReviewerException {
if (this.initialized) {
throw new IllegalStateException("object is already initialized!");
}
this.initialized = true;
if (certPath == null) {
throw new NullPointerException("certPath was null");
}
this.certPath = certPath;
List<? extends Certificate> certificates = certPath.getCertificates();
this.certs = certificates;
this.n = certificates.size();
if (this.certs.isEmpty()) {
throw new CertPathReviewerException(new ErrorBundle(RESOURCE_NAME, "CertPathReviewer.emptyCertPath"));
}
PKIXParameters pKIXParameters2 = (PKIXParameters) pKIXParameters.clone();
this.pkixParams = pKIXParameters2;
this.validDate = getValidDate(pKIXParameters2);
this.notifications = null;
this.errors = null;
this.trustAnchor = null;
this.subjectPublicKey = null;
this.policyTree = null;
}
protected Collection getTrustAnchors(X509Certificate x509Certificate, Set set) throws CertPathReviewerException {
ArrayList arrayList = new ArrayList();
Iterator it = set.iterator();
X509CertSelector x509CertSelector = new X509CertSelector();
try {
x509CertSelector.setSubject(getEncodedIssuerPrincipal(x509Certificate).getEncoded());
byte[] extensionValue = x509Certificate.getExtensionValue(X509Extensions.AuthorityKeyIdentifier.getId());
if (extensionValue != null) {
AuthorityKeyIdentifier authorityKeyIdentifier = AuthorityKeyIdentifier.getInstance(ASN1Primitive.fromByteArray(((ASN1OctetString) ASN1Primitive.fromByteArray(extensionValue)).getOctets()));
x509CertSelector.setSerialNumber(authorityKeyIdentifier.getAuthorityCertSerialNumber());
byte[] keyIdentifier = authorityKeyIdentifier.getKeyIdentifier();
if (keyIdentifier != null) {
x509CertSelector.setSubjectKeyIdentifier(new DEROctetString(keyIdentifier).getEncoded());
}
}
while (it.hasNext()) {
TrustAnchor trustAnchor = (TrustAnchor) it.next();
if (trustAnchor.getTrustedCert() != null) {
if (x509CertSelector.match(trustAnchor.getTrustedCert())) {
arrayList.add(trustAnchor);
}
} else if (trustAnchor.getCAName() != null && trustAnchor.getCAPublicKey() != null && getEncodedIssuerPrincipal(x509Certificate).equals(new X500Principal(trustAnchor.getCAName()))) {
arrayList.add(trustAnchor);
}
}
return arrayList;
} catch (IOException unused) {
throw new CertPathReviewerException(new ErrorBundle(RESOURCE_NAME, "CertPathReviewer.trustAnchorIssuerError"));
}
}
public TrustAnchor getTrustAnchor() {
doChecks();
return this.trustAnchor;
}
public PublicKey getSubjectPublicKey() {
doChecks();
return this.subjectPublicKey;
}
public PolicyNode getPolicyTree() {
doChecks();
return this.policyTree;
}
protected Vector getOCSPUrls(AuthorityInformationAccess authorityInformationAccess) {
Vector vector = new Vector();
if (authorityInformationAccess != null) {
AccessDescription[] accessDescriptions = authorityInformationAccess.getAccessDescriptions();
for (int i = 0; i < accessDescriptions.length; i++) {
if (accessDescriptions[i].getAccessMethod().equals(AccessDescription.id_ad_ocsp)) {
GeneralName accessLocation = accessDescriptions[i].getAccessLocation();
if (accessLocation.getTagNo() == 6) {
vector.add(((DERIA5String) accessLocation.getName()).getString());
}
}
}
}
return vector;
}
public List[] getNotifications() {
doChecks();
return this.notifications;
}
public List getNotifications(int i) {
doChecks();
return this.notifications[i + 1];
}
public List[] getErrors() {
doChecks();
return this.errors;
}
public List getErrors(int i) {
doChecks();
return this.errors[i + 1];
}
public int getCertPathSize() {
return this.n;
}
public CertPath getCertPath() {
return this.certPath;
}
protected Vector getCRLDistUrls(CRLDistPoint cRLDistPoint) {
Vector vector = new Vector();
if (cRLDistPoint != null) {
for (DistributionPoint distributionPoint : cRLDistPoint.getDistributionPoints()) {
DistributionPointName distributionPoint2 = distributionPoint.getDistributionPoint();
if (distributionPoint2.getType() == 0) {
GeneralName[] names = GeneralNames.getInstance(distributionPoint2.getName()).getNames();
for (int i = 0; i < names.length; i++) {
if (names[i].getTagNo() == 6) {
vector.add(((DERIA5String) names[i].getName()).getString());
}
}
}
}
}
return vector;
}
protected void doChecks() {
if (!this.initialized) {
throw new IllegalStateException("Object not initialized. Call init() first.");
}
if (this.notifications != null) {
return;
}
int i = this.n + 1;
this.notifications = new List[i];
this.errors = new List[i];
int i2 = 0;
while (true) {
List[] listArr = this.notifications;
if (i2 >= listArr.length) {
checkSignatures();
checkNameConstraints();
checkPathLength();
checkPolicy();
checkCriticalExtensions();
return;
}
listArr[i2] = new ArrayList();
this.errors[i2] = new ArrayList();
i2++;
}
}
protected void checkRevocation(PKIXParameters pKIXParameters, X509Certificate x509Certificate, Date date, X509Certificate x509Certificate2, PublicKey publicKey, Vector vector, Vector vector2, int i) throws CertPathReviewerException {
checkCRLs(pKIXParameters, x509Certificate, date, x509Certificate2, publicKey, vector, i);
}
/* JADX WARN: Removed duplicated region for block: B:100:0x02b4 */
/* JADX WARN: Removed duplicated region for block: B:186:0x02cc */
/* JADX WARN: Removed duplicated region for block: B:97:0x029f */
/*
Code decompiled incorrectly, please refer to instructions dump.
To view partially-correct add '--show-bad-code' argument
*/
protected void checkCRLs(java.security.cert.PKIXParameters r20, java.security.cert.X509Certificate r21, java.util.Date r22, java.security.cert.X509Certificate r23, java.security.PublicKey r24, java.util.Vector r25, int r26) throws org.bouncycastle.x509.CertPathReviewerException {
/*
Method dump skipped, instructions count: 1149
To view this dump add '--comments-level debug' option
*/
throw new UnsupportedOperationException("Method not decompiled: org.bouncycastle.x509.PKIXCertPathReviewer.checkCRLs(java.security.cert.PKIXParameters, java.security.cert.X509Certificate, java.util.Date, java.security.cert.X509Certificate, java.security.PublicKey, java.util.Vector, int):void");
}
protected void addNotification(ErrorBundle errorBundle, int i) {
if (i < -1 || i >= this.n) {
throw new IndexOutOfBoundsException();
}
this.notifications[i + 1].add(errorBundle);
}
protected void addNotification(ErrorBundle errorBundle) {
this.notifications[0].add(errorBundle);
}
protected void addError(ErrorBundle errorBundle, int i) {
if (i < -1 || i >= this.n) {
throw new IndexOutOfBoundsException();
}
this.errors[i + 1].add(errorBundle);
}
protected void addError(ErrorBundle errorBundle) {
this.errors[0].add(errorBundle);
}
private boolean processQcStatements(X509Certificate x509Certificate, int i) {
ErrorBundle errorBundle;
try {
ASN1Sequence aSN1Sequence = (ASN1Sequence) getExtensionValue(x509Certificate, QC_STATEMENT);
boolean z = false;
for (int i2 = 0; i2 < aSN1Sequence.size(); i2++) {
QCStatement qCStatement = QCStatement.getInstance(aSN1Sequence.getObjectAt(i2));
if (QCStatement.id_etsi_qcs_QcCompliance.equals(qCStatement.getStatementId())) {
errorBundle = new ErrorBundle(RESOURCE_NAME, "CertPathReviewer.QcEuCompliance");
} else {
if (!QCStatement.id_qcs_pkixQCSyntax_v1.equals(qCStatement.getStatementId())) {
if (QCStatement.id_etsi_qcs_QcSSCD.equals(qCStatement.getStatementId())) {
errorBundle = new ErrorBundle(RESOURCE_NAME, "CertPathReviewer.QcSSCD");
} else if (QCStatement.id_etsi_qcs_LimiteValue.equals(qCStatement.getStatementId())) {
MonetaryValue monetaryValue = MonetaryValue.getInstance(qCStatement.getStatementInfo());
monetaryValue.getCurrency();
double doubleValue = monetaryValue.getAmount().doubleValue() * Math.pow(10.0d, monetaryValue.getExponent().doubleValue());
addNotification(monetaryValue.getCurrency().isAlphabetic() ? new ErrorBundle(RESOURCE_NAME, "CertPathReviewer.QcLimitValueAlpha", new Object[]{monetaryValue.getCurrency().getAlphabetic(), new TrustedInput(new Double(doubleValue)), monetaryValue}) : new ErrorBundle(RESOURCE_NAME, "CertPathReviewer.QcLimitValueNum", new Object[]{Integers.valueOf(monetaryValue.getCurrency().getNumeric()), new TrustedInput(new Double(doubleValue)), monetaryValue}), i);
} else {
addNotification(new ErrorBundle(RESOURCE_NAME, "CertPathReviewer.QcUnknownStatement", new Object[]{qCStatement.getStatementId(), new UntrustedInput(qCStatement)}), i);
z = true;
}
}
}
addNotification(errorBundle, i);
}
return !z;
} catch (AnnotatedException unused) {
addError(new ErrorBundle(RESOURCE_NAME, "CertPathReviewer.QcStatementExtError"), i);
return false;
}
}
private X509CRL getCRL(String str) throws CertPathReviewerException {
try {
URL url = new URL(str);
if (!url.getProtocol().equals("http") && !url.getProtocol().equals("https")) {
return null;
}
HttpURLConnection httpURLConnection = (HttpURLConnection) url.openConnection();
httpURLConnection.setUseCaches(false);
httpURLConnection.setDoInput(true);
httpURLConnection.connect();
if (httpURLConnection.getResponseCode() == 200) {
return (X509CRL) CertificateFactory.getInstance("X.509", BouncyCastleProvider.PROVIDER_NAME).generateCRL(httpURLConnection.getInputStream());
}
throw new Exception(httpURLConnection.getResponseMessage());
} catch (Exception e) {
throw new CertPathReviewerException(new ErrorBundle(RESOURCE_NAME, "CertPathReviewer.loadCrlDistPointError", new Object[]{new UntrustedInput(str), e.getMessage(), e, e.getClass().getName()}));
}
}
/* JADX WARN: Can't wrap try/catch for region: R(13:80|81|(6:(15:83|84|85|(11:87|88|(2:91|89)|92|93|(2:96|94)|97|98|99|100|101)|108|88|(1:89)|92|93|(1:94)|97|98|99|100|101)|97|98|99|100|101)|111|84|85|(0)|108|88|(1:89)|92|93|(1:94)) */
/* JADX WARN: Can't wrap try/catch for region: R(15:28|(2:138|139)(2:30|(2:132|133)(3:32|(3:118|119|(2:121|(5:123|124|125|126|127)))|34))|(2:35|36)|37|(18:80|81|(15:83|84|85|(11:87|88|(2:91|89)|92|93|(2:96|94)|97|98|99|100|101)|108|88|(1:89)|92|93|(1:94)|97|98|99|100|101)|111|84|85|(0)|108|88|(1:89)|92|93|(1:94)|97|98|99|100|101)(1:39)|(1:43)|44|(7:46|(2:48|(1:50))(1:78)|51|52|(2:54|(1:56))(1:75)|57|(1:61))(1:79)|62|63|64|66|67|69|70) */
/* JADX WARN: Code restructure failed: missing block: B:110:0x029d, code lost:
addError(new org.bouncycastle.i18n.ErrorBundle(org.bouncycastle.x509.PKIXCertPathReviewer.RESOURCE_NAME, "CertPathReviewer.crlAuthInfoAccError"), r6);
*/
/* JADX WARN: Code restructure failed: missing block: B:72:0x03c6, code lost:
addError(new org.bouncycastle.i18n.ErrorBundle(org.bouncycastle.x509.PKIXCertPathReviewer.RESOURCE_NAME, "CertPathReviewer.pubKeyError"), r12);
*/
/* JADX WARN: Code restructure failed: missing block: B:74:0x03c4, code lost:
r7 = r18;
*/
/* JADX WARN: Removed duplicated region for block: B:150:0x0163 */
/* JADX WARN: Removed duplicated region for block: B:154:0x013b */
/* JADX WARN: Removed duplicated region for block: B:21:0x013e */
/* JADX WARN: Removed duplicated region for block: B:28:0x0173 */
/* JADX WARN: Removed duplicated region for block: B:39:0x0320 */
/* JADX WARN: Removed duplicated region for block: B:41:0x032a */
/* JADX WARN: Removed duplicated region for block: B:46:0x0354 */
/* JADX WARN: Removed duplicated region for block: B:79:0x03ae */
/* JADX WARN: Removed duplicated region for block: B:80:0x0278 A[EXC_TOP_SPLITTER, SYNTHETIC] */
/* JADX WARN: Removed duplicated region for block: B:87:0x0298 A[Catch: AnnotatedException -> 0x029d, TRY_LEAVE, TryCatch #15 {AnnotatedException -> 0x029d, blocks: (B:85:0x0290, B:87:0x0298), top: B:84:0x0290 }] */
/* JADX WARN: Removed duplicated region for block: B:91:0x02ba A[LOOP:1: B:89:0x02b4->B:91:0x02ba, LOOP_END] */
/* JADX WARN: Removed duplicated region for block: B:96:0x02dd A[LOOP:2: B:94:0x02d7->B:96:0x02dd, LOOP_END] */
/* JADX WARN: Removed duplicated region for block: B:9:0x00f7 */
/*
Code decompiled incorrectly, please refer to instructions dump.
To view partially-correct add '--show-bad-code' argument
*/
private void checkSignatures() {
/*
Method dump skipped, instructions count: 995
To view this dump add '--comments-level debug' option
*/
throw new UnsupportedOperationException("Method not decompiled: org.bouncycastle.x509.PKIXCertPathReviewer.checkSignatures():void");
}
/* JADX WARN: Removed duplicated region for block: B:224:0x013d A[Catch: CertPathReviewerException -> 0x0607, TRY_LEAVE, TryCatch #8 {CertPathReviewerException -> 0x0607, blocks: (B:15:0x006f, B:19:0x007f, B:22:0x008c, B:26:0x009c, B:27:0x00a7, B:29:0x00ad, B:32:0x00ce, B:33:0x00d6, B:35:0x00dc, B:41:0x00e1, B:42:0x00ed, B:48:0x00f9, B:51:0x0100, B:52:0x0109, B:54:0x010f, B:57:0x0119, B:63:0x0120, B:65:0x0124, B:69:0x0210, B:71:0x0216, B:72:0x0219, B:74:0x021f, B:76:0x022b, B:83:0x0233, B:81:0x0236, B:87:0x0239, B:89:0x023f, B:90:0x0248, B:92:0x024e, B:101:0x0271, B:102:0x027d, B:103:0x027e, B:109:0x0282, B:111:0x028a, B:112:0x028e, B:114:0x0294, B:117:0x02b6, B:119:0x02c0, B:121:0x02c5, B:122:0x02d1, B:124:0x02d2, B:125:0x02de, B:128:0x02e1, B:129:0x02ee, B:131:0x02f4, B:133:0x031a, B:135:0x0332, B:136:0x0329, B:139:0x0339, B:140:0x033f, B:142:0x0345, B:151:0x034d, B:146:0x0377, B:157:0x0355, B:158:0x0361, B:160:0x0363, B:161:0x0372, B:163:0x0380, B:172:0x039f, B:174:0x03a9, B:175:0x03ad, B:177:0x03b3, B:191:0x03c2, B:180:0x03d3, B:199:0x03e4, B:201:0x03ee, B:107:0x0430, B:208:0x03fa, B:209:0x0408, B:211:0x0409, B:212:0x0417, B:219:0x0419, B:220:0x0427, B:221:0x0133, B:222:0x0137, B:224:0x013d, B:227:0x0153, B:229:0x015d, B:230:0x0162, B:232:0x0168, B:233:0x0176, B:235:0x017c, B:261:0x0188, B:245:0x0195, B:246:0x019b, B:248:0x01a1, B:256:0x01ba, B:237:0x018b, B:244:0x018f, B:263:0x01f3, B:268:0x0203, B:269:0x020f, B:276:0x043f, B:277:0x044c, B:279:0x044d, B:284:0x045e, B:286:0x0468, B:287:0x046d, B:289:0x0473, B:292:0x0481, B:306:0x049a, B:313:0x05ed, B:314:0x05f9, B:316:0x04a5, B:317:0x04b1, B:318:0x04b2, B:320:0x04b8, B:322:0x04c0, B:324:0x04c6, B:326:0x04d0, B:327:0x04d3, B:329:0x04d9, B:331:0x04e9, B:332:0x04ed, B:334:0x04f3, B:336:0x04fb, B:339:0x04fe, B:341:0x0501, B:342:0x0505, B:344:0x050b, B:347:0x051b, B:349:0x0521, B:350:0x0526, B:352:0x052c, B:354:0x0538, B:356:0x053c, B:359:0x053f, B:361:0x0544, B:362:0x0550, B:364:0x0555, B:366:0x055f, B:367:0x0562, B:369:0x0568, B:371:0x0578, B:372:0x057c, B:374:0x0582, B:377:0x0592, B:382:0x0596, B:385:0x0599, B:387:0x059c, B:388:0x05a2, B:390:0x05a8, B:392:0x05ba, B:398:0x05c3, B:400:0x05c9, B:401:0x05cc, B:403:0x05d2, B:405:0x05de, B:407:0x05e2, B:410:0x05e5, B:414:0x05fa, B:415:0x0606), top: B:14:0x006f, inners: #0, #1, #2, #3, #4, #5, #7, #10 }] */
/* JADX WARN: Removed duplicated region for block: B:63:0x0120 A[Catch: CertPathReviewerException -> 0x0607, TryCatch #8 {CertPathReviewerException -> 0x0607, blocks: (B:15:0x006f, B:19:0x007f, B:22:0x008c, B:26:0x009c, B:27:0x00a7, B:29:0x00ad, B:32:0x00ce, B:33:0x00d6, B:35:0x00dc, B:41:0x00e1, B:42:0x00ed, B:48:0x00f9, B:51:0x0100, B:52:0x0109, B:54:0x010f, B:57:0x0119, B:63:0x0120, B:65:0x0124, B:69:0x0210, B:71:0x0216, B:72:0x0219, B:74:0x021f, B:76:0x022b, B:83:0x0233, B:81:0x0236, B:87:0x0239, B:89:0x023f, B:90:0x0248, B:92:0x024e, B:101:0x0271, B:102:0x027d, B:103:0x027e, B:109:0x0282, B:111:0x028a, B:112:0x028e, B:114:0x0294, B:117:0x02b6, B:119:0x02c0, B:121:0x02c5, B:122:0x02d1, B:124:0x02d2, B:125:0x02de, B:128:0x02e1, B:129:0x02ee, B:131:0x02f4, B:133:0x031a, B:135:0x0332, B:136:0x0329, B:139:0x0339, B:140:0x033f, B:142:0x0345, B:151:0x034d, B:146:0x0377, B:157:0x0355, B:158:0x0361, B:160:0x0363, B:161:0x0372, B:163:0x0380, B:172:0x039f, B:174:0x03a9, B:175:0x03ad, B:177:0x03b3, B:191:0x03c2, B:180:0x03d3, B:199:0x03e4, B:201:0x03ee, B:107:0x0430, B:208:0x03fa, B:209:0x0408, B:211:0x0409, B:212:0x0417, B:219:0x0419, B:220:0x0427, B:221:0x0133, B:222:0x0137, B:224:0x013d, B:227:0x0153, B:229:0x015d, B:230:0x0162, B:232:0x0168, B:233:0x0176, B:235:0x017c, B:261:0x0188, B:245:0x0195, B:246:0x019b, B:248:0x01a1, B:256:0x01ba, B:237:0x018b, B:244:0x018f, B:263:0x01f3, B:268:0x0203, B:269:0x020f, B:276:0x043f, B:277:0x044c, B:279:0x044d, B:284:0x045e, B:286:0x0468, B:287:0x046d, B:289:0x0473, B:292:0x0481, B:306:0x049a, B:313:0x05ed, B:314:0x05f9, B:316:0x04a5, B:317:0x04b1, B:318:0x04b2, B:320:0x04b8, B:322:0x04c0, B:324:0x04c6, B:326:0x04d0, B:327:0x04d3, B:329:0x04d9, B:331:0x04e9, B:332:0x04ed, B:334:0x04f3, B:336:0x04fb, B:339:0x04fe, B:341:0x0501, B:342:0x0505, B:344:0x050b, B:347:0x051b, B:349:0x0521, B:350:0x0526, B:352:0x052c, B:354:0x0538, B:356:0x053c, B:359:0x053f, B:361:0x0544, B:362:0x0550, B:364:0x0555, B:366:0x055f, B:367:0x0562, B:369:0x0568, B:371:0x0578, B:372:0x057c, B:374:0x0582, B:377:0x0592, B:382:0x0596, B:385:0x0599, B:387:0x059c, B:388:0x05a2, B:390:0x05a8, B:392:0x05ba, B:398:0x05c3, B:400:0x05c9, B:401:0x05cc, B:403:0x05d2, B:405:0x05de, B:407:0x05e2, B:410:0x05e5, B:414:0x05fa, B:415:0x0606), top: B:14:0x006f, inners: #0, #1, #2, #3, #4, #5, #7, #10 }] */
/* JADX WARN: Removed duplicated region for block: B:71:0x0216 A[Catch: CertPathReviewerException -> 0x0607, TryCatch #8 {CertPathReviewerException -> 0x0607, blocks: (B:15:0x006f, B:19:0x007f, B:22:0x008c, B:26:0x009c, B:27:0x00a7, B:29:0x00ad, B:32:0x00ce, B:33:0x00d6, B:35:0x00dc, B:41:0x00e1, B:42:0x00ed, B:48:0x00f9, B:51:0x0100, B:52:0x0109, B:54:0x010f, B:57:0x0119, B:63:0x0120, B:65:0x0124, B:69:0x0210, B:71:0x0216, B:72:0x0219, B:74:0x021f, B:76:0x022b, B:83:0x0233, B:81:0x0236, B:87:0x0239, B:89:0x023f, B:90:0x0248, B:92:0x024e, B:101:0x0271, B:102:0x027d, B:103:0x027e, B:109:0x0282, B:111:0x028a, B:112:0x028e, B:114:0x0294, B:117:0x02b6, B:119:0x02c0, B:121:0x02c5, B:122:0x02d1, B:124:0x02d2, B:125:0x02de, B:128:0x02e1, B:129:0x02ee, B:131:0x02f4, B:133:0x031a, B:135:0x0332, B:136:0x0329, B:139:0x0339, B:140:0x033f, B:142:0x0345, B:151:0x034d, B:146:0x0377, B:157:0x0355, B:158:0x0361, B:160:0x0363, B:161:0x0372, B:163:0x0380, B:172:0x039f, B:174:0x03a9, B:175:0x03ad, B:177:0x03b3, B:191:0x03c2, B:180:0x03d3, B:199:0x03e4, B:201:0x03ee, B:107:0x0430, B:208:0x03fa, B:209:0x0408, B:211:0x0409, B:212:0x0417, B:219:0x0419, B:220:0x0427, B:221:0x0133, B:222:0x0137, B:224:0x013d, B:227:0x0153, B:229:0x015d, B:230:0x0162, B:232:0x0168, B:233:0x0176, B:235:0x017c, B:261:0x0188, B:245:0x0195, B:246:0x019b, B:248:0x01a1, B:256:0x01ba, B:237:0x018b, B:244:0x018f, B:263:0x01f3, B:268:0x0203, B:269:0x020f, B:276:0x043f, B:277:0x044c, B:279:0x044d, B:284:0x045e, B:286:0x0468, B:287:0x046d, B:289:0x0473, B:292:0x0481, B:306:0x049a, B:313:0x05ed, B:314:0x05f9, B:316:0x04a5, B:317:0x04b1, B:318:0x04b2, B:320:0x04b8, B:322:0x04c0, B:324:0x04c6, B:326:0x04d0, B:327:0x04d3, B:329:0x04d9, B:331:0x04e9, B:332:0x04ed, B:334:0x04f3, B:336:0x04fb, B:339:0x04fe, B:341:0x0501, B:342:0x0505, B:344:0x050b, B:347:0x051b, B:349:0x0521, B:350:0x0526, B:352:0x052c, B:354:0x0538, B:356:0x053c, B:359:0x053f, B:361:0x0544, B:362:0x0550, B:364:0x0555, B:366:0x055f, B:367:0x0562, B:369:0x0568, B:371:0x0578, B:372:0x057c, B:374:0x0582, B:377:0x0592, B:382:0x0596, B:385:0x0599, B:387:0x059c, B:388:0x05a2, B:390:0x05a8, B:392:0x05ba, B:398:0x05c3, B:400:0x05c9, B:401:0x05cc, B:403:0x05d2, B:405:0x05de, B:407:0x05e2, B:410:0x05e5, B:414:0x05fa, B:415:0x0606), top: B:14:0x006f, inners: #0, #1, #2, #3, #4, #5, #7, #10 }] */
/* JADX WARN: Removed duplicated region for block: B:89:0x023f A[Catch: CertPathReviewerException -> 0x0607, TryCatch #8 {CertPathReviewerException -> 0x0607, blocks: (B:15:0x006f, B:19:0x007f, B:22:0x008c, B:26:0x009c, B:27:0x00a7, B:29:0x00ad, B:32:0x00ce, B:33:0x00d6, B:35:0x00dc, B:41:0x00e1, B:42:0x00ed, B:48:0x00f9, B:51:0x0100, B:52:0x0109, B:54:0x010f, B:57:0x0119, B:63:0x0120, B:65:0x0124, B:69:0x0210, B:71:0x0216, B:72:0x0219, B:74:0x021f, B:76:0x022b, B:83:0x0233, B:81:0x0236, B:87:0x0239, B:89:0x023f, B:90:0x0248, B:92:0x024e, B:101:0x0271, B:102:0x027d, B:103:0x027e, B:109:0x0282, B:111:0x028a, B:112:0x028e, B:114:0x0294, B:117:0x02b6, B:119:0x02c0, B:121:0x02c5, B:122:0x02d1, B:124:0x02d2, B:125:0x02de, B:128:0x02e1, B:129:0x02ee, B:131:0x02f4, B:133:0x031a, B:135:0x0332, B:136:0x0329, B:139:0x0339, B:140:0x033f, B:142:0x0345, B:151:0x034d, B:146:0x0377, B:157:0x0355, B:158:0x0361, B:160:0x0363, B:161:0x0372, B:163:0x0380, B:172:0x039f, B:174:0x03a9, B:175:0x03ad, B:177:0x03b3, B:191:0x03c2, B:180:0x03d3, B:199:0x03e4, B:201:0x03ee, B:107:0x0430, B:208:0x03fa, B:209:0x0408, B:211:0x0409, B:212:0x0417, B:219:0x0419, B:220:0x0427, B:221:0x0133, B:222:0x0137, B:224:0x013d, B:227:0x0153, B:229:0x015d, B:230:0x0162, B:232:0x0168, B:233:0x0176, B:235:0x017c, B:261:0x0188, B:245:0x0195, B:246:0x019b, B:248:0x01a1, B:256:0x01ba, B:237:0x018b, B:244:0x018f, B:263:0x01f3, B:268:0x0203, B:269:0x020f, B:276:0x043f, B:277:0x044c, B:279:0x044d, B:284:0x045e, B:286:0x0468, B:287:0x046d, B:289:0x0473, B:292:0x0481, B:306:0x049a, B:313:0x05ed, B:314:0x05f9, B:316:0x04a5, B:317:0x04b1, B:318:0x04b2, B:320:0x04b8, B:322:0x04c0, B:324:0x04c6, B:326:0x04d0, B:327:0x04d3, B:329:0x04d9, B:331:0x04e9, B:332:0x04ed, B:334:0x04f3, B:336:0x04fb, B:339:0x04fe, B:341:0x0501, B:342:0x0505, B:344:0x050b, B:347:0x051b, B:349:0x0521, B:350:0x0526, B:352:0x052c, B:354:0x0538, B:356:0x053c, B:359:0x053f, B:361:0x0544, B:362:0x0550, B:364:0x0555, B:366:0x055f, B:367:0x0562, B:369:0x0568, B:371:0x0578, B:372:0x057c, B:374:0x0582, B:377:0x0592, B:382:0x0596, B:385:0x0599, B:387:0x059c, B:388:0x05a2, B:390:0x05a8, B:392:0x05ba, B:398:0x05c3, B:400:0x05c9, B:401:0x05cc, B:403:0x05d2, B:405:0x05de, B:407:0x05e2, B:410:0x05e5, B:414:0x05fa, B:415:0x0606), top: B:14:0x006f, inners: #0, #1, #2, #3, #4, #5, #7, #10 }] */
/*
Code decompiled incorrectly, please refer to instructions dump.
To view partially-correct add '--show-bad-code' argument
*/
private void checkPolicy() {
/*
Method dump skipped, instructions count: 1556
To view this dump add '--comments-level debug' option
*/
throw new UnsupportedOperationException("Method not decompiled: org.bouncycastle.x509.PKIXCertPathReviewer.checkPolicy():void");
}
private void checkPathLength() {
BasicConstraints basicConstraints;
BigInteger pathLenConstraint;
int intValue;
int i = this.n;
int i2 = 0;
for (int size = this.certs.size() - 1; size > 0; size--) {
X509Certificate x509Certificate = (X509Certificate) this.certs.get(size);
if (!isSelfIssued(x509Certificate)) {
if (i <= 0) {
addError(new ErrorBundle(RESOURCE_NAME, "CertPathReviewer.pathLengthExtended"));
}
i--;
i2++;
}
try {
basicConstraints = BasicConstraints.getInstance(getExtensionValue(x509Certificate, BASIC_CONSTRAINTS));
} catch (AnnotatedException unused) {
addError(new ErrorBundle(RESOURCE_NAME, "CertPathReviewer.processLengthConstError"), size);
basicConstraints = null;
}
if (basicConstraints != null && (pathLenConstraint = basicConstraints.getPathLenConstraint()) != null && (intValue = pathLenConstraint.intValue()) < i) {
i = intValue;
}
}
addNotification(new ErrorBundle(RESOURCE_NAME, "CertPathReviewer.totalPathLength", new Object[]{Integers.valueOf(i2)}));
}
private void checkNameConstraints() {
PKIXNameConstraintValidator pKIXNameConstraintValidator = new PKIXNameConstraintValidator();
try {
for (int size = this.certs.size() - 1; size > 0; size--) {
X509Certificate x509Certificate = (X509Certificate) this.certs.get(size);
if (!isSelfIssued(x509Certificate)) {
X500Principal subjectPrincipal = getSubjectPrincipal(x509Certificate);
try {
ASN1Sequence aSN1Sequence = (ASN1Sequence) new ASN1InputStream(new ByteArrayInputStream(subjectPrincipal.getEncoded())).readObject();
try {
pKIXNameConstraintValidator.checkPermittedDN(aSN1Sequence);
try {
pKIXNameConstraintValidator.checkExcludedDN(aSN1Sequence);
try {
ASN1Sequence aSN1Sequence2 = (ASN1Sequence) getExtensionValue(x509Certificate, SUBJECT_ALTERNATIVE_NAME);
if (aSN1Sequence2 != null) {
for (int i = 0; i < aSN1Sequence2.size(); i++) {
GeneralName generalName = GeneralName.getInstance(aSN1Sequence2.getObjectAt(i));
try {
pKIXNameConstraintValidator.checkPermitted(generalName);
pKIXNameConstraintValidator.checkExcluded(generalName);
} catch (PKIXNameConstraintValidatorException e) {
throw new CertPathReviewerException(new ErrorBundle(RESOURCE_NAME, "CertPathReviewer.notPermittedEmail", new Object[]{new UntrustedInput(generalName)}), e, this.certPath, size);
}
}
}
} catch (AnnotatedException e2) {
throw new CertPathReviewerException(new ErrorBundle(RESOURCE_NAME, "CertPathReviewer.subjAltNameExtError"), e2, this.certPath, size);
}
} catch (PKIXNameConstraintValidatorException e3) {
throw new CertPathReviewerException(new ErrorBundle(RESOURCE_NAME, "CertPathReviewer.excludedDN", new Object[]{new UntrustedInput(subjectPrincipal.getName())}), e3, this.certPath, size);
}
} catch (PKIXNameConstraintValidatorException e4) {
throw new CertPathReviewerException(new ErrorBundle(RESOURCE_NAME, "CertPathReviewer.notPermittedDN", new Object[]{new UntrustedInput(subjectPrincipal.getName())}), e4, this.certPath, size);
}
} catch (IOException e5) {
throw new CertPathReviewerException(new ErrorBundle(RESOURCE_NAME, "CertPathReviewer.ncSubjectNameError", new Object[]{new UntrustedInput(subjectPrincipal)}), e5, this.certPath, size);
}
}
try {
ASN1Sequence aSN1Sequence3 = (ASN1Sequence) getExtensionValue(x509Certificate, NAME_CONSTRAINTS);
if (aSN1Sequence3 != null) {
NameConstraints nameConstraints = NameConstraints.getInstance(aSN1Sequence3);
GeneralSubtree[] permittedSubtrees = nameConstraints.getPermittedSubtrees();
if (permittedSubtrees != null) {
pKIXNameConstraintValidator.intersectPermittedSubtree(permittedSubtrees);
}
GeneralSubtree[] excludedSubtrees = nameConstraints.getExcludedSubtrees();
if (excludedSubtrees != null) {
for (int i2 = 0; i2 != excludedSubtrees.length; i2++) {
pKIXNameConstraintValidator.addExcludedSubtree(excludedSubtrees[i2]);
}
}
}
} catch (AnnotatedException e6) {
throw new CertPathReviewerException(new ErrorBundle(RESOURCE_NAME, "CertPathReviewer.ncExtError"), e6, this.certPath, size);
}
}
} catch (CertPathReviewerException e7) {
addError(e7.getErrorMessage(), e7.getIndex());
}
}
private void checkCriticalExtensions() {
List<PKIXCertPathChecker> certPathCheckers = this.pkixParams.getCertPathCheckers();
Iterator<PKIXCertPathChecker> it = certPathCheckers.iterator();
while (it.hasNext()) {
try {
try {
it.next().init(false);
} catch (CertPathValidatorException e) {
throw new CertPathReviewerException(new ErrorBundle(RESOURCE_NAME, "CertPathReviewer.certPathCheckerError", new Object[]{e.getMessage(), e, e.getClass().getName()}), e);
}
} catch (CertPathReviewerException e2) {
addError(e2.getErrorMessage(), e2.getIndex());
return;
}
}
for (int size = this.certs.size() - 1; size >= 0; size--) {
X509Certificate x509Certificate = (X509Certificate) this.certs.get(size);
Set<String> criticalExtensionOIDs = x509Certificate.getCriticalExtensionOIDs();
if (criticalExtensionOIDs != null && !criticalExtensionOIDs.isEmpty()) {
criticalExtensionOIDs.remove(KEY_USAGE);
criticalExtensionOIDs.remove(CERTIFICATE_POLICIES);
criticalExtensionOIDs.remove(POLICY_MAPPINGS);
criticalExtensionOIDs.remove(INHIBIT_ANY_POLICY);
criticalExtensionOIDs.remove(ISSUING_DISTRIBUTION_POINT);
criticalExtensionOIDs.remove(DELTA_CRL_INDICATOR);
criticalExtensionOIDs.remove(POLICY_CONSTRAINTS);
criticalExtensionOIDs.remove(BASIC_CONSTRAINTS);
criticalExtensionOIDs.remove(SUBJECT_ALTERNATIVE_NAME);
criticalExtensionOIDs.remove(NAME_CONSTRAINTS);
String str = QC_STATEMENT;
if (criticalExtensionOIDs.contains(str) && processQcStatements(x509Certificate, size)) {
criticalExtensionOIDs.remove(str);
}
Iterator<PKIXCertPathChecker> it2 = certPathCheckers.iterator();
while (it2.hasNext()) {
try {
it2.next().check(x509Certificate, criticalExtensionOIDs);
} catch (CertPathValidatorException e3) {
throw new CertPathReviewerException(new ErrorBundle(RESOURCE_NAME, "CertPathReviewer.criticalExtensionError", new Object[]{e3.getMessage(), e3, e3.getClass().getName()}), e3.getCause(), this.certPath, size);
}
}
if (!criticalExtensionOIDs.isEmpty()) {
Iterator<String> it3 = criticalExtensionOIDs.iterator();
while (it3.hasNext()) {
addError(new ErrorBundle(RESOURCE_NAME, "CertPathReviewer.unknownCriticalExt", new Object[]{new ASN1ObjectIdentifier(it3.next())}), size);
}
}
}
}
}
private String IPtoString(byte[] bArr) {
try {
return InetAddress.getByAddress(bArr).getHostAddress();
} catch (Exception unused) {
StringBuffer stringBuffer = new StringBuffer();
for (int i = 0; i != bArr.length; i++) {
stringBuffer.append(Integer.toHexString(bArr[i] & UnsignedBytes.MAX_VALUE));
stringBuffer.append(' ');
}
return stringBuffer.toString();
}
}
public PKIXCertPathReviewer(CertPath certPath, PKIXParameters pKIXParameters) throws CertPathReviewerException {
init(certPath, pKIXParameters);
}
public PKIXCertPathReviewer() {
}
}