| | | 1 | | namespace Renci.SshNet.Security.Cryptography.Ciphers |
| | | 2 | | { |
| | | 3 | | /// <summary> |
| | | 4 | | /// Base class for cipher padding implementations. |
| | | 5 | | /// </summary> |
| | | 6 | | public abstract class CipherPadding |
| | | 7 | | { |
| | | 8 | | /// <summary> |
| | | 9 | | /// Pads the specified input to match the block size. |
| | | 10 | | /// </summary> |
| | | 11 | | /// <param name="blockSize">Size of the block.</param> |
| | | 12 | | /// <param name="input">The input.</param> |
| | | 13 | | /// <returns> |
| | | 14 | | /// Padded data array. |
| | | 15 | | /// </returns> |
| | | 16 | | public byte[] Pad(int blockSize, byte[] input) |
| | 12 | 17 | | { |
| | 12 | 18 | | return Pad(blockSize, input, 0, input.Length); |
| | 12 | 19 | | } |
| | | 20 | | |
| | | 21 | | /// <summary> |
| | | 22 | | /// Pads the specified input to match the block size. |
| | | 23 | | /// </summary> |
| | | 24 | | /// <param name="blockSize">Size of the block.</param> |
| | | 25 | | /// <param name="input">The input.</param> |
| | | 26 | | /// <param name="offset">The zero-based offset in <paramref name="input"/> at which the data to pad starts.</par |
| | | 27 | | /// <param name="length">The number of bytes in <paramref name="input"/> to take into account.</param> |
| | | 28 | | /// <returns> |
| | | 29 | | /// The padded data array. |
| | | 30 | | /// </returns> |
| | | 31 | | public abstract byte[] Pad(int blockSize, byte[] input, int offset, int length); |
| | | 32 | | |
| | | 33 | | /// <summary> |
| | | 34 | | /// Pads the specified input with a given number of bytes. |
| | | 35 | | /// </summary> |
| | | 36 | | /// <param name="input">The input.</param> |
| | | 37 | | /// <param name="paddinglength">The number of bytes to pad the input with.</param> |
| | | 38 | | /// <returns> |
| | | 39 | | /// The padded data array. |
| | | 40 | | /// </returns> |
| | | 41 | | public byte[] Pad(byte[] input, int paddinglength) |
| | 0 | 42 | | { |
| | 0 | 43 | | return Pad(input, 0, input.Length, paddinglength); |
| | 0 | 44 | | } |
| | | 45 | | |
| | | 46 | | /// <summary> |
| | | 47 | | /// Pads the specified input with a given number of bytes. |
| | | 48 | | /// </summary> |
| | | 49 | | /// <param name="input">The input.</param> |
| | | 50 | | /// <param name="offset">The zero-based offset in <paramref name="input"/> at which the data to pad starts.</par |
| | | 51 | | /// <param name="length">The number of bytes in <paramref name="input"/> to take into account.</param> |
| | | 52 | | /// <param name="paddinglength">The number of bytes to pad the input with.</param> |
| | | 53 | | /// <returns> |
| | | 54 | | /// The padded data array. |
| | | 55 | | /// </returns> |
| | | 56 | | public abstract byte[] Pad(byte[] input, int offset, int length, int paddinglength); |
| | | 57 | | } |
| | | 58 | | } |