tomSecretsBundleKey function

Uint8List tomSecretsBundleKey(
  1. List<int> adminKey,
  2. List<int> serviceNonce,
  3. List<int> adminNonce
)

The bundle key of one admin connection: HKDF-SHA256(adminKey, salt = serviceNonce || adminNonce, info = "tsm-bundle-v1"), 32 bytes.

Implementation

Uint8List tomSecretsBundleKey(
  List<int> adminKey,
  List<int> serviceNonce,
  List<int> adminNonce,
) {
  if (serviceNonce.length != tomSecretsKeyBytes ||
      adminNonce.length != tomSecretsKeyBytes) {
    throw ArgumentError('a nonce is $tomSecretsKeyBytes bytes');
  }
  // RFC 5869 with one block of output.
  final prk = crypto.Hmac(crypto.sha256, [
    ...serviceNonce,
    ...adminNonce,
  ]).convert(adminKey).bytes;
  final okm = crypto.Hmac(
    crypto.sha256,
    prk,
  ).convert([...ascii.encode(tomSecretsBundleInfo), 1]).bytes;
  return Uint8List.fromList(okm);
}