mirror of
https://github.com/RfidResearchGroup/proxmark3.git
synced 2025-08-20 13:23:51 -07:00
fix crc overshadowing
This commit is contained in:
parent
91897f1f2e
commit
c4920d7179
4 changed files with 25 additions and 25 deletions
|
@ -81,9 +81,9 @@
|
|||
#define Logic1 Iso15693Logic1
|
||||
#define FrameEOF Iso15693FrameEOF
|
||||
|
||||
#define Crc(data, len) crc(CRC_15693, (data), (len))
|
||||
#define CheckCrc(data, len) check_crc(CRC_15693, (data), (len))
|
||||
#define AddCrc(data, len) compute_crc(CRC_15693, (data), (len), (data)+(len), (data)+(len)+1)
|
||||
//#define Crc(data, len) Crc(CRC_15693, (data), (len))
|
||||
#define CheckCrc15(data, len) check_crc(CRC_15693, (data), (len))
|
||||
#define AddCrc15(data, len) compute_crc(CRC_15693, (data), (len), (data)+(len), (data)+(len)+1)
|
||||
|
||||
#define sprintUID(target,uid) Iso15693sprintUID((target), (uid))
|
||||
|
||||
|
@ -629,7 +629,7 @@ static void BuildIdentifyRequest(uint8_t *cmdout) {
|
|||
// no mask
|
||||
cmd[2] = 0x00;
|
||||
// CRC
|
||||
AddCrc(cmd, 3);
|
||||
AddCrc15(cmd, 3);
|
||||
// coding as high speed (1 out of 4)
|
||||
CodeIso15693AsReader(cmd, CMD_ID_RESP);
|
||||
memcpy(cmdout, cmd, CMD_ID_RESP);
|
||||
|
@ -658,7 +658,7 @@ static void BuildReadBlockRequest(uint8_t **out, uint8_t *uid, uint8_t blockNumb
|
|||
// Block number to read
|
||||
cmd[10] = blockNumber;//0x00;
|
||||
// CRC
|
||||
AddCrc(cmd, 11);
|
||||
AddCrc15(cmd, 11);
|
||||
CodeIso15693AsReader(cmd, CMD_READ_RESP);
|
||||
memcpy(out, cmd, CMD_ID_RESP);
|
||||
}
|
||||
|
@ -685,7 +685,7 @@ static void BuildInventoryResponse(uint8_t *cmdout, uint8_t *uid) {
|
|||
cmd[8] = uid[1]; //0x05;
|
||||
cmd[9] = uid[0]; //0xe0;
|
||||
// CRC
|
||||
AddCrc(cmd, 10);
|
||||
AddCrc15(cmd, 10);
|
||||
CodeIso15693AsReader(cmd, CMD_INV_RESP);
|
||||
memcpy(cmdout, cmd, CMD_INV_RESP);
|
||||
}
|
||||
|
@ -932,7 +932,7 @@ void BruteforceIso15693Afi(uint32_t speed) {
|
|||
data[0] = ISO15_REQ_SUBCARRIER_SINGLE | ISO15_REQ_DATARATE_HIGH | ISO15_REQ_INVENTORY | ISO15_REQINV_SLOT1;
|
||||
data[1] = ISO15_CMD_INVENTORY;
|
||||
data[2] = 0; // mask length
|
||||
AddCrc(data, 3);
|
||||
AddCrc15(data, 3);
|
||||
datalen += 2;
|
||||
|
||||
recvlen = SendDataTag(data, datalen, false, speed, buf);
|
||||
|
@ -951,7 +951,7 @@ void BruteforceIso15693Afi(uint32_t speed) {
|
|||
|
||||
for (uint16_t i = 0; i < 256; i++) {
|
||||
data[2] = i & 0xFF;
|
||||
AddCrc(data, 4);
|
||||
AddCrc15(data, 4);
|
||||
datalen += 2;
|
||||
recvlen = SendDataTag(data, datalen, false, speed, buf);
|
||||
WDT_HIT();
|
||||
|
|
|
@ -29,9 +29,9 @@
|
|||
#define Logic1 Iso15693Logic1
|
||||
#define FrameEOF Iso15693FrameEOF
|
||||
|
||||
#define Crc(data, len) crc(CRC_15693, (data), (len))
|
||||
#define CheckCrc(data, len) check_crc(CRC_15693, (data), (len))
|
||||
#define AddCrc(data, len) compute_crc(CRC_15693, (data), (len), (data)+(len), (data)+(len)+1)
|
||||
#define Crc15(data, len) Crc(CRC_15693, (data), (len))
|
||||
#define CheckCrc15(data, len) check_crc(CRC_15693, (data), (len))
|
||||
#define AddCrc15(data, len) compute_crc(CRC_15693, (data), (len), (data)+(len), (data)+(len)+1)
|
||||
|
||||
#define sprintUID(target, uid) Iso15693sprintUID((target), (uid))
|
||||
|
||||
|
@ -198,7 +198,7 @@ int getUID(uint8_t *buf) {
|
|||
c.d.asBytes[1] = ISO15_CMD_INVENTORY;
|
||||
c.d.asBytes[2] = 0; // mask length
|
||||
|
||||
AddCrc(c.d.asBytes, 3);
|
||||
AddCrc15(c.d.asBytes, 3);
|
||||
c.arg[0] = 5; // len
|
||||
|
||||
uint8_t retry;
|
||||
|
@ -212,7 +212,7 @@ int getUID(uint8_t *buf) {
|
|||
if (WaitForResponseTimeout(CMD_ACK, &resp, 2000)) {
|
||||
|
||||
uint8_t resplen = resp.arg[0];
|
||||
if (resplen >= 12 && CheckCrc(resp.d.asBytes, 12)) {
|
||||
if (resplen >= 12 && CheckCrc15(resp.d.asBytes, 12)) {
|
||||
memcpy(buf, resp.d.asBytes + 2, 8);
|
||||
return 1;
|
||||
}
|
||||
|
@ -519,7 +519,7 @@ int CmdHF15Info(const char *Cmd) {
|
|||
if (!prepareHF15Cmd(&cmd, &c, ISO15_CMD_SYSINFO))
|
||||
return 0;
|
||||
|
||||
AddCrc(req, c.arg[0]);
|
||||
AddCrc15(req, c.arg[0]);
|
||||
c.arg[0] += 2;
|
||||
|
||||
//PrintAndLogEx(NORMAL, "cmd %s", sprint_hex(c.d.asBytes, reqlen) );
|
||||
|
@ -721,7 +721,7 @@ int CmdHF15Dump(const char *Cmd) {
|
|||
for (int retry = 0; retry < 5; retry++) {
|
||||
|
||||
req[10] = blocknum;
|
||||
AddCrc(req, 11);
|
||||
AddCrc15(req, 11);
|
||||
c.arg[0] = 13;
|
||||
|
||||
clearCommandBuffer();
|
||||
|
@ -737,7 +737,7 @@ int CmdHF15Dump(const char *Cmd) {
|
|||
|
||||
recv = resp.d.asBytes;
|
||||
|
||||
if (!CheckCrc(recv, len)) {
|
||||
if (!CheckCrc15(recv, len)) {
|
||||
PrintAndLogEx(FAILED, "crc fail");
|
||||
continue;
|
||||
}
|
||||
|
@ -958,7 +958,7 @@ int CmdHF15Raw(const char *Cmd) {
|
|||
}
|
||||
|
||||
if (crc) {
|
||||
AddCrc(data, datalen);
|
||||
AddCrc15(data, datalen);
|
||||
datalen += 2;
|
||||
}
|
||||
|
||||
|
@ -1099,7 +1099,7 @@ int CmdHF15Readmulti(const char *Cmd) {
|
|||
|
||||
req[reqlen++] = pagenum;
|
||||
req[reqlen++] = pagecount;
|
||||
AddCrc(req, reqlen);
|
||||
AddCrc15(req, reqlen);
|
||||
c.arg[0] = reqlen + 2;
|
||||
|
||||
clearCommandBuffer();
|
||||
|
@ -1118,7 +1118,7 @@ int CmdHF15Readmulti(const char *Cmd) {
|
|||
|
||||
recv = resp.d.asBytes;
|
||||
|
||||
if (!CheckCrc(recv, status)) {
|
||||
if (!CheckCrc15(recv, status)) {
|
||||
PrintAndLogEx(FAILED, "CRC failed");
|
||||
return 2;
|
||||
}
|
||||
|
@ -1178,7 +1178,7 @@ int CmdHF15Read(const char *Cmd) {
|
|||
|
||||
req[reqlen++] = (uint8_t)blocknum;
|
||||
|
||||
AddCrc(req, reqlen);
|
||||
AddCrc15(req, reqlen);
|
||||
|
||||
c.arg[0] = reqlen + 2;
|
||||
|
||||
|
@ -1198,7 +1198,7 @@ int CmdHF15Read(const char *Cmd) {
|
|||
|
||||
recv = resp.d.asBytes;
|
||||
|
||||
if (!CheckCrc(recv, status)) {
|
||||
if (!CheckCrc15(recv, status)) {
|
||||
PrintAndLogEx(NORMAL, "CRC failed");
|
||||
return 2;
|
||||
}
|
||||
|
@ -1261,7 +1261,7 @@ int CmdHF15Write(const char *Cmd) {
|
|||
req[reqlen++] = temp & 0xff;
|
||||
cmd2 += 2;
|
||||
}
|
||||
AddCrc(req, reqlen);
|
||||
AddCrc15(req, reqlen);
|
||||
c.arg[0] = reqlen + 2;
|
||||
|
||||
PrintAndLogEx(NORMAL, "iso15693 writing to page %02d (0x%02X) | data ", pagenum, pagenum);
|
||||
|
@ -1282,7 +1282,7 @@ int CmdHF15Write(const char *Cmd) {
|
|||
|
||||
recv = resp.d.asBytes;
|
||||
|
||||
if (!CheckCrc(recv, status)) {
|
||||
if (!CheckCrc15(recv, status)) {
|
||||
PrintAndLogEx(FAILED, "CRC failed");
|
||||
return 2;
|
||||
}
|
||||
|
|
|
@ -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 Crc(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;
|
||||
|
|
|
@ -34,7 +34,7 @@ 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 crc(CrcType_t ct, const uint8_t *d, size_t n);
|
||||
uint16_t Crc(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);
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue