DEROctetStringParser.cs 718 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 DerOctetStringParser
  8. : Asn1OctetStringParser
  9. {
  10. private readonly DefiniteLengthInputStream stream;
  11. internal DerOctetStringParser(
  12. DefiniteLengthInputStream stream)
  13. {
  14. this.stream = stream;
  15. }
  16. public Stream GetOctetStream()
  17. {
  18. return stream;
  19. }
  20. public Asn1Object ToAsn1Object()
  21. {
  22. try
  23. {
  24. return new DerOctetString(stream.ToArray());
  25. }
  26. catch (IOException e)
  27. {
  28. throw new InvalidOperationException("IOException converting stream to byte array: " + e.Message, e);
  29. }
  30. }
  31. }
  32. }
  33. #endif