diff --git a/client/cmdhfthinfilm.c b/client/cmdhfthinfilm.c index d75144feb..38595f3f5 100644 --- a/client/cmdhfthinfilm.c +++ b/client/cmdhfthinfilm.c @@ -29,8 +29,17 @@ static int print_barcode(uint8_t *barcode, const size_t barcode_len) { PrintAndLogEx(SUCCESS, " Manufacturer : "_YELLOW_("%s") "[0x%02X]", (barcode[0] == 0xB7) ? "Thinfilm" : "unknown", barcode[0] ); PrintAndLogEx(SUCCESS, " Data format : "_YELLOW_("%02X"), barcode[1]); - PrintAndLogEx(SUCCESS, " Raw data : "_YELLOW_("%s"), sprint_hex(barcode, barcode_len) ); - + + uint8_t b1, b2; + compute_crc(CRC_14443_A, barcode, barcode_len - 2, &b1, &b2); + bool isok = (barcode[barcode_len - 1] == b1 && barcode[barcode_len - 2] == b2); + + PrintAndLogEx(SUCCESS, " checksum : "_YELLOW_("%02X %02X")"- %s", b2, b1, (isok) ? _GREEN_("OK") : _RED_("fail")); + PrintAndLogEx(SUCCESS, " Raw data : "_YELLOW_("%s"), + sprint_hex(barcode, barcode_len) + ); + + char s[45]; memset(s, 0x00, sizeof(s)); @@ -59,7 +68,7 @@ static int print_barcode(uint8_t *barcode, const size_t barcode_len) { return PM3_SUCCESS; } - snprintf(s + strlen(s), barcode_len - 1, (const char*)&barcode[2] , barcode_len - 2); + snprintf(s + strlen(s), barcode_len - 3, (const char*)&barcode[2] , barcode_len - 4); for (uint8_t i = 0; i < strlen(s); i++) { @@ -109,8 +118,8 @@ int infoThinFilm(void) { return PM3_ETIMEOUT; } - if ( resp.status == PM3_SUCCESS ) { - print_barcode( resp.data.asBytes, resp.length - 2); + if ( resp.status == PM3_SUCCESS ) { + print_barcode( resp.data.asBytes, resp.length ); } return resp.status;