The MSDN states about TransformBlock:
public int TransformBlock( byte[] inputBuffer, int inputOffset, int inputCount, byte[] outputBuffer, int outputOffset )
Return Value: The number of bytes written.
I'm assuming the output buffer is of sufficient size. Typically, the input buffer is used as output buffer, both offset 0, so this is not an issue.
Is there any condition that could cause the return value to be not equal to the inputCount?
Assuming the .net implementation is equivalent to the mono implementation, the answer is: never. It throws an exception, or it returns inputCount
.
This strange method exists because it implements ICryptoTransform
. ICryptoTransform
is also used by block ciphers, where a difference between input and output size can indeed happen.
IMO this is bad class design. The interface implementation should have been explicit, and the user should have been given a clean interface, similar to HashCore
and HashFinal
, which are the extension points of HashAlgorithm
.