calculateMac method

  1. @override
Future<Mac> calculateMac(
  1. List<int> bytes, {
  2. required SecretKey secretKey,
  3. List<int> nonce = const <int>[],
  4. List<int> aad = const <int>[],
})
override

Calculates message authentication code.

The parameter secretKey must be non-empty.

The parameter nonce is optional and rarely required by MAC algorithms. The default value is const <int>[].

The parameter aad is Associated Authenticated Data (AAD). It can be empty. If it's non-empty and the algorithm does not support AAD, the the method throws ArgumentError.

Implementation

@override
Future<Mac> calculateMac(
  List<int> bytes, {
  required SecretKey secretKey,
  List<int> nonce = const <int>[],
  List<int> aad = const <int>[],
}) async {
  final sink = await newMacSink(
    secretKey: secretKey,
    nonce: nonce,
    aad: aad,
  );
  sink.addSlice(bytes, 0, bytes.length, true);
  return await sink.mac();
}