doFinal method

  1. @override
int doFinal(
  1. Uint8List out,
  2. int outOff
)
override

Store the MAC of previously given data in buffer out starting at offset outOff. This method returns the size of the digest.

Implementation

@override
int doFinal(Uint8List out, int outOff) {
  var blockSize = _cipher.blockSize;

  if (_padding == null) {
    //
    // pad with zeroes
    //
    while (_bufOff < blockSize) {
      _buf[_bufOff] = 0;
      _bufOff++;
    }
  } else {
    if (_bufOff == blockSize) {
      _cipher.processBlock(_buf, 0, _mac, 0);
      _bufOff = 0;
    }

    _padding.addPadding(_buf, _bufOff);
  }

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

  out.setRange(outOff, outOff + _macSize, _mac);

  reset();

  return _macSize;
}