ClpIBlockCipherPadding.pas 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. { *********************************************************************************** }
  2. { * CryptoLib Library * }
  3. { * Copyright (c) 2018 - 20XX Ugochukwu Mmaduekwe * }
  4. { * Github Repository <https://github.com/Xor-el> * }
  5. { * Distributed under the MIT software license, see the accompanying file LICENSE * }
  6. { * or visit http://www.opensource.org/licenses/mit-license.php. * }
  7. { * Acknowledgements: * }
  8. { * * }
  9. { * Thanks to Sphere 10 Software (http://www.sphere10.com/) for sponsoring * }
  10. { * development of this library * }
  11. { * ******************************************************************************* * }
  12. (* &&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& *)
  13. unit ClpIBlockCipherPadding;
  14. {$I ..\Include\CryptoLib.inc}
  15. interface
  16. uses
  17. ClpISecureRandom,
  18. ClpCryptoLibTypes;
  19. type
  20. /// <remarks>Block cipher padders are expected to conform to this interface.</remarks>
  21. IBlockCipherPadding = interface(IInterface)
  22. ['{BF2886A5-1020-4270-B8E5-3BA9FDB9DA56}']
  23. /// <summary>
  24. /// Initialise the padder.
  25. /// </summary>
  26. /// <param name="random">
  27. /// param parameters, if any required.
  28. /// </param>
  29. procedure Init(const random: ISecureRandom);
  30. /// <returns>
  31. /// return the name of the algorithm the cipher implements.
  32. /// </returns>
  33. function GetPaddingName: String;
  34. /// <summary>
  35. /// Return the name of the algorithm the cipher implements.
  36. /// </summary>
  37. property PaddingName: String read GetPaddingName;
  38. /// <summary>
  39. /// add the pad bytes to the passed in block, returning the number of
  40. /// bytes added.
  41. /// </summary>
  42. /// <param name="input">
  43. /// input block to pad
  44. /// </param>
  45. /// <param name="inOff">
  46. /// offset to start the padding from in the block
  47. /// </param>
  48. /// <returns>
  49. /// returns number of bytes added
  50. /// </returns>
  51. function AddPadding(const input: TCryptoLibByteArray; inOff: Int32): Int32;
  52. /// <summary>
  53. /// return the number of pad bytes present in the block.
  54. /// </summary>
  55. /// <param name="input">
  56. /// block to count pad bytes in
  57. /// </param>
  58. /// <returns>
  59. /// the number of pad bytes present in the block.
  60. /// </returns>
  61. /// <exception cref="EInvalidCipherTextCryptoLibException">
  62. /// if the padding is badly formed or invalid.
  63. /// </exception>
  64. function PadCount(const input: TCryptoLibByteArray): Int32;
  65. end;
  66. implementation
  67. end.