76 lines
3.1 KiB
Java
76 lines
3.1 KiB
Java
package org.bouncycastle.asn1.ess;
|
|
|
|
import org.bouncycastle.asn1.ASN1Encodable;
|
|
import org.bouncycastle.asn1.ASN1EncodableVector;
|
|
import org.bouncycastle.asn1.ASN1Object;
|
|
import org.bouncycastle.asn1.ASN1OctetString;
|
|
import org.bouncycastle.asn1.ASN1Primitive;
|
|
import org.bouncycastle.asn1.ASN1Sequence;
|
|
import org.bouncycastle.asn1.DERSequence;
|
|
import org.bouncycastle.asn1.oiw.OIWObjectIdentifiers;
|
|
import org.bouncycastle.asn1.x509.AlgorithmIdentifier;
|
|
import org.bouncycastle.asn1.x509.DigestInfo;
|
|
import org.bouncycastle.asn1.x509.IssuerSerial;
|
|
|
|
/* loaded from: classes6.dex */
|
|
public class OtherCertID extends ASN1Object {
|
|
private IssuerSerial issuerSerial;
|
|
private ASN1Encodable otherCertHash;
|
|
|
|
@Override // org.bouncycastle.asn1.ASN1Object, org.bouncycastle.asn1.ASN1Encodable
|
|
public ASN1Primitive toASN1Primitive() {
|
|
ASN1EncodableVector aSN1EncodableVector = new ASN1EncodableVector();
|
|
aSN1EncodableVector.add(this.otherCertHash);
|
|
IssuerSerial issuerSerial = this.issuerSerial;
|
|
if (issuerSerial != null) {
|
|
aSN1EncodableVector.add(issuerSerial);
|
|
}
|
|
return new DERSequence(aSN1EncodableVector);
|
|
}
|
|
|
|
public IssuerSerial getIssuerSerial() {
|
|
return this.issuerSerial;
|
|
}
|
|
|
|
public byte[] getCertHash() {
|
|
return this.otherCertHash.toASN1Primitive() instanceof ASN1OctetString ? ((ASN1OctetString) this.otherCertHash.toASN1Primitive()).getOctets() : DigestInfo.getInstance(this.otherCertHash).getDigest();
|
|
}
|
|
|
|
public AlgorithmIdentifier getAlgorithmHash() {
|
|
return this.otherCertHash.toASN1Primitive() instanceof ASN1OctetString ? new AlgorithmIdentifier(OIWObjectIdentifiers.idSHA1) : DigestInfo.getInstance(this.otherCertHash).getAlgorithmId();
|
|
}
|
|
|
|
public static OtherCertID getInstance(Object obj) {
|
|
if (obj instanceof OtherCertID) {
|
|
return (OtherCertID) obj;
|
|
}
|
|
if (obj != null) {
|
|
return new OtherCertID(ASN1Sequence.getInstance(obj));
|
|
}
|
|
return null;
|
|
}
|
|
|
|
public OtherCertID(AlgorithmIdentifier algorithmIdentifier, byte[] bArr, IssuerSerial issuerSerial) {
|
|
this.otherCertHash = new DigestInfo(algorithmIdentifier, bArr);
|
|
this.issuerSerial = issuerSerial;
|
|
}
|
|
|
|
public OtherCertID(AlgorithmIdentifier algorithmIdentifier, byte[] bArr) {
|
|
this.otherCertHash = new DigestInfo(algorithmIdentifier, bArr);
|
|
}
|
|
|
|
private OtherCertID(ASN1Sequence aSN1Sequence) {
|
|
if (aSN1Sequence.size() <= 0 || aSN1Sequence.size() > 2) {
|
|
StringBuilder sb = new StringBuilder("Bad sequence size: ");
|
|
sb.append(aSN1Sequence.size());
|
|
throw new IllegalArgumentException(sb.toString());
|
|
}
|
|
boolean z = aSN1Sequence.getObjectAt(0).toASN1Primitive() instanceof ASN1OctetString;
|
|
ASN1Encodable objectAt = aSN1Sequence.getObjectAt(0);
|
|
this.otherCertHash = z ? ASN1OctetString.getInstance(objectAt) : DigestInfo.getInstance(objectAt);
|
|
if (aSN1Sequence.size() > 1) {
|
|
this.issuerSerial = IssuerSerial.getInstance(aSN1Sequence.getObjectAt(1));
|
|
}
|
|
}
|
|
}
|