448 lines
17 KiB
Java
448 lines
17 KiB
Java
package o;
|
|
|
|
import java.io.IOException;
|
|
import java.math.BigInteger;
|
|
import java.security.InvalidKeyException;
|
|
import java.security.NoSuchAlgorithmException;
|
|
import java.security.NoSuchProviderException;
|
|
import java.security.Principal;
|
|
import java.security.Provider;
|
|
import java.security.PublicKey;
|
|
import java.security.Signature;
|
|
import java.security.SignatureException;
|
|
import java.security.cert.CRLException;
|
|
import java.security.cert.Certificate;
|
|
import java.security.cert.CertificateEncodingException;
|
|
import java.security.cert.X509CRL;
|
|
import java.security.cert.X509CRLEntry;
|
|
import java.security.cert.X509Certificate;
|
|
import java.util.Collections;
|
|
import java.util.Date;
|
|
import java.util.Enumeration;
|
|
import java.util.HashSet;
|
|
import java.util.Iterator;
|
|
import java.util.Set;
|
|
import javax.security.auth.x500.X500Principal;
|
|
import o.C15433gqb;
|
|
import org.bouncycastle.asn1.ASN1Encoding;
|
|
import org.spongycastle.asn1.ASN1Integer;
|
|
|
|
/* loaded from: classes6.dex */
|
|
final class gqF extends X509CRL {
|
|
private int a;
|
|
private gpA b;
|
|
private boolean c;
|
|
private boolean d = false;
|
|
private gqQ e;
|
|
private String i;
|
|
private byte[] j;
|
|
|
|
private static boolean c(X509CRL x509crl) throws CRLException {
|
|
try {
|
|
byte[] extensionValue = x509crl.getExtensionValue(C15394gpK.f9146o.d);
|
|
if (extensionValue != null) {
|
|
byte[] b = gnD.b((Object) extensionValue).b();
|
|
if ((b != null ? new gpV(AbstractC15317gnH.a(b)) : null).d) {
|
|
return true;
|
|
}
|
|
}
|
|
return false;
|
|
} catch (Exception e) {
|
|
throw new C15426gqE("Exception reading IssuingDistributionPoint", e);
|
|
}
|
|
}
|
|
|
|
/* JADX INFO: Access modifiers changed from: protected */
|
|
public gqF(gqQ gqq, gpA gpa) throws CRLException {
|
|
this.e = gqq;
|
|
this.b = gpa;
|
|
try {
|
|
this.i = C15430gqM.d(gpa.b);
|
|
if (gpa.b.a != null) {
|
|
this.j = gpa.b.a.i().c(ASN1Encoding.DER);
|
|
} else {
|
|
this.j = null;
|
|
}
|
|
this.c = c(this);
|
|
} catch (Exception e) {
|
|
throw new CRLException("CRL contents invalid: ".concat(String.valueOf(e)));
|
|
}
|
|
}
|
|
|
|
@Override // java.security.cert.X509Extension
|
|
public final boolean hasUnsupportedCriticalExtension() {
|
|
Set criticalExtensionOIDs = getCriticalExtensionOIDs();
|
|
if (criticalExtensionOIDs == null) {
|
|
return false;
|
|
}
|
|
criticalExtensionOIDs.remove(C15394gpK.f9146o.d);
|
|
criticalExtensionOIDs.remove(C15394gpK.h.d);
|
|
return !criticalExtensionOIDs.isEmpty();
|
|
}
|
|
|
|
private Set d(boolean z) {
|
|
C15391gpH c15391gpH;
|
|
if (getVersion() != 2 || (c15391gpH = this.b.d.c) == null) {
|
|
return null;
|
|
}
|
|
HashSet hashSet = new HashSet();
|
|
Enumeration elements = c15391gpH.a.elements();
|
|
while (elements.hasMoreElements()) {
|
|
C15314gnC c15314gnC = (C15314gnC) elements.nextElement();
|
|
if (z == ((C15394gpK) c15391gpH.d.get(c15314gnC)).p) {
|
|
hashSet.add(c15314gnC.d);
|
|
}
|
|
}
|
|
return hashSet;
|
|
}
|
|
|
|
@Override // java.security.cert.X509Extension
|
|
public final Set getCriticalExtensionOIDs() {
|
|
return d(true);
|
|
}
|
|
|
|
@Override // java.security.cert.X509Extension
|
|
public final Set getNonCriticalExtensionOIDs() {
|
|
return d(false);
|
|
}
|
|
|
|
@Override // java.security.cert.X509CRL
|
|
public final byte[] getEncoded() throws CRLException {
|
|
try {
|
|
return this.b.c(ASN1Encoding.DER);
|
|
} catch (IOException e) {
|
|
throw new CRLException(e.toString());
|
|
}
|
|
}
|
|
|
|
@Override // java.security.cert.X509CRL
|
|
public final void verify(PublicKey publicKey) throws CRLException, NoSuchAlgorithmException, InvalidKeyException, NoSuchProviderException, SignatureException {
|
|
Signature signature;
|
|
try {
|
|
signature = this.e.e(getSigAlgName());
|
|
} catch (Exception unused) {
|
|
signature = Signature.getInstance(getSigAlgName());
|
|
}
|
|
e(publicKey, signature);
|
|
}
|
|
|
|
@Override // java.security.cert.X509CRL
|
|
public final void verify(PublicKey publicKey, String str) throws CRLException, NoSuchAlgorithmException, InvalidKeyException, NoSuchProviderException, SignatureException {
|
|
Signature signature;
|
|
if (str != null) {
|
|
signature = Signature.getInstance(getSigAlgName(), str);
|
|
} else {
|
|
signature = Signature.getInstance(getSigAlgName());
|
|
}
|
|
e(publicKey, signature);
|
|
}
|
|
|
|
@Override // java.security.cert.X509CRL
|
|
public final void verify(PublicKey publicKey, Provider provider) throws CRLException, NoSuchAlgorithmException, InvalidKeyException, SignatureException {
|
|
Signature signature;
|
|
if (provider != null) {
|
|
signature = Signature.getInstance(getSigAlgName(), provider);
|
|
} else {
|
|
signature = Signature.getInstance(getSigAlgName());
|
|
}
|
|
e(publicKey, signature);
|
|
}
|
|
|
|
@Override // java.security.cert.X509CRL
|
|
public final int getVersion() {
|
|
ASN1Integer aSN1Integer = this.b.d.i;
|
|
if (aSN1Integer == null) {
|
|
return 1;
|
|
}
|
|
return new BigInteger(aSN1Integer.b).intValue() + 1;
|
|
}
|
|
|
|
@Override // java.security.cert.X509CRL
|
|
public final Principal getIssuerDN() {
|
|
return new gqV(C15417gpt.c(this.b.d.e.i()));
|
|
}
|
|
|
|
@Override // java.security.cert.X509CRL
|
|
public final X500Principal getIssuerX500Principal() {
|
|
try {
|
|
return new X500Principal(this.b.d.e.l());
|
|
} catch (IOException unused) {
|
|
throw new IllegalStateException("can't encode issuer DN");
|
|
}
|
|
}
|
|
|
|
@Override // java.security.cert.X509CRL
|
|
public final Date getThisUpdate() {
|
|
return this.b.d.f.c();
|
|
}
|
|
|
|
@Override // java.security.cert.X509CRL
|
|
public final Date getNextUpdate() {
|
|
if (this.b.d.d != null) {
|
|
return this.b.d.d.c();
|
|
}
|
|
return null;
|
|
}
|
|
|
|
@Override // java.security.cert.X509CRL
|
|
public final X509CRLEntry getRevokedCertificate(BigInteger bigInteger) {
|
|
Enumeration d = this.b.d();
|
|
C15417gpt c15417gpt = null;
|
|
while (d.hasMoreElements()) {
|
|
C15433gqb.Sts sts = (C15433gqb.Sts) d.nextElement();
|
|
if (bigInteger.equals(new BigInteger(ASN1Integer.e(sts.e.d(0)).b))) {
|
|
return new C15429gqI(sts, this.c, c15417gpt);
|
|
}
|
|
if (this.c && sts.e.e() == 3) {
|
|
C15394gpK c15394gpK = (C15394gpK) sts.a().d.get(C15394gpK.a);
|
|
if (c15394gpK != null) {
|
|
AbstractC15315gnE b = C15394gpK.b(c15394gpK);
|
|
gpO[] gpoArr = (b != null ? new gpP(AbstractC15317gnH.a(b)) : null).b;
|
|
gpO[] gpoArr2 = new gpO[gpoArr.length];
|
|
System.arraycopy(gpoArr, 0, gpoArr2, 0, gpoArr.length);
|
|
c15417gpt = C15417gpt.c(gpoArr2[0].d);
|
|
}
|
|
}
|
|
}
|
|
return null;
|
|
}
|
|
|
|
@Override // java.security.cert.X509CRL
|
|
public final byte[] getSigAlgParams() {
|
|
byte[] bArr = this.j;
|
|
if (bArr == null) {
|
|
return null;
|
|
}
|
|
int length = bArr.length;
|
|
byte[] bArr2 = new byte[length];
|
|
System.arraycopy(bArr, 0, bArr2, 0, length);
|
|
return bArr2;
|
|
}
|
|
|
|
@Override // java.security.cert.CRL
|
|
public final String toString() {
|
|
StringBuffer stringBuffer = new StringBuffer(" Version: ");
|
|
String b = grR.b();
|
|
stringBuffer.append(getVersion()).append(b);
|
|
stringBuffer.append(" IssuerDN: ").append(getIssuerDN()).append(b);
|
|
stringBuffer.append(" This update: ").append(getThisUpdate()).append(b);
|
|
stringBuffer.append(" Next update: ").append(getNextUpdate()).append(b);
|
|
stringBuffer.append(" Signature Algorithm: ").append(getSigAlgName()).append(b);
|
|
byte[] signature = getSignature();
|
|
stringBuffer.append(" Signature: ").append(new String(grS.e(signature, 0, 20))).append(b);
|
|
for (int i = 20; i < signature.length; i += 20) {
|
|
if (i < signature.length - 20) {
|
|
stringBuffer.append(" ").append(new String(grS.e(signature, i, 20))).append(b);
|
|
} else {
|
|
stringBuffer.append(" ").append(new String(grS.e(signature, i, signature.length - i))).append(b);
|
|
}
|
|
}
|
|
C15391gpH c15391gpH = this.b.d.c;
|
|
if (c15391gpH != null) {
|
|
Enumeration elements = c15391gpH.a.elements();
|
|
if (elements.hasMoreElements()) {
|
|
stringBuffer.append(" Extensions: ").append(b);
|
|
}
|
|
while (elements.hasMoreElements()) {
|
|
C15314gnC c15314gnC = (C15314gnC) elements.nextElement();
|
|
C15394gpK c15394gpK = (C15394gpK) c15391gpH.d.get(c15314gnC);
|
|
if (c15394gpK.v != null) {
|
|
C15348gnx c15348gnx = new C15348gnx(c15394gpK.v.b());
|
|
stringBuffer.append(" critical(").append(c15394gpK.p).append(") ");
|
|
try {
|
|
if (c15314gnC.equals(C15394gpK.e)) {
|
|
stringBuffer.append(new C15390gpE(new BigInteger(1, ASN1Integer.e((Object) c15348gnx.b()).b))).append(b);
|
|
} else if (c15314gnC.equals(C15394gpK.h)) {
|
|
StringBuilder sb = new StringBuilder();
|
|
sb.append("Base CRL: ");
|
|
sb.append(new C15390gpE(new BigInteger(1, ASN1Integer.e((Object) c15348gnx.b()).b)));
|
|
stringBuffer.append(sb.toString()).append(b);
|
|
} else if (c15314gnC.equals(C15394gpK.f9146o)) {
|
|
AbstractC15315gnE b2 = c15348gnx.b();
|
|
stringBuffer.append(b2 != null ? new gpV(AbstractC15317gnH.a(b2)) : null).append(b);
|
|
} else if (c15314gnC.equals(C15394gpK.c)) {
|
|
AbstractC15315gnE b3 = c15348gnx.b();
|
|
stringBuffer.append(b3 != null ? new gpC(AbstractC15317gnH.a(b3)) : null).append(b);
|
|
} else if (c15314gnC.equals(C15394gpK.j)) {
|
|
AbstractC15315gnE b4 = c15348gnx.b();
|
|
stringBuffer.append(b4 != null ? new gpC(AbstractC15317gnH.a(b4)) : null).append(b);
|
|
} else {
|
|
stringBuffer.append(c15314gnC.d);
|
|
stringBuffer.append(" value = ").append(C15408gpk.d(c15348gnx.b())).append(b);
|
|
}
|
|
} catch (Exception unused) {
|
|
stringBuffer.append(c15314gnC.d);
|
|
stringBuffer.append(" value = *****").append(b);
|
|
}
|
|
} else {
|
|
stringBuffer.append(b);
|
|
}
|
|
}
|
|
}
|
|
Set<? extends X509CRLEntry> revokedCertificates = getRevokedCertificates();
|
|
if (revokedCertificates != null) {
|
|
Iterator<? extends X509CRLEntry> it = revokedCertificates.iterator();
|
|
while (it.hasNext()) {
|
|
stringBuffer.append(it.next());
|
|
stringBuffer.append(b);
|
|
}
|
|
}
|
|
return stringBuffer.toString();
|
|
}
|
|
|
|
@Override // java.security.cert.CRL
|
|
public final boolean isRevoked(Certificate certificate) {
|
|
C15433gqb.Sts sts;
|
|
C15417gpt c15417gpt;
|
|
if (!certificate.getType().equals("X.509")) {
|
|
throw new IllegalArgumentException("X.509 CRL used with non X.509 Cert");
|
|
}
|
|
Enumeration d = this.b.d();
|
|
C15417gpt c15417gpt2 = this.b.d.e;
|
|
if (d.hasMoreElements()) {
|
|
X509Certificate x509Certificate = (X509Certificate) certificate;
|
|
BigInteger serialNumber = x509Certificate.getSerialNumber();
|
|
while (d.hasMoreElements()) {
|
|
Object nextElement = d.nextElement();
|
|
if (nextElement instanceof C15433gqb.Sts) {
|
|
sts = (C15433gqb.Sts) nextElement;
|
|
} else {
|
|
sts = nextElement != null ? new C15433gqb.Sts(AbstractC15317gnH.a(nextElement)) : null;
|
|
}
|
|
if (this.c && sts.e.e() == 3) {
|
|
C15394gpK c15394gpK = (C15394gpK) sts.a().d.get(C15394gpK.a);
|
|
if (c15394gpK != null) {
|
|
AbstractC15315gnE b = C15394gpK.b(c15394gpK);
|
|
gpO[] gpoArr = (b != null ? new gpP(AbstractC15317gnH.a(b)) : null).b;
|
|
gpO[] gpoArr2 = new gpO[gpoArr.length];
|
|
System.arraycopy(gpoArr, 0, gpoArr2, 0, gpoArr.length);
|
|
c15417gpt2 = C15417gpt.c(gpoArr2[0].d);
|
|
}
|
|
}
|
|
if (new BigInteger(ASN1Integer.e(sts.e.d(0)).b).equals(serialNumber)) {
|
|
if (certificate instanceof X509Certificate) {
|
|
c15417gpt = C15417gpt.c(x509Certificate.getIssuerX500Principal().getEncoded());
|
|
} else {
|
|
try {
|
|
byte[] encoded = certificate.getEncoded();
|
|
c15417gpt = (encoded != null ? new C15389gpD(AbstractC15317gnH.a(encoded)) : null).e.c;
|
|
} catch (CertificateEncodingException e) {
|
|
StringBuilder sb = new StringBuilder("Cannot process certificate: ");
|
|
sb.append(e.getMessage());
|
|
throw new IllegalArgumentException(sb.toString());
|
|
}
|
|
}
|
|
return c15417gpt2.equals(c15417gpt);
|
|
}
|
|
}
|
|
}
|
|
return false;
|
|
}
|
|
|
|
@Override // java.security.cert.X509CRL
|
|
public final boolean equals(Object obj) {
|
|
if (this == obj) {
|
|
return true;
|
|
}
|
|
if (!(obj instanceof X509CRL)) {
|
|
return false;
|
|
}
|
|
if (obj instanceof gqF) {
|
|
gqF gqf = (gqF) obj;
|
|
if (this.d && gqf.d && gqf.a != this.a) {
|
|
return false;
|
|
}
|
|
return this.b.equals(gqf.b);
|
|
}
|
|
return super.equals(obj);
|
|
}
|
|
|
|
@Override // java.security.cert.X509CRL
|
|
public final int hashCode() {
|
|
if (!this.d) {
|
|
this.d = true;
|
|
this.a = super.hashCode();
|
|
}
|
|
return this.a;
|
|
}
|
|
|
|
private void e(PublicKey publicKey, Signature signature) throws CRLException, NoSuchAlgorithmException, InvalidKeyException, SignatureException {
|
|
if (!this.b.b.equals(this.b.d.b)) {
|
|
throw new CRLException("Signature algorithm on CertificateList does not match TBSCertList.");
|
|
}
|
|
signature.initVerify(publicKey);
|
|
signature.update(getTBSCertList());
|
|
if (!signature.verify(getSignature())) {
|
|
throw new SignatureException("CRL does not verify with supplied public key.");
|
|
}
|
|
}
|
|
|
|
@Override // java.security.cert.X509Extension
|
|
public final byte[] getExtensionValue(String str) {
|
|
C15391gpH c15391gpH = this.b.d.c;
|
|
if (c15391gpH == null) {
|
|
return null;
|
|
}
|
|
C15394gpK c15394gpK = (C15394gpK) c15391gpH.d.get(new C15314gnC(str));
|
|
if (c15394gpK == null) {
|
|
return null;
|
|
}
|
|
try {
|
|
return c15394gpK.v.l();
|
|
} catch (Exception e) {
|
|
StringBuilder sb = new StringBuilder("error parsing ");
|
|
sb.append(e.toString());
|
|
throw new IllegalStateException(sb.toString());
|
|
}
|
|
}
|
|
|
|
@Override // java.security.cert.X509CRL
|
|
public final Set getRevokedCertificates() {
|
|
HashSet hashSet = new HashSet();
|
|
Enumeration d = this.b.d();
|
|
C15417gpt c15417gpt = null;
|
|
while (d.hasMoreElements()) {
|
|
C15433gqb.Sts sts = (C15433gqb.Sts) d.nextElement();
|
|
hashSet.add(new C15429gqI(sts, this.c, c15417gpt));
|
|
if (this.c && sts.e.e() == 3) {
|
|
C15394gpK c15394gpK = (C15394gpK) sts.a().d.get(C15394gpK.a);
|
|
if (c15394gpK != null) {
|
|
AbstractC15315gnE b = C15394gpK.b(c15394gpK);
|
|
gpO[] gpoArr = (b != null ? new gpP(AbstractC15317gnH.a(b)) : null).b;
|
|
gpO[] gpoArr2 = new gpO[gpoArr.length];
|
|
System.arraycopy(gpoArr, 0, gpoArr2, 0, gpoArr.length);
|
|
c15417gpt = C15417gpt.c(gpoArr2[0].d);
|
|
}
|
|
}
|
|
}
|
|
if (hashSet.isEmpty()) {
|
|
return null;
|
|
}
|
|
return Collections.unmodifiableSet(hashSet);
|
|
}
|
|
|
|
@Override // java.security.cert.X509CRL
|
|
public final String getSigAlgOID() {
|
|
return this.b.b.e.d;
|
|
}
|
|
|
|
@Override // java.security.cert.X509CRL
|
|
public final byte[] getSignature() {
|
|
return this.b.c.e();
|
|
}
|
|
|
|
@Override // java.security.cert.X509CRL
|
|
public final byte[] getTBSCertList() throws CRLException {
|
|
try {
|
|
return this.b.d.c(ASN1Encoding.DER);
|
|
} catch (IOException e) {
|
|
throw new CRLException(e.toString());
|
|
}
|
|
}
|
|
|
|
@Override // java.security.cert.X509CRL
|
|
public final String getSigAlgName() {
|
|
return this.i;
|
|
}
|
|
}
|