Quantcast
Channel: sshnet Issue Tracker Rss Feed
Viewing all articles
Browse latest Browse all 1026

Edited Issue: Wrong PKCS7 padding in DES algorithm [1580]

$
0
0
public class PKCS7Padding : CipherPadding
{
/// <summary>
/// Transforms the specified input.
/// </summary>
/// <param name="blockSize">Size of the block.</param>
/// <param name="input">The input.</param>
/// <returns>
/// Padded data array.
/// </returns>
public override byte[] Pad(int blockSize, byte[] input)
{
var numOfPaddedBytes = blockSize - (input.Length % blockSize);

var output = new byte[input.Length + numOfPaddedBytes];
Buffer.BlockCopy(input, 0, output, 0, input.Length);
for (int i = 0; i < numOfPaddedBytes; i++)
{
//Wrong
//output[input.Length + i] = output[input.Length - 1];

//Should be like this
output[input.Length + i] = (byte)numOfPaddedBytes;
}

return output;
}
}

Viewing all articles
Browse latest Browse all 1026

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>