decryptBlock method
Decrypt exactly 1 block (16 bytes)
Implementation
@override
List<int> decryptBlock(List<int> input, [List<int>? dst]) {
final out = dst ?? List<int>.filled(blockSize, 0);
if (input.length != blockSize) {
throw ArgumentException.invalidOperationArguments(
"decryptBlock",
name: "input",
reason: "Invalid input bytes length.",
);
}
// Always copy input first because decryptBlock may mutate the buffer
final saved = input.clone();
// Decrypt into tmpBlock (never into input!)
_cipher.decryptBlock(saved, _tmpBlock);
// XOR with previous block
for (int i = 0; i < blockSize; i++) {
out[i] = (_tmpBlock[i] ^ _prevBlock[i]).toU8;
}
// Update chaining value
_prevBlock.setAll(0, saved);
return out;
}