TlsBlockCipherImpl.cs 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. #if !BESTHTTP_DISABLE_ALTERNATE_SSL && (!UNITY_WEBGL || UNITY_EDITOR)
  2. #pragma warning disable
  3. using System;
  4. using System.IO;
  5. namespace BestHTTP.SecureProtocol.Org.BouncyCastle.Tls.Crypto.Impl
  6. {
  7. /// <summary>Interface for block cipher services.</summary>
  8. public interface TlsBlockCipherImpl
  9. {
  10. /// <summary>Set the key to be used by the block cipher implementation supporting this service.</summary>
  11. /// <param name="key">array holding the block cipher key.</param>
  12. /// <param name="keyOff">offset into the array the key starts at.</param>
  13. /// <param name="keyLen">length of the key in the array.</param>
  14. /// <exception cref="IOException"/>
  15. void SetKey(byte[] key, int keyOff, int keyLen);
  16. /// <summary>Initialise the parameters for operator.</summary>
  17. /// <param name="iv">array holding the initialization vector (IV).</param>
  18. /// <param name="ivOff">offset into the array the IV starts at.</param>
  19. /// <param name="ivLen">length of the IV in the array.</param>
  20. /// <exception cref="IOException">if the parameters are inappropriate.</exception>
  21. void Init(byte[] iv, int ivOff, int ivLen);
  22. /// <summary>Perform the cipher encryption/decryption returning the output in output.</summary>
  23. /// <remarks>
  24. /// Note: we have to use DoFinal() here as it is the only way to guarantee output from the underlying cipher.
  25. /// </remarks>
  26. /// <param name="input">array holding input data to the cipher.</param>
  27. /// <param name="inputOffset">offset into input array data starts at.</param>
  28. /// <param name="inputLength">length of the input data in the array.</param>
  29. /// <param name="output">array to hold the cipher output.</param>
  30. /// <param name="outputOffset">offset into output array to start saving output.</param>
  31. /// <returns>the amount of data written to output.</returns>
  32. /// <exception cref="IOException">in case of failure.</exception>
  33. int DoFinal(byte[] input, int inputOffset, int inputLength, byte[] output, int outputOffset);
  34. /// <summary>Return the blocksize (in bytes) of the underlying block cipher.</summary>
  35. /// <returns>the cipher's blocksize.</returns>
  36. int GetBlockSize();
  37. }
  38. }
  39. #pragma warning restore
  40. #endif