processBlock method
Process a whole block of data given by inp
and starting at offset
inpOff
.
The resulting cipher text is put in out
beginning at position outOff
.
This method returns the total bytes processed (which is the same as the block size of the algorithm).
Implementation
@override
int processBlock(Uint8List inp, int inpOff, Uint8List out, int outOff) {
if (_workingKey == null) {
throw StateError('AES engine not initialised');
}
if ((inpOff + (32 / 2)) > inp.lengthInBytes) {
throw ArgumentError('Input buffer too short');
}
if ((outOff + (32 / 2)) > out.lengthInBytes) {
throw ArgumentError('Output buffer too short');
}
var inpView = ByteData.view(inp.buffer, inp.offsetInBytes, inp.length);
var outView = ByteData.view(out.buffer, out.offsetInBytes, out.length);
if (_forEncryption) {
_unpackBlock(inpView, inpOff);
_encryptBlock(_workingKey!);
_packBlock(outView, outOff);
} else {
_unpackBlock(inpView, inpOff);
_decryptBlock(_workingKey!);
_packBlock(outView, outOff);
}
return _BLOCK_SIZE;
}