IBlockCipher.cs 1.6 KB

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