what-the-bank/sources/org/bouncycastle/asn1/cmp/PKIHeader.java

181 lines
6.6 KiB
Java
Raw Permalink Normal View History

2024-07-27 18:17:47 +07:00
package org.bouncycastle.asn1.cmp;
import java.util.Enumeration;
import org.bouncycastle.asn1.ASN1Encodable;
import org.bouncycastle.asn1.ASN1EncodableVector;
import org.bouncycastle.asn1.ASN1GeneralizedTime;
import org.bouncycastle.asn1.ASN1Integer;
import org.bouncycastle.asn1.ASN1Object;
import org.bouncycastle.asn1.ASN1OctetString;
import org.bouncycastle.asn1.ASN1Primitive;
import org.bouncycastle.asn1.ASN1Sequence;
import org.bouncycastle.asn1.ASN1TaggedObject;
import org.bouncycastle.asn1.DERSequence;
import org.bouncycastle.asn1.DERTaggedObject;
import org.bouncycastle.asn1.x500.X500Name;
import org.bouncycastle.asn1.x509.AlgorithmIdentifier;
import org.bouncycastle.asn1.x509.GeneralName;
/* loaded from: classes6.dex */
public class PKIHeader extends ASN1Object {
public static final int CMP_1999 = 1;
public static final int CMP_2000 = 2;
public static final GeneralName NULL_NAME = new GeneralName(X500Name.getInstance(new DERSequence()));
private PKIFreeText freeText;
private ASN1Sequence generalInfo;
private ASN1GeneralizedTime messageTime;
private AlgorithmIdentifier protectionAlg;
private ASN1Integer pvno;
private ASN1OctetString recipKID;
private ASN1OctetString recipNonce;
private GeneralName recipient;
private GeneralName sender;
private ASN1OctetString senderKID;
private ASN1OctetString senderNonce;
private ASN1OctetString transactionID;
@Override // org.bouncycastle.asn1.ASN1Object, org.bouncycastle.asn1.ASN1Encodable
public ASN1Primitive toASN1Primitive() {
ASN1EncodableVector aSN1EncodableVector = new ASN1EncodableVector();
aSN1EncodableVector.add(this.pvno);
aSN1EncodableVector.add(this.sender);
aSN1EncodableVector.add(this.recipient);
addOptional(aSN1EncodableVector, 0, this.messageTime);
addOptional(aSN1EncodableVector, 1, this.protectionAlg);
addOptional(aSN1EncodableVector, 2, this.senderKID);
addOptional(aSN1EncodableVector, 3, this.recipKID);
addOptional(aSN1EncodableVector, 4, this.transactionID);
addOptional(aSN1EncodableVector, 5, this.senderNonce);
addOptional(aSN1EncodableVector, 6, this.recipNonce);
addOptional(aSN1EncodableVector, 7, this.freeText);
addOptional(aSN1EncodableVector, 8, this.generalInfo);
return new DERSequence(aSN1EncodableVector);
}
public ASN1OctetString getTransactionID() {
return this.transactionID;
}
public ASN1OctetString getSenderNonce() {
return this.senderNonce;
}
public ASN1OctetString getSenderKID() {
return this.senderKID;
}
public GeneralName getSender() {
return this.sender;
}
public GeneralName getRecipient() {
return this.recipient;
}
public ASN1OctetString getRecipNonce() {
return this.recipNonce;
}
public ASN1OctetString getRecipKID() {
return this.recipKID;
}
public ASN1Integer getPvno() {
return this.pvno;
}
public AlgorithmIdentifier getProtectionAlg() {
return this.protectionAlg;
}
public ASN1GeneralizedTime getMessageTime() {
return this.messageTime;
}
public InfoTypeAndValue[] getGeneralInfo() {
ASN1Sequence aSN1Sequence = this.generalInfo;
if (aSN1Sequence == null) {
return null;
}
int size = aSN1Sequence.size();
InfoTypeAndValue[] infoTypeAndValueArr = new InfoTypeAndValue[size];
for (int i = 0; i < size; i++) {
infoTypeAndValueArr[i] = InfoTypeAndValue.getInstance(this.generalInfo.getObjectAt(i));
}
return infoTypeAndValueArr;
}
public PKIFreeText getFreeText() {
return this.freeText;
}
public static PKIHeader getInstance(Object obj) {
if (obj instanceof PKIHeader) {
return (PKIHeader) obj;
}
if (obj != null) {
return new PKIHeader(ASN1Sequence.getInstance(obj));
}
return null;
}
private void addOptional(ASN1EncodableVector aSN1EncodableVector, int i, ASN1Encodable aSN1Encodable) {
if (aSN1Encodable != null) {
aSN1EncodableVector.add(new DERTaggedObject(true, i, aSN1Encodable));
}
}
private PKIHeader(ASN1Sequence aSN1Sequence) {
Enumeration objects = aSN1Sequence.getObjects();
this.pvno = ASN1Integer.getInstance(objects.nextElement());
this.sender = GeneralName.getInstance(objects.nextElement());
this.recipient = GeneralName.getInstance(objects.nextElement());
while (objects.hasMoreElements()) {
ASN1TaggedObject aSN1TaggedObject = (ASN1TaggedObject) objects.nextElement();
switch (aSN1TaggedObject.getTagNo()) {
case 0:
this.messageTime = ASN1GeneralizedTime.getInstance(aSN1TaggedObject, true);
break;
case 1:
this.protectionAlg = AlgorithmIdentifier.getInstance(aSN1TaggedObject, true);
break;
case 2:
this.senderKID = ASN1OctetString.getInstance(aSN1TaggedObject, true);
break;
case 3:
this.recipKID = ASN1OctetString.getInstance(aSN1TaggedObject, true);
break;
case 4:
this.transactionID = ASN1OctetString.getInstance(aSN1TaggedObject, true);
break;
case 5:
this.senderNonce = ASN1OctetString.getInstance(aSN1TaggedObject, true);
break;
case 6:
this.recipNonce = ASN1OctetString.getInstance(aSN1TaggedObject, true);
break;
case 7:
this.freeText = PKIFreeText.getInstance(aSN1TaggedObject, true);
break;
case 8:
this.generalInfo = ASN1Sequence.getInstance(aSN1TaggedObject, true);
break;
default:
StringBuilder sb = new StringBuilder("unknown tag number: ");
sb.append(aSN1TaggedObject.getTagNo());
throw new IllegalArgumentException(sb.toString());
}
}
}
private PKIHeader(ASN1Integer aSN1Integer, GeneralName generalName, GeneralName generalName2) {
this.pvno = aSN1Integer;
this.sender = generalName;
this.recipient = generalName2;
}
public PKIHeader(int i, GeneralName generalName, GeneralName generalName2) {
this(new ASN1Integer(i), generalName, generalName2);
}
}