IMac.cs 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. #if !BESTHTTP_DISABLE_ALTERNATE_SSL && (!UNITY_WEBGL || UNITY_EDITOR)
  2. using System;
  3. namespace Org.BouncyCastle.Crypto
  4. {
  5. /**
  6. * The base interface for implementations of message authentication codes (MACs).
  7. */
  8. public interface IMac
  9. {
  10. /**
  11. * Initialise the MAC.
  12. *
  13. * @param param the key and other data required by the MAC.
  14. * @exception ArgumentException if the parameters argument is
  15. * inappropriate.
  16. */
  17. void Init(ICipherParameters parameters);
  18. /**
  19. * Return the name of the algorithm the MAC implements.
  20. *
  21. * @return the name of the algorithm the MAC implements.
  22. */
  23. string AlgorithmName { get; }
  24. /**
  25. * Return the block size for this MAC (in bytes).
  26. *
  27. * @return the block size for this MAC in bytes.
  28. */
  29. int GetMacSize();
  30. /**
  31. * add a single byte to the mac for processing.
  32. *
  33. * @param in the byte to be processed.
  34. * @exception InvalidOperationException if the MAC is not initialised.
  35. */
  36. void Update(byte input);
  37. /**
  38. * @param in the array containing the input.
  39. * @param inOff the index in the array the data begins at.
  40. * @param len the length of the input starting at inOff.
  41. * @exception InvalidOperationException if the MAC is not initialised.
  42. * @exception DataLengthException if there isn't enough data in in.
  43. */
  44. void BlockUpdate(byte[] input, int inOff, int len);
  45. /**
  46. * Compute the final stage of the MAC writing the output to the out
  47. * parameter.
  48. * <p>
  49. * doFinal leaves the MAC in the same state it was after the last init.
  50. * </p>
  51. * @param out the array the MAC is to be output to.
  52. * @param outOff the offset into the out buffer the output is to start at.
  53. * @exception DataLengthException if there isn't enough space in out.
  54. * @exception InvalidOperationException if the MAC is not initialised.
  55. */
  56. int DoFinal(byte[] output, int outOff);
  57. /**
  58. * Reset the MAC. At the end of resetting the MAC should be in the
  59. * in the same state it was after the last init (if there was one).
  60. */
  61. void Reset();
  62. }
  63. }
  64. #endif