package org.bouncycastle.asn1.cms; import org.bouncycastle.asn1.ASN1Choice; import org.bouncycastle.asn1.ASN1Object; import org.bouncycastle.asn1.ASN1Primitive; import org.bouncycastle.asn1.ASN1Sequence; import org.bouncycastle.asn1.ASN1TaggedObject; import org.bouncycastle.asn1.DERTaggedObject; /* loaded from: classes6.dex */ public class KeyAgreeRecipientIdentifier extends ASN1Object implements ASN1Choice { private IssuerAndSerialNumber issuerSerial; private RecipientKeyIdentifier rKeyID; @Override // org.bouncycastle.asn1.ASN1Object, org.bouncycastle.asn1.ASN1Encodable public ASN1Primitive toASN1Primitive() { IssuerAndSerialNumber issuerAndSerialNumber = this.issuerSerial; return issuerAndSerialNumber != null ? issuerAndSerialNumber.toASN1Primitive() : new DERTaggedObject(false, 0, this.rKeyID); } public RecipientKeyIdentifier getRKeyID() { return this.rKeyID; } public IssuerAndSerialNumber getIssuerAndSerialNumber() { return this.issuerSerial; } public static KeyAgreeRecipientIdentifier getInstance(ASN1TaggedObject aSN1TaggedObject, boolean z) { return getInstance(ASN1Sequence.getInstance(aSN1TaggedObject, z)); } public static KeyAgreeRecipientIdentifier getInstance(Object obj) { if (obj == null || (obj instanceof KeyAgreeRecipientIdentifier)) { return (KeyAgreeRecipientIdentifier) obj; } if (obj instanceof ASN1Sequence) { return new KeyAgreeRecipientIdentifier(IssuerAndSerialNumber.getInstance(obj)); } if (obj instanceof ASN1TaggedObject) { ASN1TaggedObject aSN1TaggedObject = (ASN1TaggedObject) obj; if (aSN1TaggedObject.getTagNo() == 0) { return new KeyAgreeRecipientIdentifier(RecipientKeyIdentifier.getInstance(aSN1TaggedObject, false)); } } StringBuilder sb = new StringBuilder("Invalid KeyAgreeRecipientIdentifier: "); sb.append(obj.getClass().getName()); throw new IllegalArgumentException(sb.toString()); } public KeyAgreeRecipientIdentifier(RecipientKeyIdentifier recipientKeyIdentifier) { this.issuerSerial = null; this.rKeyID = recipientKeyIdentifier; } public KeyAgreeRecipientIdentifier(IssuerAndSerialNumber issuerAndSerialNumber) { this.issuerSerial = issuerAndSerialNumber; this.rKeyID = null; } }