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

SignedData

public class SignedData : Asn1Encodable
using System; namespace Org.BouncyCastle.Asn1.Pkcs { public class SignedData : Asn1Encodable { private readonly DerInteger m_version; private readonly Asn1Set m_digestAlgorithms; private readonly ContentInfo m_contentInfo; private readonly Asn1Set m_certificates; private readonly Asn1Set m_crls; private readonly Asn1Set m_signerInfos; public DerInteger Version => m_version; public Asn1Set DigestAlgorithms => m_digestAlgorithms; public ContentInfo ContentInfo => m_contentInfo; public Asn1Set Certificates => m_certificates; public Asn1Set Crls => m_crls; public Asn1Set SignerInfos => m_signerInfos; public static SignedData GetInstance(object obj) { if (obj == null) return null; SignedData signedData = obj as SignedData; if (signedData != null) return signedData; return new SignedData(Asn1Sequence.GetInstance(obj)); } public static SignedData GetInstance(Asn1TaggedObject taggedObject, bool declaredExplicit) { return new SignedData(Asn1Sequence.GetInstance(taggedObject, declaredExplicit)); } public static SignedData GetTagged(Asn1TaggedObject taggedObject, bool declaredExplicit) { return new SignedData(Asn1Sequence.GetTagged(taggedObject, declaredExplicit)); } private SignedData(Asn1Sequence seq) { int count = seq.Count; int sequencePosition = 0; if (count < 4 || count > 6) throw new ArgumentException("Bad sequence size: " + count.ToString(), "seq"); m_version = DerInteger.GetInstance(seq[sequencePosition++]); m_digestAlgorithms = Asn1Set.GetInstance(seq[sequencePosition++]); m_contentInfo = ContentInfo.GetInstance(seq[sequencePosition++]); m_certificates = Asn1Utilities.ReadOptionalContextTagged(seq, ref sequencePosition, 0, false, Asn1Set.GetTagged); m_crls = Asn1Utilities.ReadOptionalContextTagged(seq, ref sequencePosition, 1, false, Asn1Set.GetTagged); m_signerInfos = Asn1Set.GetInstance(seq[sequencePosition++]); if (sequencePosition != count) throw new ArgumentException("Unexpected elements in sequence", "seq"); } public SignedData(DerInteger _version, Asn1Set _digestAlgorithms, ContentInfo _contentInfo, Asn1Set _certificates, Asn1Set _crls, Asn1Set _signerInfos) { if (_version == null) throw new ArgumentNullException("_version"); m_version = _version; if (_digestAlgorithms == null) throw new ArgumentNullException("_digestAlgorithms"); m_digestAlgorithms = _digestAlgorithms; if (_contentInfo == null) throw new ArgumentNullException("_contentInfo"); m_contentInfo = _contentInfo; m_certificates = _certificates; m_crls = _crls; if (_signerInfos == null) throw new ArgumentNullException("_signerInfos"); m_signerInfos = _signerInfos; } public override Asn1Object ToAsn1Object() { Asn1EncodableVector asn1EncodableVector = new Asn1EncodableVector(6); asn1EncodableVector.Add(m_version, m_digestAlgorithms, m_contentInfo); asn1EncodableVector.AddOptionalTagged(false, 0, m_certificates); asn1EncodableVector.AddOptionalTagged(false, 1, m_crls); asn1EncodableVector.Add(m_signerInfos); return new BerSequence(asn1EncodableVector); } } }