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 <bytes> m <mask>");
+ PrintAndLog("Usage: analyse chksum [h] [v] b <bytes> m <mask>");
PrintAndLog("Options:");
PrintAndLog(" h This help");
+ PrintAndLog(" v supress header");
PrintAndLog(" b <bytes> bytes to calc missing XOR in a LCR");
PrintAndLog(" m <mask> bit mask to limit the outpuyt");
PrintAndLog("");
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;
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;
}
// 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) {
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;
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
return sum;
}
-
-
// measuring LFSR maximum length
int CmdAnalyseLfsr(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)
, calcSumNibbleXor(data, len, mask)
, calcSumCrumbXor(data, len, mask)
, calcBSDchecksum8(data, len, mask)
- , calcBSDchecksum4(data, len, mask)
+ , calcBSDchecksum4(data, len, mask)
);
return 0;
}