IDigest.cs 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. #if !BESTHTTP_DISABLE_ALTERNATE_SSL && (!UNITY_WEBGL || UNITY_EDITOR)
  2. #pragma warning disable
  3. using System;
  4. namespace Best.HTTP.SecureProtocol.Org.BouncyCastle.Crypto
  5. {
  6. /// <remarks>Base interface for a message digest.</remarks>
  7. public interface IDigest
  8. {
  9. /// <summary>The algorithm name.</summary>
  10. string AlgorithmName { get; }
  11. /// <summary>Return the size, in bytes, of the digest produced by this message digest.</summary>
  12. /// <returns>the size, in bytes, of the digest produced by this message digest.</returns>
  13. int GetDigestSize();
  14. /// <summary>Return the size, in bytes, of the internal buffer used by this digest.</summary>
  15. /// <returns>the size, in bytes, of the internal buffer used by this digest.</returns>
  16. int GetByteLength();
  17. /// <summary>Update the message digest with a single byte.</summary>
  18. /// <param name="input">the input byte to be entered.</param>
  19. void Update(byte input);
  20. /// <summary>Update the message digest with a block of bytes.</summary>
  21. /// <param name="input">the byte array containing the data.</param>
  22. /// <param name="inOff">the offset into the byte array where the data starts.</param>
  23. /// <param name="inLen">the length of the data.</param>
  24. void BlockUpdate(byte[] input, int inOff, int inLen);
  25. #if NETCOREAPP2_1_OR_GREATER || NETSTANDARD2_1_OR_GREATER || UNITY_2021_2_OR_NEWER
  26. /// <summary>Update the message digest with a span of bytes.</summary>
  27. /// <param name="input">the span containing the data.</param>
  28. void BlockUpdate(ReadOnlySpan<byte> input);
  29. #endif
  30. /// <summary>Close the digest, producing the final digest value.</summary>
  31. /// <remarks>This call leaves the digest reset.</remarks>
  32. /// <param name="output">the byte array the digest is to be copied into.</param>
  33. /// <param name="outOff">the offset into the byte array the digest is to start at.</param>
  34. /// <returns>the number of bytes written</returns>
  35. int DoFinal(byte[] output, int outOff);
  36. #if NETCOREAPP2_1_OR_GREATER || NETSTANDARD2_1_OR_GREATER || UNITY_2021_2_OR_NEWER
  37. /// <summary>Close the digest, producing the final digest value.</summary>
  38. /// <remarks>This call leaves the digest reset.</remarks>
  39. /// <param name="output">the span the digest is to be copied into.</param>
  40. /// <returns>the number of bytes written</returns>
  41. int DoFinal(Span<byte> output);
  42. #endif
  43. /// <summary>Reset the digest back to its initial state.</summary>
  44. void Reset();
  45. }
  46. }
  47. #pragma warning restore
  48. #endif