hitag1/S trace: add crc check

Example:

[usb] pm3 --> trace load -f traces/lf_HitagS256_dump.trace
[+] loaded 272 bytes from binary file traces/lf_HitagS256_dump.trace
[+] Recorded Activity (TraceLen = 272 bytes)
[?] try `trace list -1 -t ...` to view trace.  Remember the `-1` param
[usb] pm3 --> trace list -t hitags -c
[=] downloading tracelog data from device
[+] Recorded activity (trace len = 272 bytes)
[=] start = start of start frame end = end of frame. src = source of transfer
[=] Hitag1 / Hitag2 / HitagS - Timings in ETU (8us)

      Start |        End | Src | Data (! denotes parity error)                                           | CRC | Annotation
------------+------------+-----+-------------------------------------------------------------------------+-----+--------------------
          0 |          0 | Rdr |18(5)                                                                    |     |
        117 |        117 | Tag |21  a5  b4 [73]                                                          | !crc|
          0 |          0 | Rdr |00(5) 21  a5  b4  73 [8c]                                                |  ok |
        117 |        117 | Tag |c9  00  00  aa [75]                                                      |  ok |
          0 |          0 | Rdr |0c(4) 00 [ab]                                                            |  ok |
        117 |        117 | Tag |21  a5  b4  73 [53]                                                      |  ok |
          0 |          0 | Rdr |0c(4) 01 [b6]                                                            |  ok |
        117 |        117 | Tag |c9  00  00  aa [75]                                                      |  ok |
          0 |          0 | Rdr |0c(4) 02 [91]                                                            |  ok |
        117 |        117 | Tag |48  54  4f  4e [2c]                                                      |  ok |
          0 |          0 | Rdr |0c(4) 03 [8c]                                                            |  ok |
        117 |        117 | Tag |4d  49  4b  52 [1e]                                                      |  ok |
          0 |          0 | Rdr |0c(4) 04 [df]                                                            |  ok |
        117 |        117 | Tag |00  00  00  00 [a6]                                                      |  ok |
          0 |          0 | Rdr |0c(4) 05 [c2]                                                            |  ok |
        117 |        117 | Tag |00  00  00  00 [a6]                                                      |  ok |
          0 |          0 | Rdr |0c(4) 06 [e5]                                                            |  ok |
        118 |        118 | Tag |00  00  00  00 [a6]                                                      |  ok |
          0 |          0 | Rdr |0c(4) 07 [f8]                                                            |  ok |
        118 |        118 | Tag |57  5f  4f  4b [88]                                                      |  ok |
          0 |          0 | Rdr |0c(4) 08 [43]                                                            |  ok |
This commit is contained in:
Philippe Teuwen committed 2021-12-30 01:46:41 +01:00
1 parent 8a85702662
commit 85def31a8d
5 files changed
+35 -6

No files matched your search

+5 -6
View File
@@ -216,10 +216,11 @@ static uint16_t printTraceLine(uint16_t tracepos, uint16_t traceLen, uint8_t *tr
case ISO_15693:
crcStatus = iso15693_CRC_check(frame, data_len);
break;
case PROTO_CRYPTORF:
case PROTO_HITAG1:
case PROTO_HITAG2:
case PROTO_HITAGS:
crcStatus = hitag1_CRC_check(frame, (data_len * 8) - ((8 - parityBytes[0]) % 8));
case PROTO_CRYPTORF:
case PROTO_HITAG2:
default:
break;
}
@@ -292,10 +293,8 @@ static uint16_t printTraceLine(uint16_t tracepos, uint16_t traceLen, uint8_t *tr
if (markCRCBytes) {
//CRC-command
if (((protocol == PROTO_HITAG1) || (protocol == PROTO_HITAGS)) && (data_len > 1)) {
// notes hitag S:
// pm3 is using UID REQUEST Adv -> SOF is 111(AC) then 111111(MC)
// for unknown reason, recorded SOF in trace is 1111 instead of 111111 (or should be even skipped)
// CRC on tag response is SOF excluded
// Note that UID REQUEST response has no CRC, but we don't know
// if the response we see is a UID
char *pos1 = line[(data_len - 1) / 18] + (((data_len - 1) % 18) * 4) + offset - 1;
(*pos1) = '[';
char *pos2 = line[(data_len) / 18] + (((data_len) % 18) * 4) + offset - 2;