X-Git-Url: https://git.zerfleddert.de/cgi-bin/gitweb.cgi/proxmark3-svn/blobdiff_plain/cd91e41cb53263b0354aded7b5f6008e6f774ce6..f72669f366f07210befb8e21e711204e592dae37:/client/nonce2key/crapto1.c diff --git a/client/nonce2key/crapto1.c b/client/nonce2key/crapto1.c index 65e5d4b2..9f6f7f6b 100644 --- a/client/nonce2key/crapto1.c +++ b/client/nonce2key/crapto1.c @@ -468,21 +468,18 @@ static struct Crypto1State* check_pfx_parity(uint32_t prefix, uint32_t rresp, ui return sl + good; } static struct Crypto1State* check_pfx_parity_ex(uint32_t prefix, uint32_t odd, uint32_t even, struct Crypto1State* sl) { - struct Crypto1State s; + uint32_t c = 0; - s.odd = odd ^ fastfwd[1][c]; - s.even = even ^ fastfwd[0][c]; - - lfsr_rollback_bit(&s, 0, 0); - lfsr_rollback_bit(&s, 0, 0); - lfsr_rollback_bit(&s, 0, 0); + sl->odd = odd ^ fastfwd[1][c]; + sl->even = even ^ fastfwd[0][c]; - lfsr_rollback_word(&s, 0, 0); - lfsr_rollback_word(&s, prefix | c << 5, 1); + lfsr_rollback_bit(sl, 0, 0); + lfsr_rollback_bit(sl, 0, 0); + lfsr_rollback_bit(sl, 0, 0); + lfsr_rollback_word(sl, 0, 0); + lfsr_rollback_word(sl, prefix | c << 5, 1); - sl->odd = s.odd; - sl->even = s.even; return ++sl; } @@ -541,24 +538,19 @@ struct Crypto1State* lfsr_common_prefix_ex(uint32_t pfx, uint8_t ks[8]) goto out; } - // for(o = odd; *o + 1; ++o) - // for(e = even; *e + 1; ++e) - // for(top = 0; top < 64; ++top) { - // *o += 1 << 21; - // *e += (!(top & 7) + 1) << 21; - // s = check_pfx_parity_ex(pfx, *o, *e, s); - // } - for(o = odd; *o != -1; ++o) - for(e = even; *e != -1; ++e) + for(o = odd; *o + 1; ++o) + for(e = even; *e + 1; ++e) for(top = 0; top < 64; ++top) { - *o = (*o & 0x1fffff) | (top << 21); - *e = (*e & 0x1fffff) | (top >> 3) << 21; + *o += 1 << 21; + *e += (!(top & 7) + 1) << 21; s = check_pfx_parity_ex(pfx, *o, *e, s); } - s->odd = s->even = -1; + // in this version, -1 signifies end of states + s->odd = s->even = -1; + out: free(odd); free(even); return statelist; -} +} \ No newline at end of file