init method

  1. @override
void init(
  1. covariant KeyParameter params
)
override

Init the MAC with its initialization params. The type of CipherParameters depends on the algorithm being used (see the documentation of each implementation to find out more).

Implementation

@override
void init(covariant KeyParameter params) {
  _digest.reset();

  var key = params.key;
  var keyLength = key.length;

  if (keyLength > _blockLength) {
    _digest.update(key, 0, keyLength);
    _digest.doFinal(_inputPad, 0);

    keyLength = _digestSize;
  } else {
    _inputPad.setRange(0, keyLength, key);
  }

  _inputPad.fillRange(keyLength, _inputPad.length, 0);

  _outputBuf.setRange(0, _blockLength, _inputPad);

  _xorPad(_inputPad, _blockLength, _ipad);
  _xorPad(_outputBuf, _blockLength, _opad);

  _digest.update(_inputPad, 0, _inputPad.length);
}