mirror of
https://github.com/RfidResearchGroup/proxmark3.git
synced 2025-08-21 13:53:55 -07:00
remove old iso14443crc.c, fully replaced by crc16.c functions.
This commit is contained in:
parent
bf8745e668
commit
ac88c435f6
20 changed files with 39 additions and 96 deletions
|
@ -129,7 +129,7 @@ uint16_t update_crc16(uint16_t crc, uint8_t c) {
|
|||
}
|
||||
|
||||
// two ways. msb or lsb loop.
|
||||
uint16_t crc16(uint8_t const *d, size_t length, uint16_t remainder, uint16_t polynomial, bool refin, bool refout) {
|
||||
uint16_t Crc16(uint8_t const *d, size_t length, uint16_t remainder, uint16_t polynomial, bool refin, bool refout) {
|
||||
if (length == 0)
|
||||
return (~remainder);
|
||||
|
||||
|
@ -191,7 +191,7 @@ void compute_crc(CrcType_t ct, const uint8_t *d, size_t n, uint8_t *first, uint8
|
|||
*first = (crc & 0xFF);
|
||||
*second = ((crc >> 8) & 0xFF);
|
||||
}
|
||||
uint16_t Crc(CrcType_t ct, const uint8_t *d, size_t n) {
|
||||
uint16_t Crc16ex(CrcType_t ct, const uint8_t *d, size_t n) {
|
||||
|
||||
// can't calc a crc on less than 3 byte. (1byte + 2 crc bytes)
|
||||
if (n < 3) return 0;
|
||||
|
|
|
@ -32,9 +32,9 @@ typedef enum {
|
|||
|
||||
uint16_t update_crc16_ex(uint16_t crc, uint8_t c, uint16_t polynomial);
|
||||
uint16_t update_crc16(uint16_t crc, uint8_t c);
|
||||
uint16_t crc16(uint8_t const *d, size_t length, uint16_t remainder, uint16_t polynomial, bool refin, bool refout);
|
||||
uint16_t Crc16(uint8_t const *d, size_t length, uint16_t remainder, uint16_t polynomial, bool refin, bool refout);
|
||||
|
||||
uint16_t Crc(CrcType_t ct, const uint8_t *d, size_t n);
|
||||
uint16_t Crc16ex(CrcType_t ct, const uint8_t *d, size_t n);
|
||||
void compute_crc(CrcType_t ct, const uint8_t *d, size_t n, uint8_t *first, uint8_t *second);
|
||||
bool check_crc(CrcType_t ct, const uint8_t *d, size_t n);
|
||||
|
||||
|
|
|
@ -1,44 +0,0 @@
|
|||
//-----------------------------------------------------------------------------
|
||||
// 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"
|
||||
|
||||
|
||||
uint16_t UpdateCrc14443(uint8_t b, uint16_t *crc) {
|
||||
b = (b ^ (uint8_t)((*crc) & 0x00FF));
|
||||
b = (b ^ (b << 4));
|
||||
*crc = (*crc >> 8) ^ ((uint16_t) b << 8) ^ ((uint16_t) b << 3) ^ ((uint16_t) b >> 4);
|
||||
return (*crc);
|
||||
}
|
||||
|
||||
void ComputeCrc14443(uint16_t CrcType, const uint8_t *data, int length,
|
||||
uint8_t *TransmitFirst, uint8_t *TransmitSecond) {
|
||||
uint8_t b;
|
||||
uint16_t crc = CrcType;
|
||||
|
||||
do {
|
||||
b = *data++;
|
||||
UpdateCrc14443(b, &crc);
|
||||
} while (--length);
|
||||
|
||||
if (CrcType == CRC_14443_B)
|
||||
crc = ~crc; /* ISO/IEC 13239 (formerly ISO/IEC 3309) */
|
||||
|
||||
*TransmitFirst = (uint8_t)(crc & 0xFF);
|
||||
*TransmitSecond = (uint8_t)((crc >> 8) & 0xFF);
|
||||
return;
|
||||
}
|
||||
|
||||
bool CheckCrc14443(uint16_t CrcType, const uint8_t *data, int length) {
|
||||
if (length < 3) return false;
|
||||
uint8_t b1, b2;
|
||||
ComputeCrc14443(CrcType, data, length - 2, &b1, &b2);
|
||||
if ((b1 == data[length - 2]) && (b2 == data[length - 1]))
|
||||
return true;
|
||||
return false;
|
||||
}
|
|
@ -1,19 +0,0 @@
|
|||
//-----------------------------------------------------------------------------
|
||||
// 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.
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
#ifndef __ISO14443CRC_H
|
||||
#define __ISO14443CRC_H
|
||||
#include "common.h"
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Routines to compute the CRCs (two different flavours, just for confusion)
|
||||
// required for ISO 14443, swiped directly from the spec.
|
||||
|
||||
uint16_t UpdateCrc14443(uint8_t b, uint16_t *crc);
|
||||
|
||||
#endif
|
Loading…
Add table
Add a link
Reference in a new issue