package org.bouncycastle.asn1.x509; import java.util.Enumeration; import java.util.Hashtable; import java.util.Vector; import org.bouncycastle.asn1.ASN1Encodable; import org.bouncycastle.asn1.ASN1EncodableVector; 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.DERSequence; /* loaded from: classes6.dex */ public class ExtendedKeyUsage extends ASN1Object { ASN1Sequence seq; Hashtable usageTable = new Hashtable(); @Override // org.bouncycastle.asn1.ASN1Object, org.bouncycastle.asn1.ASN1Encodable public ASN1Primitive toASN1Primitive() { return this.seq; } public int size() { return this.usageTable.size(); } public boolean hasKeyPurposeId(KeyPurposeId keyPurposeId) { return this.usageTable.get(keyPurposeId) != null; } public KeyPurposeId[] getUsages() { KeyPurposeId[] keyPurposeIdArr = new KeyPurposeId[this.seq.size()]; Enumeration objects = this.seq.getObjects(); int i = 0; while (objects.hasMoreElements()) { keyPurposeIdArr[i] = KeyPurposeId.getInstance(objects.nextElement()); i++; } return keyPurposeIdArr; } public static ExtendedKeyUsage getInstance(ASN1TaggedObject aSN1TaggedObject, boolean z) { return getInstance(ASN1Sequence.getInstance(aSN1TaggedObject, z)); } public static ExtendedKeyUsage getInstance(Object obj) { if (obj instanceof ExtendedKeyUsage) { return (ExtendedKeyUsage) obj; } if (obj != null) { return new ExtendedKeyUsage(ASN1Sequence.getInstance(obj)); } return null; } public static ExtendedKeyUsage fromExtensions(Extensions extensions) { return getInstance(extensions.getExtensionParsedValue(Extension.extendedKeyUsage)); } public ExtendedKeyUsage(KeyPurposeId[] keyPurposeIdArr) { ASN1EncodableVector aSN1EncodableVector = new ASN1EncodableVector(); for (int i = 0; i != keyPurposeIdArr.length; i++) { aSN1EncodableVector.add(keyPurposeIdArr[i]); Hashtable hashtable = this.usageTable; KeyPurposeId keyPurposeId = keyPurposeIdArr[i]; hashtable.put(keyPurposeId, keyPurposeId); } this.seq = new DERSequence(aSN1EncodableVector); } public ExtendedKeyUsage(KeyPurposeId keyPurposeId) { this.seq = new DERSequence(keyPurposeId); this.usageTable.put(keyPurposeId, keyPurposeId); } private ExtendedKeyUsage(ASN1Sequence aSN1Sequence) { this.seq = aSN1Sequence; Enumeration objects = aSN1Sequence.getObjects(); while (objects.hasMoreElements()) { ASN1Encodable aSN1Encodable = (ASN1Encodable) objects.nextElement(); if (!(aSN1Encodable.toASN1Primitive() instanceof ASN1ObjectIdentifier)) { throw new IllegalArgumentException("Only ASN1ObjectIdentifiers allowed in ExtendedKeyUsage."); } this.usageTable.put(aSN1Encodable, aSN1Encodable); } } public ExtendedKeyUsage(Vector vector) { ASN1EncodableVector aSN1EncodableVector = new ASN1EncodableVector(); Enumeration elements = vector.elements(); while (elements.hasMoreElements()) { KeyPurposeId keyPurposeId = KeyPurposeId.getInstance(elements.nextElement()); aSN1EncodableVector.add(keyPurposeId); this.usageTable.put(keyPurposeId, keyPurposeId); } this.seq = new DERSequence(aSN1EncodableVector); } }