updateView method
Transforms input like update, but returns a view directly onto the
native output buffer instead of copying it — no per-chunk allocation.
The returned view is valid only until the next call to update or
updateView on this instance. That call may reuse or grow outBuf,
so anything holding the view past it is reading freed or overwritten
memory. The one sanctioned consumer is a synchronous Socket.add,
which copies the bytes before this method can be called again; do not
store the view, pass it across an await, or hand it to anything
asynchronous. Everything else should use update.
Implementation
Uint8List updateView(Uint8List input) {
if (_state.released) {
throw StateError('AesCtrFfiCipher.updateView called after dispose');
}
if (input.isEmpty) return Uint8List(0);
checkInlLength(
input.length, 'input', 'EVP_EncryptUpdate', AtEncryptionException.new);
_state.ensureCapacity(input.length);
_state.inBuf.asTypedList(input.length).setAll(0, input);
if (_encryptUpdate(_state.ctx, _state.outBuf, _state.outLen, _state.inBuf,
input.length) <=
0) {
throw AtEncryptionException('AES-CTR (FFI) transform failed');
}
return _state.outBuf.asTypedList(_state.outLen.value);
}