fixed parity calc and add parity print. works.

This commit is contained in:
merlokk 2018-01-29 19:39:28 +02:00
commit 4c1327a90e
3 changed files with 7 additions and 3 deletions

View file

@ -2599,7 +2599,6 @@ int CmdHF14AMfSniff(const char *Cmd){
} else {
oddparitybuf(bufPtr, len, parity);
PrintAndLog("%s(%d):%s [%s] c[%s]", isTag ? "TAG":"RDR", num, sprint_hex(bufPtr, len), printBitsPar(bufPtr + len, len), printBitsPar(parity, len));
PrintAndLog("p:%s %s", sprint_hex(bufPtr + len, parlen), sprint_hex_inrow(parity, parlen));
if (wantLogToFile)
AddLogHex(logHexFileName, isTag ? "TAG: ":"RDR: ", bufPtr, len);
if (wantDecrypt)

View file

@ -20,6 +20,7 @@
#include "usb_cmd.h"
#include "cmdmain.h"
#include "ui.h"
#include "parity.h"
#include "util.h"
#include "iso14443crc.h"
@ -714,7 +715,9 @@ int mfTraceDecode(uint8_t *data_src, int len, bool wantSaveToEmlFile) {
memcpy(data, data_src, len);
if ((traceCrypto1) && ((traceState == TRACE_IDLE) || (traceState > TRACE_AUTH_OK))) {
mf_crypto1_decrypt(traceCrypto1, data, len, 0);
PrintAndLog("dec> %s", sprint_hex(data, len));
uint8_t parity[16];
oddparitybuf(data, len, parity);
PrintAndLog("dec> %s [%s]", sprint_hex(data, len), printBitsPar(parity, len));
AddLogHex(logHexFileName, "dec> ", data, len);
}

View file

@ -13,6 +13,7 @@
#include <stdint.h>
#include <stdbool.h>
#include <string.h>
extern const uint8_t OddByteParity[256];
@ -22,8 +23,9 @@ static inline bool oddparity8(const uint8_t x) {
}
static inline void oddparitybuf(const uint8_t *x, size_t len, uint8_t *parity) {
memset(parity, 0x00, len / 8 + 1);
for (int i = 0; i < len; i++)
parity[i / 8] ^= oddparity8(*x >> ((i % 8) * 8) & 0xff) << (i % 8);
parity[i / 8] |= oddparity8(x[i]) << (7 - (i % 8));
}
static inline bool evenparity8(const uint8_t x) {