BlockCipher.Encrypt fails if input message length is not a multiple of BlockSize. The error is "Invalid output buffer".
This seems to be due to the following code in EncryptBlock function of BlockCipher class:
var output = new byte[data.Length];
if (data.Length % this._blockSize > 0)
{
if (this._padding == null)
{
throw new ArgumentException("data");
}
data = this._padding.Pad(this._blockSize, data);
}
The size of output array is determined before the padding of input data. As a result, after the padding input array is longer than output array.
The same applies to Decrypt function.
Comments: Fixed in 2014.4.6-beta2.
This seems to be due to the following code in EncryptBlock function of BlockCipher class:
var output = new byte[data.Length];
if (data.Length % this._blockSize > 0)
{
if (this._padding == null)
{
throw new ArgumentException("data");
}
data = this._padding.Pad(this._blockSize, data);
}
The size of output array is determined before the padding of input data. As a result, after the padding input array is longer than output array.
The same applies to Decrypt function.
Comments: Fixed in 2014.4.6-beta2.