streamXOR method
XORs source data with the keystream and writes the result to the destination.
This method XORs the bytes from the source List<int>
with the keystream generated by the Counter (CTR)
mode and writes the result to the destination List<int>
. It ensures that the keystream is continuously
generated as needed, filling the buffer when it's exhausted.
Parameters:
src
: The source data to be XORed with the keystream.dst
: The destinationList<int>
where the XORed result will be written.
Note: This method effectively applies the CTR mode encryption by XORing the source data with the keystream, allowing for secure encryption of data.
Implementation
void streamXOR(List<int> src, List<int> dst) {
for (var i = 0; i < src.length; i++) {
if (_bufpos == _buffer.length) {
_fillBuffer();
}
dst[i] = (src[i] & mask8) ^ _buffer[_bufpos++];
}
}