From 459835b5ca0e0d8eb3a7b2ec9c73b8ec7f27c3ae Mon Sep 17 00:00:00 2001 From: iceman1001 Date: Wed, 27 Mar 2019 15:29:45 +0100 Subject: [PATCH 1/2] fix: 'hf mf sim' - Mifare simulation now works against Android etc. Thanks to @eloff --- armsrc/iso14443a.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/armsrc/iso14443a.c b/armsrc/iso14443a.c index 3e53468de..1b8d9d092 100644 --- a/armsrc/iso14443a.c +++ b/armsrc/iso14443a.c @@ -3329,9 +3329,18 @@ void Mifare1ksim(uint8_t flags, uint8_t exitAfterNReads, uint8_t arg2, uint8_t * break; } + + /* ans = prng_successor(nonce, 96) ^ crypto1_word(pcs, 0, 0); num_to_bytes(ans, 4, rAUTH_AT); EmSendCmd(rAUTH_AT, sizeof(rAUTH_AT)); + */ + + ans = prng_successor(nonce, 96); + num_to_bytes(ans, 4, response); + mf_crypto1_encrypt(pcs, response, 4, response_par); + EmSendCmdPar(response, 4, response_par); + LED_C_ON(); if (MF_DBGLEVEL >= 3) { From 5fd98db92da9b7da43fef8df1bd6c7c5995295b6 Mon Sep 17 00:00:00 2001 From: iceman1001 Date: Wed, 27 Mar 2019 15:35:43 +0100 Subject: [PATCH 2/2] fix: LF FDX-B demod - more lenient with max errors. Thanks to @maltehillmann --- client/cmddata.c | 19 +++++++++++-------- client/cmdlffdx.c | 4 ++-- 2 files changed, 13 insertions(+), 10 deletions(-) diff --git a/client/cmddata.c b/client/cmddata.c index 146d30ba7..dfa15f598 100644 --- a/client/cmddata.c +++ b/client/cmddata.c @@ -615,17 +615,20 @@ int Cmdmandecoderaw(const char *Cmd) { return 1; } -//by marshmellow -//biphase decode -//take 01 or 10 = 0 and 11 or 00 = 1 -//takes 2 arguments "offset" default = 0 if 1 it will shift the decode by one bit -// and "invert" default = 0 if 1 it will invert output -// the argument offset allows us to manually shift if the output is incorrect - [EDIT: now auto detects] +/* + * @author marshmellow + * biphase decode + * decodes 01 or 10 -> ZERO + * 11 or 00 -> ONE + * param offset adjust start position + * param invert invert output + * param masxErr maximum tolerated errors + */ int CmdBiphaseDecodeRaw(const char *Cmd) { size_t size = 0; int offset = 0, invert = 0, maxErr = 20, errCnt = 0; char cmdp = tolower(param_getchar(Cmd, 0)); - if (strlen(Cmd) > 3 || cmdp == 'h') return usage_data_biphaserawdecode(); + if (strlen(Cmd) > 5 || cmdp == 'h') return usage_data_biphaserawdecode(); sscanf(Cmd, "%i %i %i", &offset, &invert, &maxErr); if (DemodBufferLen == 0) { @@ -665,7 +668,7 @@ int CmdBiphaseDecodeRaw(const char *Cmd) { // - ASK Demod then Biphase decode GraphBuffer samples int ASKbiphaseDemod(const char *Cmd, bool verbose) { //ask raw demod GraphBuffer first - int offset = 0, clk = 0, invert = 0, maxErr = 0; + int offset = 0, clk = 0, invert = 0, maxErr = 100; sscanf(Cmd, "%i %i %i %i", &offset, &clk, &invert, &maxErr); uint8_t BitStream[MAX_DEMOD_BUF_LEN]; diff --git a/client/cmdlffdx.c b/client/cmdlffdx.c index bc1f1e9dc..972ef9627 100644 --- a/client/cmdlffdx.c +++ b/client/cmdlffdx.c @@ -160,7 +160,7 @@ int getFDXBits(uint64_t national_id, uint16_t country, uint8_t isanimal, uint8_t int CmdFDXBdemodBI(const char *Cmd) { int clk = 32; - int invert = 1, errCnt = 0, offset = 0, maxErr = 0; + int invert = 1, errCnt = 0, offset = 0, maxErr = 100; uint8_t bs[MAX_DEMOD_BUF_LEN]; size_t size = getFromGraphBuf(bs); @@ -236,7 +236,7 @@ int CmdFdxDemod(const char *Cmd) { //Differential Biphase / di-phase (inverted biphase) //get binary from ask wave - if (!ASKbiphaseDemod("0 32 1 0", false)) { + if (!ASKbiphaseDemod("0 32 1 100", false)) { PrintAndLogEx(DEBUG, "DEBUG: Error - FDX-B ASKbiphaseDemod failed"); return 0; }