DigestInputBuffer.cs 834 B

12345678910111213141516171819202122232425262728293031323334353637383940
  1. #if !BESTHTTP_DISABLE_ALTERNATE_SSL && (!UNITY_WEBGL || UNITY_EDITOR)
  2. using System.IO;
  3. using Org.BouncyCastle.Utilities.IO;
  4. namespace Org.BouncyCastle.Crypto.Tls
  5. {
  6. internal class DigestInputBuffer
  7. : MemoryStream
  8. {
  9. internal void UpdateDigest(IDigest d)
  10. {
  11. WriteTo(new DigStream(d));
  12. }
  13. private class DigStream
  14. : BaseOutputStream
  15. {
  16. private readonly IDigest d;
  17. internal DigStream(IDigest d)
  18. {
  19. this.d = d;
  20. }
  21. public override void WriteByte(byte b)
  22. {
  23. d.Update(b);
  24. }
  25. public override void Write(byte[] buf, int off, int len)
  26. {
  27. d.BlockUpdate(buf, off, len);
  28. }
  29. }
  30. }
  31. }
  32. #endif