From 92c288ab85fbe5d154ca32bb0dd88920362b7c99 Mon Sep 17 00:00:00 2001 From: iceman1001 Date: Wed, 11 Jun 2025 21:40:54 +0200 Subject: [PATCH] style --- armsrc/iso14443a.c | 13 +++++++------ armsrc/mifaresim.c | 2 +- armsrc/mifareutil.c | 6 +----- 3 files changed, 9 insertions(+), 12 deletions(-) diff --git a/armsrc/iso14443a.c b/armsrc/iso14443a.c index e6764b2af..3e7bc6fee 100644 --- a/armsrc/iso14443a.c +++ b/armsrc/iso14443a.c @@ -1768,7 +1768,7 @@ void SimulateIso14443aTag(uint8_t tagType, uint16_t flags, uint8_t *useruid, uin numReads++; // Increment number of times reader requested a block if (exitAfterNReads > 0 && numReads == exitAfterNReads) { - Dbprintf("[MFUEMUL_WORK] %d reads done, exiting", numReads); + Dbprintf("[MFUEMUL_WORK] " _YELLOW_("%u") " reads done, exiting", numReads); finished = true; } } @@ -2441,7 +2441,7 @@ int EmSendCmd14443aRaw(const uint8_t *resp, uint16_t respLen) { int EmSend4bit(uint8_t resp) { Code4bitAnswerAsTag(resp); - tosend_t *ts = get_tosend(); + const tosend_t *ts = get_tosend(); int res = EmSendCmd14443aRaw(ts->buf, ts->max); // do the tracing for the previous reader request and this tag answer: uint8_t par[1] = {0x00}; @@ -2463,7 +2463,7 @@ int EmSendCmdPar(uint8_t *resp, uint16_t respLen, uint8_t *par) { } int EmSendCmdParEx(uint8_t *resp, uint16_t respLen, uint8_t *par, bool collision) { CodeIso14443aAsTagPar(resp, respLen, par, collision); - tosend_t *ts = get_tosend(); + const tosend_t *ts = get_tosend(); int res = EmSendCmd14443aRaw(ts->buf, ts->max); // do the tracing for the previous reader request and this tag answer: @@ -2633,7 +2633,7 @@ static int GetIso14443aAnswerFromTag(uint8_t *receivedResponse, uint16_t rec_max void ReaderTransmitBitsPar(const uint8_t *frame, uint16_t bits, uint8_t *par, uint32_t *timing) { CodeIso14443aBitsAsReaderPar(frame, bits, par); // Send command to tag - tosend_t *ts = get_tosend(); + const tosend_t *ts = get_tosend(); TransmitFor14443a(ts->buf, ts->max, timing); if (g_trigger) LED_A_ON(); @@ -2801,7 +2801,7 @@ static int GetATQA(uint8_t *resp, uint16_t resp_len, uint8_t *resp_par, const is // Use the temporary polling parameters do { - iso14a_polling_frame_t *frp = &p.frames[curr]; + const iso14a_polling_frame_t *frp = &p.frames[curr]; if (frp->last_byte_bits == 8) { ReaderTransmit(frp->frame, frp->frame_length, NULL); @@ -4211,8 +4211,9 @@ void SimulateIso14443aTagAID(uint8_t tagType, uint16_t flags, uint8_t *uid, uint8_t offset = 0; switch (receivedCmd[0]) { case 0x0B: // IBlock with CID - case 0x0A: + case 0x0A: { offset = 1; + } case 0x02: // IBlock without CID case 0x03: { dynamic_response_info.response[0] = receivedCmd[0]; diff --git a/armsrc/mifaresim.c b/armsrc/mifaresim.c index c58025473..f45b96f08 100644 --- a/armsrc/mifaresim.c +++ b/armsrc/mifaresim.c @@ -1052,7 +1052,7 @@ void Mifare1ksim(uint16_t flags, uint8_t exitAfterNReads, uint8_t *uid, uint16_t numReads++; if (exitAfterNReads > 0 && numReads == exitAfterNReads) { - Dbprintf("[MFEMUL_WORK] %d reads done, exiting", numReads); + Dbprintf("[MFEMUL_WORK] " _YELLOW_("%u") " reads done, exiting", numReads); finished = true; } break; diff --git a/armsrc/mifareutil.c b/armsrc/mifareutil.c index 8247fae69..651e4a5a0 100644 --- a/armsrc/mifareutil.c +++ b/armsrc/mifareutil.c @@ -440,21 +440,17 @@ int mifare_ultra_aes_auth(uint8_t keyno, uint8_t *keybytes) { uint8_t key[16] = { 0 }; memcpy(key, keybytes, sizeof(key)); - uint16_t len = 0; - // 1 cmd + 16 bytes + 2 crc uint8_t resp[19] = {0x00}; uint8_t respPar[5] = {0}; - // setup AES mbedtls_aes_context actx; mbedtls_aes_init(&actx); - mbedtls_aes_init(&actx); mbedtls_aes_setkey_dec(&actx, key, 128); // Send REQUEST AUTHENTICATION / receive tag nonce - len = mifare_sendcmd_short(NULL, CRYPT_NONE, MIFARE_ULAES_AUTH_1, keyno, resp, sizeof(resp), respPar, NULL); + uint16_t len = mifare_sendcmd_short(NULL, CRYPT_NONE, MIFARE_ULAES_AUTH_1, keyno, resp, sizeof(resp), respPar, NULL); if (len != 19) { if (g_dbglevel >= DBG_ERROR) Dbprintf("Cmd Error: %02x - expected 19 got " _RED_("%u"), resp[0], len); return 0;