mirror of
https://github.com/RfidResearchGroup/proxmark3.git
synced 2025-08-19 21:03:48 -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
|
@ -17,7 +17,6 @@
|
|||
#include "apps.h"
|
||||
#include "util.h"
|
||||
#include "string.h"
|
||||
#include "iso14443crc.h"
|
||||
#include "iso14443a.h"
|
||||
#include "crapto1/crapto1.h"
|
||||
#include "mifareutil.h"
|
||||
|
|
|
@ -6,7 +6,6 @@
|
|||
#include "apps.h"
|
||||
#include "string.h"
|
||||
#include "BigBuf.h"
|
||||
#include "iso14443crc.h"
|
||||
#include "iso14443a.h"
|
||||
#include "desfire_key.h"
|
||||
#include "mifareutil.h"
|
||||
|
|
|
@ -22,7 +22,6 @@
|
|||
|
||||
#include "iso14443a.h"
|
||||
#include "mifaresim.h"
|
||||
#include "iso14443crc.h"
|
||||
#include "crapto1/crapto1.h"
|
||||
#include "BigBuf.h"
|
||||
#include "string.h"
|
||||
|
|
|
@ -15,6 +15,10 @@
|
|||
|
||||
#include <stdint.h>
|
||||
|
||||
#ifndef CheckCrc14A
|
||||
# define CheckCrc14A(data, len) check_crc(CRC_14443_A, (data), (len))
|
||||
#endif
|
||||
|
||||
void Mifare1ksim(uint16_t flags, uint8_t exitAfterNReads, uint8_t arg2, uint8_t *datain);
|
||||
|
||||
#define AC_DATA_READ 0
|
||||
|
|
|
@ -10,6 +10,10 @@
|
|||
|
||||
#include "mifaresniff.h"
|
||||
|
||||
#ifndef CheckCrc14A
|
||||
# define CheckCrc14A(data, len) check_crc(CRC_14443_A, (data), (len))
|
||||
#endif
|
||||
|
||||
//static int sniffState = SNF_INIT;
|
||||
static uint8_t sniffUIDType = 0;
|
||||
static uint8_t sniffUID[10] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
|
||||
|
@ -229,7 +233,7 @@ bool RAMFUNC MfSniffLogic(const uint8_t *data, uint16_t len, uint8_t *parity, ui
|
|||
|
||||
if ( !reader ) break;
|
||||
if ( len != 9 ) break;
|
||||
if ( !CheckCrc14443(CRC_14443_A, data, 9)) break;
|
||||
if ( !CheckCrc14A(data, 9)) break;
|
||||
if ( data[1] != 0x70 ) break;
|
||||
|
||||
Dbprintf("[!] UID | %x", data[0]);
|
||||
|
@ -266,7 +270,7 @@ bool RAMFUNC MfSniffLogic(const uint8_t *data, uint16_t len, uint8_t *parity, ui
|
|||
}
|
||||
case SNF_SAK:{
|
||||
// SAK from card?
|
||||
if ((!reader) && (len == 3) && (CheckCrc14443(CRC_14443_A, data, 3))) {
|
||||
if ((!reader) && (len == 3) && (CheckCrc14A(data, 3))) {
|
||||
sniffSAK = data[0];
|
||||
// CL2 UID part to be expected
|
||||
if (( sniffSAK == 0x04) && (sniffUIDType == SNF_UID_4)) {
|
||||
|
|
|
@ -15,7 +15,6 @@
|
|||
#include "apps.h"
|
||||
#include "util.h"
|
||||
#include "string.h"
|
||||
#include "iso14443crc.h"
|
||||
#include "iso14443a.h"
|
||||
#include "crapto1/crapto1.h"
|
||||
#include "mifareutil.h"
|
||||
|
|
|
@ -17,7 +17,6 @@
|
|||
#include "parity.h"
|
||||
#include "util.h"
|
||||
#include "string.h"
|
||||
#include "iso14443crc.h"
|
||||
#include "iso14443a.h"
|
||||
#include "crapto1/crapto1.h"
|
||||
#include "des.h"
|
||||
|
|
|
@ -300,7 +300,7 @@ int CmdAnalyseCRC(const char *Cmd) {
|
|||
// ISO14443 crc B
|
||||
compute_crc(CRC_14443_B, data, len, &b1, &b2);
|
||||
uint16_t crcBB_1 = b1 << 8 | b2;
|
||||
uint16_t bbb = Crc(CRC_14443_B, data, len);
|
||||
uint16_t bbb = Crc16ex(CRC_14443_B, data, len);
|
||||
PrintAndLogEx(NORMAL, "ISO14443 crc B | %04x == %04x \n", crcBB_1, bbb);
|
||||
|
||||
|
||||
|
@ -321,40 +321,40 @@ int CmdAnalyseCRC(const char *Cmd) {
|
|||
PrintAndLogEx(NORMAL, "CRC16 based\n\n");
|
||||
|
||||
// input from commandline
|
||||
PrintAndLogEx(NORMAL, "CCITT | %X (29B1 expected)", Crc(CRC_CCITT, dataStr, sizeof(dataStr)));
|
||||
PrintAndLogEx(NORMAL, "CCITT | %X (29B1 expected)", Crc16ex(CRC_CCITT, dataStr, sizeof(dataStr)));
|
||||
|
||||
uint8_t poll[] = {0xb2, 0x4d, 0x12, 0x01, 0x01, 0x2e, 0x3d, 0x17, 0x26, 0x47, 0x80, 0x95, 0x00, 0xf1, 0x00, 0x00, 0x00, 0x01, 0x43, 0x00, 0xb3, 0x7f};
|
||||
PrintAndLogEx(NORMAL, "FeliCa | %04X (B37F expected)", Crc(CRC_FELICA, poll + 2, sizeof(poll) - 4));
|
||||
PrintAndLogEx(NORMAL, "FeliCa | %04X (0000 expected)", Crc(CRC_FELICA, poll + 2, sizeof(poll) - 2));
|
||||
PrintAndLogEx(NORMAL, "FeliCa | %04X (B37F expected)", Crc16ex(CRC_FELICA, poll + 2, sizeof(poll) - 4));
|
||||
PrintAndLogEx(NORMAL, "FeliCa | %04X (0000 expected)", Crc16ex(CRC_FELICA, poll + 2, sizeof(poll) - 2));
|
||||
|
||||
uint8_t sel_corr[] = { 0x40, 0xe1, 0xe1, 0xff, 0xfe, 0x5f, 0x02, 0x3c, 0x43, 0x01};
|
||||
PrintAndLogEx(NORMAL, "iCLASS | %04x (0143 expected)", Crc(CRC_ICLASS, sel_corr, sizeof(sel_corr) - 2));
|
||||
PrintAndLogEx(NORMAL, "iCLASS | %04x (0143 expected)", Crc16ex(CRC_ICLASS, sel_corr, sizeof(sel_corr) - 2));
|
||||
PrintAndLogEx(NORMAL, "---------------------------------------------------------------\n\n\n");
|
||||
|
||||
// ISO14443 crc A
|
||||
compute_crc(CRC_14443_A, dataStr, sizeof(dataStr), &b1, &b2);
|
||||
uint16_t crcAA = b1 << 8 | b2;
|
||||
PrintAndLogEx(NORMAL, "ISO14443 crc A | %04x or %04x (BF05 expected)\n", crcAA, Crc(CRC_14443_A, dataStr, sizeof(dataStr)));
|
||||
PrintAndLogEx(NORMAL, "ISO14443 crc A | %04x or %04x (BF05 expected)\n", crcAA, Crc16ex(CRC_14443_A, dataStr, sizeof(dataStr)));
|
||||
|
||||
// ISO14443 crc B
|
||||
compute_crc(CRC_14443_B, dataStr, sizeof(dataStr), &b1, &b2);
|
||||
uint16_t crcBB = b1 << 8 | b2;
|
||||
PrintAndLogEx(NORMAL, "ISO14443 crc B | %04x or %04x (906E expected)\n", crcBB, Crc(CRC_14443_B, dataStr, sizeof(dataStr)));
|
||||
PrintAndLogEx(NORMAL, "ISO14443 crc B | %04x or %04x (906E expected)\n", crcBB, Crc16ex(CRC_14443_B, dataStr, sizeof(dataStr)));
|
||||
|
||||
// ISO15693 crc (x.25)
|
||||
compute_crc(CRC_15693, dataStr, sizeof(dataStr), &b1, &b2);
|
||||
uint16_t crcCC = b1 << 8 | b2;
|
||||
PrintAndLogEx(NORMAL, "ISO15693 crc X25| %04x or %04x (906E expected)\n", crcCC, Crc(CRC_15693, dataStr, sizeof(dataStr)));
|
||||
PrintAndLogEx(NORMAL, "ISO15693 crc X25| %04x or %04x (906E expected)\n", crcCC, Crc16ex(CRC_15693, dataStr, sizeof(dataStr)));
|
||||
|
||||
// ICLASS
|
||||
compute_crc(CRC_ICLASS, dataStr, sizeof(dataStr), &b1, &b2);
|
||||
uint16_t crcDD = b1 << 8 | b2;
|
||||
PrintAndLogEx(NORMAL, "ICLASS crc | %04x or %04x\n", crcDD, Crc(CRC_ICLASS, dataStr, sizeof(dataStr)));
|
||||
PrintAndLogEx(NORMAL, "ICLASS crc | %04x or %04x\n", crcDD, Crc16ex(CRC_ICLASS, dataStr, sizeof(dataStr)));
|
||||
|
||||
// FeliCa
|
||||
compute_crc(CRC_FELICA, dataStr, sizeof(dataStr), &b1, &b2);
|
||||
uint16_t crcEE = b1 << 8 | b2;
|
||||
PrintAndLogEx(NORMAL, "FeliCa | %04x or %04x (31C3 expected)\n", crcEE, Crc(CRC_FELICA, dataStr, sizeof(dataStr)));
|
||||
PrintAndLogEx(NORMAL, "FeliCa | %04x or %04x (31C3 expected)\n", crcEE, Crc16ex(CRC_FELICA, dataStr, sizeof(dataStr)));
|
||||
|
||||
free(data);
|
||||
return 0;
|
||||
|
|
|
@ -24,7 +24,6 @@
|
|||
#include "util.h"
|
||||
#include "cmdparser.h"
|
||||
#include "cmdmain.h"
|
||||
#include "iso14443crc.h"
|
||||
#include "mifare.h"
|
||||
#include "cmdhfmf.h"
|
||||
#include "cmdhfmfu.h"
|
||||
|
|
|
@ -29,12 +29,19 @@
|
|||
#define Logic1 Iso15693Logic1
|
||||
#define FrameEOF Iso15693FrameEOF
|
||||
|
||||
#define Crc15(data, len) Crc(CRC_15693, (data), (len))
|
||||
#define CheckCrc15(data, len) check_crc(CRC_15693, (data), (len))
|
||||
#ifndef Crc15
|
||||
# define Crc15(data, len) Crc16ex(CRC_15693, (data), (len))
|
||||
#endif
|
||||
#ifndef CheckCrc15
|
||||
# define CheckCrc15(data, len) check_crc(CRC_15693, (data), (len))
|
||||
#endif
|
||||
#ifndef AddCrc15
|
||||
#define AddCrc15(data, len) compute_crc(CRC_15693, (data), (len), (data)+(len), (data)+(len)+1)
|
||||
#endif
|
||||
|
||||
#define sprintUID(target, uid) Iso15693sprintUID((target), (uid))
|
||||
|
||||
#ifndef sprintUID
|
||||
# define sprintUID(target, uid) Iso15693sprintUID((target), (uid))
|
||||
#endif
|
||||
// structure and database for uid -> tagtype lookups
|
||||
typedef struct {
|
||||
uint64_t uid;
|
||||
|
|
|
@ -22,7 +22,6 @@
|
|||
#include "util.h"
|
||||
#include "cmdparser.h"
|
||||
#include "comms.h" // getfromdevice
|
||||
#include "iso14443crc.h"
|
||||
#include "cmdhf.h" // list cmd
|
||||
#include "mifare.h" // felica_card_select_t struct
|
||||
|
||||
|
|
|
@ -15,7 +15,7 @@
|
|||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <sys/stat.h>
|
||||
#include "iso14443crc.h" // Can also be used for iClass, using 0xE012 as CRC-type
|
||||
//#include "iso14443crc.h" // Can also be used for iClass, using 0xE012 as CRC-type
|
||||
#include "proxmark3.h"
|
||||
#include "ui.h"
|
||||
#include "cmdparser.h"
|
||||
|
|
|
@ -18,7 +18,6 @@
|
|||
#include <time.h>
|
||||
#include <mbedtls/aes.h>
|
||||
#include "proxmark3.h"
|
||||
#include "iso14443crc.h"
|
||||
#include "ui.h"
|
||||
#include "cmdparser.h"
|
||||
#include "common.h"
|
||||
|
|
|
@ -18,7 +18,6 @@
|
|||
#include "proxmark3.h"
|
||||
#include "../include/common.h"
|
||||
#include "../include/mifare.h"
|
||||
#include "iso14443crc.h"
|
||||
#include "ui.h"
|
||||
#include "cmdparser.h"
|
||||
#include "util.h"
|
||||
|
|
|
@ -467,7 +467,7 @@ static int l_crc16(lua_State *L) {
|
|||
size_t size;
|
||||
const char *p_str = luaL_checklstring(L, 1, &size);
|
||||
|
||||
uint16_t checksum = Crc(CRC_CCITT, (uint8_t *) p_str, size);
|
||||
uint16_t checksum = Crc16ex(CRC_CCITT, (uint8_t *) p_str, size);
|
||||
lua_pushunsigned(L, checksum);
|
||||
return 1;
|
||||
}
|
||||
|
|
|
@ -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