ProtectedPart.cs 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. #if !BESTHTTP_DISABLE_ALTERNATE_SSL && (!UNITY_WEBGL || UNITY_EDITOR)
  2. #pragma warning disable
  3. using System;
  4. using BestHTTP.SecureProtocol.Org.BouncyCastle.Utilities;
  5. namespace BestHTTP.SecureProtocol.Org.BouncyCastle.Asn1.Cmp
  6. {
  7. public class ProtectedPart
  8. : Asn1Encodable
  9. {
  10. private readonly PkiHeader header;
  11. private readonly PkiBody body;
  12. private ProtectedPart(Asn1Sequence seq)
  13. {
  14. header = PkiHeader.GetInstance(seq[0]);
  15. body = PkiBody.GetInstance(seq[1]);
  16. }
  17. public static ProtectedPart GetInstance(object obj)
  18. {
  19. if (obj is ProtectedPart)
  20. return (ProtectedPart)obj;
  21. if (obj is Asn1Sequence)
  22. return new ProtectedPart((Asn1Sequence)obj);
  23. throw new ArgumentException("Invalid object: " + BestHTTP.SecureProtocol.Org.BouncyCastle.Utilities.Platform.GetTypeName(obj), "obj");
  24. }
  25. public ProtectedPart(PkiHeader header, PkiBody body)
  26. {
  27. this.header = header;
  28. this.body = body;
  29. }
  30. public virtual PkiHeader Header
  31. {
  32. get { return header; }
  33. }
  34. public virtual PkiBody Body
  35. {
  36. get { return body; }
  37. }
  38. /**
  39. * <pre>
  40. * ProtectedPart ::= SEQUENCE {
  41. * header PKIHeader,
  42. * body PKIBody
  43. * }
  44. * </pre>
  45. * @return a basic ASN.1 object representation.
  46. */
  47. public override Asn1Object ToAsn1Object()
  48. {
  49. return new DerSequence(header, body);
  50. }
  51. }
  52. }
  53. #pragma warning restore
  54. #endif