GeneralPkiMessage.cs 1.7 KB

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