0

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?

1 Answer 1

2

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.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.