From 62a4af0abbf2e1a9c859561c4b1ecc9cbdee7629 Mon Sep 17 00:00:00 2001 From: merlokk Date: Fri, 9 Feb 2018 14:36:11 +0200 Subject: [PATCH] added printing candidates count --- client/mifarehost.c | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/client/mifarehost.c b/client/mifarehost.c index 3b4d5168..6a97f2bc 100644 --- a/client/mifarehost.c +++ b/client/mifarehost.c @@ -909,15 +909,22 @@ int mfTraceDecode(uint8_t *data_src, int len, uint8_t parity, bool wantSaveToEml else printf("key> the same key test. check nt parity error.\n"); - uint32_t ntx = prng_successor(nt, 90); + uint32_t ntc = prng_successor(nt, 90); + uint32_t ntx = 0; + int ntcnt = 0; for (int i = 0; i < 16383; i++) { - ntx = prng_successor(ntx, 1); - if (NTParityCheck(ntx)){ - printf("key> nt candidate=%08x nonce distance=%d\n", ntx, nonce_distance(nt, ntx)); - break; + ntc = prng_successor(ntc, 1); + if (NTParityCheck(ntc)){ + if (!ntcnt) + ntx = ntc; + ntcnt++; } } - + if (ntcnt) + printf("key> nt candidate=%08x nonce distance=%d candidates count=%d\n", ntx, nonce_distance(nt, ntx), ntcnt); + else + printf("key> don't have any nt candidate( \n"); + nt = ntx; ks2 = ar_enc ^ prng_successor(ntx, 64); ks3 = at_enc ^ prng_successor(ntx, 96);