- qsort(statelists[1].head.keyhead, statelists[1].len, sizeof(uint64_t), compare_uint64);
- statelists[0].len = intersection(statelists[0].head.keyhead, statelists[1].head.keyhead);
+
+ if (num_unique_nonces > 1) {
+ qsort(statelists[1].head.keyhead, statelists[1].len, sizeof(uint64_t), compare_uint64);
+ statelists[0].len = intersection(statelists[0].head.keyhead, statelists[1].head.keyhead);
+ }
+ else {
+ PrintAndLog("Nonce 1 and 2 are the same!");
+ }
+
+ if (statelists[0].len > 100) {
+ PrintAndLog("We have %d keys to check. This will take a very long time!", statelists[0].len);
+ PrintAndLog("Press button to abort.");
+ }
+ else if (statelists[0].len < 1) {
+ PrintAndLog("No candidate keys to check!");
+ }
+ else {
+ PrintAndLog("We have %d key(s) to check.", statelists[0].len);
+ }
+
+ uint32_t max_keys = (statelists[0].len > (USB_CMD_DATA_SIZE / 6)) ? (USB_CMD_DATA_SIZE / 6) : statelists[0].len;
+ keyBlock = calloc(max_keys, 6);
+
+ if (keyBlock == NULL) {
+ free(statelists[0].head.slhead);
+ free(statelists[1].head.slhead);
+ return -4;
+ }