verifyMac function

void verifyMac(
  1. Uint8List hmacKey,
  2. Uint8List nonce,
  3. Uint8List ciphertext,
  4. Uint8List mac,
)

Implementation

void verifyMac(
    Uint8List hmacKey, Uint8List nonce, Uint8List ciphertext, Uint8List mac) {
  Uint8List calculatedMac = calculateMac(hmacKey, nonce, ciphertext);
  if (!const ListEquality().equals(calculatedMac, mac)) {
    throw Exception('Invalid MAC');
  }
}