From d9ed7f2c2499b1609c219663b43b5e6496096f7e Mon Sep 17 00:00:00 2001 From: Romain Tartiere Date: Sat, 1 Jan 2011 15:27:36 +0000 Subject: [PATCH] Fix CRC localisation code. New issue Summary: Add regression tests for CRC location in encyphered data files. The CRC position location code in mifare_cryto_postprocess_data() shall be checked. new issue Summary: Rework mifare_cryto_postprocess_data() CRC localisations The function has two different implementation of the same feature: locate a CRC at the end of a decyphered stream and check it. The crc32 will fail if the last CRC byte is 0x80, and the crc16 code looks awful. A refactoring would make our life easier. --- libfreefare/mifare_desfire_crypto.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libfreefare/mifare_desfire_crypto.c b/libfreefare/mifare_desfire_crypto.c index 912ad10..8f7dfa2 100644 --- a/libfreefare/mifare_desfire_crypto.c +++ b/libfreefare/mifare_desfire_crypto.c @@ -552,7 +552,7 @@ mifare_cryto_postprocess_data (MifareTag tag, void *data, ssize_t *nbytes, int c } else { end_crc_pos++; } - } while (!verified && (end_crc_pos < *nbytes - 1)); + } while (!verified && (end_crc_pos < *nbytes)); if (!verified) { warnx ("(3)DES not verified");