update method

  1. @override
void update(
  1. Uint8List inp,
  2. int inOff,
  3. int len
)
override

Add len bytes of data contained in inp, starting at position inpOff to the MAC'ed input.

Implementation

@override
void update(Uint8List inp, int inOff, int len) {
  if (len < 0) {
    throw ArgumentError('Can\'t have a negative input length!');
  }

  var blockSize = _cipher.blockSize;
  var gapLen = blockSize - _bufOff;

  if (len > gapLen) {
    _buf.setRange(_bufOff, _bufOff + gapLen, inp.sublist(inOff));

    _cipher.processBlock(_buf, 0, _mac, 0);

    _bufOff = 0;
    len -= gapLen;
    inOff += gapLen;

    while (len > blockSize) {
      _cipher.processBlock(inp, inOff, _mac, 0);

      len -= blockSize;
      inOff += blockSize;
    }
  }

  _buf.setRange(_bufOff, _bufOff + len, inp.sublist(inOff));

  _bufOff += len;
}