expandNext method

void expandNext()

Performs the expand part of the key derivation function, using currentT as input and output buffer.

Implementation

void expandNext() {
  var n = _generatedBytes ~/ _hashLen + 1;
  if (n >= 256) {
    throw ArgumentError(
        'HKDF cannot generate more than 255 blocks of HashLen size');
  }

  // special case for T(0): T(0) is empty, so no update
  if (_generatedBytes != 0) {
    _hMac.update(_currentT, 0, _hashLen);
  }

  _hMac.update(_info!, 0, _info!.length);
  _hMac.updateByte(n);
  _hMac.doFinal(_currentT, 0);
}