NullDigest.cs 843 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. #if !BESTHTTP_DISABLE_ALTERNATE_SSL && (!UNITY_WEBGL || UNITY_EDITOR)
  2. using System;
  3. using System.IO;
  4. namespace Org.BouncyCastle.Crypto.Digests
  5. {
  6. public class NullDigest : IDigest
  7. {
  8. private readonly MemoryStream bOut = new MemoryStream();
  9. public string AlgorithmName
  10. {
  11. get { return "NULL"; }
  12. }
  13. public int GetByteLength()
  14. {
  15. // TODO Is this okay?
  16. return 0;
  17. }
  18. public int GetDigestSize()
  19. {
  20. return (int) bOut.Length;
  21. }
  22. public void Update(byte b)
  23. {
  24. bOut.WriteByte(b);
  25. }
  26. public void BlockUpdate(byte[] inBytes, int inOff, int len)
  27. {
  28. bOut.Write(inBytes, inOff, len);
  29. }
  30. public int DoFinal(byte[] outBytes, int outOff)
  31. {
  32. byte[] res = bOut.ToArray();
  33. res.CopyTo(outBytes, outOff);
  34. Reset();
  35. return res.Length;
  36. }
  37. public void Reset()
  38. {
  39. bOut.SetLength(0);
  40. }
  41. }
  42. }
  43. #endif