]>
cvs.zerfleddert.de Git - proxmark3-svn/blob - common/iso14443crc.c
1 #include "iso14443crc.h"
3 static unsigned short UpdateCrc14443(unsigned char ch
, unsigned short *lpwCrc
)
5 ch
= (ch
^ (unsigned char) ((*lpwCrc
) & 0x00FF));
7 *lpwCrc
= (*lpwCrc
>> 8) ^ ((unsigned short) ch
<< 8) ^
8 ((unsigned short) ch
<< 3) ^ ((unsigned short) ch
>> 4);
12 void ComputeCrc14443(int CrcType
,
13 unsigned char *Data
, int Length
,
14 unsigned char *TransmitFirst
,
15 unsigned char *TransmitSecond
)
17 unsigned char chBlock
;
18 unsigned short wCrc
=CrcType
;
22 UpdateCrc14443(chBlock
, &wCrc
);
25 if (CrcType
== CRC_14443_B
)
26 wCrc
= ~wCrc
; /* ISO/IEC 13239 (formerly ISO/IEC 3309) */
28 *TransmitFirst
= (unsigned char) (wCrc
& 0xFF);
29 *TransmitSecond
= (unsigned char) ((wCrc
>> 8) & 0xFF);