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

PkiPublicationInfo

using Org.BouncyCastle.Math; using System; namespace Org.BouncyCastle.Asn1.Crmf { public class PkiPublicationInfo : Asn1Encodable { public static readonly DerInteger DontPublish = DerInteger.Zero; public static readonly DerInteger PleasePublish = DerInteger.One; private readonly DerInteger m_action; private readonly Asn1Sequence m_pubInfos; public virtual DerInteger Action => m_action; public static PkiPublicationInfo GetInstance(object obj) { if (obj == null) return null; PkiPublicationInfo pkiPublicationInfo = obj as PkiPublicationInfo; if (pkiPublicationInfo != null) return pkiPublicationInfo; return new PkiPublicationInfo(Asn1Sequence.GetInstance(obj)); } public static PkiPublicationInfo GetInstance(Asn1TaggedObject taggedObject, bool declaredExplicit) { return new PkiPublicationInfo(Asn1Sequence.GetInstance(taggedObject, declaredExplicit)); } public static PkiPublicationInfo GetTagged(Asn1TaggedObject taggedObject, bool declaredExplicit) { return new PkiPublicationInfo(Asn1Sequence.GetTagged(taggedObject, declaredExplicit)); } private PkiPublicationInfo(Asn1Sequence seq) { int count = seq.Count; if (count < 1 || count > 2) throw new ArgumentException("Bad sequence size: " + count.ToString(), "seq"); int sequencePosition = 0; m_action = DerInteger.GetInstance(seq[sequencePosition++]); m_pubInfos = Asn1Utilities.ReadOptional(seq, ref sequencePosition, Asn1Sequence.GetOptional); if (sequencePosition != count) throw new ArgumentException("Unexpected elements in sequence", "seq"); } public PkiPublicationInfo(BigInteger action) : this(new DerInteger(action)) { } public PkiPublicationInfo(DerInteger action) { if (action == null) throw new ArgumentNullException("action"); m_action = action; } public PkiPublicationInfo(SinglePubInfo pubInfo) : this((pubInfo == null) ? null : new SinglePubInfo[1] { pubInfo }) { } public PkiPublicationInfo(SinglePubInfo[] pubInfos) { m_action = PleasePublish; if (pubInfos != null) m_pubInfos = new DerSequence(pubInfos); } public virtual SinglePubInfo[] GetPubInfos() { return m_pubInfos?.MapElements(SinglePubInfo.GetInstance); } public override Asn1Object ToAsn1Object() { if (m_pubInfos != null) return new DerSequence(m_action, m_pubInfos); return new DerSequence(m_action); } } }