fix cpp warnings
This commit is contained in:
1 parent
1a437d4a18
commit
a2d10d7910
8 files changed
+82
-62
No files matched your search
@@ -1839,15 +1839,13 @@ void annotateSeos(char *exp, size_t size, uint8_t *cmd, uint8_t cmdsize, bool is
|
||||
}
|
||||
|
||||
if (memcmp(cmd + pos, "\x00\x87\x00", 3) == 0) {
|
||||
|
||||
uint8_t ks = cmd[pos + 3];
|
||||
if (memcmp(cmd + pos + 3 + 1, "\x04\x7c\x02\x81\x00", 5) == 0) {
|
||||
snprintf(exp, size, "GET CHALLENGE " _WHITE_("(") " key " _MAGENTA_("%02X") " )", ks);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (memcmp(cmd + pos, "\x00\x87\x00", 3) == 0) {
|
||||
uint8_t ks = cmd[pos + 3];
|
||||
if (memcmp(cmd + pos + 3 + 1, "\x2C\x7C\x2A\x82\x28", 5) == 0) {
|
||||
snprintf(exp, size, "MUTUAL AUTHENTICATION " _WHITE_("(") " key " _MAGENTA_("%02X") " )", ks);
|
||||
}
|
||||
|
||||
+27
-11
@@ -705,10 +705,12 @@ static int CmdEM410xClone(const char *Cmd) {
|
||||
PacketResponseNG resp;
|
||||
|
||||
if (hts) {
|
||||
|
||||
lf_hitag_data_t packet;
|
||||
memset(&packet, 0, sizeof(packet));
|
||||
|
||||
for (size_t step = 0; step < 3; step++) {
|
||||
|
||||
switch (step) {
|
||||
case 0: {
|
||||
hitags_config_t config = {0};
|
||||
@@ -722,18 +724,21 @@ static int CmdEM410xClone(const char *Cmd) {
|
||||
config.RES4 = 0x01;
|
||||
config.RES5 = 0x01;
|
||||
switch (clk) {
|
||||
case 64:
|
||||
case 64: {
|
||||
// 2 kBit/s
|
||||
config.TTFDR = 0x02;
|
||||
break;
|
||||
case 32:
|
||||
}
|
||||
case 32: {
|
||||
// 4 kBit/s
|
||||
config.TTFDR = 0x00;
|
||||
break;
|
||||
case 16:
|
||||
}
|
||||
case 16: {
|
||||
// 8 kBit/s
|
||||
config.TTFDR = 0x01;
|
||||
break;
|
||||
}
|
||||
}
|
||||
//TODO: keep other fields?
|
||||
memcpy(packet.data, &config, sizeof(config));
|
||||
@@ -741,30 +746,35 @@ static int CmdEM410xClone(const char *Cmd) {
|
||||
packet.page = 1;
|
||||
break;
|
||||
}
|
||||
case 1:
|
||||
case 1: {
|
||||
memcpy(packet.data, &data[HITAGS_PAGE_SIZE * 0], HITAGS_PAGE_SIZE);
|
||||
packet.page = 4;
|
||||
break;
|
||||
case 2:
|
||||
}
|
||||
case 2: {
|
||||
memcpy(packet.data, &data[HITAGS_PAGE_SIZE * 1], HITAGS_PAGE_SIZE);
|
||||
packet.page = 5;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
packet.cmd = HTSF_82xx;
|
||||
memcpy(packet.pwd, "\xBB\xDD\x33\x99", HITAGS_PAGE_SIZE);
|
||||
packet.mode = HITAGS_UID_REQ_FADV;
|
||||
|
||||
SendCommandNG(CMD_LF_HITAGS_WRITE, (uint8_t *)&packet, sizeof(packet));
|
||||
if (WaitForResponseTimeout(CMD_LF_HITAGS_WRITE, &resp, 4000) == false) {
|
||||
PrintAndLogEx(WARNING, "timeout while waiting for reply");
|
||||
return PM3_ETIMEOUT;
|
||||
}
|
||||
|
||||
if (resp.status != PM3_SUCCESS) {
|
||||
PrintAndLogEx(WARNING, "Something went wrong in step %zu", step);
|
||||
return resp.status;
|
||||
}
|
||||
}
|
||||
} else if (htu) {
|
||||
|
||||
lf_hitag_data_t packet;
|
||||
memset(&packet, 0, sizeof(packet));
|
||||
|
||||
@@ -774,6 +784,7 @@ static int CmdEM410xClone(const char *Cmd) {
|
||||
// memcpy(packet.pwd, "\x9A\xC4\x99\x9C", HITAGU_BLOCK_SIZE);
|
||||
|
||||
for (size_t step = 0; step < 3; step++) {
|
||||
|
||||
switch (step) {
|
||||
case 0: {
|
||||
// Configure datarate based on clock
|
||||
@@ -789,27 +800,32 @@ static int CmdEM410xClone(const char *Cmd) {
|
||||
config.ttf = 0x01; // enable TTF
|
||||
|
||||
switch (clk) {
|
||||
case 64:
|
||||
case 64: {
|
||||
break;
|
||||
case 32:
|
||||
}
|
||||
case 32: {
|
||||
config.datarate = 0x01;
|
||||
break;
|
||||
case 16:
|
||||
}
|
||||
case 16: {
|
||||
config.datarate = 0x02;
|
||||
break;
|
||||
}
|
||||
}
|
||||
packet.data[0] = reflect8(*(uint8_t *)&config);
|
||||
packet.page = HITAGU_CONFIG_PADR; // Config block
|
||||
break;
|
||||
}
|
||||
case 1:
|
||||
case 1: {
|
||||
memcpy(packet.data, &data[HITAGU_BLOCK_SIZE * 0], HITAGU_BLOCK_SIZE);
|
||||
packet.page = 0; // Start writing EM410x data
|
||||
break;
|
||||
case 2:
|
||||
}
|
||||
case 2: {
|
||||
memcpy(packet.data, &data[HITAGU_BLOCK_SIZE * 1], HITAGU_BLOCK_SIZE);
|
||||
packet.page = 1; // Continue with second block
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
SendCommandNG(CMD_LF_HITAGU_WRITE, (uint8_t *)&packet, sizeof(packet));
|
||||
@@ -859,7 +875,7 @@ static int CmdEM410xClone(const char *Cmd) {
|
||||
switch (resp.status) {
|
||||
case PM3_SUCCESS: {
|
||||
PrintAndLogEx(SUCCESS, "Done!");
|
||||
PrintAndLogEx(HINT, "Hint: Try " _YELLOW_("`lf em 410x reader`") " to verify");
|
||||
PrintAndLogEx(HINT, "Hint: Try `" _YELLOW_("lf em 410x reader") "` to verify");
|
||||
break;
|
||||
}
|
||||
default: {
|
||||
|
||||
@@ -210,7 +210,6 @@ static int process_hitagu_common_args(CLIParserContext *ctx, lf_hitag_data_t *co
|
||||
|
||||
int res = CLIParamHexToBuf(arg_get_str(ctx, 2), key, HITAG_PASSWORD_SIZE, &key_len);
|
||||
if (res != 0) {
|
||||
CLIParserFree(ctx);
|
||||
return PM3_EINVARG;
|
||||
}
|
||||
|
||||
@@ -341,6 +340,7 @@ static int CmdLFHitagURead(const char *Cmd) {
|
||||
lf_hitag_data_t packet;
|
||||
|
||||
if (process_hitagu_common_args(ctx, &packet) < 0) {
|
||||
CLIParserFree(ctx);
|
||||
return PM3_EINVARG;
|
||||
}
|
||||
|
||||
@@ -613,7 +613,10 @@ static int CmdLFHitagUWrite(const char *Cmd) {
|
||||
|
||||
lf_hitag_data_t packet;
|
||||
|
||||
if (process_hitagu_common_args(ctx, &packet) < 0) return PM3_EINVARG;
|
||||
if (process_hitagu_common_args(ctx, &packet) < 0) {
|
||||
CLIParserFree(ctx);
|
||||
return PM3_EINVARG;
|
||||
}
|
||||
|
||||
int page = arg_get_int_def(ctx, 3, 0);
|
||||
|
||||
|
||||
@@ -1916,15 +1916,14 @@ void DesfirePrintAppList(DesfireContext_t *dctx, PICCInfo_t *PICCInfo, AppListS
|
||||
}
|
||||
|
||||
if (appList[i].numberOfKeys > 0) {
|
||||
|
||||
PrintKeySettings(appList[i].keySettings, appList[i].numKeysRaw, true, true);
|
||||
|
||||
if (appList[i].numberOfKeys > 0) {
|
||||
PrintAndLogEx(SUCCESS, "Key versions [0..%d] " NOLF, appList[i].numberOfKeys - 1);
|
||||
for (uint8_t keyn = 0; keyn < appList[i].numberOfKeys; keyn++) {
|
||||
PrintAndLogEx(NORMAL, "%s %02x" NOLF, (keyn == 0) ? "" : ",", appList[i].keyVersions[keyn]);
|
||||
}
|
||||
PrintAndLogEx(NORMAL, "\n");
|
||||
PrintAndLogEx(SUCCESS, "Key versions [0..%d] " NOLF, appList[i].numberOfKeys - 1);
|
||||
for (uint8_t keyn = 0; keyn < appList[i].numberOfKeys; keyn++) {
|
||||
PrintAndLogEx(NORMAL, "%s %02x" NOLF, (keyn == 0) ? "" : ",", appList[i].keyVersions[keyn]);
|
||||
}
|
||||
PrintAndLogEx(NORMAL, "\n");
|
||||
|
||||
if (appList[i].filesReaded) {
|
||||
PrintAndLogEx(SUCCESS, "Application have " _GREEN_("%zu") " files", appList[i].filesCount);
|
||||
@@ -1935,10 +1934,11 @@ void DesfirePrintAppList(DesfireContext_t *dctx, PICCInfo_t *PICCInfo, AppListS
|
||||
PrintAndLogEx(SUCCESS, "--------------------------------- " _CYAN_("File %02x") " ----------------------------------", appList[i].fileList[fnum].fileNum);
|
||||
PrintAndLogEx(SUCCESS, "File ID : " _GREEN_("%02x"), appList[i].fileList[fnum].fileNum);
|
||||
if (appList[i].isoPresent) {
|
||||
if (appList[i].fileList[fnum].fileISONum != 0)
|
||||
if (appList[i].fileList[fnum].fileISONum != 0) {
|
||||
PrintAndLogEx(SUCCESS, "File ISO ID : %04x", appList[i].fileList[fnum].fileISONum);
|
||||
else
|
||||
} else {
|
||||
PrintAndLogEx(SUCCESS, "File ISO ID : " _YELLOW_("n/a"));
|
||||
}
|
||||
}
|
||||
DesfirePrintFileSettingsExtended(&appList[i].fileList[fnum].fileSettings);
|
||||
}
|
||||
@@ -2289,16 +2289,19 @@ static void PrintKeySettingsApp(uint8_t keysettings, uint8_t numkeys, bool print
|
||||
PrintAndLogEx(SUCCESS, "Application level rights");
|
||||
uint8_t rights = ((keysettings >> 4) & 0x0F);
|
||||
switch (rights) {
|
||||
case 0x0:
|
||||
case 0x0: {
|
||||
PrintAndLogEx(SUCCESS, " - AMK authentication is necessary to change any key (default)");
|
||||
break;
|
||||
case 0xE:
|
||||
}
|
||||
case 0xE: {
|
||||
PrintAndLogEx(SUCCESS, " - Authentication with the key to be changed (same KeyNo) is necessary to change a key");
|
||||
break;
|
||||
case 0xF:
|
||||
}
|
||||
case 0xF: {
|
||||
PrintAndLogEx(SUCCESS, " - All keys (except AMK,see Bit0) within this application are frozen");
|
||||
break;
|
||||
default:
|
||||
}
|
||||
default: {
|
||||
PrintAndLogEx(SUCCESS,
|
||||
" - Authentication with the specified key " _YELLOW_("(0x%02x)") " is necessary to change any key.\n"
|
||||
"A change key and a PICC master key (CMK) can only be changed after authentication with the master key.\n"
|
||||
@@ -2306,6 +2309,7 @@ static void PrintKeySettingsApp(uint8_t keysettings, uint8_t numkeys, bool print
|
||||
rights & 0x0f
|
||||
);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
PrintAndLogEx(SUCCESS, "[%c...] AMK Configuration changeable : %s", (keysettings & (1 << 3)) ? '1' : '0', (keysettings & (1 << 3)) ? _GREEN_("YES") : _RED_("NO (frozen)"));
|
||||
@@ -2324,10 +2328,11 @@ static void PrintKeySettingsApp(uint8_t keysettings, uint8_t numkeys, bool print
|
||||
}
|
||||
|
||||
void PrintKeySettings(uint8_t keysettings, uint8_t numkeys, bool applevel, bool print2ndbyte) {
|
||||
if (applevel)
|
||||
if (applevel) {
|
||||
PrintKeySettingsApp(keysettings, numkeys, print2ndbyte);
|
||||
else
|
||||
} else {
|
||||
PrintKeySettingsPICC(keysettings, numkeys, print2ndbyte);
|
||||
}
|
||||
}
|
||||
|
||||
static const char *DesfireUnknownStr = "unknown";
|
||||
|
||||
@@ -503,18 +503,22 @@ uint8_t DesfireKeyAlgoToType(DesfireCryptoAlgorithm keyType) {
|
||||
|
||||
void DesfirePrintCardKeyType(uint8_t keyType) {
|
||||
switch (keyType) {
|
||||
case 00:
|
||||
case 00: {
|
||||
PrintAndLogEx(SUCCESS, "Key type... " _YELLOW_("2TDEA"));
|
||||
break;
|
||||
case 01:
|
||||
}
|
||||
case 01: {
|
||||
PrintAndLogEx(SUCCESS, "Key type... " _YELLOW_("3TDEA"));
|
||||
break;
|
||||
case 02:
|
||||
}
|
||||
case 02: {
|
||||
PrintAndLogEx(SUCCESS, "Key type... " _YELLOW_("AES"));
|
||||
break;
|
||||
default:
|
||||
}
|
||||
default: {
|
||||
PrintAndLogEx(SUCCESS, "Key type... " _YELLOW_("unknown") " - 0x%02x", keyType);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user