X-Git-Url: https://git.zerfleddert.de/cgi-bin/gitweb.cgi/proxmark3-svn/blobdiff_plain/62dc7d4a6f72effa3ad22fadbd5c199f496e9471..57e1e31dce70a58da1736b9579a869c1df313a13:/client/cmdanalyse.c diff --git a/client/cmdanalyse.c b/client/cmdanalyse.c index 3cb1eb71..a8deb67f 100644 --- a/client/cmdanalyse.c +++ b/client/cmdanalyse.c @@ -30,9 +30,10 @@ int usage_analyse_checksum(void) { PrintAndLog("The bytes will be added with eachother and than limited with the applied mask"); PrintAndLog("Finally compute ones' complement of the least significant bytes"); PrintAndLog(""); - PrintAndLog("Usage: analyse chksum [h] b m "); + PrintAndLog("Usage: analyse chksum [h] [v] b m "); PrintAndLog("Options:"); PrintAndLog(" h This help"); + PrintAndLog(" v supress header"); PrintAndLog(" b bytes to calc missing XOR in a LCR"); PrintAndLog(" m bit mask to limit the outpuyt"); PrintAndLog(""); @@ -87,7 +88,7 @@ static uint16_t calcSumCrumbAdd( uint8_t* bytes, uint8_t len, uint32_t mask) { return sum; } static uint16_t calcSumCrumbAddOnes( uint8_t* bytes, uint8_t len, uint32_t mask) { - return ~calcSumCrumbAdd(bytes, len, mask); + return (~calcSumCrumbAdd(bytes, len, mask) & mask); } static uint16_t calcSumNibbleAdd( uint8_t* bytes, uint8_t len, uint32_t mask) { uint8_t sum = 0; @@ -99,7 +100,7 @@ static uint16_t calcSumNibbleAdd( uint8_t* bytes, uint8_t len, uint32_t mask) { return sum; } static uint16_t calcSumNibbleAddOnes( uint8_t* bytes, uint8_t len, uint32_t mask){ - return ~calcSumNibbleAdd(bytes, len, mask); + return (~calcSumNibbleAdd(bytes, len, mask) & mask); } static uint16_t calcSumCrumbXor( uint8_t* bytes, uint8_t len, uint32_t mask) { uint8_t sum = 0; @@ -137,7 +138,7 @@ static uint16_t calcSumByteAdd( uint8_t* bytes, uint8_t len, uint32_t mask) { } // Ones complement static uint16_t calcSumByteAddOnes( uint8_t* bytes, uint8_t len, uint32_t mask) { - return ~calcSumByteAdd(bytes, len, mask); + return (~calcSumByteAdd(bytes, len, mask) & mask); } static uint16_t calcSumByteSub( uint8_t* bytes, uint8_t len, uint32_t mask) { @@ -148,7 +149,7 @@ static uint16_t calcSumByteSub( uint8_t* bytes, uint8_t len, uint32_t mask) { return sum; } static uint16_t calcSumByteSubOnes( uint8_t* bytes, uint8_t len, uint32_t mask){ - return ~calcSumByteSub(bytes, len, mask); + return (~calcSumByteSub(bytes, len, mask) & mask); } static uint16_t calcSumNibbleSub( uint8_t* bytes, uint8_t len, uint32_t mask) { uint8_t sum = 0; @@ -160,7 +161,7 @@ static uint16_t calcSumNibbleSub( uint8_t* bytes, uint8_t len, uint32_t mask) { return sum; } static uint16_t calcSumNibbleSubOnes( uint8_t* bytes, uint8_t len, uint32_t mask) { - return ~calcSumNibbleSub(bytes, len, mask); + return (~calcSumNibbleSub(bytes, len, mask) & mask); } // BSD shift checksum 8bit version @@ -189,8 +190,6 @@ static uint16_t calcBSDchecksum4( uint8_t* bytes, uint8_t len, uint32_t mask){ return sum; } - - // measuring LFSR maximum length int CmdAnalyseLfsr(const char *Cmd){ @@ -324,10 +323,10 @@ int CmdAnalyseCHKSUM(const char *Cmd){ if (useHeader) { PrintAndLog(" add | sub | add 1's compl | sub 1's compl | xor"); - PrintAndLog("byte nibble crumb | byte nibble | byte nibble cumb | byte nibble | byte nibble cumb | BSD"); + PrintAndLog("byte nibble crumb | byte nibble | byte nibble cumb | byte nibble | byte nibble cumb | BSD |"); PrintAndLog("------------------+-------------+------------------+-----------------+--------------------"); } - PrintAndLog("0x%X 0x%X 0x%X | 0x%X 0x%X | 0x%X 0x%X 0x%X | 0x%X 0x%X | 0x%X 0x%X 0x%X | 0x%X 0x%X\n", + PrintAndLog("0x%X 0x%X 0x%X | 0x%X 0x%X | 0x%X 0x%X 0x%X | 0x%X 0x%X | 0x%X 0x%X 0x%X | 0x%X 0x%X |\n", calcSumByteAdd(data, len, mask) , calcSumNibbleAdd(data, len, mask) , calcSumCrumbAdd(data, len, mask) @@ -342,7 +341,7 @@ int CmdAnalyseCHKSUM(const char *Cmd){ , calcSumNibbleXor(data, len, mask) , calcSumCrumbXor(data, len, mask) , calcBSDchecksum8(data, len, mask) - , calcBSDchecksum4(data, len, mask) + , calcBSDchecksum4(data, len, mask) ); return 0; }