null key fix

This commit is contained in:
iceman1001 2022-01-08 15:28:36 +01:00
parent 7c7dfa7d39
commit 5ff043e5ab

View file

@ -60,14 +60,17 @@ int hfgal_diversify_key(uint8_t *site_key, uint8_t *uid, uint8_t uid_len,
int res = mfdes_kdf_input_gallagher(uid, uid_len, key_num, aid, key_output, &kdf_input_len);
PM3_RET_IF_ERR_WITH_MSG(res, "Failed generating Gallagher key diversification input");
uint8_t key[sizeof(DEFAULT_SITE_KEY)];
if (site_key == NULL) {
PrintAndLogEx(INFO, "hfgal_diversify_key is using default site key");
memcpy(site_key, DEFAULT_SITE_KEY, sizeof(DEFAULT_SITE_KEY));
memcpy(key, DEFAULT_SITE_KEY, sizeof(key));
} else {
memcpy(key, site_key, sizeof(key));
}
// Make temporary DesfireContext
DesfireContext_t dctx = {0};
DesfireSetKey(&dctx, 0, T_AES, site_key);
DesfireSetKey(&dctx, 0, T_AES, key);
// Diversify input & copy to output buffer
MifareKdfAn10922(&dctx, DCOMasterKey, key_output, kdf_input_len);