]> git.zerfleddert.de Git - proxmark3-svn/commitdiff
FIX: this commit solves a sneaky bug in 'LF VIKING' commands. The getVikingBits...
authoriceman1001 <iceman@iuse.se>
Sun, 24 Apr 2016 19:41:45 +0000 (21:41 +0200)
committericeman1001 <iceman@iuse.se>
Sun, 24 Apr 2016 19:41:45 +0000 (21:41 +0200)
ADD:  added some extra message in debugmode when looking at viking tags.

client/cmddata.c
client/cmdlfviking.c
common/lfdemod.c

index 55c2d1951ae886733bfeb03e16d1b28eec6cc0cd..2e363054b0e3e8a773fe6754773d91ee801c4184 100644 (file)
@@ -660,7 +660,7 @@ int CmdVikingDemod(const char *Cmd)
        //call lfdemod.c demod for Viking
        int ans = VikingDemod_AM(DemodBuffer, &size);
        if (ans < 0) {
-               if (g_debugMode) PrintAndLog("Error Viking_Demod %d", ans);
+               if (g_debugMode) PrintAndLog("Error Viking_Demod %d %s", ans, (ans == -5)?"[chksum error]":"");
                return 0;
        }
        //got a good demod
index b91aced8eeb567738e24063cfd422f3668935f88..039e4ae6015a3bdd7a99a4a63df69d614f777d7a 100644 (file)
@@ -47,9 +47,9 @@ int usage_lf_viking_sim(void) {
 
 // calc checksum
 uint64_t getVikingBits(uint32_t id) {
-       uint8_t checksum = (id>>24) ^ ((id>>16) & 0xFF) ^ ((id>>8) & 0xFF) ^ (id & 0xFF) ^ 0xF2 ^ 0xA8;
+       uint8_t checksum = ((id>>24) & 0xFF) ^ ((id>>16) & 0xFF) ^ ((id>>8) & 0xFF) ^ (id & 0xFF) ^ 0xF2 ^ 0xA8;
        uint64_t ret = (uint64_t)0xF2 << 56;
-       ret |= (id << 8);
+       ret |= (uint64_t)id << 8;
        ret     |= checksum;
        return ret;
 }
index cb3e9f0b8a417aa9198262b38d0df42000a1bddd..f27ffff35c119f158cad162d89ed60bf6762952f 100644 (file)
@@ -679,10 +679,15 @@ int VikingDemod_AM(uint8_t *dest, size_t *size) {
        uint8_t preamble[] = {1,1,1,1,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};
        uint8_t errChk = preambleSearch(dest, preamble, sizeof(preamble), size, &startIdx);
        if (errChk == 0) return -4; //preamble not found
-       uint32_t checkCalc = bytebits_to_byte(dest+startIdx,8) ^ bytebits_to_byte(dest+startIdx+8,8) ^ bytebits_to_byte(dest+startIdx+16,8)
-           ^ bytebits_to_byte(dest+startIdx+24,8) ^ bytebits_to_byte(dest+startIdx+32,8) ^ bytebits_to_byte(dest+startIdx+40,8) 
-           ^ bytebits_to_byte(dest+startIdx+48,8) ^ bytebits_to_byte(dest+startIdx+56,8);
-       if ( checkCalc != 0xA8 ) return -5;
+       uint32_t checkCalc = bytebits_to_byte(dest+startIdx,8) ^ 
+                                                bytebits_to_byte(dest+startIdx+8,8) ^ 
+                                                bytebits_to_byte(dest+startIdx+16,8) ^ 
+                                                bytebits_to_byte(dest+startIdx+24,8) ^ 
+                                                bytebits_to_byte(dest+startIdx+32,8) ^ 
+                                                bytebits_to_byte(dest+startIdx+40,8) ^ 
+                                                bytebits_to_byte(dest+startIdx+48,8) ^ 
+                                                bytebits_to_byte(dest+startIdx+56,8);
+       if ( checkCalc != 0xA8 ) return -5;     
        if (*size != 64) return -6;
        //return start position
        return (int) startIdx;
Impressum, Datenschutz