Fix Gallagher data decoding & CRC checks

Descramble function was re-scrambling the data
Skip constant magic prefix `7FEA` to get correct data to decode
Fix offsets & bitmasks to correctly decode card and region codes
Fix CRC refin & refout parameters (both now false)
This commit is contained in:
DarkMatterMatt 2021-02-10 15:47:14 +13:00
commit a4da1476b6
2 changed files with 36 additions and 12 deletions

View file

@ -126,10 +126,10 @@ uint32_t CRC8Legic(uint8_t *buff, size_t size) {
crc_update2(&crc, buff[i], 8);
return reflect8(crc_finish(&crc));
}
// width=8 poly=0x107, init=0x2C refin=true refout=true xorout=0x0000 check=0 name="CRC-8/CARDX"
// width=8 poly=0x7, init=0x2C refin=false refout=false xorout=0x0000 check=0 name="CRC-8/CARDX"
uint32_t CRC8Cardx(uint8_t *buff, size_t size) {
crc_t crc;
crc_init_ref(&crc, 8, 0x107, 0x2C, 0, true, true);
crc_init_ref(&crc, 8, 0x7, 0x2C, 0, false, false);
for (size_t i = 0; i < size; ++i)
crc_update2(&crc, buff[i], 8);
return crc_finish(&crc);