BerSequence.cs 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. #if !BESTHTTP_DISABLE_ALTERNATE_SSL && (!UNITY_WEBGL || UNITY_EDITOR)
  2. namespace Org.BouncyCastle.Asn1
  3. {
  4. public class BerSequence
  5. : DerSequence
  6. {
  7. public static new readonly BerSequence Empty = new BerSequence();
  8. public static new BerSequence FromVector(
  9. Asn1EncodableVector v)
  10. {
  11. return v.Count < 1 ? Empty : new BerSequence(v);
  12. }
  13. /**
  14. * create an empty sequence
  15. */
  16. public BerSequence()
  17. {
  18. }
  19. /**
  20. * create a sequence containing one object
  21. */
  22. public BerSequence(
  23. Asn1Encodable obj)
  24. : base(obj)
  25. {
  26. }
  27. public BerSequence(
  28. params Asn1Encodable[] v)
  29. : base(v)
  30. {
  31. }
  32. /**
  33. * create a sequence containing a vector of objects.
  34. */
  35. public BerSequence(
  36. Asn1EncodableVector v)
  37. : base(v)
  38. {
  39. }
  40. /*
  41. */
  42. internal override void Encode(
  43. DerOutputStream derOut)
  44. {
  45. if (derOut is Asn1OutputStream || derOut is BerOutputStream)
  46. {
  47. derOut.WriteByte(Asn1Tags.Sequence | Asn1Tags.Constructed);
  48. derOut.WriteByte(0x80);
  49. foreach (Asn1Encodable o in this)
  50. {
  51. derOut.WriteObject(o);
  52. }
  53. derOut.WriteByte(0x00);
  54. derOut.WriteByte(0x00);
  55. }
  56. else
  57. {
  58. base.Encode(derOut);
  59. }
  60. }
  61. }
  62. }
  63. #endif