hf mf sniff works with the same key

This commit is contained in:
merlokk 2018-02-02 19:58:11 +02:00
commit 4e0341b568

View file

@ -575,6 +575,7 @@ struct Crypto1State *traceCrypto1 = NULL;
struct Crypto1State *revstate; struct Crypto1State *revstate;
uint64_t lfsr; uint64_t lfsr;
uint64_t ui64Key;
uint32_t ks2; uint32_t ks2;
uint32_t ks3; uint32_t ks3;
@ -848,18 +849,27 @@ int mfTraceDecode(uint8_t *data_src, int len, bool wantSaveToEmlFile) {
lfsr_rollback_word(revstate, uid ^ nt, 0); lfsr_rollback_word(revstate, uid ^ nt, 0);
crypto1_get_lfsr(revstate, &lfsr); crypto1_get_lfsr(revstate, &lfsr);
ui64Key = lfsr;
printf("key> %x%x Prng:%s\n", printf("key> %x%x Prng:%s\n",
(unsigned int)((lfsr & 0xFFFFFFFF00000000) >> 32), (unsigned int)(lfsr & 0xFFFFFFFF), (unsigned int)((lfsr & 0xFFFFFFFF00000000) >> 32), (unsigned int)(lfsr & 0xFFFFFFFF),
validate_prng_nonce(nt) ? "WEAK": "HARDEND"); validate_prng_nonce(nt) ? "WEAK": "HARDEND");
AddLogUint64(logHexFileName, "key> ", lfsr); AddLogUint64(logHexFileName, "key> ", lfsr);
} else { } else {
if (validate_prng_nonce(nt)) { if (validate_prng_nonce(nt)) {
struct Crypto1State *pcs;
pcs = crypto1_create(ui64Key);
uint32_t nt1 = crypto1_word(pcs, nt_enc ^ uid, 1) ^ nt_enc;
uint32_t ar = prng_successor(nt1, 64);
uint32_t at = prng_successor(nt1, 96);
printf("key> nested auth uid: %08x nt: %08x ar: %08x at: %08x\n", uid, nt1, ar, at);
uint32_t nr1 = crypto1_word(pcs, nr_enc, 1) ^ nr_enc;
uint32_t ar1 = crypto1_word(pcs, 0, 0) ^ ar_enc;
uint32_t at1 = crypto1_word(pcs, 0, 0) ^ at_enc;
printf("key> nr1: %08x ar1: %08x at1: %08x\n", nr1, ar1, at1);
ks2 = ar_enc ^ prng_successor(nt1, 64);
printf("key> nested... TBD\n"); ks3 = at_enc ^ prng_successor(nt1, 96);
crypto1_destroy(traceCrypto1);
traceState = TRACE_ERROR;
} else { } else {
printf("key> hardnested not implemented!\n"); printf("key> hardnested not implemented!\n");