From 772728bcec6c792d7b012c6c0658d2b30783cfc8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vincent=20Rivi=C3=A8re?= Date: Wed, 16 Oct 2024 16:37:11 +0200 Subject: [PATCH] Fix mifare_cryto_postprocess_data() with MDCM_MACED + AS_LEGACY This caused mifare_desfire_read_data() to fail with CRYPTO_ERROR when the communication settings are set to 1 (Plain+MAC). In this case, the received frame doesn't contain any CRC (only MAC). --- 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 b9a3c713..535ddd3b 100644 --- a/libfreefare/mifare_desfire_crypto.c +++ b/libfreefare/mifare_desfire_crypto.c @@ -499,7 +499,7 @@ mifare_cryto_postprocess_data(FreefareTag tag, void *data, ssize_t *nbytes, int break; } - edl = enciphered_data_length(tag, *nbytes - 1, communication_settings); + edl = enciphered_data_length(tag, *nbytes - 1, communication_settings | NO_CRC); if (!(edata = malloc(edl))) abort();