-
Notifications
You must be signed in to change notification settings - Fork 115
Open
Description
While debugging another issue, I stumbled upon that code in read_data():
libfreefare/libfreefare/mifare_desfire.c
Line 1708 in c2b0cfa
| if ((MIFARE_DESFIRE(tag)->session_key) && (cs | MDCM_MACED)) { |
The (cs | MDCM_MACED) expression is obviously wrong as it is is always true.
Furthermore, there is something wrong in the main logic:
libfreefare/libfreefare/mifare_desfire.c
Lines 1707 to 1718 in c2b0cfa
| uint8_t ocs = cs; | |
| if ((MIFARE_DESFIRE(tag)->session_key) && (cs | MDCM_MACED)) { | |
| switch (MIFARE_DESFIRE(tag)->authentication_scheme) { | |
| case AS_LEGACY: | |
| break; | |
| case AS_NEW: | |
| cs = MDCM_PLAIN; | |
| break; | |
| } | |
| } | |
| uint8_t *p = mifare_cryto_preprocess_data(tag, cmd, &__cmd_n, 8, MDCM_PLAIN | CMAC_COMMAND); | |
| cs = ocs; |
The whole cs computation is useless, because its value is never used. Its initial value is saved into ocs at the beginning of the block, then restored afterwards. So there must be something missing (or just old unused code).
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels