GeneralPkiMessage.cs 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. #if !BESTHTTP_DISABLE_ALTERNATE_SSL && (!UNITY_WEBGL || UNITY_EDITOR)
  2. #pragma warning disable
  3. using Best.HTTP.SecureProtocol.Org.BouncyCastle.Asn1;
  4. using Best.HTTP.SecureProtocol.Org.BouncyCastle.Asn1.Cmp;
  5. namespace Best.HTTP.SecureProtocol.Org.BouncyCastle.Cmp
  6. {
  7. public class GeneralPkiMessage
  8. {
  9. private readonly PkiMessage m_pkiMessage;
  10. private static PkiMessage ParseBytes(byte[] encoding)
  11. {
  12. return PkiMessage.GetInstance(Asn1Object.FromByteArray(encoding));
  13. }
  14. /// <summary>
  15. /// Wrap a PKIMessage ASN.1 structure.
  16. /// </summary>
  17. /// <param name="pkiMessage">PKI message.</param>
  18. public GeneralPkiMessage(PkiMessage pkiMessage)
  19. {
  20. this.m_pkiMessage = pkiMessage;
  21. }
  22. /// <summary>
  23. /// Create a PKIMessage from the passed in bytes.
  24. /// </summary>
  25. /// <param name="encoding">BER/DER encoding of the PKIMessage</param>
  26. public GeneralPkiMessage(byte[] encoding)
  27. : this(ParseBytes(encoding))
  28. {
  29. }
  30. public virtual PkiHeader Header => m_pkiMessage.Header;
  31. public virtual PkiBody Body => m_pkiMessage.Body;
  32. /// <summary>
  33. /// Return true if this message has protection bits on it. A return value of true
  34. /// indicates the message can be used to construct a ProtectedPKIMessage.
  35. /// </summary>
  36. public virtual bool HasProtection => m_pkiMessage.Protection != null;
  37. public virtual PkiMessage ToAsn1Structure() => m_pkiMessage;
  38. }
  39. }
  40. #pragma warning restore
  41. #endif