From c6a886fb4f25b8925956a267ed3d2f60455adf4a Mon Sep 17 00:00:00 2001
From: Oleg Moiseenko <olegmsn@gmail.com>
Date: Sat, 10 Feb 2018 23:06:01 +0200
Subject: [PATCH] added mock of key check

---
 client/cmdhflist.c | 13 ++++++++++++-
 client/cmdhflist.h |  1 +
 2 files changed, 13 insertions(+), 1 deletion(-)

diff --git a/client/cmdhflist.c b/client/cmdhflist.c
index 43e0e562..30249579 100644
--- a/client/cmdhflist.c
+++ b/client/cmdhflist.c
@@ -23,6 +23,7 @@
 #include "protocols.h"
 #include "crapto1/crapto1.h"
 #include "mifarehost.h"
+#include "mifaredefault.h"
 
 
 enum MifareAuthSeq {
@@ -291,10 +292,17 @@ bool DecodeMifareData(uint8_t *cmd, uint8_t cmdsize, bool isResponse, uint8_t *m
 			
 			// check last used key
 			if (mfLastKey) {
-				
+				if (NestedCheckKey(mfLastKey, &AuthData, cmd, cmdsize)) {
+				};
 			}
 			
 			// check default keys
+			for (int defaultKeyCounter = 0; defaultKeyCounter < MifareDefaultKeysSize; defaultKeyCounter++){
+				if (NestedCheckKey(MifareDefaultKeys[defaultKeyCounter], &AuthData, cmd, cmdsize)) {
+					
+					break;
+				};
+			}
 			
 			// nested
 			if (validate_prng_nonce(AuthData.nt)) {
@@ -317,3 +325,6 @@ bool DecodeMifareData(uint8_t *cmd, uint8_t cmdsize, bool isResponse, uint8_t *m
 	return *mfDataLen > 0;
 }
 
+bool NestedCheckKey(uint64_t key, TAuthData *ad, uint8_t *cmd, uint8_t cmdsize) {
+	return false;
+}
\ No newline at end of file
diff --git a/client/cmdhflist.h b/client/cmdhflist.h
index 7d95cc1c..d0298de5 100644
--- a/client/cmdhflist.h
+++ b/client/cmdhflist.h
@@ -33,5 +33,6 @@ extern uint8_t mifare_CRC_check(bool isResponse, uint8_t* data, uint8_t len);
 extern void annotateIso14443a(char *exp, size_t size, uint8_t* cmd, uint8_t cmdsize);
 extern void annotateMifare(char *exp, size_t size, uint8_t* cmd, uint8_t cmdsize, uint8_t* parity, uint8_t paritysize, bool isResponse);
 extern bool DecodeMifareData(uint8_t *cmd, uint8_t cmdsize, bool isResponse, uint8_t *mfData, size_t *mfDataLen);
+extern bool NestedCheckKey(uint64_t key, TAuthData *ad, uint8_t *cmd, uint8_t cmdsize);
 
 #endif // CMDHFLIST
-- 
2.39.5