- PrintAndLog("--sector:%2d, block:%3d, key type:%C, key count:%2d ", i, b, t?'B':'A', keycnt);\r
- uint32_t max_keys = keycnt>USB_CMD_DATA_SIZE/6?USB_CMD_DATA_SIZE/6:keycnt;\r
- for (uint32_t c = 0; c < keycnt; c+=max_keys) {\r
- uint32_t size = keycnt-c>max_keys?max_keys:keycnt-c;\r
- res = mfCheckKeys(b, t, true, size, &keyBlock[6*c], &key64);\r
- if (res != 1) {\r
- if (!res) {\r
- PrintAndLog("Found valid key:[%012"llx"]",key64);\r
- num_to_bytes(key64, 6, foundKey[t][i]);\r
- validKey[t][i] = true;\r
- } \r
+ \r
+ // skip already found keys.\r
+ if (e_sector[i].foundKey[trgKeyType]) continue;\r
+ \r
+ PrintAndLog("--sector:%2d, block:%3d, key type:%C, key count:%2d ", i, b, trgKeyType ? 'B':'A', keycnt);\r
+ \r
+ uint32_t max_keys = keycnt > (USB_CMD_DATA_SIZE/6) ? (USB_CMD_DATA_SIZE/6) : keycnt;\r
+ \r
+ for (uint32_t c = 0; c < keycnt; c += max_keys) {\r
+ \r
+ uint32_t size = keycnt-c > max_keys ? max_keys : keycnt-c;\r
+ \r
+ res = mfCheckKeys(b, trgKeyType, true, size, &keyBlock[6*c], &key64);\r
+ if (!res) {\r
+ PrintAndLog("Found valid key:[%012"llx"]",key64); \r
+ e_sector[i].Key[trgKeyType] = key64;\r
+ e_sector[i].foundKey[trgKeyType] = TRUE;\r
+ break;\r