From 15f2fb4010343b511a4aafe8f1a3353116eef9b7 Mon Sep 17 00:00:00 2001 From: Eloff Date: Fri, 12 Apr 2019 00:35:02 +0300 Subject: [PATCH] duplicate method --- armsrc/mifaresim.c | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/armsrc/mifaresim.c b/armsrc/mifaresim.c index fb89b2909..3b7e91687 100644 --- a/armsrc/mifaresim.c +++ b/armsrc/mifaresim.c @@ -370,12 +370,6 @@ static bool MifareSimInit(uint16_t flags, uint8_t *datain, tag_response_info_t * return true; } -static bool HasValidCRC(uint8_t *receivedCmd, uint16_t receivedCmd_len) { - uint8_t CRC_byte_1, CRC_byte_2; - compute_crc(CRC_14443_A, receivedCmd, receivedCmd_len - 2, &CRC_byte_1, &CRC_byte_2); - return (receivedCmd[receivedCmd_len - 2] == CRC_byte_1 && receivedCmd[receivedCmd_len - 1] == CRC_byte_2); -} - /** *MIFARE 1K simulate. @@ -772,7 +766,7 @@ void Mifare1ksim(uint16_t flags, uint8_t exitAfterNReads, uint8_t arg2, uint8_t memcpy(receivedCmd_dec, receivedCmd, receivedCmd_len); } - if (!HasValidCRC(receivedCmd_dec, receivedCmd_len)) { // all commands must have a valid CRC + if (!CheckCrc14A(receivedCmd_dec, receivedCmd_len)) { // all commands must have a valid CRC EmSend4bit(encrypted_data ? mf_crypto1_encrypt4bit(pcs, CARD_NACK_NA) : CARD_NACK_NA); if (MF_DBGLEVEL >= MF_DBG_EXTENDED) Dbprintf("[MFEMUL_WORK] All commands must have a valid CRC %02X (%d)", receivedCmd_dec, receivedCmd_len); break; @@ -1138,7 +1132,7 @@ void Mifare1ksim(uint16_t flags, uint8_t exitAfterNReads, uint8_t arg2, uint8_t case MFEMUL_WRITEBL2: { if (receivedCmd_len == MAX_MIFARE_FRAME_SIZE) { mf_crypto1_decryptEx(pcs, receivedCmd, receivedCmd_len, receivedCmd_dec); - if (HasValidCRC(receivedCmd_dec, receivedCmd_len)) { + if (CheckCrc14A(receivedCmd_dec, receivedCmd_len)) { if (IsSectorTrailer(cardWRBL)) { emlGetMem(response, cardWRBL, 1); if (!IsAccessAllowed(cardWRBL, cardAUTHKEY, AC_KEYA_WRITE)) {