deriveKey function

Uint8List deriveKey(
  1. Digest algo,
  2. Uint8List sessionId,
  3. Uint8List exH,
  4. BigInt K,
  5. int id,
  6. int bytes,
)

Implementation

Uint8List deriveKey(Digest algo, Uint8List sessionId, Uint8List exH, BigInt K,
    int id, int bytes) {
  Uint8List ret = Uint8List(0);
  while (ret.length < bytes) {
    Digester digest = Digester(algo);
    digest.updateBigInt(K);
    digest.updateRaw(exH);
    if (ret.isEmpty) {
      digest.updateByte(id);
      digest.updateRaw(sessionId);
    } else {
      digest.updateRaw(ret);
    }
    ret = Uint8List.fromList(ret + digest.finish());
  }
  return viewUint8List(ret, 0, bytes);
}