mirror of
https://github.com/RfidResearchGroup/proxmark3.git
synced 2024-09-21 15:56:21 +08:00
createapp fully works
This commit is contained in:
parent
2f2942c7db
commit
1b3e34c928
|
@ -5034,7 +5034,7 @@ static int CmdHF14ADesDefault(const char *Cmd) {
|
||||||
|
|
||||||
static int CmdHF14ADesCreateApp(const char *Cmd) {
|
static int CmdHF14ADesCreateApp(const char *Cmd) {
|
||||||
CLIParserContext *ctx;
|
CLIParserContext *ctx;
|
||||||
CLIParserInit(&ctx, "hf mfdes createid",
|
CLIParserInit(&ctx, "hf mfdes createaid",
|
||||||
"Create application. Master key needs to be provided.",
|
"Create application. Master key needs to be provided.",
|
||||||
"option rawdata have priority over the rest settings, and options ks1 and ks2 have priority over corresponded key settings\n"
|
"option rawdata have priority over the rest settings, and options ks1 and ks2 have priority over corresponded key settings\n"
|
||||||
"\n"\
|
"\n"\
|
||||||
|
@ -5065,9 +5065,9 @@ static int CmdHF14ADesCreateApp(const char *Cmd) {
|
||||||
" 6E = with FID, 3TDEA, 14 keys\n"\
|
" 6E = with FID, 3TDEA, 14 keys\n"\
|
||||||
" AE = with FID, AES, 14 keys\n"\
|
" AE = with FID, AES, 14 keys\n"\
|
||||||
"\n"\
|
"\n"\
|
||||||
"hf mfdes createid --rawdata 123456 -> execute create by rawdata\n"\
|
"hf mfdes createaid --rawdata 123456 -> execute create by rawdata\n"\
|
||||||
"hf mfdes createid --aid 123456 --fid 2345 --dfname aid123456 -> app aid, iso file id, and iso df name is specified\n"
|
"hf mfdes createaid --aid 123456 --fid 2345 --dfname aid123456 -> app aid, iso file id, and iso df name is specified\n"
|
||||||
"hf mfdes createid --aid 123456 --fid 2345 --dfname aid123456 --dstalgo aes -> with algorithm for key AES");
|
"hf mfdes createaid --aid 123456 --fid 2345 --dfname aid123456 --dstalgo aes -> with algorithm for key AES");
|
||||||
|
|
||||||
void *argtable[] = {
|
void *argtable[] = {
|
||||||
arg_param_begin,
|
arg_param_begin,
|
||||||
|
@ -5156,10 +5156,15 @@ static int CmdHF14ADesCreateApp(const char *Cmd) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (keycount > 0x0e || keycount < 1) {
|
if (keycount > 0x0e || keycount < 1) {
|
||||||
PrintAndLogEx(ERR, "Key count must be in the range 0x01..0x0e");
|
PrintAndLogEx(ERR, "Key count must be in the range 1..14");
|
||||||
return PM3_ESOFT;
|
return PM3_ESOFT;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (dfnamelen > 16) {
|
||||||
|
PrintAndLogEx(ERR, "DF name must be a maximum of 16 bytes in length");
|
||||||
|
return PM3_EINVARG;
|
||||||
|
}
|
||||||
|
|
||||||
res = DesfireSelectAndAuthenticate(&dctx, securechann, 0x000000, verbose);
|
res = DesfireSelectAndAuthenticate(&dctx, securechann, 0x000000, verbose);
|
||||||
if (res != PM3_SUCCESS) {
|
if (res != PM3_SUCCESS) {
|
||||||
DropField();
|
DropField();
|
||||||
|
@ -5178,19 +5183,21 @@ static int CmdHF14ADesCreateApp(const char *Cmd) {
|
||||||
|
|
||||||
if (!ks2present) {
|
if (!ks2present) {
|
||||||
if (keycount > 0) {
|
if (keycount > 0) {
|
||||||
//data[4] keycount
|
data[4] &= 0xf0;
|
||||||
|
data[4] |= keycount & 0x0f;
|
||||||
}
|
}
|
||||||
//data[4] dstalgo
|
uint8_t kt = DesfireKeyAlgoToType(dstalgo);
|
||||||
|
data[4] &= 0x3f;
|
||||||
|
data[4] |= (kt & 0x03) << 6;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
datalen = 5;
|
datalen = 5;
|
||||||
if (fileidpresent || (data[4] & 0x20) != 0) {
|
if (fileidpresent || (data[4] & 0x20) != 0) {
|
||||||
data[5] = fileid & 0xff;
|
data[5] = fileid & 0xff;
|
||||||
data[6] = (fileid >> 8) & 0xff;
|
data[6] = (fileid >> 8) & 0xff;
|
||||||
data[4] |= 0x20; // set bit FileID in the ks2
|
data[4] |= 0x20; // set bit FileID in the ks2
|
||||||
memcpy(&data[7], dfname, dfnamelen);
|
memcpy(&data[7], dfname, dfnamelen);
|
||||||
datalen = 7 + 16;
|
datalen = 7 + dfnamelen;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -988,6 +988,15 @@ int DesfireChangeKeySettings(DesfireContext *dctx, uint8_t *data, size_t len) {
|
||||||
return DesfireCommandTxData(dctx, MFDES_CHANGE_KEY_SETTINGS, data, len);
|
return DesfireCommandTxData(dctx, MFDES_CHANGE_KEY_SETTINGS, data, len);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
uint8_t DesfireKeyAlgoToType(DesfireCryptoAlgorythm keyType) {
|
||||||
|
switch(keyType) {
|
||||||
|
case T_DES: return 0x00;
|
||||||
|
case T_3DES: return 0x00;
|
||||||
|
case T_3K3DES: return 0x01;
|
||||||
|
case T_AES: return 0x02;
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
static void PrintKeyType(uint8_t keytype) {
|
static void PrintKeyType(uint8_t keytype) {
|
||||||
switch (keytype) {
|
switch (keytype) {
|
||||||
case 00:
|
case 00:
|
||||||
|
|
|
@ -53,5 +53,6 @@ int DesfireGetKeyVersion(DesfireContext *dctx, uint8_t *data, size_t len, uint8_
|
||||||
int DesfireGetKeySettings(DesfireContext *dctx, uint8_t *resp, size_t *resplen);
|
int DesfireGetKeySettings(DesfireContext *dctx, uint8_t *resp, size_t *resplen);
|
||||||
int DesfireChangeKeySettings(DesfireContext *dctx, uint8_t *data, size_t len);
|
int DesfireChangeKeySettings(DesfireContext *dctx, uint8_t *data, size_t len);
|
||||||
void PrintKeySettings(uint8_t keysettings, uint8_t numkeys, bool applevel, bool print2ndbyte);
|
void PrintKeySettings(uint8_t keysettings, uint8_t numkeys, bool applevel, bool print2ndbyte);
|
||||||
|
uint8_t DesfireKeyAlgoToType(DesfireCryptoAlgorythm keyType);
|
||||||
|
|
||||||
#endif // __DESFIRECORE_H
|
#endif // __DESFIRECORE_H
|
||||||
|
|
Loading…
Reference in a new issue