]> cvs.zerfleddert.de Git - proxmark3-svn/commitdiff
move ks to authdata
authorOleg Moiseenko <olegmsn@gmail.com>
Sat, 10 Feb 2018 22:40:24 +0000 (00:40 +0200)
committerOleg Moiseenko <olegmsn@gmail.com>
Sat, 10 Feb 2018 22:40:24 +0000 (00:40 +0200)
client/cmdhflist.c
client/cmdhflist.h

index 06bd8d18deb47288ba0b3da585d0039413f53c9c..1701c13ae8908b55ab2f8fcf851019fdcead0738 100644 (file)
@@ -43,6 +43,8 @@ void ClearAuthData() {
        AuthData.uid = 0;
        AuthData.nt = 0;
        AuthData.first_auth = true;
+       AuthData.ks2 = 0;
+       AuthData.ks3 = 0;
 }
 
 /**
@@ -266,9 +268,9 @@ bool DecodeMifareData(uint8_t *cmd, uint8_t cmdsize, bool isResponse, uint8_t *m
        
        if (MifareAuthState == masFirstData) {
                if (AuthData.first_auth) {
-                       uint32_t ks2 = AuthData.ar_enc ^ prng_successor(AuthData.nt, 64);
-                       uint32_t ks3 = AuthData.at_enc ^ prng_successor(AuthData.nt, 96);
-                       struct Crypto1State *revstate = lfsr_recovery64(ks2, ks3);
+                       AuthData.ks2 = AuthData.ar_enc ^ prng_successor(AuthData.nt, 64);
+                       AuthData.ks3 = AuthData.at_enc ^ prng_successor(AuthData.nt, 96);
+                       struct Crypto1State *revstate = lfsr_recovery64(AuthData.ks2, AuthData.ks3);
                        lfsr_rollback_word(revstate, 0, 0);
                        lfsr_rollback_word(revstate, 0, 0);
                        lfsr_rollback_word(revstate, AuthData.nr_enc, 1);
@@ -281,12 +283,12 @@ bool DecodeMifareData(uint8_t *cmd, uint8_t cmdsize, bool isResponse, uint8_t *m
                        PrintAndLog("            |          * | key | probable key:%x%x Prng:%s   ks2:%08x ks3:%08x |     |", 
                                (unsigned int)((lfsr & 0xFFFFFFFF00000000) >> 32), (unsigned int)(lfsr & 0xFFFFFFFF), 
                                validate_prng_nonce(AuthData.nt) ? "WEAK": "HARD",
-                               ks2,
-                               ks3);
+                               AuthData.ks2,
+                               AuthData.ks3);
                        
                        AuthData.first_auth = false;
 
-                       traceCrypto1 = lfsr_recovery64(ks2, ks3);
+                       traceCrypto1 = lfsr_recovery64(AuthData.ks2, AuthData.ks3);
                } else {
                        printf("uid:%x nt:%x ar_enc:%x at_enc:%x\n", AuthData.uid, AuthData.nt, AuthData.ar_enc, AuthData.at_enc);
                        
@@ -321,7 +323,9 @@ bool DecodeMifareData(uint8_t *cmd, uint8_t cmdsize, bool isResponse, uint8_t *m
                                
                                                crypto1_destroy(pcs);
                                                if (CheckCrc14443(CRC_14443_A, mfData, cmdsize)) {
-                                                       traceCrypto1 = lfsr_recovery64(ks2, ks3);
+                                                       AuthData.ks2 = ks2;
+                                                       AuthData.ks3 = ks3;
+                                                       traceCrypto1 = lfsr_recovery64(AuthData.ks2, AuthData.ks3);
                                                        break;
                                                }
                                        }                                               
index aa037658f42c4dbc9dfd3bc591efb8c6971d5cf1..76b57392259e2ade054ad91ab277c1b1ea08d851 100644 (file)
@@ -25,6 +25,8 @@ typedef struct {
        uint32_t at_enc;    // encrypted tag response
        uint8_t at_enc_par; // encrypted tag response parity
        bool first_auth;    // is first authentication
+       uint32_t ks2;           // ar ^ ar_enc
+       uint32_t ks3;       // at ^ at_enc
 } TAuthData;
 extern void ClearAuthData();
 
Impressum, Datenschutz