BEROctetStringParser.cs 738 B

123456789101112131415161718192021222324252627282930313233343536373839
  1. #if !BESTHTTP_DISABLE_ALTERNATE_SSL && (!UNITY_WEBGL || UNITY_EDITOR)
  2. using System;
  3. using System.IO;
  4. using Org.BouncyCastle.Utilities.IO;
  5. namespace Org.BouncyCastle.Asn1
  6. {
  7. public class BerOctetStringParser
  8. : Asn1OctetStringParser
  9. {
  10. private readonly Asn1StreamParser _parser;
  11. internal BerOctetStringParser(
  12. Asn1StreamParser parser)
  13. {
  14. _parser = parser;
  15. }
  16. public Stream GetOctetStream()
  17. {
  18. return new ConstructedOctetStream(_parser);
  19. }
  20. public Asn1Object ToAsn1Object()
  21. {
  22. try
  23. {
  24. return new BerOctetString(Streams.ReadAll(GetOctetStream()));
  25. }
  26. catch (IOException e)
  27. {
  28. throw new Asn1ParsingException("IOException converting stream to byte array: " + e.Message, e);
  29. }
  30. }
  31. }
  32. }
  33. #endif