Skip to content

Commit

Permalink
Return EACCES when authentication to a DESFire tag fails
Browse files Browse the repository at this point in the history
Note that in case the tag didn't authenticate us, we've also
tag->last_picc_error = AUTHENTICATION_ERROR
But in the unlikely event that we didn't authenticate the tag
(e.g. if the tag is fake and pretends the auth was ok)
only errno = EACCES will be set
  • Loading branch information
doegox committed Mar 14, 2014
1 parent c72a559 commit c4e657f
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions libfreefare/mifare_desfire.c
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,8 @@ static ssize_t read_data (MifareTag tag, uint8_t command, uint8_t file_no, off_
res[__##res##_n-2] = __res[__##res##_n-1]; \
__##res##_n--; \
if ((1 == __##res##_n) && (ADDITIONAL_FRAME != res[__##res##_n-1]) && (OPERATION_OK != res[__##res##_n-1])) { \
if (res[0] == AUTHENTICATION_ERROR) \
errno = EACCES; \
return MIFARE_DESFIRE (tag)->last_picc_error = res[0], -1; \
} \
memcpy (res, __res, __##res##_n - 1); \
Expand Down Expand Up @@ -416,6 +418,7 @@ authenticate (MifareTag tag, uint8_t cmd, uint8_t key_no, MifareDESFireKey key)
hexdump (PCD_RndA_s, key_length, "PCD ", 0);
hexdump (PICC_RndA_s, key_length, "PICC ", 0);
#endif
errno = EACCES;
return -1;
}

Expand Down

0 comments on commit c4e657f

Please sign in to comment.