deriveKeys static method

DerivedKeys deriveKeys(
  1. Uint8List key,
  2. String name
)

Implementation

static DerivedKeys deriveKeys(Uint8List key, String name) {
  final zerosalt = Uint8List(8);
  final prk = Hmac(sha256, zerosalt).convert(key);
  final b = Uint8List(1);
  b[0] = 1;
  final aesKey = Hmac(sha256, prk.bytes).convert(utf8.encode(name) + b);
  b[0] = 2;
  final hmacKey =
      Hmac(sha256, prk.bytes).convert(aesKey.bytes + utf8.encode(name) + b);
  return DerivedKeys(
    aesKey: Uint8List.fromList(aesKey.bytes),
    hmacKey: Uint8List.fromList(hmacKey.bytes),
  );
}