mirror of
https://github.com/RfidResearchGroup/proxmark3.git
synced 2025-08-21 05:43:48 -07:00
style
This commit is contained in:
parent
0b106665d4
commit
bb4dad45d9
1 changed files with 16 additions and 17 deletions
|
@ -1356,10 +1356,13 @@ void MifareNested(uint8_t blockNo, uint8_t keyType, uint8_t targetBlockNo, uint8
|
|||
LED_C_ON();
|
||||
|
||||
// get crypted nonces for target sector
|
||||
for (i = 0; i < 2 && !isOK; i++) { // look for exactly two different nonces
|
||||
for (i = 0; ((i < 2) && (isOK == PM3_SUCCESS)); i++) {
|
||||
|
||||
// look for exactly two different nonces
|
||||
|
||||
target_nt[i] = 0;
|
||||
while (target_nt[i] == 0) { // continue until we have an unambiguous nonce
|
||||
// continue until we have an unambiguous nonce
|
||||
while (target_nt[i] == 0) {
|
||||
|
||||
// Test if the action was cancelled
|
||||
if (BUTTON_PRESS() || data_available()) {
|
||||
|
@ -1373,7 +1376,7 @@ void MifareNested(uint8_t blockNo, uint8_t keyType, uint8_t targetBlockNo, uint8
|
|||
continue;
|
||||
}
|
||||
|
||||
if (!iso14443a_select_card(uid, NULL, &cuid, true, 0, true)) {
|
||||
if (iso14443a_select_card(uid, NULL, &cuid, true, 0, true) == false) {
|
||||
if (g_dbglevel >= DBG_INFO) Dbprintf("Nested: Can't select card");
|
||||
continue;
|
||||
};
|
||||
|
@ -1452,6 +1455,7 @@ void MifareNested(uint8_t blockNo, uint8_t keyType, uint8_t targetBlockNo, uint8
|
|||
memcpy(payload.nt_b, &target_nt[1], 4);
|
||||
memcpy(payload.ks_b, &target_ks[1], 4);
|
||||
|
||||
LED_B_ON();
|
||||
reply_ng(CMD_HF_MIFARE_NESTED, PM3_SUCCESS, (uint8_t *)&payload, sizeof(payload));
|
||||
FpgaWriteConfWord(FPGA_MAJOR_MODE_OFF);
|
||||
LEDsoff();
|
||||
|
@ -1497,7 +1501,7 @@ void MifareStaticNested(uint8_t blockNo, uint8_t keyType, uint8_t targetBlockNo,
|
|||
continue;
|
||||
};
|
||||
|
||||
// first colleciton
|
||||
// first collection
|
||||
if (mifare_classic_authex(pcs, cuid, blockNo, keyType, ui64Key, AUTH_FIRST, &nt1, NULL)) {
|
||||
continue;
|
||||
};
|
||||
|
@ -1519,7 +1523,7 @@ void MifareStaticNested(uint8_t blockNo, uint8_t keyType, uint8_t targetBlockNo,
|
|||
nt2 = bytes_to_num(receivedAnswer, 4);
|
||||
target_ks[0] = nt2 ^ target_nt[0];
|
||||
|
||||
// second colleciton
|
||||
// second collection
|
||||
|
||||
if (mifare_classic_halt(pcs, cuid)) {
|
||||
continue;
|
||||
|
@ -2074,7 +2078,6 @@ void MifareChkKeys(uint8_t *datain, uint8_t reserved_mem) {
|
|||
|
||||
uint64_t key = 0;
|
||||
uint32_t cuid = 0;
|
||||
int i, res;
|
||||
uint8_t cascade_levels = 0;
|
||||
struct {
|
||||
uint8_t key[6];
|
||||
|
@ -2113,12 +2116,12 @@ void MifareChkKeys(uint8_t *datain, uint8_t reserved_mem) {
|
|||
|
||||
set_tracing(false);
|
||||
|
||||
for (i = 0; i < key_count; i++) {
|
||||
for (uint16_t i = 0; i < key_count; i++) {
|
||||
|
||||
// Iceman: use piwi's faster nonce collecting part in hardnested.
|
||||
if (!have_uid) { // need a full select cycle to get the uid first
|
||||
if (have_uid == false) { // need a full select cycle to get the uid first
|
||||
iso14a_card_select_t card_info;
|
||||
if (!iso14443a_select_card(uid, &card_info, &cuid, true, 0, true)) {
|
||||
if (iso14443a_select_card(uid, &card_info, &cuid, true, 0, true) == false) {
|
||||
if (g_dbglevel >= DBG_ERROR) Dbprintf("ChkKeys: Can't select card (ALL)");
|
||||
--i; // try same key once again
|
||||
continue;
|
||||
|
@ -2138,7 +2141,7 @@ void MifareChkKeys(uint8_t *datain, uint8_t reserved_mem) {
|
|||
}
|
||||
have_uid = true;
|
||||
} else { // no need for anticollision. We can directly select the card
|
||||
if (!iso14443a_select_card(uid, NULL, NULL, false, cascade_levels, true)) {
|
||||
if (iso14443a_select_card(uid, NULL, NULL, false, cascade_levels, true) == false) {
|
||||
if (g_dbglevel >= DBG_ERROR) Dbprintf("ChkKeys: Can't select card (UID)");
|
||||
--i; // try same key once again
|
||||
continue;
|
||||
|
@ -2146,12 +2149,10 @@ void MifareChkKeys(uint8_t *datain, uint8_t reserved_mem) {
|
|||
}
|
||||
|
||||
key = bytes_to_num(datain + i * 6, 6);
|
||||
res = mifare_classic_auth(pcs, cuid, blockNo, keyType, key, AUTH_FIRST);
|
||||
|
||||
if (mifare_classic_auth(pcs, cuid, blockNo, keyType, key, AUTH_FIRST)) {
|
||||
// CHK_TIMEOUT();
|
||||
|
||||
if (res)
|
||||
continue;
|
||||
}
|
||||
|
||||
memcpy(keyresult.key, datain + i * 6, 6);
|
||||
keyresult.found = true;
|
||||
|
@ -2159,14 +2160,12 @@ void MifareChkKeys(uint8_t *datain, uint8_t reserved_mem) {
|
|||
}
|
||||
|
||||
LED_B_ON();
|
||||
crypto1_deinit(pcs);
|
||||
|
||||
reply_ng(CMD_HF_MIFARE_CHKKEYS, PM3_SUCCESS, (uint8_t *)&keyresult, sizeof(keyresult));
|
||||
FpgaWriteConfWord(FPGA_MAJOR_MODE_OFF);
|
||||
LEDsoff();
|
||||
|
||||
set_tracing(false);
|
||||
crypto1_deinit(pcs);
|
||||
|
||||
g_dbglevel = oldbg;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue