From 09b4c3eed1a8fd91bb06267a52b7e87592941a10 Mon Sep 17 00:00:00 2001 From: merlokk <807634+merlokk@users.noreply.github.com> Date: Sat, 21 Aug 2021 00:05:04 +0300 Subject: [PATCH] rename --- client/src/cmdhfmfdes.c | 2 +- client/src/mifare/desfirecrypto.c | 2 +- client/src/mifare/desfirecrypto.h | 2 +- client/src/mifare/desfiretest.c | 4 ++-- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/client/src/cmdhfmfdes.c b/client/src/cmdhfmfdes.c index 2e4ddf173..31dd64750 100644 --- a/client/src/cmdhfmfdes.c +++ b/client/src/cmdhfmfdes.c @@ -5043,7 +5043,7 @@ static int CmdHF14ADesWriteData(const char *Cmd) { uint8_t sessionkey[16] = {0}; uint8_t uid[7] = {0}; memcpy(uid, dctx.uid, MAX(dctx.uidlen, 7)); - DesfireGenTransSessionKey(trkey, transactionCounter, uid, false, sessionkey); + DesfireGenTransSessionKeyEV2(trkey, transactionCounter, uid, false, sessionkey); aes_decode(NULL, sessionkey, resp, resp, CRYPTO_AES_BLOCK_SIZE); PrintAndLogEx(INFO, "Prev reader id [%zu]: %s", resplen, sprint_hex(resp, resplen)); diff --git a/client/src/mifare/desfirecrypto.c b/client/src/mifare/desfirecrypto.c index fee29f340..db898db1d 100644 --- a/client/src/mifare/desfirecrypto.c +++ b/client/src/mifare/desfirecrypto.c @@ -649,7 +649,7 @@ int DesfireEV2CalcCMAC(DesfireContext *ctx, uint8_t cmd, uint8_t *data, size_t d // https://www.nxp.com/docs/en/data-sheet/MF2DLHX0.pdf // page 42 -void DesfireGenTransSessionKey(uint8_t *key, uint32_t trCntr, uint8_t *uid, bool forMAC, uint8_t *sessionkey) { +void DesfireGenTransSessionKeyEV2(uint8_t *key, uint32_t trCntr, uint8_t *uid, bool forMAC, uint8_t *sessionkey) { uint8_t xiv[CRYPTO_AES_BLOCK_SIZE] = {0}; if (forMAC) { diff --git a/client/src/mifare/desfirecrypto.h b/client/src/mifare/desfirecrypto.h index 78d0ceee5..9ed9ef5a5 100644 --- a/client/src/mifare/desfirecrypto.h +++ b/client/src/mifare/desfirecrypto.h @@ -141,7 +141,7 @@ void DesfireGenSessionKeyEV1(const uint8_t rnda[], const uint8_t rndb[], Desfire void DesfireGenSessionKeyEV2(uint8_t *key, uint8_t *rndA, uint8_t *rndB, bool enckey, uint8_t *sessionkey); void DesfireEV2FillIV(DesfireContext *ctx, bool ivforcommand, uint8_t *iv); int DesfireEV2CalcCMAC(DesfireContext *ctx, uint8_t cmd, uint8_t *data, size_t datalen, uint8_t *mac); -void DesfireGenTransSessionKey(uint8_t *key, uint32_t trCntr, uint8_t *uid, bool forMAC, uint8_t *sessionkey); +void DesfireGenTransSessionKeyEV2(uint8_t *key, uint32_t trCntr, uint8_t *uid, bool forMAC, uint8_t *sessionkey); int DesfireLRPCalcCMAC(DesfireContext *ctx, uint8_t cmd, uint8_t *data, size_t datalen, uint8_t *mac); diff --git a/client/src/mifare/desfiretest.c b/client/src/mifare/desfiretest.c index a4ff117b0..75f819dc3 100644 --- a/client/src/mifare/desfiretest.c +++ b/client/src/mifare/desfiretest.c @@ -462,11 +462,11 @@ static bool TestTransSessionKeys(void) { uint32_t trCntr = 8; uint8_t sessionkey[16] = {0}; - DesfireGenTransSessionKey(key, trCntr, uid, true, sessionkey); + DesfireGenTransSessionKeyEV2(key, trCntr, uid, true, sessionkey); uint8_t keymac[] = {0x7C, 0x1A, 0xD2, 0xD9, 0xC5, 0xC0, 0x81, 0x54, 0xA0, 0xA4, 0x91, 0x4B, 0x40, 0x1A, 0x65, 0x98}; res = res && (memcmp(sessionkey, keymac, sizeof(keymac)) == 0); - DesfireGenTransSessionKey(key, trCntr, uid, false, sessionkey); + DesfireGenTransSessionKeyEV2(key, trCntr, uid, false, sessionkey); uint8_t keyenc[] = {0x11, 0x9B, 0x90, 0x2A, 0x07, 0xB1, 0x8A, 0x86, 0x5B, 0x8E, 0x1B, 0x00, 0x60, 0x59, 0x47, 0x84}; res = res && (memcmp(sessionkey, keyenc, sizeof(keyenc)) == 0);