mirror of
https://github.com/RfidResearchGroup/proxmark3.git
synced 2025-08-22 22:33:48 -07:00
restrict change key algo
This commit is contained in:
parent
4c686799ab
commit
449f4edcb0
3 changed files with 12 additions and 4 deletions
|
@ -4998,7 +4998,7 @@ static int CmdHF14ADesChangeKey(const char *Cmd) {
|
|||
}
|
||||
|
||||
DesfireSetCommMode(&dctx, DCMEncryptedPlain);
|
||||
res = DesfireChangeKey(&dctx, newkeynum, newkeytype, newkeyver, newkey, oldkeytype, oldkey, true);
|
||||
res = DesfireChangeKey(&dctx, (appid == 0x000000), newkeynum, newkeytype, newkeyver, newkey, oldkeytype, oldkey, true);
|
||||
if (res == PM3_SUCCESS) {
|
||||
PrintAndLogEx(SUCCESS, "Change key " _GREEN_("ok") " ");
|
||||
} else {
|
||||
|
|
|
@ -1090,14 +1090,22 @@ void PrintKeySettings(uint8_t keysettings, uint8_t numkeys, bool applevel, bool
|
|||
PrintKeySettingsPICC(keysettings, numkeys, print2ndbyte);
|
||||
}
|
||||
|
||||
int DesfireChangeKey(DesfireContext *dctx, uint8_t newkeynum, DesfireCryptoAlgorythm newkeytype, uint32_t newkeyver, uint8_t *newkey, DesfireCryptoAlgorythm oldkeytype, uint8_t *oldkey, bool verbose) {
|
||||
int DesfireChangeKey(DesfireContext *dctx, bool change_master_key, uint8_t newkeynum, DesfireCryptoAlgorythm newkeytype, uint32_t newkeyver, uint8_t *newkey, DesfireCryptoAlgorythm oldkeytype, uint8_t *oldkey, bool verbose) {
|
||||
|
||||
uint8_t okeybuf[DESFIRE_MAX_KEY_SIZE] = {0};
|
||||
uint8_t nkeybuf[DESFIRE_MAX_KEY_SIZE] = {0};
|
||||
uint8_t pckcdata[DESFIRE_MAX_KEY_SIZE + 10] = {0};
|
||||
uint8_t *cdata = &pckcdata[2];
|
||||
uint8_t keynodata = newkeynum & 0x3f;
|
||||
|
||||
/*
|
||||
* Because new crypto methods can be setup only at application creation,
|
||||
* changing the card master key to one of them require a key_no tweak.
|
||||
*/
|
||||
if (change_master_key) {
|
||||
keynodata |= (DesfireKeyAlgoToType(newkeytype) & 0x03) << 6;
|
||||
}
|
||||
|
||||
pckcdata[0] = MFDES_CHANGE_KEY; // TODO
|
||||
pckcdata[1] = keynodata;
|
||||
|
||||
|
|
|
@ -56,6 +56,6 @@ void PrintKeySettings(uint8_t keysettings, uint8_t numkeys, bool applevel, bool
|
|||
uint8_t DesfireKeyAlgoToType(DesfireCryptoAlgorythm keyType);
|
||||
|
||||
int DesfireChangeKeyCmd(DesfireContext *dctx, uint8_t *data, size_t datalen, uint8_t *resp, size_t *resplen);
|
||||
int DesfireChangeKey(DesfireContext *dctx, uint8_t newkeynum, DesfireCryptoAlgorythm newkeytype, uint32_t newkeyver, uint8_t *newkey, DesfireCryptoAlgorythm oldkeytype, uint8_t *oldkey, bool verbose);
|
||||
int DesfireChangeKey(DesfireContext *dctx, bool change_master_key, uint8_t newkeynum, DesfireCryptoAlgorythm newkeytype, uint32_t newkeyver, uint8_t *newkey, DesfireCryptoAlgorythm oldkeytype, uint8_t *oldkey, bool verbose);
|
||||
|
||||
#endif // __DESFIRECORE_H
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue