validateMac method

void validateMac()
inherited

When decrypting, validates the generated authentication tag with the one in the input stream. When not equal throws InvalidCipherTextException. This method should be called from the doFinal method.

Implementation

void validateMac() {
  if (forEncryption) {
    return;
  }
  if (_lastMacSizeBytesOff != macSize) {
    throw InvalidCipherTextException('Input data too short');
  }
  if (!constantTimeAreEqual(mac, _lastMacSizeBytes!)) {
    throw InvalidCipherTextException('Authentication tag check failed');
  }
}