ISigner.cs 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  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. public interface ISigner
  7. {
  8. /// <summary>The algorithm name.</summary>
  9. string AlgorithmName { get; }
  10. /// <summary>Initialise the signer for signing or verification.</summary>
  11. /// <param name="forSigning">true if for signing, false otherwise.</param>
  12. /// <param name="parameters">necessary parameters.</param>
  13. void Init(bool forSigning, ICipherParameters parameters);
  14. /// <summary>Update the signer with a single byte.</summary>
  15. /// <param name="input">the input byte to be entered.</param>
  16. void Update(byte input);
  17. /// <summary>Update the signer with a block of bytes.</summary>
  18. /// <param name="input">the byte array containing the data.</param>
  19. /// <param name="inOff">the offset into the byte array where the data starts.</param>
  20. /// <param name="inLen">the length of the data.</param>
  21. void BlockUpdate(byte[] input, int inOff, int inLen);
  22. #if NETCOREAPP2_1_OR_GREATER || NETSTANDARD2_1_OR_GREATER || UNITY_2021_2_OR_NEWER
  23. /// <summary>Update the signer with a span of bytes.</summary>
  24. /// <param name="input">the span containing the data.</param>
  25. void BlockUpdate(ReadOnlySpan<byte> input);
  26. #endif
  27. /// <summary>Generate a signature for the message we've been loaded with using the key we were initialised with.
  28. /// </summary>
  29. /// <returns>A byte array containing the signature for the message.</returns>
  30. byte[] GenerateSignature();
  31. /// <summary>Return true if the internal state represents the signature described in the passed in array.
  32. /// </summary>
  33. /// <param name="signature">an array containing the candidate signature to verify.</param>
  34. /// <returns>true if the internal state represents the signature described in the passed in array.</returns>
  35. bool VerifySignature(byte[] signature);
  36. /// <summary>Reset the signer back to its initial state.</summary>
  37. void Reset();
  38. }
  39. }
  40. #pragma warning restore
  41. #endif