<PackageReference Include="BouncyCastle.Cryptography" Version="2.6.2" />

ProofOfPossession

using System; namespace Org.BouncyCastle.Asn1.Crmf { public class ProofOfPossession : Asn1Encodable, IAsn1Choice { public const int TYPE_RA_VERIFIED = 0; public const int TYPE_SIGNING_KEY = 1; public const int TYPE_KEY_ENCIPHERMENT = 2; public const int TYPE_KEY_AGREEMENT = 3; private readonly int m_tagNo; private readonly Asn1Encodable m_obj; public virtual int Type => m_tagNo; public virtual Asn1Encodable Object => m_obj; public static ProofOfPossession GetInstance(object obj) { return Asn1Utilities.GetInstanceChoice(obj, GetOptional); } public static ProofOfPossession GetInstance(Asn1TaggedObject taggedObject, bool declaredExplicit) { return Asn1Utilities.GetInstanceChoice(taggedObject, declaredExplicit, GetInstance); } public static ProofOfPossession GetOptional(Asn1Encodable element) { if (element == null) throw new ArgumentNullException("element"); ProofOfPossession proofOfPossession = element as ProofOfPossession; if (proofOfPossession != null) return proofOfPossession; Asn1TaggedObject optional = Asn1TaggedObject.GetOptional(element); if (optional != null) { Asn1Encodable optionalBaseObject = GetOptionalBaseObject(optional); if (optionalBaseObject != null) return new ProofOfPossession(optional.TagNo, optionalBaseObject); } return null; } public static ProofOfPossession 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: return Asn1Null.GetTagged(taggedObject, false); case 1: return PopoSigningKey.GetTagged(taggedObject, false); case 2: case 3: return PopoPrivKey.GetTagged(taggedObject, true); } } return null; } private ProofOfPossession(int tagNo, Asn1Encodable obj) { m_tagNo = tagNo; if (obj == null) throw new ArgumentNullException("obj"); m_obj = obj; } public ProofOfPossession() : this(0, DerNull.Instance) { } public ProofOfPossession(PopoSigningKey Poposk) : this(1, Poposk) { } public ProofOfPossession(int type, PopoPrivKey privkey) : this(type, (Asn1Encodable)privkey) { } public override Asn1Object ToAsn1Object() { return new DerTaggedObject(false, m_tagNo, m_obj); } } }