Skip to content

Commit

Permalink
move rng info and add static encrypted nonce detect placeholder
Browse files Browse the repository at this point in the history
  • Loading branch information
merlokk committed Dec 11, 2023
1 parent 784e110 commit edd004a
Showing 1 changed file with 31 additions and 28 deletions.
59 changes: 31 additions & 28 deletions client/src/cmdhfmf.c
Original file line number Diff line number Diff line change
Expand Up @@ -8863,30 +8863,6 @@ static int CmdHF14AMfInfo(const char *Cmd) {
if (setDeviceDebugLevel(DBG_NONE, false) != PM3_SUCCESS)
return PM3_EFAILED;

PrintAndLogEx(INFO, "--- " _CYAN_("RNG Information") "---------------------");

int res = detect_classic_static_nonce();
if (res == NONCE_STATIC)
PrintAndLogEx(SUCCESS, "Static nonce: " _YELLOW_("yes"));

if (res == NONCE_FAIL && verbose)
PrintAndLogEx(SUCCESS, "Static nonce: " _RED_("read failed"));

if (res == NONCE_NORMAL) {

// not static
res = detect_classic_prng();
if (res == 1)
PrintAndLogEx(SUCCESS, "Prng detection: " _GREEN_("weak"));
else if (res == 0)
PrintAndLogEx(SUCCESS, "Prng detection: " _YELLOW_("hard"));
else
PrintAndLogEx(FAILED, "Prng detection: " _RED_("fail"));

if (do_nack_test)
detect_classic_nackbug(verbose);
}

PrintAndLogEx(INFO, "--- " _CYAN_("Backdoors Information") "---------------------");
if (detect_mf_magic(true) == 0)
PrintAndLogEx(INFO, "<none>");
Expand All @@ -8898,9 +8874,9 @@ static int CmdHF14AMfInfo(const char *Cmd) {
int sectorsCnt = 1;
uint8_t *keyBlock = NULL;
uint32_t keycnt = 0;
int ret = mfLoadKeys(&keyBlock, &keycnt, NULL, 0, NULL, 0);
if (ret != PM3_SUCCESS) {
return ret;
int res = mfLoadKeys(&keyBlock, &keycnt, NULL, 0, NULL, 0);
if (res != PM3_SUCCESS) {
return res;
}

// create/initialize key storage structure
Expand Down Expand Up @@ -8938,6 +8914,34 @@ static int CmdHF14AMfInfo(const char *Cmd) {
free(keyBlock);
free(e_sector);

PrintAndLogEx(INFO, "--- " _CYAN_("RNG Information") "---------------------");

res = detect_classic_static_nonce();
if (res == NONCE_STATIC)
PrintAndLogEx(SUCCESS, "Static nonce: " _YELLOW_("yes"));

if (res == NONCE_FAIL && verbose)
PrintAndLogEx(SUCCESS, "Static nonce: " _RED_("read failed"));

if (res == NONCE_NORMAL) {
// not static
res = detect_classic_prng();
if (res == 1)
PrintAndLogEx(SUCCESS, "Prng detection: " _GREEN_("weak"));
else if (res == 0)
PrintAndLogEx(SUCCESS, "Prng detection: " _YELLOW_("hard"));
else
PrintAndLogEx(FAILED, "Prng detection: " _RED_("fail"));


// detect static encrypted nonce
if (keyType != 0xff) {

}

if (do_nack_test)
detect_classic_nackbug(verbose);
}

uint8_t signature[32] = {0};
res = read_mfc_ev1_signature(signature);
Expand All @@ -8949,7 +8953,6 @@ static int CmdHF14AMfInfo(const char *Cmd) {
if (setDeviceDebugLevel(dbg_curr, false) != PM3_SUCCESS)
return PM3_EFAILED;

PrintAndLogEx(NORMAL, "done...");
return PM3_SUCCESS;
}

Expand Down

0 comments on commit edd004a

Please sign in to comment.