From 4a2a23c6e2f0c0f8ceb9fab1d20199696c89843c Mon Sep 17 00:00:00 2001 From: merlokk <807634+merlokk@users.noreply.github.com> Date: Sat, 7 Aug 2021 20:26:49 +0300 Subject: [PATCH] kdf an10922 test --- client/src/mifare/desfiretest.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/client/src/mifare/desfiretest.c b/client/src/mifare/desfiretest.c index b0a720e92..65d56a907 100644 --- a/client/src/mifare/desfiretest.c +++ b/client/src/mifare/desfiretest.c @@ -104,6 +104,8 @@ static bool TestCMACSubkeys(void) { return res; } +// https://www.nxp.com/docs/en/application-note/AN10922.pdf +// page 8 static bool TestAn10922KDFAES(void) { bool res = true; @@ -113,6 +115,11 @@ static bool TestAn10922KDFAES(void) { DesfireSetKey(&dctx, 0, T_AES, key); memcpy(dctx.sessionKeyMAC, key, sizeof(key)); + uint8_t kdfInput[] = {0x04, 0x78, 0x2E, 0x21, 0x80, 0x1D, 0x80, 0x30, 0x42, 0xF5, 0x4E, 0x58, 0x50, 0x20, 0x41, 0x62, 0x75}; + MifareKdfAn10922(&dctx, kdfInput, sizeof(kdfInput)); + + uint8_t dkey[] = {0xA8, 0xDD, 0x63, 0xA3, 0xB8, 0x9D, 0x54, 0xB3, 0x7C, 0xA8, 0x02, 0x47, 0x3F, 0xDA, 0x91, 0x75}; + res = res && (memcmp(dctx.key, dkey, sizeof(dkey)) == 0); if (res) PrintAndLogEx(INFO, "AES An10922....... " _GREEN_("passed"));