mirror of
https://github.com/RfidResearchGroup/proxmark3.git
synced 2025-08-20 13:23:51 -07:00
Gallagher key checking is now supported on MIFARE Desfire
Both `hf mfdes auth` and `hf mfdes chk` now support Key Diversification for AN10922 and as special treat, Gallagher issued cards. For `hf mfdes auth`: ``` -d, --kdf <kdf> Key Derivation Function (KDF) (0=None, 1=AN10922, 2=Gallagher) -i, --kdfi <kdfi> KDF input (HEX 1-31 bytes) ``` And for `hf mfdes chk`: ``` -f, --kdf <kdf> Key Derivation Function (KDF) (0=None, 1=AN10922, Gallagher) -i, --kdfi <kdfi> KDF input (HEX 1-31 bytes) ``` Examples: - `hf mfdes auth -a 2081f4 -m 3 -t 4 -d 2 -n 2 -k 00112233445566778899aabbccddeeff` Will diversify the key for key `2` on AID `2081F4` for Gallagher issued cards - `hf mfdes chk -f 1 -i 00112233 -d mfdes_default_keys` Will read in all the default keys from the dictionary, and diversify them using AN10922 with the input data `00112233` - `hf mfdes chk -f 2 -d mfdes_default_keys` Will read in all the default keys from the dictionary, and diversify them using AN10922 but with input data generated from the card's UID, AID and key number.
This commit is contained in:
parent
634c69398d
commit
c9a10631de
5 changed files with 105 additions and 3 deletions
|
@ -423,6 +423,47 @@ uint32_t lf_t55xx_white_pwdgen(uint32_t id) {
|
|||
return pwd;
|
||||
}
|
||||
|
||||
// Gallagher Desfire Key Diversification Input for Cardax Card Data Application
|
||||
int mfdes_kdf_input_gallagher(uint8_t *uid, uint8_t uidLen, uint8_t keyNo, uint32_t aid, uint8_t *kdfInputOut, uint8_t *kdfInputLen) {
|
||||
if (uid == NULL || (uidLen != 4 && uidLen != 7) || keyNo > 2 || kdfInputOut == NULL || kdfInputLen == NULL) {
|
||||
if (g_debugMode) {
|
||||
PrintAndLogEx(WARNING, "Invalid arguments");
|
||||
}
|
||||
return PM3_EINVARG;
|
||||
}
|
||||
|
||||
// Verify the AppID is a valid Gallagher AppID
|
||||
if ((aid & 0xF0FFFF) != 0x2081F4) {
|
||||
if (g_debugMode) {
|
||||
PrintAndLogEx(WARNING, "Invalid Gallagher AID %06X", aid);
|
||||
}
|
||||
return PM3_EINVARG;
|
||||
}
|
||||
|
||||
int len = 0;
|
||||
// If the keyNo == 1, then omit the UID.
|
||||
if (keyNo != 1) {
|
||||
if (*kdfInputLen < (4 + uidLen)) {
|
||||
return PM3_EINVARG;
|
||||
}
|
||||
|
||||
memcpy(kdfInputOut, uid, uidLen);
|
||||
len += uidLen;
|
||||
} else if (*kdfInputLen < 4) {
|
||||
return PM3_EINVARG;
|
||||
}
|
||||
|
||||
kdfInputOut[len++] = keyNo;
|
||||
|
||||
kdfInputOut[len++] = aid & 0xff;
|
||||
kdfInputOut[len++] = (aid >> 8) & 0xff;
|
||||
kdfInputOut[len++] = (aid >> 16) & 0xff;
|
||||
|
||||
*kdfInputLen = len;
|
||||
|
||||
return PM3_SUCCESS;
|
||||
}
|
||||
|
||||
//------------------------------------
|
||||
// Self tests
|
||||
//------------------------------------
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue