mirror of
https://github.com/RfidResearchGroup/proxmark3.git
synced 2025-07-05 20:41:34 -07:00
Make CRC size explicit in some cmd/reply size calculations
This commit is contained in:
parent
63392baa40
commit
67da1c8ca5
4 changed files with 10 additions and 9 deletions
|
@ -1764,7 +1764,7 @@ void SimulateIso14443aTag(uint8_t tagType, uint16_t flags, uint8_t *useruid, uin
|
|||
} else {
|
||||
// first blocks of emu are header
|
||||
uint16_t start = (block * 4) + MFU_DUMP_PREFIX_LENGTH;
|
||||
uint8_t emdata[MIFARE_BLOCK_SIZE + 2] = {0};
|
||||
uint8_t emdata[MIFARE_BLOCK_SIZE + CRC16_SIZE] = {0};
|
||||
emlGet(emdata, start, MIFARE_BLOCK_SIZE);
|
||||
AddCrc14A(emdata, MIFARE_BLOCK_SIZE);
|
||||
EmSendCmd(emdata, sizeof(emdata));
|
||||
|
@ -1783,7 +1783,7 @@ void SimulateIso14443aTag(uint8_t tagType, uint16_t flags, uint8_t *useruid, uin
|
|||
// block1 = 4byte UID.
|
||||
p_response = &responses[RESP_INDEX_UIDC1];
|
||||
} else { // all other tags (16 byte block tags)
|
||||
uint8_t emdata[MIFARE_BLOCK_SIZE + 2] = {0};
|
||||
uint8_t emdata[MIFARE_BLOCK_SIZE + CRC16_SIZE] = {0};
|
||||
emlGet(emdata, block, MIFARE_BLOCK_SIZE);
|
||||
AddCrc14A(emdata, MIFARE_BLOCK_SIZE);
|
||||
EmSendCmd(emdata, sizeof(emdata));
|
||||
|
|
|
@ -2909,7 +2909,7 @@ void MifareCGetBlock(uint32_t arg0, uint32_t arg1, uint8_t *datain) {
|
|||
}
|
||||
|
||||
// read block
|
||||
if ((mifare_sendcmd_short(NULL, CRYPT_NONE, ISO14443A_CMD_READBLOCK, blockNo, receivedAnswer, sizeof(receivedAnswer), receivedAnswerPar, NULL) != MIFARE_BLOCK_SIZE + 2)) {
|
||||
if ((mifare_sendcmd_short(NULL, CRYPT_NONE, ISO14443A_CMD_READBLOCK, blockNo, receivedAnswer, sizeof(receivedAnswer), receivedAnswerPar, NULL) != MIFARE_BLOCK_SIZE + CRC16_SIZE)) {
|
||||
if (g_dbglevel >= DBG_ERROR) Dbprintf("read block send command error");
|
||||
errormsg = 0;
|
||||
break;
|
||||
|
@ -3515,7 +3515,7 @@ void MifareGen3Blk(uint8_t block_len, uint8_t *block) {
|
|||
|
||||
int retval = PM3_SUCCESS;
|
||||
uint8_t block_cmd[5] = { 0x90, 0xf0, 0xcc, 0xcc, 0x10 };
|
||||
uint8_t cmdlen = sizeof(block_cmd) + MIFARE_BLOCK_SIZE + 2;
|
||||
uint8_t cmdlen = sizeof(block_cmd) + MIFARE_BLOCK_SIZE + CRC16_SIZE;
|
||||
uint8_t *cmd = BigBuf_calloc(cmdlen);
|
||||
|
||||
iso14a_card_select_t *card_info = (iso14a_card_select_t *) BigBuf_calloc(sizeof(iso14a_card_select_t));
|
||||
|
@ -3532,7 +3532,7 @@ void MifareGen3Blk(uint8_t block_len, uint8_t *block) {
|
|||
|
||||
bool doReselect = false;
|
||||
if (block_len < MIFARE_BLOCK_SIZE) {
|
||||
if ((mifare_sendcmd_short(NULL, CRYPT_NONE, ISO14443A_CMD_READBLOCK, 0, &cmd[sizeof(block_cmd)], MIFARE_BLOCK_SIZE + 2, NULL, NULL) != MIFARE_BLOCK_SIZE + 2)) {
|
||||
if ((mifare_sendcmd_short(NULL, CRYPT_NONE, ISO14443A_CMD_READBLOCK, 0, &cmd[sizeof(block_cmd)], MIFARE_BLOCK_SIZE + CRC16_SIZE, NULL, NULL) != MIFARE_BLOCK_SIZE + CRC16_SIZE)) {
|
||||
if (g_dbglevel >= DBG_ERROR) Dbprintf("Read manufacturer block failed");
|
||||
retval = PM3_ESOFT;
|
||||
goto OUT;
|
||||
|
@ -3567,7 +3567,7 @@ void MifareGen3Blk(uint8_t block_len, uint8_t *block) {
|
|||
}
|
||||
}
|
||||
|
||||
retval = DoGen3Cmd(cmd, sizeof(block_cmd) + MIFARE_BLOCK_SIZE + 2);
|
||||
retval = DoGen3Cmd(cmd, sizeof(block_cmd) + MIFARE_BLOCK_SIZE + CRC16_SIZE);
|
||||
}
|
||||
|
||||
OUT:
|
||||
|
|
|
@ -1039,8 +1039,8 @@ void Mifare1ksim(uint16_t flags, uint8_t exitAfterNReads, uint8_t *uid, uint16_t
|
|||
}
|
||||
}
|
||||
AddCrc14A(response, MIFARE_BLOCK_SIZE);
|
||||
mf_crypto1_encrypt(pcs, response, MIFARE_BLOCK_SIZE + 2, response_par);
|
||||
EmSendCmdPar(response, MIFARE_BLOCK_SIZE + 2, response_par);
|
||||
mf_crypto1_encrypt(pcs, response, MIFARE_BLOCK_SIZE + CRC16_SIZE, response_par);
|
||||
EmSendCmdPar(response, MIFARE_BLOCK_SIZE + CRC16_SIZE, response_par);
|
||||
FpgaDisableTracing();
|
||||
|
||||
if (g_dbglevel >= DBG_EXTENDED) {
|
||||
|
@ -1309,7 +1309,7 @@ void Mifare1ksim(uint16_t flags, uint8_t exitAfterNReads, uint8_t *uid, uint16_t
|
|||
// WRITE BL2
|
||||
case MFEMUL_WRITEBL2: {
|
||||
|
||||
if (receivedCmd_len == MIFARE_BLOCK_SIZE + 2) {
|
||||
if (receivedCmd_len == MIFARE_BLOCK_SIZE + CRC16_SIZE) {
|
||||
|
||||
mf_crypto1_decryptEx(pcs, receivedCmd, receivedCmd_len, receivedCmd_dec);
|
||||
|
||||
|
|
|
@ -20,6 +20,7 @@
|
|||
|
||||
#include "common.h"
|
||||
|
||||
#define CRC16_SIZE 2
|
||||
#define CRC16_POLY_CCITT 0x1021
|
||||
#define CRC16_POLY_KERMIT 0x8408
|
||||
#define CRC16_POLY_LEGIC 0xc6c6 //0x6363
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue