Chg : 'hf thinfilm info' - added crc check

This commit is contained in:
iceman1001 2019-08-01 11:09:51 -04:00
commit a331090c6a

View file

@ -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, " Manufacturer : "_YELLOW_("%s") "[0x%02X]", (barcode[0] == 0xB7) ? "Thinfilm" : "unknown", barcode[0] );
PrintAndLogEx(SUCCESS, " Data format : "_YELLOW_("%02X"), barcode[1]); 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]; char s[45];
memset(s, 0x00, sizeof(s)); memset(s, 0x00, sizeof(s));
@ -59,7 +68,7 @@ static int print_barcode(uint8_t *barcode, const size_t barcode_len) {
return PM3_SUCCESS; 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++) { for (uint8_t i = 0; i < strlen(s); i++) {
@ -109,8 +118,8 @@ int infoThinFilm(void) {
return PM3_ETIMEOUT; return PM3_ETIMEOUT;
} }
if ( resp.status == PM3_SUCCESS ) { if ( resp.status == PM3_SUCCESS ) {
print_barcode( resp.data.asBytes, resp.length - 2); print_barcode( resp.data.asBytes, resp.length );
} }
return resp.status; return resp.status;