package org.bouncycastle.asn1.cms; import org.bouncycastle.asn1.ASN1Choice; import org.bouncycastle.asn1.ASN1Encodable; 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.DERTaggedObject; import org.bouncycastle.asn1.x509.SubjectKeyIdentifier; /* loaded from: classes6.dex */ public class OriginatorIdentifierOrKey extends ASN1Object implements ASN1Choice { private ASN1Encodable id; @Override // org.bouncycastle.asn1.ASN1Object, org.bouncycastle.asn1.ASN1Encodable public ASN1Primitive toASN1Primitive() { return this.id.toASN1Primitive(); } public SubjectKeyIdentifier getSubjectKeyIdentifier() { ASN1Encodable aSN1Encodable = this.id; if ((aSN1Encodable instanceof ASN1TaggedObject) && ((ASN1TaggedObject) aSN1Encodable).getTagNo() == 0) { return SubjectKeyIdentifier.getInstance((ASN1TaggedObject) this.id, false); } return null; } public OriginatorPublicKey getOriginatorKey() { ASN1Encodable aSN1Encodable = this.id; if ((aSN1Encodable instanceof ASN1TaggedObject) && ((ASN1TaggedObject) aSN1Encodable).getTagNo() == 1) { return OriginatorPublicKey.getInstance((ASN1TaggedObject) this.id, false); } return null; } public IssuerAndSerialNumber getIssuerAndSerialNumber() { ASN1Encodable aSN1Encodable = this.id; if (aSN1Encodable instanceof IssuerAndSerialNumber) { return (IssuerAndSerialNumber) aSN1Encodable; } return null; } public ASN1Encodable getId() { return this.id; } public static OriginatorIdentifierOrKey getInstance(ASN1TaggedObject aSN1TaggedObject, boolean z) { if (z) { return getInstance(aSN1TaggedObject.getObject()); } throw new IllegalArgumentException("Can't implicitly tag OriginatorIdentifierOrKey"); } public static OriginatorIdentifierOrKey getInstance(Object obj) { if (obj == null || (obj instanceof OriginatorIdentifierOrKey)) { return (OriginatorIdentifierOrKey) obj; } if ((obj instanceof IssuerAndSerialNumber) || (obj instanceof ASN1Sequence)) { return new OriginatorIdentifierOrKey(IssuerAndSerialNumber.getInstance(obj)); } if (obj instanceof ASN1TaggedObject) { ASN1TaggedObject aSN1TaggedObject = (ASN1TaggedObject) obj; if (aSN1TaggedObject.getTagNo() == 0) { return new OriginatorIdentifierOrKey(SubjectKeyIdentifier.getInstance(aSN1TaggedObject, false)); } if (aSN1TaggedObject.getTagNo() == 1) { return new OriginatorIdentifierOrKey(OriginatorPublicKey.getInstance(aSN1TaggedObject, false)); } } StringBuilder sb = new StringBuilder("Invalid OriginatorIdentifierOrKey: "); sb.append(obj.getClass().getName()); throw new IllegalArgumentException(sb.toString()); } public OriginatorIdentifierOrKey(SubjectKeyIdentifier subjectKeyIdentifier) { this.id = new DERTaggedObject(false, 0, subjectKeyIdentifier); } public OriginatorIdentifierOrKey(OriginatorPublicKey originatorPublicKey) { this.id = new DERTaggedObject(false, 1, originatorPublicKey); } public OriginatorIdentifierOrKey(IssuerAndSerialNumber issuerAndSerialNumber) { this.id = issuerAndSerialNumber; } public OriginatorIdentifierOrKey(ASN1Primitive aSN1Primitive) { this.id = aSN1Primitive; } public OriginatorIdentifierOrKey(ASN1OctetString aSN1OctetString) { this(new SubjectKeyIdentifier(aSN1OctetString.getOctets())); } }