checkMac method
Future<void>
checkMac({
- required MacAlgorithm macAlgorithm,
- required SecretKey secretKey,
- required List<
int> aad,
Checks that the secret box has correct MAC.
Throws SecretBoxAuthenticationError if the MAC is incorrect.
Implementation
Future<void> checkMac({
required MacAlgorithm macAlgorithm,
required SecretKey secretKey,
required List<int> aad,
}) async {
final correctMac = await macAlgorithm.calculateMac(
cipherText,
secretKey: secretKey,
nonce: nonce,
aad: aad,
);
if (correctMac != mac) {
throw SecretBoxAuthenticationError();
}
}