IMac.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. /// <summary>The base interface for implementations of message authentication codes (MACs).</summary>
  7. public interface IMac
  8. {
  9. /// <summary>Initialise the MAC.</summary>
  10. /// <param name="parameters">The key or other data required by the MAC.</param>
  11. void Init(ICipherParameters parameters);
  12. /// <summary>The algorithm name.</summary>
  13. string AlgorithmName { get; }
  14. /// <summary>Return the size, in bytes, of the MAC produced by this implementation.</summary>
  15. /// <returns>the size, in bytes, of the MAC produced by this implementation.</returns>
  16. int GetMacSize();
  17. /// <summary>Update the MAC 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 MAC 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 MAC 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>Perform final calculations, producing the result MAC.</summary>
  31. /// <remarks>This call leaves the MAC reset.</remarks>
  32. /// <param name="output">the byte array the MAC is to be copied into.</param>
  33. /// <param name="outOff">the offset into the byte array the MAC 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>Perform final calculations, producing the result MAC.</summary>
  38. /// <remarks>This call leaves the MAC reset.</remarks>
  39. /// <param name="output">the span the MAC 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 MAC back to its initial state.</summary>
  44. void Reset();
  45. }
  46. }
  47. #pragma warning restore
  48. #endif