]> git.zerfleddert.de Git - proxmark3-svn/blobdiff - common/iso14443crc.c
Adding homebrew tap method for macOS
[proxmark3-svn] / common / iso14443crc.c
index f91b3ce1c5d9213b1d8cc4a6cee674c26b68a226..a6def1a91be2df84675660c67ec636ecc3ba4b55 100644 (file)
@@ -1,3 +1,11 @@
+//-----------------------------------------------------------------------------
+// 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 "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;
+}
Impressum, Datenschutz