diff --git a/common/crc.c b/common/crc.c index 8fe75cbf3..ea4a90b84 100644 --- a/common/crc.c +++ b/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->final_xor = final_xor; crc->mask = (1L<refin = FALSE; - crc->refout = FALSE; + crc->refin = false; + crc->refout = false; crc_clear(crc); } @@ -98,7 +98,15 @@ uint32_t CRC8Maxim(uint8_t *buff, size_t size) { crc_update2(&crc, buff[i], 8); 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" uint32_t CRC4Legic(uint8_t *cmd, size_t size) { crc_t crc; diff --git a/common/crc.h b/common/crc.h index 22b703fe5..eb129ee2d 100644 --- a/common/crc.h +++ b/common/crc.h @@ -53,6 +53,9 @@ extern uint32_t crc_finish(crc_t *crc); // Calculate CRC-8/Maxim checksum 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 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), \ .final_xor = (_final_xor), \ .mask = ((1L<<(_order))-1) \ - .refin = FALSE, \ - .refout = FALSE \ + .refin = false, \ + .refout = false \ } #endif /* __CRC_H */ diff --git a/common/usb_cdc.c b/common/usb_cdc.c index 44c24afd1..c6dec3760 100644 --- a/common/usb_cdc.c +++ b/common/usb_cdc.c @@ -442,7 +442,6 @@ bool usb_check() { return (btConfiguration) ? true : false; } - bool usb_poll() { if (!usb_check()) return false; diff --git a/include/proxmark3.h b/include/proxmark3.h index 23d7b1ceb..05b5885b6 100644 --- a/include/proxmark3.h +++ b/include/proxmark3.h @@ -61,9 +61,6 @@ #define SPI_FPGA_MODE 0 #define SPI_LCD_MODE 1 -#define TRUE 1 -#define FALSE 0 - #ifndef COTAG_BITS #define COTAG_BITS 264 #endif