mirror of
https://github.com/RfidResearchGroup/proxmark3.git
synced 2025-08-21 13:53:55 -07:00
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:
parent
8a85702662
commit
85def31a8d
5 changed files with 35 additions and 6 deletions
22
common/crc.c
22
common/crc.c
|
@ -147,3 +147,25 @@ uint32_t CRC8Hitag1(uint8_t *buff, size_t size) {
|
|||
}
|
||||
return crc_finish(&crc);
|
||||
}
|
||||
|
||||
uint32_t CRC8Hitag1Bits(uint8_t *buff, size_t bitsize) {
|
||||
crc_t crc;
|
||||
uint8_t data = 0;
|
||||
uint8_t n = 0;
|
||||
crc_init_ref(&crc, 8, 0x1d, 0xff, 0, false, false);
|
||||
uint8_t i;
|
||||
for (i = 0; i < bitsize; i++) {
|
||||
data <<= 1;
|
||||
data += (buff[i/8] >> (7 - (i % 8))) & 1;
|
||||
n += 1;
|
||||
if (n == 8) {
|
||||
crc_update2(&crc, data, n);
|
||||
n = 0;
|
||||
data = 0;
|
||||
}
|
||||
}
|
||||
if (n > 0) {
|
||||
crc_update2(&crc, data, n);
|
||||
}
|
||||
return crc_finish(&crc);
|
||||
}
|
|
@ -78,5 +78,6 @@ uint32_t CRC8Cardx(uint8_t *buff, size_t size);
|
|||
|
||||
// Calculate CRC-8/Hitag1, ZX8211 checksum
|
||||
uint32_t CRC8Hitag1(uint8_t *buff, size_t size);
|
||||
uint32_t CRC8Hitag1Bits(uint8_t *buff, size_t bitsize);
|
||||
|
||||
#endif /* __CRC_H */
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue