return crc_finish(&crc);
}
-
// width=4 poly=0xC, reversed poly=0x7 init=0x5 refin=true refout=true xorout=0x0000 check= name="CRC-4/LEGIC"
// width=8 poly=0x63, reversed poly=0x8D init=0x55 refin=true refout=true xorout=0x0000 check=0xC6 name="CRC-8/LEGIC"
// the CRC needs to be reversed before returned.
for ( int i=0; i < size; ++i)
crc_update(&crc, buff[i], 8);
return crc_finish(&crc);
+}
+//width=16 poly=0x8408 init=0xffff refin=false refout=true xorout=0xffff check=0xF0B8 name="CRC-16/ISO/IEC 13239"
+uint32_t CRC16_Iso15693(uint8_t *buff, size_t size) {
+ crc_t crc;
+ crc_init_ref(&crc, 16, 0x8408, 0xFFFF, 0xFFFF, true, false);
+ for ( int i=0; i < size; ++i)
+ crc_update(&crc, buff[i], 8);
+ return reflect(crc_finish(&crc), 16);
+}
+//width=16 poly=0x8408 init=0xffff refin=true refout=true xorout=0x0BC3 check=0xF0B8 name="CRC-16/ICLASS"
+uint32_t CRC16_ICLASS(uint8_t *buff, size_t size) {
+
+ crc_t crc;
+ crc_init_ref(&crc, 16, 0x8408, 0xFFFF, 0x0BC3, false, false);
+ for ( int i=0; i < size; ++i)
+ crc_update(&crc, buff[i], 8);
+ return crc_finish(&crc);
}
\ No newline at end of file
// test crc 16.
uint32_t CRC16_DNP(uint8_t *buff, size_t size);
uint32_t CRC16_CCITT(uint8_t *buff, size_t size);
+uint32_t CRC16_Iso15693(uint8_t *buff, size_t size);
+uint32_t CRC16_ICLASS(uint8_t *buff, size_t size);
/* Static initialization of a crc structure */
#define CRC_INITIALIZER(_order, _polynom, _initial_value, _final_xor) { \
// ISO15693 CRC & other commons
//-----------------------------------------------------------------------------
-
-#include "proxmark3.h"
-#include <stdint.h>
-#include <stdlib.h>
-//#include "iso15693tools.h"
-
-#define POLY 0x8408
-
+#include "iso15693tools.h"
// The CRC as described in ISO 15693-Part 3-Annex C
// v buffer with data
// uid[] the UID in transmission order
// return: ptr to string
char* Iso15693sprintUID(char *target,uint8_t *uid) {
- static char tempbuf[2*8+1]="";
- if (target==NULL) target=tempbuf;
- sprintf(target,"%02X%02X%02X%02X%02X%02X%02X%02X",
- uid[7],uid[6],uid[5],uid[4],uid[3],uid[2],uid[1],uid[0]);
- return target;
+ static char tempbuf[2*8+1] = "";
+ if (target==NULL) target=tempbuf;
+ sprintf(target,"%02X%02X%02X%02X%02X%02X%02X%02X",
+ uid[7],uid[6],uid[5],uid[4],uid[3],uid[2],uid[1],uid[0]);
+ return target;
}
uint16_t iclass_crc16(char *data_p, unsigned short length)
#ifndef ISO15693_H__
#define ISO15693_H__
+#include "proxmark3.h"
+#include <stdint.h>
+#include <stdlib.h>
+
+#define POLY 0x8408
+
+
// ISO15693 CRC
#define ISO15_CRC_PRESET (uint16_t)0xFFFF
#define ISO15_CRC_POLY (uint16_t)0x8408