mirror of
https://github.com/RfidResearchGroup/proxmark3.git
synced 2025-08-24 07:05:40 -07:00
make style
This commit is contained in:
parent
1b3e34c928
commit
480bd87207
2 changed files with 39 additions and 188 deletions
|
@ -5227,159 +5227,6 @@ static int CmdHF14ADesCreateApp(const char *Cmd) {
|
||||||
|
|
||||||
DropField();
|
DropField();
|
||||||
return PM3_SUCCESS;
|
return PM3_SUCCESS;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*CLIParserContext *ctx;
|
|
||||||
CLIParserInit(&ctx, "hf mfdes createaid",
|
|
||||||
"Create Application ID",
|
|
||||||
"hf mfdes createaid -a 123456 -f 1111 -k 0E -l 2E --name Test"
|
|
||||||
);
|
|
||||||
|
|
||||||
void *argtable[] = {
|
|
||||||
arg_param_begin,
|
|
||||||
arg_strx0("a", "aid", "<hex>", "App ID to create as hex bytes (3 hex bytes)"),
|
|
||||||
arg_strx0("f", "fid", "<hex>", "File ID to create"),
|
|
||||||
arg_strx0("k", "ks1", "<hex>", "Key Setting 1 (Application Master Key Settings)"),
|
|
||||||
arg_strx0("l", "ks2", "<hex>", "Key Setting 2"),
|
|
||||||
arg_str0(NULL, "name", "<ascii>", "App ISO-4 Name"),
|
|
||||||
arg_param_end
|
|
||||||
};
|
|
||||||
CLIExecWithReturn(ctx, Cmd, argtable, false);
|
|
||||||
KeySetting 1 (AMK Setting):
|
|
||||||
0: Allow change master key
|
|
||||||
1: Free Directory list access without master key
|
|
||||||
0: AMK auth needed for GetFileSettings and GetKeySettings
|
|
||||||
1: No AMK auth needed for GetFileIDs, GetISOFileIDs, GetFileSettings, GetKeySettings
|
|
||||||
2: Free create/delete without master key
|
|
||||||
0: CreateFile/DeleteFile only with AMK auth
|
|
||||||
1: CreateFile/DeleteFile always
|
|
||||||
3: Configuration changable
|
|
||||||
0: Configuration frozen
|
|
||||||
1: Configuration changable if authenticated with AMK (default)
|
|
||||||
4-7: ChangeKey Access Rights
|
|
||||||
0: Application master key needed (default)
|
|
||||||
0x1..0xD: Auth with specific key needed to change any key
|
|
||||||
0xE: Auth with the key to be changed (same KeyNo) is necessary to change a key
|
|
||||||
0xF: All Keys within this application are frozen
|
|
||||||
|
|
||||||
|
|
||||||
KeySetting 2:
|
|
||||||
0..3: Number of keys stored within the application (max. 14 keys)
|
|
||||||
4: RFU
|
|
||||||
5: Use of 2 byte ISO FID, 0: No, 1: Yes
|
|
||||||
6..7: Crypto Method 00: DES/3DES, 01: 3K3DES, 10: AES
|
|
||||||
Example:
|
|
||||||
2E = FID, DES, 14 keys
|
|
||||||
6E = FID, 3K3DES, 14 keys
|
|
||||||
AE = FID, AES, 14 keys
|
|
||||||
|
|
||||||
int aidlength = 3;
|
|
||||||
uint8_t aid[3] = {0};
|
|
||||||
CLIGetHexWithReturn(ctx, 1, aid, &aidlength);
|
|
||||||
|
|
||||||
int fidlength = 2;
|
|
||||||
uint8_t fid[2] = {0};
|
|
||||||
CLIGetHexWithReturn(ctx, 2, fid, &fidlength);
|
|
||||||
|
|
||||||
int keylen1 = 1;
|
|
||||||
uint8_t keysetting1[1] = {0};
|
|
||||||
CLIGetHexWithReturn(ctx, 3, keysetting1, &keylen1);
|
|
||||||
|
|
||||||
int keylen2 = 1;
|
|
||||||
uint8_t keysetting2[1] = {0};
|
|
||||||
CLIGetHexWithReturn(ctx, 4, keysetting2, &keylen2);
|
|
||||||
|
|
||||||
int namelen = 16;
|
|
||||||
uint8_t name[16] = {0};
|
|
||||||
CLIGetStrWithReturn(ctx, 5, name, &namelen);
|
|
||||||
CLIParserFree(ctx);
|
|
||||||
|
|
||||||
swap24(aid);
|
|
||||||
swap16(fid);
|
|
||||||
|
|
||||||
if (aidlength != 3) {
|
|
||||||
PrintAndLogEx(ERR, "AID must have 3 bytes length");
|
|
||||||
return PM3_EINVARG;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (fidlength != 2 && fidlength != 0) {
|
|
||||||
PrintAndLogEx(ERR, "FID must have 2 bytes length");
|
|
||||||
return PM3_EINVARG;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool usefid = (fidlength != 0);
|
|
||||||
|
|
||||||
if (keylen1 != 1) {
|
|
||||||
PrintAndLogEx(ERR, "Keysetting1 must have 1 byte length");
|
|
||||||
return PM3_EINVARG;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (keylen2 != 1) {
|
|
||||||
PrintAndLogEx(ERR, "Keysetting2 must have 1 byte length");
|
|
||||||
return PM3_EINVARG;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (namelen > 16) {
|
|
||||||
PrintAndLogEx(ERR, "Name has a max. of 16 bytes length");
|
|
||||||
return PM3_EINVARG;
|
|
||||||
}
|
|
||||||
bool usename = true;
|
|
||||||
if (namelen == 0) usename = false;
|
|
||||||
|
|
||||||
//90 ca 00 00 0e 3cb849 09 22 10e1 d27600 00850101 00
|
|
||||||
*char name[]="Test";
|
|
||||||
uint8_t aid[]={0x12,0x34,0x56};
|
|
||||||
uint8_t fid[]={0x11,0x22};
|
|
||||||
uint8_t keysetting1=0xEE;
|
|
||||||
uint8_t keysetting2=0xEE;
|
|
||||||
|
|
||||||
if (memcmp(aid, "\x00\x00\x00", 3) == 0) {
|
|
||||||
PrintAndLogEx(WARNING, _RED_(" Creating root aid 000000 is forbidden"));
|
|
||||||
return PM3_ESOFT;
|
|
||||||
}
|
|
||||||
|
|
||||||
aidhdr_t aidhdr;
|
|
||||||
memcpy(aidhdr.aid, aid, sizeof(aid));
|
|
||||||
aidhdr.keysetting1 = keysetting1[0];
|
|
||||||
aidhdr.keysetting2 = keysetting2[0];
|
|
||||||
|
|
||||||
if (usefid)
|
|
||||||
memcpy(aidhdr.fid, fid, sizeof(aidhdr.fid));
|
|
||||||
|
|
||||||
if (usename)
|
|
||||||
memcpy(aidhdr.name, name, sizeof(aidhdr.name));
|
|
||||||
|
|
||||||
PrintAndLogEx(INFO, "Creating AID using:");
|
|
||||||
PrintAndLogEx(INFO, "AID %s", sprint_hex_inrow(aidhdr.aid, sizeof(aidhdr.aid)));
|
|
||||||
PrintAndLogEx(INFO, "Key set1 0x%02X", aidhdr.keysetting1);
|
|
||||||
PrintAndLogEx(INFO, "Key Set2 0x%02X", aidhdr.keysetting2);
|
|
||||||
if (usefid)
|
|
||||||
PrintAndLogEx(INFO, "FID %s", sprint_hex_inrow(aidhdr.fid, sizeof(aidhdr.fid)));
|
|
||||||
if (usename)
|
|
||||||
PrintAndLogEx(INFO, "DF Name %s", aidhdr.name);
|
|
||||||
|
|
||||||
|
|
||||||
uint8_t rootaid[3] = {0x00, 0x00, 0x00};
|
|
||||||
int res = handler_desfire_select_application(rootaid);
|
|
||||||
if (res != PM3_SUCCESS) {
|
|
||||||
DropFieldDesfire();
|
|
||||||
return res;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
int res = handler_desfire_createapp(&aidhdr, usename, usefid);
|
|
||||||
DropFieldDesfire();
|
|
||||||
if (res == PM3_SUCCESS) {
|
|
||||||
PrintAndLogEx(SUCCESS, "Successfully created aid.");
|
|
||||||
}
|
|
||||||
return res;*/
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static int CmdHF14ADesDeleteApp(const char *Cmd) {
|
static int CmdHF14ADesDeleteApp(const char *Cmd) {
|
||||||
|
|
|
@ -989,11 +989,15 @@ int DesfireChangeKeySettings(DesfireContext *dctx, uint8_t *data, size_t len) {
|
||||||
}
|
}
|
||||||
|
|
||||||
uint8_t DesfireKeyAlgoToType(DesfireCryptoAlgorythm keyType) {
|
uint8_t DesfireKeyAlgoToType(DesfireCryptoAlgorythm keyType) {
|
||||||
switch(keyType) {
|
switch (keyType) {
|
||||||
case T_DES: return 0x00;
|
case T_DES:
|
||||||
case T_3DES: return 0x00;
|
return 0x00;
|
||||||
case T_3K3DES: return 0x01;
|
case T_3DES:
|
||||||
case T_AES: return 0x02;
|
return 0x00;
|
||||||
|
case T_3K3DES:
|
||||||
|
return 0x01;
|
||||||
|
case T_AES:
|
||||||
|
return 0x02;
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue