extract method

KeyParameter extract(
  1. Uint8List? salt,
  2. Uint8List ikm
)

Performs the extract part of the key derivation function.

Implementation

KeyParameter extract(Uint8List? salt, Uint8List ikm) {
  if (salt == null || salt.isEmpty) {
    if (_hashLen != _hMac.macSize) {
      throw ArgumentError(
          'Hash length doesn\'t equal MAC size of: ${_hMac.algorithmName}');
    }

    _hMac.init(KeyParameter(Uint8List(_hashLen)));
  } else {
    _hMac.init(KeyParameter(salt));
  }

  _hMac.update(ikm, 0, ikm.length);

  var prk = Uint8List(_hashLen);
  _hMac.doFinal(prk, 0);
  return KeyParameter(prk);
}