X-Git-Url: https://git.zerfleddert.de/cgi-bin/gitweb.cgi/proxmark3-svn/blobdiff_plain/fdcc61d3189f7e91db27a865c25d923849ec47d5..c5f8c67ab472defdab1331e2baffb3ab8049867f:/common/iso14443crc.c?ds=sidebyside diff --git a/common/iso14443crc.c b/common/iso14443crc.c index f91b3ce1..851546ae 100644 --- a/common/iso14443crc.c +++ b/common/iso14443crc.c @@ -1,4 +1,12 @@ -#include "iso14443crc.h" +//----------------------------------------------------------------------------- +// This code is licensed to you under the terms of the GNU GPL, version 2 or, +// at your option, any later version. See the LICENSE.txt file for the text of +// the license. +//----------------------------------------------------------------------------- +// ISO14443 CRC calculation code. +//----------------------------------------------------------------------------- + +#include "../common/iso14443crc.h" static unsigned short UpdateCrc14443(unsigned char ch, unsigned short *lpwCrc) { @@ -10,7 +18,7 @@ static unsigned short UpdateCrc14443(unsigned char ch, unsigned short *lpwCrc) } void ComputeCrc14443(int CrcType, - unsigned char *Data, int Length, + const unsigned char *Data, int Length, unsigned char *TransmitFirst, unsigned char *TransmitSecond) { @@ -29,3 +37,12 @@ void ComputeCrc14443(int CrcType, *TransmitSecond = (unsigned char) ((wCrc >> 8) & 0xFF); return; } + +int CheckCrc14443(int CrcType, const unsigned char *Data, int Length) { + unsigned char b1; + unsigned char b2; + if (Length < 3) return 0; + ComputeCrc14443(CrcType, Data, Length - 2, &b1, &b2); + if ((b1 == Data[Length - 2]) && (b2 == Data[Length - 1])) return 1; + return 0; +}