NullDigest.cs 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  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.Utilities.IO;
  6. namespace BestHTTP.SecureProtocol.Org.BouncyCastle.Crypto.Digests
  7. {
  8. public class NullDigest : IDigest
  9. {
  10. private readonly MemoryStream bOut = new MemoryStream();
  11. public string AlgorithmName
  12. {
  13. get { return "NULL"; }
  14. }
  15. public int GetByteLength()
  16. {
  17. // TODO Is this okay?
  18. return 0;
  19. }
  20. public int GetDigestSize()
  21. {
  22. return (int)bOut.Length;
  23. }
  24. public void Update(byte b)
  25. {
  26. bOut.WriteByte(b);
  27. }
  28. public void BlockUpdate(byte[] inBytes, int inOff, int len)
  29. {
  30. bOut.Write(inBytes, inOff, len);
  31. }
  32. public int DoFinal(byte[] outBytes, int outOff)
  33. {
  34. try
  35. {
  36. return Streams.WriteBufTo(bOut, outBytes, outOff);
  37. }
  38. finally
  39. {
  40. Reset();
  41. }
  42. }
  43. public void Reset()
  44. {
  45. bOut.SetLength(0);
  46. }
  47. }
  48. }
  49. #pragma warning restore
  50. #endif