While debugging another issue, I stumbled upon that code in read_data():
|
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:
|
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).
While debugging another issue, I stumbled upon that code in
read_data():libfreefare/libfreefare/mifare_desfire.c
Line 1708 in c2b0cfa
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
The whole
cscomputation is useless, because its value is never used. Its initial value is saved intoocsat the beginning of the block, then restored afterwards. So there must be something missing (or just old unused code).