<PackageReference Include="BouncyCastle.Cryptography" Version="2.7.0-beta.98" />

KekRecipientInfo

using Org.BouncyCastle.Asn1.X509; using System; namespace Org.BouncyCastle.Asn1.Cms { public class KekRecipientInfo : Asn1Encodable { private readonly DerInteger m_version; private readonly KekIdentifier m_kekID; private readonly AlgorithmIdentifier m_keyEncryptionAlgorithm; private readonly Asn1OctetString m_encryptedKey; public DerInteger Version => m_version; public KekIdentifier KekID => m_kekID; public AlgorithmIdentifier KeyEncryptionAlgorithm => m_keyEncryptionAlgorithm; public Asn1OctetString EncryptedKey => m_encryptedKey; public static KekRecipientInfo GetInstance(object obj) { if (obj == null) return null; KekRecipientInfo kekRecipientInfo = obj as KekRecipientInfo; if (kekRecipientInfo != null) return kekRecipientInfo; return new KekRecipientInfo(Asn1Sequence.GetInstance(obj)); } public static KekRecipientInfo GetInstance(Asn1TaggedObject obj, bool explicitly) { return new KekRecipientInfo(Asn1Sequence.GetInstance(obj, explicitly)); } public static KekRecipientInfo GetTagged(Asn1TaggedObject taggedObject, bool declaredExplicit) { return new KekRecipientInfo(Asn1Sequence.GetTagged(taggedObject, declaredExplicit)); } public KekRecipientInfo(KekIdentifier kekID, AlgorithmIdentifier keyEncryptionAlgorithm, Asn1OctetString encryptedKey) { m_version = DerInteger.Four; if (kekID == null) throw new ArgumentNullException("kekID"); m_kekID = kekID; if (keyEncryptionAlgorithm == null) throw new ArgumentNullException("keyEncryptionAlgorithm"); m_keyEncryptionAlgorithm = keyEncryptionAlgorithm; if (encryptedKey == null) throw new ArgumentNullException("encryptedKey"); m_encryptedKey = encryptedKey; } [Obsolete("Use 'GetInstance' instead")] public KekRecipientInfo(Asn1Sequence seq) { int count = seq.Count; if (count != 4) throw new ArgumentException("Bad sequence size: " + count.ToString(), "seq"); m_version = DerInteger.GetInstance(seq[0]); m_kekID = KekIdentifier.GetInstance(seq[1]); m_keyEncryptionAlgorithm = AlgorithmIdentifier.GetInstance(seq[2]); m_encryptedKey = Asn1OctetString.GetInstance(seq[3]); } public override Asn1Object ToAsn1Object() { return new DerSequence(m_version, m_kekID, m_keyEncryptionAlgorithm, m_encryptedKey); } } }