TlsSuiteMac.cs 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637
  1. #if !BESTHTTP_DISABLE_ALTERNATE_SSL && (!UNITY_WEBGL || UNITY_EDITOR)
  2. #pragma warning disable
  3. using System;
  4. namespace BestHTTP.SecureProtocol.Org.BouncyCastle.Tls.Crypto.Impl
  5. {
  6. /// <summary>Base interface for a generic TLS MAC implementation for use with a bulk cipher.</summary>
  7. public interface TlsSuiteMac
  8. {
  9. /// <summary>Return the output length (in bytes) of this MAC.</summary>
  10. /// <returns>The output length of this MAC.</returns>
  11. int Size { get; }
  12. /// <summary>Calculate the MAC for some given data.</summary>
  13. /// <param name="seqNo">The sequence number of the record.</param>
  14. /// <param name="type">The content type of the message.</param>
  15. /// <param name="message">A byte array containing the message.</param>
  16. /// <param name="offset">The number of bytes to skip, before the message starts.</param>
  17. /// <param name="length">The length of the message.</param>
  18. /// <returns>A new byte array containing the MAC value.</returns>
  19. byte[] CalculateMac(long seqNo, short type, byte[] message, int offset, int length);
  20. /// <summary>Constant time calculation of the MAC for some given data with a given expected length.</summary>
  21. /// <param name="seqNo">The sequence number of the record.</param>
  22. /// <param name="type">The content type of the message.</param>
  23. /// <param name="message">A byte array containing the message.</param>
  24. /// <param name="offset">The number of bytes to skip, before the message starts.</param>
  25. /// <param name="length">The length of the message.</param>
  26. /// <param name="expectedLength">The expected length of the full message.</param>
  27. /// <param name="randomData">Random data for padding out the MAC calculation if required.</param>
  28. /// <returns>A new byte array containing the MAC value.</returns>
  29. byte[] CalculateMacConstantTime(long seqNo, short type, byte[] message, int offset, int length,
  30. int expectedLength, byte[] randomData);
  31. }
  32. }
  33. #pragma warning restore
  34. #endif