IBlockCipherPadding.cs 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. #if !BESTHTTP_DISABLE_ALTERNATE_SSL && (!UNITY_WEBGL || UNITY_EDITOR)
  2. #pragma warning disable
  3. using System;
  4. using Best.HTTP.SecureProtocol.Org.BouncyCastle.Security;
  5. namespace Best.HTTP.SecureProtocol.Org.BouncyCastle.Crypto.Paddings
  6. {
  7. /// <summary>Block cipher padders are expected to conform to this interface.</summary>
  8. public interface IBlockCipherPadding
  9. {
  10. /// <summary>Initialise the padder.</summary>
  11. /// <param name="random">A source of randomness, if any required.</param>
  12. void Init(SecureRandom random);
  13. /// <summary>The name of the algorithm this padder implements.</summary>
  14. string PaddingName { get; }
  15. /// <summary>Add padding to the passed in block.</summary>
  16. /// <param name="input">the block to add padding to.</param>
  17. /// <param name="inOff">the offset into the block the padding is to start at.</param>
  18. /// <returns>the number of bytes of padding added.</returns>
  19. int AddPadding(byte[] input, int inOff);
  20. #if NETCOREAPP2_1_OR_GREATER || NETSTANDARD2_1_OR_GREATER || UNITY_2021_2_OR_NEWER
  21. /// <summary>Add padding to the passed in block.</summary>
  22. /// <param name="block">the block to add padding to.</param>
  23. /// <param name="position">the offset into the block the padding is to start at.</param>
  24. /// <returns>the number of bytes of padding added.</returns>
  25. int AddPadding(Span<byte> block, int position);
  26. #endif
  27. /// <summary>Determine the length of padding present in the passed in block.</summary>
  28. /// <param name="input">the block to check padding for.</param>
  29. /// <returns>the number of bytes of padding present.</returns>
  30. int PadCount(byte[] input);
  31. #if NETCOREAPP2_1_OR_GREATER || NETSTANDARD2_1_OR_GREATER || UNITY_2021_2_OR_NEWER
  32. /// <summary>Determine the length of padding present in the passed in block.</summary>
  33. /// <param name="block">the block to check padding for.</param>
  34. /// <returns>the number of bytes of padding present.</returns>
  35. int PadCount(ReadOnlySpan<byte> block);
  36. #endif
  37. }
  38. }
  39. #pragma warning restore
  40. #endif