+ // print nested statistic\r
+ PrintAndLog("\n\n-----------------------------------------------\nNested statistic:\nIterations count: %d", iterations);\r
+ PrintAndLog("Time in nested: %1.3f (%1.3f sec per key)", ((float)(msclock() - msclock1))/1000.0, ((float)(msclock() - msclock1))/iterations/1000.0);\r
+ \r
+ // check if we have unrecognized keys\r
+ bool notFoundKeys = false;\r
+ for (i = 0; i < SectorsCnt; i++) {\r
+ for (j = 0; j < 2; j++) {\r
+ if (!e_sector[i].foundKey[j]) {\r
+ notFoundKeys = true;\r
+ break;\r
+ }\r
+ }\r
+ if (notFoundKeys) break;\r
+ } \r
+ \r
+ if (notFoundKeys) {\r
+ PrintAndLog("-----------------------------------------------\n");\r
+ PrintAndLog("We have unrecognized keys. Trying to check if we have this keys on key buffer...");\r
+\r
+ // fill keyBlock with known keys\r
+ int cnt = 0;\r
+ for (i = 0; i < SectorsCnt; i++) {\r
+ for (j = 0; j < 2; j++) {\r
+ if (e_sector[i].foundKey[j]) {\r
+ // try to insert key to keyBlock \r
+ if (cnt < NESTED_KEY_COUNT) {\r
+\r
+ // search for dublicates\r
+ bool dubl = false;\r
+ for (int v = 0; v < NESTED_KEY_COUNT; v++) {\r
+ if (e_sector[i].Key[j] == bytes_to_num((uint8_t*)(keyBlock + v * 6), 6)) {\r
+ dubl = true;\r
+ break;\r
+ }\r
+ }\r
+ \r
+ // insert\r
+ if (!dubl) {\r
+ num_to_bytes(e_sector[i].Key[j], 6, (uint8_t*)(keyBlock + cnt * 6));\r
+ cnt++;\r
+ }\r
+ }\r
+ }\r
+ }\r
+ }\r