tomSecretsChallengeInput function

Uint8List tomSecretsChallengeInput(
  1. String label,
  2. List<int> serviceNonce,
  3. List<int> adminNonce,
  4. int serviceStart,
)

The MAC input: label's ASCII, both nonces, serviceStart as 8 bytes big-endian.

Implementation

Uint8List tomSecretsChallengeInput(
  String label,
  List<int> serviceNonce,
  List<int> adminNonce,
  int serviceStart,
) {
  if (serviceNonce.length != tomSecretsKeyBytes ||
      adminNonce.length != tomSecretsKeyBytes) {
    throw ArgumentError('a nonce is $tomSecretsKeyBytes bytes');
  }
  final start = ByteData(8)..setUint64(0, serviceStart);
  return Uint8List.fromList([
    ...ascii.encode(label),
    ...serviceNonce,
    ...adminNonce,
    ...start.buffer.asUint8List(),
  ]);
}