using Org.BouncyCastle.Asn1; using Org.BouncyCastle.Asn1.Cmp; namespace Org.BouncyCastle.Cmp { public class GeneralPkiMessage { private readonly PkiMessage m_pkiMessage; private static PkiMessage ParseBytes(byte[] encoding) { return PkiMessage.GetInstance(Asn1Object.FromByteArray(encoding)); } /// /// Wrap a PKIMessage ASN.1 structure. /// /// PKI message. public GeneralPkiMessage(PkiMessage pkiMessage) { this.m_pkiMessage = pkiMessage; } /// /// Create a PKIMessage from the passed in bytes. /// /// BER/DER encoding of the PKIMessage public GeneralPkiMessage(byte[] encoding) : this(ParseBytes(encoding)) { } public virtual PkiHeader Header => m_pkiMessage.Header; public virtual PkiBody Body => m_pkiMessage.Body; /// /// Return true if this message has protection bits on it. A return value of true /// indicates the message can be used to construct a ProtectedPKIMessage. /// public virtual bool HasProtection => m_pkiMessage.Protection != null; public virtual PkiMessage ToAsn1Structure() => m_pkiMessage; } }