IBufferedCipher.cs 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. #if !BESTHTTP_DISABLE_ALTERNATE_SSL && (!UNITY_WEBGL || UNITY_EDITOR)
  2. #pragma warning disable
  3. using System;
  4. namespace Best.HTTP.SecureProtocol.Org.BouncyCastle.Crypto
  5. {
  6. /// <remarks>Block cipher engines are expected to conform to this interface.</remarks>
  7. public interface IBufferedCipher
  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">If true the cipher is initialised for encryption,
  13. /// if false for decryption.</param>
  14. /// <param name="parameters">The key and other data required by the cipher.</param>
  15. void Init(bool forEncryption, ICipherParameters parameters);
  16. int GetBlockSize();
  17. int GetOutputSize(int inputLen);
  18. int GetUpdateOutputSize(int inputLen);
  19. byte[] ProcessByte(byte input);
  20. int ProcessByte(byte input, byte[] output, int outOff);
  21. #if NETCOREAPP2_1_OR_GREATER || NETSTANDARD2_1_OR_GREATER || UNITY_2021_2_OR_NEWER
  22. int ProcessByte(byte input, Span<byte> output);
  23. #endif
  24. byte[] ProcessBytes(byte[] input);
  25. byte[] ProcessBytes(byte[] input, int inOff, int length);
  26. int ProcessBytes(byte[] input, byte[] output, int outOff);
  27. int ProcessBytes(byte[] input, int inOff, int length, byte[] output, int outOff);
  28. #if NETCOREAPP2_1_OR_GREATER || NETSTANDARD2_1_OR_GREATER || UNITY_2021_2_OR_NEWER
  29. int ProcessBytes(ReadOnlySpan<byte> input, Span<byte> output);
  30. #endif
  31. byte[] DoFinal();
  32. byte[] DoFinal(byte[] input);
  33. byte[] DoFinal(byte[] input, int inOff, int length);
  34. int DoFinal(byte[] output, int outOff);
  35. int DoFinal(byte[] input, byte[] output, int outOff);
  36. int DoFinal(byte[] input, int inOff, int length, byte[] output, int outOff);
  37. #if NETCOREAPP2_1_OR_GREATER || NETSTANDARD2_1_OR_GREATER || UNITY_2021_2_OR_NEWER
  38. int DoFinal(Span<byte> output);
  39. int DoFinal(ReadOnlySpan<byte> input, Span<byte> output);
  40. #endif
  41. /// <summary>
  42. /// Reset the cipher. After resetting the cipher is in the same state
  43. /// as it was after the last init (if there was one).
  44. /// </summary>
  45. void Reset();
  46. }
  47. }
  48. #pragma warning restore
  49. #endif