what-the-bank/sources/org/bouncycastle/asn1/x509/TBSCertList.java

236 lines
8.0 KiB
Java
Raw Normal View History

2024-07-27 18:17:47 +07:00
package org.bouncycastle.asn1.x509;
import java.util.Enumeration;
import java.util.NoSuchElementException;
import org.bouncycastle.asn1.ASN1EncodableVector;
import org.bouncycastle.asn1.ASN1GeneralizedTime;
import org.bouncycastle.asn1.ASN1Integer;
import org.bouncycastle.asn1.ASN1Object;
import org.bouncycastle.asn1.ASN1Primitive;
import org.bouncycastle.asn1.ASN1Sequence;
import org.bouncycastle.asn1.ASN1TaggedObject;
import org.bouncycastle.asn1.ASN1UTCTime;
import org.bouncycastle.asn1.DERSequence;
import org.bouncycastle.asn1.DERTaggedObject;
import org.bouncycastle.asn1.x500.X500Name;
/* loaded from: classes6.dex */
public class TBSCertList extends ASN1Object {
Extensions crlExtensions;
X500Name issuer;
Time nextUpdate;
ASN1Sequence revokedCertificates;
AlgorithmIdentifier signature;
Time thisUpdate;
ASN1Integer version;
@Override // org.bouncycastle.asn1.ASN1Object, org.bouncycastle.asn1.ASN1Encodable
public ASN1Primitive toASN1Primitive() {
ASN1EncodableVector aSN1EncodableVector = new ASN1EncodableVector();
ASN1Integer aSN1Integer = this.version;
if (aSN1Integer != null) {
aSN1EncodableVector.add(aSN1Integer);
}
aSN1EncodableVector.add(this.signature);
aSN1EncodableVector.add(this.issuer);
aSN1EncodableVector.add(this.thisUpdate);
Time time = this.nextUpdate;
if (time != null) {
aSN1EncodableVector.add(time);
}
ASN1Sequence aSN1Sequence = this.revokedCertificates;
if (aSN1Sequence != null) {
aSN1EncodableVector.add(aSN1Sequence);
}
if (this.crlExtensions != null) {
aSN1EncodableVector.add(new DERTaggedObject(0, this.crlExtensions));
}
return new DERSequence(aSN1EncodableVector);
}
public int getVersionNumber() {
ASN1Integer aSN1Integer = this.version;
if (aSN1Integer == null) {
return 1;
}
return aSN1Integer.getValue().intValue() + 1;
}
public ASN1Integer getVersion() {
return this.version;
}
public Time getThisUpdate() {
return this.thisUpdate;
}
public AlgorithmIdentifier getSignature() {
return this.signature;
}
/* loaded from: classes6.dex */
public static class CRLEntry extends ASN1Object {
Extensions crlEntryExtensions;
ASN1Sequence seq;
@Override // org.bouncycastle.asn1.ASN1Object, org.bouncycastle.asn1.ASN1Encodable
public ASN1Primitive toASN1Primitive() {
return this.seq;
}
public boolean hasExtensions() {
return this.seq.size() == 3;
}
public ASN1Integer getUserCertificate() {
return ASN1Integer.getInstance(this.seq.getObjectAt(0));
}
public Time getRevocationDate() {
return Time.getInstance(this.seq.getObjectAt(1));
}
public Extensions getExtensions() {
if (this.crlEntryExtensions == null && this.seq.size() == 3) {
this.crlEntryExtensions = Extensions.getInstance(this.seq.getObjectAt(2));
}
return this.crlEntryExtensions;
}
public static CRLEntry getInstance(Object obj) {
if (obj instanceof CRLEntry) {
return (CRLEntry) obj;
}
if (obj != null) {
return new CRLEntry(ASN1Sequence.getInstance(obj));
}
return null;
}
private CRLEntry(ASN1Sequence aSN1Sequence) {
if (aSN1Sequence.size() >= 2 && aSN1Sequence.size() <= 3) {
this.seq = aSN1Sequence;
} else {
StringBuilder sb = new StringBuilder("Bad sequence size: ");
sb.append(aSN1Sequence.size());
throw new IllegalArgumentException(sb.toString());
}
}
}
public CRLEntry[] getRevokedCertificates() {
ASN1Sequence aSN1Sequence = this.revokedCertificates;
if (aSN1Sequence == null) {
return new CRLEntry[0];
}
int size = aSN1Sequence.size();
CRLEntry[] cRLEntryArr = new CRLEntry[size];
for (int i = 0; i < size; i++) {
cRLEntryArr[i] = CRLEntry.getInstance(this.revokedCertificates.getObjectAt(i));
}
return cRLEntryArr;
}
public Enumeration getRevokedCertificateEnumeration() {
ASN1Sequence aSN1Sequence = this.revokedCertificates;
return aSN1Sequence == null ? new EmptyEnumeration() : new RevokedCertificatesEnumeration(this, aSN1Sequence.getObjects());
}
public Time getNextUpdate() {
return this.nextUpdate;
}
/* loaded from: classes6.dex */
class EmptyEnumeration implements Enumeration {
final TBSCertList this$0;
@Override // java.util.Enumeration
public boolean hasMoreElements() {
return false;
}
@Override // java.util.Enumeration
public Object nextElement() {
throw new NoSuchElementException("Empty Enumeration");
}
private EmptyEnumeration(TBSCertList tBSCertList) {
this.this$0 = tBSCertList;
}
}
public X500Name getIssuer() {
return this.issuer;
}
/* loaded from: classes6.dex */
class RevokedCertificatesEnumeration implements Enumeration {
private final Enumeration en;
final TBSCertList this$0;
@Override // java.util.Enumeration
public Object nextElement() {
return CRLEntry.getInstance(this.en.nextElement());
}
@Override // java.util.Enumeration
public boolean hasMoreElements() {
return this.en.hasMoreElements();
}
RevokedCertificatesEnumeration(TBSCertList tBSCertList, Enumeration enumeration) {
this.this$0 = tBSCertList;
this.en = enumeration;
}
}
public Extensions getExtensions() {
return this.crlExtensions;
}
public static TBSCertList getInstance(ASN1TaggedObject aSN1TaggedObject, boolean z) {
return getInstance(ASN1Sequence.getInstance(aSN1TaggedObject, z));
}
public static TBSCertList getInstance(Object obj) {
if (obj instanceof TBSCertList) {
return (TBSCertList) obj;
}
if (obj != null) {
return new TBSCertList(ASN1Sequence.getInstance(obj));
}
return null;
}
public TBSCertList(ASN1Sequence aSN1Sequence) {
if (aSN1Sequence.size() < 3 || aSN1Sequence.size() > 7) {
StringBuilder sb = new StringBuilder("Bad sequence size: ");
sb.append(aSN1Sequence.size());
throw new IllegalArgumentException(sb.toString());
}
int i = 0;
if (aSN1Sequence.getObjectAt(0) instanceof ASN1Integer) {
this.version = ASN1Integer.getInstance(aSN1Sequence.getObjectAt(0));
i = 1;
} else {
this.version = null;
}
this.signature = AlgorithmIdentifier.getInstance(aSN1Sequence.getObjectAt(i));
this.issuer = X500Name.getInstance(aSN1Sequence.getObjectAt(i + 1));
int i2 = i + 3;
this.thisUpdate = Time.getInstance(aSN1Sequence.getObjectAt(i + 2));
if (i2 < aSN1Sequence.size() && ((aSN1Sequence.getObjectAt(i2) instanceof ASN1UTCTime) || (aSN1Sequence.getObjectAt(i2) instanceof ASN1GeneralizedTime) || (aSN1Sequence.getObjectAt(i2) instanceof Time))) {
this.nextUpdate = Time.getInstance(aSN1Sequence.getObjectAt(i2));
i2 = i + 4;
}
if (i2 < aSN1Sequence.size() && !(aSN1Sequence.getObjectAt(i2) instanceof ASN1TaggedObject)) {
this.revokedCertificates = ASN1Sequence.getInstance(aSN1Sequence.getObjectAt(i2));
i2++;
}
if (i2 >= aSN1Sequence.size() || !(aSN1Sequence.getObjectAt(i2) instanceof ASN1TaggedObject)) {
return;
}
this.crlExtensions = Extensions.getInstance(ASN1Sequence.getInstance((ASN1TaggedObject) aSN1Sequence.getObjectAt(i2), true));
}
}