From e7902ca0a5984f873e45fb4af3c2e40b173efb73 Mon Sep 17 00:00:00 2001 From: iceman Date: Mon, 15 Feb 2016 02:45:43 +0100 Subject: [PATCH 1/6] chg: removed testmessage --- client/cmdhfmf.c | 1 - 1 file changed, 1 deletion(-) diff --git a/client/cmdhfmf.c b/client/cmdhfmf.c index d6cae59f0..3142fcd88 100644 --- a/client/cmdhfmf.c +++ b/client/cmdhfmf.c @@ -712,7 +712,6 @@ int CmdHF14AMfNested(const char *Cmd) // nested sectors iterations = 0; - PrintAndLog("enter nested..."); bool calibrate = true; for (i = 0; i < NESTED_SECTOR_RETRY; i++) { From 6e91de5a8d1bd3c94f6bf6c80e284a374a5c7187 Mon Sep 17 00:00:00 2001 From: iceman Date: Mon, 15 Feb 2016 02:46:15 +0100 Subject: [PATCH 2/6] add: added a test function for nonce distance --- armsrc/crapto1.h | 1 + 1 file changed, 1 insertion(+) diff --git a/armsrc/crapto1.h b/armsrc/crapto1.h index 9262b956c..7ea6fa28f 100644 --- a/armsrc/crapto1.h +++ b/armsrc/crapto1.h @@ -32,6 +32,7 @@ uint8_t crypto1_bit(struct Crypto1State*, uint8_t, int); uint8_t crypto1_byte(struct Crypto1State*, uint8_t, int); uint32_t crypto1_word(struct Crypto1State*, uint32_t, int); uint32_t prng_successor(uint32_t x, uint32_t n); +uint32_t prng_successor_one(uint32_t x); struct Crypto1State* lfsr_recovery32(uint32_t ks2, uint32_t in); struct Crypto1State* lfsr_recovery64(uint32_t ks2, uint32_t ks3); From a70fcfb65597ff22e4b2b8735d1afa550386603c Mon Sep 17 00:00:00 2001 From: iceman Date: Mon, 15 Feb 2016 02:46:48 +0100 Subject: [PATCH 3/6] add: added a noncedistance method --- armsrc/crypto1.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/armsrc/crypto1.c b/armsrc/crypto1.c index 98d38b2bf..68cb9b4e5 100644 --- a/armsrc/crypto1.c +++ b/armsrc/crypto1.c @@ -141,3 +141,13 @@ uint32_t prng_successor(uint32_t x, uint32_t n) return SWAPENDIAN(x); } + +uint32_t prng_successor_one(uint32_t x) +{ + SWAPENDIAN(x); + + x = x >> 1 | (x >> 16 ^ x >> 18 ^ x >> 19 ^ x >> 21) << 31; + + return SWAPENDIAN(x); +} + From 5fdf867253e9a97f8fd81564cf0a165722a67358 Mon Sep 17 00:00:00 2001 From: iceman Date: Mon, 15 Feb 2016 02:49:04 +0100 Subject: [PATCH 4/6] CHG: some timing --- client/nonce2key/nonce2key.c | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/client/nonce2key/nonce2key.c b/client/nonce2key/nonce2key.c index 2d0590df3..95924e5e7 100644 --- a/client/nonce2key/nonce2key.c +++ b/client/nonce2key/nonce2key.c @@ -16,6 +16,7 @@ int nonce2key(uint32_t uid, uint32_t nt, uint32_t nr, uint64_t par_info, uint64_t ks_info, uint64_t * key) { + struct Crypto1State *state; uint32_t i, pos, rr = 0, nr_diff; byte_t bt, ks3x[8], par[8][8]; @@ -39,17 +40,22 @@ int nonce2key(uint32_t uid, uint32_t nt, uint32_t nr, uint64_t par_info, uint64_ for ( i = 0; i < 8; i++) { nr_diff = nr | i << 5; - printf("| %02x |%08x|", i << 5, nr_diff); - printf(" %01x | %01x |", ks3x[i], ks3x[i]^5); + printf("| %02x |%08x| %01x | %01x |", i << 5, nr_diff, ks3x[i], ks3x[i]^5); + for (pos = 0; pos < 7; pos++) printf("%01x,", par[i][pos]); printf("%01x|\n", par[i][7]); } printf("+----+--------+---+-----+---------------+\n"); + clock_t t1 = clock(); + state = lfsr_common_prefix(nr, rr, ks3x, par); lfsr_rollback_word(state, uid^nt, 0); crypto1_get_lfsr(state, key); crypto1_destroy(state); + + t1 = clock() - t1; + if ( t1 > 0 ) PrintAndLog("Time in nonce2key: %.0f ticks \n", (float)t1); return 0; } @@ -167,9 +173,9 @@ int tryMfk64(uint64_t myuid, uint8_t *data, uint8_t *outputkey ){ pcs = &mpcs; uid = myuid;//(uint32_t)bytes_to_num(data + 0, 4); - nt = *(uint32_t*)(data+8); - nr_enc = *(uint32_t*)(data+12); - ar_enc = *(uint32_t*)(data+16); + nt = *(uint32_t*)(data+8); + nr_enc = *(uint32_t*)(data+12); + ar_enc = *(uint32_t*)(data+16); crypto1_word(pcs, nr_enc , 1); at_enc = prng_successor(nt, 96) ^ crypto1_word(pcs, 0, 0); @@ -195,4 +201,4 @@ int tryMfk64(uint64_t myuid, uint8_t *data, uint8_t *outputkey ){ num_to_bytes(key, 6, outputkey); crypto1_destroy(revstate); return 0; -} \ No newline at end of file +} From 4211fdce315b6f20d624374d5a249627bf871a06 Mon Sep 17 00:00:00 2001 From: iceman Date: Mon, 15 Feb 2016 02:49:26 +0100 Subject: [PATCH 5/6] chg: the windows exe annoys the linux compiler --- tools/mfkey/Makefile | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/tools/mfkey/Makefile b/tools/mfkey/Makefile index a1bc44ad0..79b42a435 100755 --- a/tools/mfkey/Makefile +++ b/tools/mfkey/Makefile @@ -5,7 +5,8 @@ LDFLAGS = OBJS = crapto1.o crypto1.o HEADERS = crapto1.h -EXES = mfkey64 mfkey64.exe mfkey32 mfkey32.exe mfkey32v2 mfkey32v2.exe +EXES = mfkey64 mfkey32 mfkey32v2 +WINEXE = mfkey64.exe mfkey32.exe mfkey32v2.exe LIBS = all: $(OBJS) $(EXES) $(LIBS) @@ -14,4 +15,5 @@ all: $(OBJS) $(EXES) $(LIBS) $(LD) $(CFLAGS) -o $@ $< $(OBJS) $(LDFLAGS) clean: - rm -f $(OBJS) $(EXES) $(LIBS) + rm -f $(OBJS) $(EXES) $(LIBS) $(WINEXE) + From 3989d6fff6a686f2e7b3fa2242592ecf897d7ee4 Mon Sep 17 00:00:00 2001 From: iceman Date: Mon, 15 Feb 2016 02:50:00 +0100 Subject: [PATCH 6/6] chg: the windows exe annoys the linux compiler --- tools/nonce2key/Makefile | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/tools/nonce2key/Makefile b/tools/nonce2key/Makefile index 43a87c3f8..a46169f41 100644 --- a/tools/nonce2key/Makefile +++ b/tools/nonce2key/Makefile @@ -5,7 +5,8 @@ LDFLAGS = OBJS = crypto1.o crapto1.o HEADERS = crapto1.h -EXES = nonce2key nonce2key.exe +EXES = nonce2key +WINEXES = nonce2key.exe all: $(OBJS) $(EXES) @@ -16,4 +17,4 @@ all: $(OBJS) $(EXES) $(LD) $(LDFLAGS) -o $@ $(OBJS) $< clean: - rm -f $(OBJS) $(EXES) + rm -f $(OBJS) $(EXES) $(WINEXES)