TlsAeadCipherImpl.cs 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  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>Base interface for services supporting AEAD encryption/decryption.</summary>
  8. public interface TlsAeadCipherImpl
  9. {
  10. /// <summary>Set the key to be used by the AEAD cipher implementation supporting this service.</summary>
  11. /// <param name="key">array holding the AEAD 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 the AEAD operator.</summary>
  17. /// <param name="nonce">the nonce.</param>
  18. /// <param name="macSize">MAC size in bytes.</param>
  19. /// <param name="additionalData">any additional data to be included in the MAC calculation.</param>
  20. /// <exception cref="IOException">if the parameters are inappropriate.</exception>
  21. void Init(byte[] nonce, int macSize, byte[] additionalData);
  22. /// <summary>Return the maximum size of the output for input of inputLength bytes.</summary>
  23. /// <param name="inputLength">the length (in bytes) of the proposed input.</param>
  24. /// <returns>the maximum size of the output.</returns>
  25. int GetOutputSize(int inputLength);
  26. /// <summary>Perform the cipher encryption/decryption returning the output in output.</summary>
  27. /// <remarks>
  28. /// Note: we have to use DoFinal() here as it is the only way to guarantee output from the underlying cipher.
  29. /// </remarks>
  30. /// <param name="input">array holding input data to the cipher.</param>
  31. /// <param name="inputOffset">offset into input array data starts at.</param>
  32. /// <param name="inputLength">length of the input data in the array.</param>
  33. /// <param name="output">array to hold the cipher output.</param>
  34. /// <param name="outputOffset">offset into output array to start saving output.</param>
  35. /// <returns>the amount of data written to output.</returns>
  36. /// <exception cref="IOException">in case of failure.</exception>
  37. int DoFinal(byte[] input, int inputOffset, int inputLength, byte[] output, int outputOffset);
  38. }
  39. }
  40. #pragma warning restore
  41. #endif