BerSet.cs 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  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
  6. {
  7. public class BerSet
  8. : DerSet
  9. {
  10. public static new readonly BerSet Empty = new BerSet();
  11. public static new BerSet FromVector(Asn1EncodableVector elementVector)
  12. {
  13. return elementVector.Count < 1 ? Empty : new BerSet(elementVector);
  14. }
  15. internal static new BerSet FromVector(Asn1EncodableVector elementVector, bool needsSorting)
  16. {
  17. return elementVector.Count < 1 ? Empty : new BerSet(elementVector, needsSorting);
  18. }
  19. /**
  20. * create an empty sequence
  21. */
  22. public BerSet()
  23. : base()
  24. {
  25. }
  26. /**
  27. * create a set containing one object
  28. */
  29. public BerSet(Asn1Encodable element)
  30. : base(element)
  31. {
  32. }
  33. /**
  34. * create a set containing a vector of objects.
  35. */
  36. public BerSet(Asn1EncodableVector elementVector)
  37. : base(elementVector, false)
  38. {
  39. }
  40. internal BerSet(Asn1EncodableVector elementVector, bool needsSorting)
  41. : base(elementVector, needsSorting)
  42. {
  43. }
  44. internal override int EncodedLength(bool withID)
  45. {
  46. throw BestHTTP.SecureProtocol.Org.BouncyCastle.Utilities.Platform.CreateNotImplementedException("BerSet.EncodedLength");
  47. }
  48. internal override void Encode(Asn1OutputStream asn1Out, bool withID)
  49. {
  50. if (asn1Out.IsBer)
  51. {
  52. asn1Out.WriteEncodingIL(withID, Asn1Tags.Constructed | Asn1Tags.Set, elements);
  53. }
  54. else
  55. {
  56. base.Encode(asn1Out, withID);
  57. }
  58. }
  59. }
  60. }
  61. #pragma warning restore
  62. #endif