IBlockCipher.cs 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. #if !BESTHTTP_DISABLE_ALTERNATE_SSL && (!UNITY_WEBGL || UNITY_EDITOR)
  2. using System;
  3. namespace Org.BouncyCastle.Crypto
  4. {
  5. /// <remarks>Base interface for a symmetric key block cipher.</remarks>
  6. public interface IBlockCipher
  7. {
  8. /// <summary>The name of the algorithm this cipher implements.</summary>
  9. string AlgorithmName { get; }
  10. /// <summary>Initialise the cipher.</summary>
  11. /// <param name="forEncryption">Initialise for encryption if true, for decryption if false.</param>
  12. /// <param name="parameters">The key or other data required by the cipher.</param>
  13. void Init(bool forEncryption, ICipherParameters parameters);
  14. /// <returns>The block size for this cipher, in bytes.</returns>
  15. int GetBlockSize();
  16. /// <summary>Indicates whether this cipher can handle partial blocks.</summary>
  17. bool IsPartialBlockOkay { get; }
  18. /// <summary>Process a block.</summary>
  19. /// <param name="inBuf">The input buffer.</param>
  20. /// <param name="inOff">The offset into <paramref>inBuf</paramref> that the input block begins.</param>
  21. /// <param name="outBuf">The output buffer.</param>
  22. /// <param name="outOff">The offset into <paramref>outBuf</paramref> to write the output block.</param>
  23. /// <exception cref="DataLengthException">If input block is wrong size, or outBuf too small.</exception>
  24. /// <returns>The number of bytes processed and produced.</returns>
  25. int ProcessBlock(byte[] inBuf, int inOff, byte[] outBuf, int outOff);
  26. /// <summary>
  27. /// Reset the cipher to the same state as it was after the last init (if there was one).
  28. /// </summary>
  29. void Reset();
  30. }
  31. }
  32. #endif