IBlockCipher.cs 1.7 KB

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