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

91 lines
3.4 KiB
Java
Raw Permalink Normal View History

2024-07-27 18:17:47 +07:00
package org.bouncycastle.asn1.x509;
import org.bouncycastle.asn1.ASN1EncodableVector;
import org.bouncycastle.asn1.ASN1Enumerated;
import org.bouncycastle.asn1.ASN1Object;
import org.bouncycastle.asn1.ASN1ObjectIdentifier;
import org.bouncycastle.asn1.ASN1Primitive;
import org.bouncycastle.asn1.ASN1Sequence;
import org.bouncycastle.asn1.ASN1TaggedObject;
import org.bouncycastle.asn1.DERBitString;
import org.bouncycastle.asn1.DERSequence;
/* loaded from: classes6.dex */
public class ObjectDigestInfo extends ASN1Object {
public static final int otherObjectDigest = 2;
public static final int publicKey = 0;
public static final int publicKeyCert = 1;
AlgorithmIdentifier digestAlgorithm;
ASN1Enumerated digestedObjectType;
DERBitString objectDigest;
ASN1ObjectIdentifier otherObjectTypeID;
@Override // org.bouncycastle.asn1.ASN1Object, org.bouncycastle.asn1.ASN1Encodable
public ASN1Primitive toASN1Primitive() {
ASN1EncodableVector aSN1EncodableVector = new ASN1EncodableVector();
aSN1EncodableVector.add(this.digestedObjectType);
ASN1ObjectIdentifier aSN1ObjectIdentifier = this.otherObjectTypeID;
if (aSN1ObjectIdentifier != null) {
aSN1EncodableVector.add(aSN1ObjectIdentifier);
}
aSN1EncodableVector.add(this.digestAlgorithm);
aSN1EncodableVector.add(this.objectDigest);
return new DERSequence(aSN1EncodableVector);
}
public ASN1ObjectIdentifier getOtherObjectTypeID() {
return this.otherObjectTypeID;
}
public DERBitString getObjectDigest() {
return this.objectDigest;
}
public ASN1Enumerated getDigestedObjectType() {
return this.digestedObjectType;
}
public AlgorithmIdentifier getDigestAlgorithm() {
return this.digestAlgorithm;
}
public static ObjectDigestInfo getInstance(ASN1TaggedObject aSN1TaggedObject, boolean z) {
return getInstance(ASN1Sequence.getInstance(aSN1TaggedObject, z));
}
public static ObjectDigestInfo getInstance(Object obj) {
if (obj instanceof ObjectDigestInfo) {
return (ObjectDigestInfo) obj;
}
if (obj != null) {
return new ObjectDigestInfo(ASN1Sequence.getInstance(obj));
}
return null;
}
private ObjectDigestInfo(ASN1Sequence aSN1Sequence) {
if (aSN1Sequence.size() > 4 || aSN1Sequence.size() < 3) {
StringBuilder sb = new StringBuilder("Bad sequence size: ");
sb.append(aSN1Sequence.size());
throw new IllegalArgumentException(sb.toString());
}
int i = 0;
this.digestedObjectType = ASN1Enumerated.getInstance(aSN1Sequence.getObjectAt(0));
if (aSN1Sequence.size() == 4) {
i = 1;
this.otherObjectTypeID = ASN1ObjectIdentifier.getInstance(aSN1Sequence.getObjectAt(1));
}
this.digestAlgorithm = AlgorithmIdentifier.getInstance(aSN1Sequence.getObjectAt(i + 1));
this.objectDigest = DERBitString.getInstance(aSN1Sequence.getObjectAt(i + 2));
}
public ObjectDigestInfo(int i, ASN1ObjectIdentifier aSN1ObjectIdentifier, AlgorithmIdentifier algorithmIdentifier, byte[] bArr) {
this.digestedObjectType = new ASN1Enumerated(i);
if (i == 2) {
this.otherObjectTypeID = aSN1ObjectIdentifier;
}
this.digestAlgorithm = algorithmIdentifier;
this.objectDigest = new DERBitString(bArr);
}
}