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

PopoPrivKey

using Org.BouncyCastle.Asn1.Cms; using System; namespace Org.BouncyCastle.Asn1.Crmf { public class PopoPrivKey : Asn1Encodable, IAsn1Choice { public const int thisMessage = 0; public const int subsequentMessage = 1; public const int dhMAC = 2; public const int agreeMAC = 3; public const int encryptedKey = 4; private readonly int m_tagNo; private readonly Asn1Encodable m_obj; public virtual int Type => m_tagNo; public virtual Asn1Encodable Value => m_obj; public static PopoPrivKey GetInstance(object obj) { return Asn1Utilities.GetInstanceChoice(obj, GetOptional); } public static PopoPrivKey GetInstance(Asn1TaggedObject tagged, bool isExplicit) { return Asn1Utilities.GetInstanceChoice(tagged, isExplicit, GetInstance); } public static PopoPrivKey GetOptional(Asn1Encodable element) { if (element == null) throw new ArgumentNullException("element"); PopoPrivKey popoPrivKey = element as PopoPrivKey; if (popoPrivKey != null) return popoPrivKey; Asn1TaggedObject optional = Asn1TaggedObject.GetOptional(element); if (optional != null) { Asn1Encodable optionalBaseObject = GetOptionalBaseObject(optional); if (optionalBaseObject != null) return new PopoPrivKey(optional.TagNo, optionalBaseObject); } return null; } public static PopoPrivKey GetTagged(Asn1TaggedObject taggedObject, bool declaredExplicit) { return Asn1Utilities.GetTaggedChoice(taggedObject, declaredExplicit, GetInstance); } private static Asn1Encodable GetOptionalBaseObject(Asn1TaggedObject taggedObject) { if (taggedObject.HasContextTag()) { switch (taggedObject.TagNo) { case 0: case 2: return DerBitString.GetTagged(taggedObject, false); case 1: return SubsequentMessage.ValueOf(DerInteger.GetTagged(taggedObject, false).IntValueExact); case 3: return PKMacValue.GetTagged(taggedObject, false); case 4: return EnvelopedData.GetTagged(taggedObject, false); } } return null; } private PopoPrivKey(int tagNo, Asn1Encodable obj) { m_tagNo = tagNo; if (obj == null) throw new ArgumentNullException("obj"); m_obj = obj; } public PopoPrivKey(PKMacValue pkMacValue) : this(3, pkMacValue) { } public PopoPrivKey(SubsequentMessage msg) : this(1, msg) { } public override Asn1Object ToAsn1Object() { return new DerTaggedObject(false, m_tagNo, m_obj); } } }