RecipientEncryptedKey
using System;
namespace Org.BouncyCastle.Asn1.Cms
{
public class RecipientEncryptedKey : Asn1Encodable
{
private readonly KeyAgreeRecipientIdentifier m_identifier;
private readonly Asn1OctetString m_encryptedKey;
public KeyAgreeRecipientIdentifier Identifier => m_identifier;
public Asn1OctetString EncryptedKey => m_encryptedKey;
public static RecipientEncryptedKey GetInstance(object obj)
{
if (obj == null)
return null;
RecipientEncryptedKey recipientEncryptedKey = obj as RecipientEncryptedKey;
if (recipientEncryptedKey != null)
return recipientEncryptedKey;
return new RecipientEncryptedKey(Asn1Sequence.GetInstance(obj));
}
public static RecipientEncryptedKey GetInstance(Asn1TaggedObject obj, bool isExplicit)
{
return new RecipientEncryptedKey(Asn1Sequence.GetInstance(obj, isExplicit));
}
public static RecipientEncryptedKey GetTagged(Asn1TaggedObject taggedObject, bool declaredExplicit)
{
return new RecipientEncryptedKey(Asn1Sequence.GetTagged(taggedObject, declaredExplicit));
}
private RecipientEncryptedKey(Asn1Sequence seq)
{
int count = seq.Count;
if (count != 2)
throw new ArgumentException("Bad sequence size: " + count.ToString(), "seq");
m_identifier = KeyAgreeRecipientIdentifier.GetInstance(seq[0]);
m_encryptedKey = Asn1OctetString.GetInstance(seq[1]);
}
public RecipientEncryptedKey(KeyAgreeRecipientIdentifier id, Asn1OctetString encryptedKey)
{
if (id == null)
throw new ArgumentNullException("id");
m_identifier = id;
if (encryptedKey == null)
throw new ArgumentNullException("encryptedKey");
m_encryptedKey = encryptedKey;
}
public override Asn1Object ToAsn1Object()
{
return new DerSequence(m_identifier, m_encryptedKey);
}
}
}