package org.bouncycastle.asn1.crmf; import org.bouncycastle.asn1.ASN1Encodable; import org.bouncycastle.asn1.ASN1EncodableVector; import org.bouncycastle.asn1.ASN1Object; import org.bouncycastle.asn1.ASN1Primitive; import org.bouncycastle.asn1.ASN1Sequence; import org.bouncycastle.asn1.DERSequence; import org.bouncycastle.asn1.DERUTF8String; import org.bouncycastle.asn1.pkcs.PrivateKeyInfo; import org.bouncycastle.asn1.x509.GeneralName; /* loaded from: classes6.dex */ public class EncKeyWithID extends ASN1Object { private final ASN1Encodable identifier; private final PrivateKeyInfo privKeyInfo; @Override // org.bouncycastle.asn1.ASN1Object, org.bouncycastle.asn1.ASN1Encodable public ASN1Primitive toASN1Primitive() { ASN1EncodableVector aSN1EncodableVector = new ASN1EncodableVector(); aSN1EncodableVector.add(this.privKeyInfo); ASN1Encodable aSN1Encodable = this.identifier; if (aSN1Encodable != null) { aSN1EncodableVector.add(aSN1Encodable); } return new DERSequence(aSN1EncodableVector); } public boolean isIdentifierUTF8String() { return this.identifier instanceof DERUTF8String; } public boolean hasIdentifier() { return this.identifier != null; } public PrivateKeyInfo getPrivateKey() { return this.privKeyInfo; } public ASN1Encodable getIdentifier() { return this.identifier; } public static EncKeyWithID getInstance(Object obj) { if (obj instanceof EncKeyWithID) { return (EncKeyWithID) obj; } if (obj != null) { return new EncKeyWithID(ASN1Sequence.getInstance(obj)); } return null; } public EncKeyWithID(PrivateKeyInfo privateKeyInfo, GeneralName generalName) { this.privKeyInfo = privateKeyInfo; this.identifier = generalName; } public EncKeyWithID(PrivateKeyInfo privateKeyInfo, DERUTF8String dERUTF8String) { this.privKeyInfo = privateKeyInfo; this.identifier = dERUTF8String; } public EncKeyWithID(PrivateKeyInfo privateKeyInfo) { this.privKeyInfo = privateKeyInfo; this.identifier = null; } private EncKeyWithID(ASN1Sequence aSN1Sequence) { ASN1Encodable aSN1Encodable; this.privKeyInfo = PrivateKeyInfo.getInstance(aSN1Sequence.getObjectAt(0)); if (aSN1Sequence.size() > 1) { boolean z = aSN1Sequence.getObjectAt(1) instanceof DERUTF8String; aSN1Encodable = aSN1Sequence.getObjectAt(1); if (!z) { aSN1Encodable = GeneralName.getInstance(aSN1Encodable); } } else { aSN1Encodable = null; } this.identifier = aSN1Encodable; } }