p4->even = 0; p4->odd = 0;\r
statelists[0].len = p3 - statelists[0].head.slhead;\r
statelists[1].len = p4 - statelists[1].head.slhead;\r
- statelists[0].tail.sltail=--p3;\r
- statelists[1].tail.sltail=--p4;\r
+ statelists[0].tail.sltail = --p3;\r
+ statelists[1].tail.sltail = --p4;\r
\r
// the statelists now contain possible keys. The key we are searching for must be in the\r
// intersection of both lists. Create the intersection:\r
memset(buf, 0, sizeof(buf));\r
if (fgets(buf, sizeof(buf), f) == NULL) {\r
PrintAndLog("No trace file found or reading error.");\r
- fclose(f);\r
+ if (f) {\r
+ fclose(f);\r
+ f = NULL;\r
+ }\r
return 2;\r
}\r
\r
if (strlen(buf) < 32){\r
if (feof(f)) break;\r
PrintAndLog("File content error. Block data must include 32 HEX symbols");\r
- fclose(f);\r
+ if (f) {\r
+ fclose(f);\r
+ f = NULL;\r
+ }\r
return 2;\r
}\r
for (i = 0; i < 32; i += 2)\r
\r
blockNum++;\r
}\r
- fclose(f);\r
+ if (f) {\r
+ fclose(f);\r
+ f = NULL;\r
+ }\r
return 0;\r
}\r
\r
fprintf(f,"\n");\r
}\r
fflush(f);\r
- fclose(f);\r
+ if (f) {\r
+ fclose(f);\r
+ f = NULL;\r
+ }\r
return 0;\r
}\r
\r
\r
int tryDecryptWord(uint32_t nt, uint32_t ar_enc, uint32_t at_enc, uint8_t *data, int len){\r
PrintAndLog("\nEncrypted data: [%s]", sprint_hex(data, len) );\r
- struct Crypto1State *pcs = NULL;\r
+ struct Crypto1State *s;\r
ks2 = ar_enc ^ prng_successor(nt, 64);\r
ks3 = at_enc ^ prng_successor(nt, 96);\r
- pcs = lfsr_recovery64(ks2, ks3);\r
- mf_crypto1_decrypt(pcs, data, len, FALSE);\r
+ s = lfsr_recovery64(ks2, ks3);\r
+ mf_crypto1_decrypt(s, data, len, FALSE);\r
PrintAndLog("Decrypted data: [%s]", sprint_hex(data, len) );\r
- crypto1_destroy(pcs);\r
+ crypto1_destroy(s);\r
return 0;\r
}\r