CMSProcessableByteArray.cs 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. #if !BESTHTTP_DISABLE_ALTERNATE_SSL && (!UNITY_WEBGL || UNITY_EDITOR)
  2. #pragma warning disable
  3. using System;
  4. using System.IO;
  5. using BestHTTP.SecureProtocol.Org.BouncyCastle.Asn1;
  6. using BestHTTP.SecureProtocol.Org.BouncyCastle.Asn1.Cms;
  7. namespace BestHTTP.SecureProtocol.Org.BouncyCastle.Cms
  8. {
  9. /**
  10. * a holding class for a byte array of data to be processed.
  11. */
  12. public class CmsProcessableByteArray
  13. : CmsProcessable, CmsReadable
  14. {
  15. private readonly DerObjectIdentifier type;
  16. private readonly byte[] bytes;
  17. public CmsProcessableByteArray(byte[] bytes)
  18. {
  19. type = CmsObjectIdentifiers.Data;
  20. this.bytes = bytes;
  21. }
  22. public CmsProcessableByteArray(DerObjectIdentifier type, byte[] bytes)
  23. {
  24. this.bytes = bytes;
  25. this.type = type;
  26. }
  27. public DerObjectIdentifier Type
  28. {
  29. get { return type; }
  30. }
  31. public virtual Stream GetInputStream()
  32. {
  33. return new MemoryStream(bytes, false);
  34. }
  35. public virtual void Write(Stream zOut)
  36. {
  37. zOut.Write(bytes, 0, bytes.Length);
  38. }
  39. /// <returns>A clone of the byte array</returns>
  40. [Obsolete]
  41. public virtual object GetContent()
  42. {
  43. return bytes.Clone();
  44. }
  45. }
  46. }
  47. #pragma warning restore
  48. #endif