mirror of
https://github.com/RfidResearchGroup/proxmark3.git
synced 2025-08-20 21:33:47 -07:00
ADD: CRC8Mad() should be used to calc the crc-8 byte for Mifare MAD config block. Doesn't work of course...
CHG: some T/F defines..
This commit is contained in:
parent
46a0ec7130
commit
f942e1ed05
4 changed files with 16 additions and 9 deletions
14
common/crc.c
14
common/crc.c
|
@ -23,8 +23,8 @@ void crc_init(crc_t *crc, int order, uint32_t polynom, uint32_t initial_value, u
|
||||||
crc->initial_value = initial_value;
|
crc->initial_value = initial_value;
|
||||||
crc->final_xor = final_xor;
|
crc->final_xor = final_xor;
|
||||||
crc->mask = (1L<<order)-1;
|
crc->mask = (1L<<order)-1;
|
||||||
crc->refin = FALSE;
|
crc->refin = false;
|
||||||
crc->refout = FALSE;
|
crc->refout = false;
|
||||||
crc_clear(crc);
|
crc_clear(crc);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -98,7 +98,15 @@ uint32_t CRC8Maxim(uint8_t *buff, size_t size) {
|
||||||
crc_update2(&crc, buff[i], 8);
|
crc_update2(&crc, buff[i], 8);
|
||||||
return crc_finish(&crc);
|
return crc_finish(&crc);
|
||||||
}
|
}
|
||||||
|
// width=8 poly=0x1d, reversed poly=0x?? init=0xe3 refin=true refout=true xorout=0x0000 check=0xC6 name="CRC-8/MAD"
|
||||||
|
// the CRC needs to be reversed before returned.
|
||||||
|
uint32_t CRC8Mad(uint8_t *buff, size_t size) {
|
||||||
|
crc_t crc;
|
||||||
|
crc_init_ref(&crc, 8, 0x1d, 0xe3, 0, true, true);
|
||||||
|
for ( int i = 0; i < size; ++i)
|
||||||
|
crc_update2(&crc, buff[i], 8);
|
||||||
|
return reflect(crc_finish(&crc), 8);
|
||||||
|
}
|
||||||
// width=4 poly=0xC, reversed poly=0x7 init=0x5 refin=true refout=true xorout=0x0000 check= name="CRC-4/LEGIC"
|
// width=4 poly=0xC, reversed poly=0x7 init=0x5 refin=true refout=true xorout=0x0000 check= name="CRC-4/LEGIC"
|
||||||
uint32_t CRC4Legic(uint8_t *cmd, size_t size) {
|
uint32_t CRC4Legic(uint8_t *cmd, size_t size) {
|
||||||
crc_t crc;
|
crc_t crc;
|
||||||
|
|
|
@ -53,6 +53,9 @@ extern uint32_t crc_finish(crc_t *crc);
|
||||||
// Calculate CRC-8/Maxim checksum
|
// Calculate CRC-8/Maxim checksum
|
||||||
uint32_t CRC8Maxim(uint8_t *buff, size_t size);
|
uint32_t CRC8Maxim(uint8_t *buff, size_t size);
|
||||||
|
|
||||||
|
// Calculate CRC-8 Mifare MAD checksum
|
||||||
|
uint32_t CRC8Mad(uint8_t *buff, size_t size);
|
||||||
|
|
||||||
// Calculate CRC-4/Legic checksum
|
// Calculate CRC-4/Legic checksum
|
||||||
uint32_t CRC4Legic(uint8_t *buff, size_t size);
|
uint32_t CRC4Legic(uint8_t *buff, size_t size);
|
||||||
|
|
||||||
|
@ -78,8 +81,8 @@ uint32_t CRC16_ICLASS(uint8_t *buff, size_t size);
|
||||||
.initial_value = (_initial_value), \
|
.initial_value = (_initial_value), \
|
||||||
.final_xor = (_final_xor), \
|
.final_xor = (_final_xor), \
|
||||||
.mask = ((1L<<(_order))-1) \
|
.mask = ((1L<<(_order))-1) \
|
||||||
.refin = FALSE, \
|
.refin = false, \
|
||||||
.refout = FALSE \
|
.refout = false \
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif /* __CRC_H */
|
#endif /* __CRC_H */
|
||||||
|
|
|
@ -442,7 +442,6 @@ bool usb_check() {
|
||||||
return (btConfiguration) ? true : false;
|
return (btConfiguration) ? true : false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool usb_poll()
|
bool usb_poll()
|
||||||
{
|
{
|
||||||
if (!usb_check()) return false;
|
if (!usb_check()) return false;
|
||||||
|
|
|
@ -61,9 +61,6 @@
|
||||||
#define SPI_FPGA_MODE 0
|
#define SPI_FPGA_MODE 0
|
||||||
#define SPI_LCD_MODE 1
|
#define SPI_LCD_MODE 1
|
||||||
|
|
||||||
#define TRUE 1
|
|
||||||
#define FALSE 0
|
|
||||||
|
|
||||||
#ifndef COTAG_BITS
|
#ifndef COTAG_BITS
|
||||||
#define COTAG_BITS 264
|
#define COTAG_BITS 264
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue