MacSink.cs 820 B

123456789101112131415161718192021222324252627282930313233343536373839
  1. #if !BESTHTTP_DISABLE_ALTERNATE_SSL && (!UNITY_WEBGL || UNITY_EDITOR)
  2. #pragma warning disable
  3. using System;
  4. using BestHTTP.SecureProtocol.Org.BouncyCastle.Utilities.IO;
  5. namespace BestHTTP.SecureProtocol.Org.BouncyCastle.Crypto.IO
  6. {
  7. public class MacSink
  8. : BaseOutputStream
  9. {
  10. private readonly IMac mMac;
  11. public MacSink(IMac mac)
  12. {
  13. this.mMac = mac;
  14. }
  15. public virtual IMac Mac
  16. {
  17. get { return mMac; }
  18. }
  19. public override void WriteByte(byte b)
  20. {
  21. mMac.Update(b);
  22. }
  23. public override void Write(byte[] buf, int off, int len)
  24. {
  25. if (len > 0)
  26. {
  27. mMac.BlockUpdate(buf, off, len);
  28. }
  29. }
  30. }
  31. }
  32. #pragma warning restore
  33. #endif