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 = CryptoUtils.hmac(key: zerosalt, input: key);
  final b = Uint8List(1);
  b[0] = 1;
  final aesKey = CryptoUtils.hmac(key: prk, input: utf8.encode(name) + b);
  b[0] = 2;
  final hmacKey = CryptoUtils.hmac(
    key: prk,
    input: aesKey + utf8.encode(name) + b,
  );
  return DerivedKeys(
    aesKey: Uint8List.fromList(aesKey),
    hmacKey: Uint8List.fromList(hmacKey),
  );
}