package org.bouncycastle.asn1.x509; import java.io.IOException; import java.util.Enumeration; import org.bouncycastle.asn1.ASN1Encodable; import org.bouncycastle.asn1.ASN1EncodableVector; import org.bouncycastle.asn1.ASN1InputStream; import org.bouncycastle.asn1.ASN1Object; 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 SubjectPublicKeyInfo extends ASN1Object { private AlgorithmIdentifier algId; private DERBitString keyData; @Override // org.bouncycastle.asn1.ASN1Object, org.bouncycastle.asn1.ASN1Encodable public ASN1Primitive toASN1Primitive() { ASN1EncodableVector aSN1EncodableVector = new ASN1EncodableVector(); aSN1EncodableVector.add(this.algId); aSN1EncodableVector.add(this.keyData); return new DERSequence(aSN1EncodableVector); } public ASN1Primitive parsePublicKey() throws IOException { return new ASN1InputStream(this.keyData.getOctets()).readObject(); } public DERBitString getPublicKeyData() { return this.keyData; } public ASN1Primitive getPublicKey() throws IOException { return new ASN1InputStream(this.keyData.getOctets()).readObject(); } public AlgorithmIdentifier getAlgorithmId() { return this.algId; } public AlgorithmIdentifier getAlgorithm() { return this.algId; } public static SubjectPublicKeyInfo getInstance(ASN1TaggedObject aSN1TaggedObject, boolean z) { return getInstance(ASN1Sequence.getInstance(aSN1TaggedObject, z)); } public static SubjectPublicKeyInfo getInstance(Object obj) { if (obj instanceof SubjectPublicKeyInfo) { return (SubjectPublicKeyInfo) obj; } if (obj != null) { return new SubjectPublicKeyInfo(ASN1Sequence.getInstance(obj)); } return null; } public SubjectPublicKeyInfo(AlgorithmIdentifier algorithmIdentifier, byte[] bArr) { this.keyData = new DERBitString(bArr); this.algId = algorithmIdentifier; } public SubjectPublicKeyInfo(AlgorithmIdentifier algorithmIdentifier, ASN1Encodable aSN1Encodable) throws IOException { this.keyData = new DERBitString(aSN1Encodable); this.algId = algorithmIdentifier; } public SubjectPublicKeyInfo(ASN1Sequence aSN1Sequence) { if (aSN1Sequence.size() != 2) { StringBuilder sb = new StringBuilder("Bad sequence size: "); sb.append(aSN1Sequence.size()); throw new IllegalArgumentException(sb.toString()); } Enumeration objects = aSN1Sequence.getObjects(); this.algId = AlgorithmIdentifier.getInstance(objects.nextElement()); this.keyData = DERBitString.getInstance(objects.nextElement()); } }