reworked it to fit style

This commit is contained in:
iceman1001 2022-02-06 05:28:59 +01:00
commit 099abfedcf

View file

@ -125,29 +125,37 @@ static char *getProductTypeStr(uint8_t id) {
static int ul_print_nxp_silicon_info(uint8_t *card_uid) {
if (card_uid[0] != 0x04) {
return PM3_SUCCESS;
}
uint8_t uid[7];
memcpy(&uid, card_uid, 7);
if (uid[0] != 0x04) {
return PM3_SUCCESS;
}
uint8_t maskedBit1 = uid[6] & -1;
uint8_t maskedBit2 = uid[3] & -1;
unsigned long waferCoordX = ((maskedBit1 & 3) << 8) | (uid[1] & -1);
unsigned long waferCoordY = ((maskedBit1 & 12) << 6) | (uid[2] & -1);
unsigned long waferCounter = ((uid[4] & -1) << 5) | ((maskedBit1 & 240) << 17) | ((uid[5] & -1) << 13) | (maskedBit2 >> 3);
unsigned long testSite = maskedBit2 & 7;
uint16_t waferCoordX = ((uid[6] & 3) << 8) | uid[1];
uint16_t waferCoordY = ((uid[6] & 12) << 6) | uid[2];
uint32_t waferCounter = (
(uid[4] << 5) |
((uid[6] & 0xF0) << 17) |
(uid[5] << 13) |
(uid[3] >> 3)
);
uint8_t testSite = uid[3] & 7;
PrintAndLogEx(NORMAL, "");
PrintAndLogEx(INFO, "--- " _CYAN_("Tag Silicon Information"));
PrintAndLogEx(INFO, " Wafer Counter: %ld (0x%02lX)", waferCounter, waferCounter);
PrintAndLogEx(INFO, " Wafer Coordinates: [%ld, %ld] (0x%02lX, 0x%02lX)", waferCoordX, waferCoordY, waferCoordX, waferCoordY);
PrintAndLogEx(INFO, " Test Site: %ld", testSite);
PrintAndLogEx(INFO, " Wafer Counter: %" PRId32 " ( 0x%02" PRIX32 " )", waferCounter, waferCounter);
PrintAndLogEx(INFO, " Wafer Coordinates: x %" PRId16 ", y %" PRId16 " (0x%02" PRIX16 ", 0x%02" PRIX16 ")"
, waferCoordX
, waferCoordY
, waferCoordX
, waferCoordY
);
PrintAndLogEx(INFO, " Test Site: %u", testSite);
return PM3_SUCCESS;
}
/*
The 7 MSBits (=n) code the storage size itself based on 2^n,
the LSBit is set to '0' if the size is exactly 2^n