Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00025 #ifdef HAVE_CONFIG_H
00026 # include "config.h"
00027 #endif // HAVE_CONFIG_H
00028
00029 #include <stdio.h>
00030
00031 #include <nfc/nfc.h>
00032
00033 void
00034 iso14443a_crc (byte_t * pbtData, size_t szLen, byte_t * pbtCrc)
00035 {
00036 byte_t bt;
00037 uint32_t wCrc = 0x6363;
00038
00039 do {
00040 bt = *pbtData++;
00041 bt = (bt ^ (byte_t) (wCrc & 0x00FF));
00042 bt = (bt ^ (bt << 4));
00043 wCrc = (wCrc >> 8) ^ ((uint32_t) bt << 8) ^ ((uint32_t) bt << 3) ^ ((uint32_t) bt >> 4);
00044 } while (--szLen);
00045
00046 *pbtCrc++ = (byte_t) (wCrc & 0xFF);
00047 *pbtCrc = (byte_t) ((wCrc >> 8) & 0xFF);
00048 }
00049
00050 void
00051 append_iso14443a_crc (byte_t * pbtData, size_t szLen)
00052 {
00053 iso14443a_crc (pbtData, szLen, pbtData + szLen);
00054 }