]> cvs.zerfleddert.de Git - proxmark3-svn/blame - common/iso14443crc.c
Fix windows compilation issues. But still not final. We should move to pthread and...
[proxmark3-svn] / common / iso14443crc.c
CommitLineData
7fe9b0b7 1#include "iso14443crc.h"\r
2\r
3static unsigned short UpdateCrc14443(unsigned char ch, unsigned short *lpwCrc)\r
4{\r
5 ch = (ch ^ (unsigned char) ((*lpwCrc) & 0x00FF));\r
6 ch = (ch ^ (ch << 4));\r
7 *lpwCrc = (*lpwCrc >> 8) ^ ((unsigned short) ch << 8) ^\r
8 ((unsigned short) ch << 3) ^ ((unsigned short) ch >> 4);\r
9 return (*lpwCrc);\r
10}\r
11\r
12void ComputeCrc14443(int CrcType,\r
13 unsigned char *Data, int Length,\r
14 unsigned char *TransmitFirst,\r
15 unsigned char *TransmitSecond)\r
16{\r
17 unsigned char chBlock;\r
18 unsigned short wCrc=CrcType;\r
19\r
20 do {\r
21 chBlock = *Data++;\r
22 UpdateCrc14443(chBlock, &wCrc);\r
23 } while (--Length);\r
24\r
25 if (CrcType == CRC_14443_B)\r
26 wCrc = ~wCrc; /* ISO/IEC 13239 (formerly ISO/IEC 3309) */\r
27\r
28 *TransmitFirst = (unsigned char) (wCrc & 0xFF);\r
29 *TransmitSecond = (unsigned char) ((wCrc >> 8) & 0xFF);\r
30 return;\r
31}\r
Impressum, Datenschutz