checkMac method
Recomputes the MAC over the response and compares. The MAC field is removed only when it matched, as in the Java, so a failed check leaves the message untouched for logging.
Implementation
Future<bool> checkMac(IsoMsg message, int macLength) async {
final Uint8List expected = await _generate(message, macLength);
final int macField = message.maxField > 64 ? 128 : 64;
final Uint8List? received = message.getBytes(macField);
if (received == null || received.length != expected.length) return false;
for (int i = 0; i < expected.length; i++) {
if (received[i] != expected[i]) return false;
}
message.unset(macField);
return true;
}