111 lines
4.3 KiB
Java
111 lines
4.3 KiB
Java
package org.bouncycastle.asn1.icao;
|
|
|
|
import java.util.Enumeration;
|
|
import org.bouncycastle.asn1.ASN1EncodableVector;
|
|
import org.bouncycastle.asn1.ASN1Integer;
|
|
import org.bouncycastle.asn1.ASN1Object;
|
|
import org.bouncycastle.asn1.ASN1Primitive;
|
|
import org.bouncycastle.asn1.ASN1Sequence;
|
|
import org.bouncycastle.asn1.DERSequence;
|
|
import org.bouncycastle.asn1.x509.AlgorithmIdentifier;
|
|
|
|
/* loaded from: classes6.dex */
|
|
public class LDSSecurityObject extends ASN1Object implements ICAOObjectIdentifiers {
|
|
public static final int ub_DataGroups = 16;
|
|
private DataGroupHash[] datagroupHash;
|
|
private AlgorithmIdentifier digestAlgorithmIdentifier;
|
|
private ASN1Integer version;
|
|
private LDSVersionInfo versionInfo;
|
|
|
|
@Override // org.bouncycastle.asn1.ASN1Object, org.bouncycastle.asn1.ASN1Encodable
|
|
public ASN1Primitive toASN1Primitive() {
|
|
ASN1EncodableVector aSN1EncodableVector = new ASN1EncodableVector();
|
|
aSN1EncodableVector.add(this.version);
|
|
aSN1EncodableVector.add(this.digestAlgorithmIdentifier);
|
|
ASN1EncodableVector aSN1EncodableVector2 = new ASN1EncodableVector();
|
|
int i = 0;
|
|
while (true) {
|
|
DataGroupHash[] dataGroupHashArr = this.datagroupHash;
|
|
if (i >= dataGroupHashArr.length) {
|
|
break;
|
|
}
|
|
aSN1EncodableVector2.add(dataGroupHashArr[i]);
|
|
i++;
|
|
}
|
|
aSN1EncodableVector.add(new DERSequence(aSN1EncodableVector2));
|
|
LDSVersionInfo lDSVersionInfo = this.versionInfo;
|
|
if (lDSVersionInfo != null) {
|
|
aSN1EncodableVector.add(lDSVersionInfo);
|
|
}
|
|
return new DERSequence(aSN1EncodableVector);
|
|
}
|
|
|
|
public LDSVersionInfo getVersionInfo() {
|
|
return this.versionInfo;
|
|
}
|
|
|
|
public int getVersion() {
|
|
return this.version.getValue().intValue();
|
|
}
|
|
|
|
public AlgorithmIdentifier getDigestAlgorithmIdentifier() {
|
|
return this.digestAlgorithmIdentifier;
|
|
}
|
|
|
|
public DataGroupHash[] getDatagroupHash() {
|
|
return this.datagroupHash;
|
|
}
|
|
|
|
public static LDSSecurityObject getInstance(Object obj) {
|
|
if (obj instanceof LDSSecurityObject) {
|
|
return (LDSSecurityObject) obj;
|
|
}
|
|
if (obj != null) {
|
|
return new LDSSecurityObject(ASN1Sequence.getInstance(obj));
|
|
}
|
|
return null;
|
|
}
|
|
|
|
private void checkDatagroupHashSeqSize(int i) {
|
|
if (i < 2 || i > 16) {
|
|
throw new IllegalArgumentException("wrong size in DataGroupHashValues : not in (2..16)");
|
|
}
|
|
}
|
|
|
|
public LDSSecurityObject(AlgorithmIdentifier algorithmIdentifier, DataGroupHash[] dataGroupHashArr, LDSVersionInfo lDSVersionInfo) {
|
|
this.version = new ASN1Integer(0L);
|
|
this.version = new ASN1Integer(1L);
|
|
this.digestAlgorithmIdentifier = algorithmIdentifier;
|
|
this.datagroupHash = dataGroupHashArr;
|
|
this.versionInfo = lDSVersionInfo;
|
|
checkDatagroupHashSeqSize(dataGroupHashArr.length);
|
|
}
|
|
|
|
public LDSSecurityObject(AlgorithmIdentifier algorithmIdentifier, DataGroupHash[] dataGroupHashArr) {
|
|
this.version = new ASN1Integer(0L);
|
|
this.version = new ASN1Integer(0L);
|
|
this.digestAlgorithmIdentifier = algorithmIdentifier;
|
|
this.datagroupHash = dataGroupHashArr;
|
|
checkDatagroupHashSeqSize(dataGroupHashArr.length);
|
|
}
|
|
|
|
private LDSSecurityObject(ASN1Sequence aSN1Sequence) {
|
|
this.version = new ASN1Integer(0L);
|
|
if (aSN1Sequence == null || aSN1Sequence.size() == 0) {
|
|
throw new IllegalArgumentException("null or empty sequence passed.");
|
|
}
|
|
Enumeration objects = aSN1Sequence.getObjects();
|
|
this.version = ASN1Integer.getInstance(objects.nextElement());
|
|
this.digestAlgorithmIdentifier = AlgorithmIdentifier.getInstance(objects.nextElement());
|
|
ASN1Sequence aSN1Sequence2 = ASN1Sequence.getInstance(objects.nextElement());
|
|
if (this.version.getValue().intValue() == 1) {
|
|
this.versionInfo = LDSVersionInfo.getInstance(objects.nextElement());
|
|
}
|
|
checkDatagroupHashSeqSize(aSN1Sequence2.size());
|
|
this.datagroupHash = new DataGroupHash[aSN1Sequence2.size()];
|
|
for (int i = 0; i < aSN1Sequence2.size(); i++) {
|
|
this.datagroupHash[i] = DataGroupHash.getInstance(aSN1Sequence2.getObjectAt(i));
|
|
}
|
|
}
|
|
}
|