Invalidate authentication when changing the currently used key.

This commit is contained in:
Romain Tartiere 2010-12-18 01:32:56 +00:00
parent 143042fb0b
commit 48b161d67c

View file

@ -554,6 +554,15 @@ mifare_desfire_change_key (MifareTag tag, uint8_t key_no, MifareDESFireKey new_k
ssize_t sn = __res_n; ssize_t sn = __res_n;
mifare_cryto_postprocess_data (tag, res, &sn, MDCM_PLAIN | CMAC_COMMAND | CMAC_VERIFY); mifare_cryto_postprocess_data (tag, res, &sn, MDCM_PLAIN | CMAC_COMMAND | CMAC_VERIFY);
/*
* If we changed the current authenticated key, we are not authenticated
* anymore.
*/
if (key_no == MIFARE_DESFIRE (tag)->authenticated_key_no) {
free (MIFARE_DESFIRE (tag)->session_key);
MIFARE_DESFIRE (tag)->session_key = NULL;
}
return 0; return 0;
} }