]> git.zerfleddert.de Git - proxmark3-svn/commitdiff
chg: @piwi's code cleanup and some more.
authoriceman1001 <iceman@iuse.se>
Wed, 22 Feb 2017 23:03:10 +0000 (00:03 +0100)
committericeman1001 <iceman@iuse.se>
Wed, 22 Feb 2017 23:03:10 +0000 (00:03 +0100)
ref: https://github.com/Proxmark/proxmark3/commit/43534cbad22da2db2e1b59f9e08f0cadfe0d8d54

31 files changed:
armsrc/appmain.c
armsrc/apps.h
client/cmdcrc.c
client/cmddata.c
client/cmdhfemv.c
client/cmdhfepa.c
client/cmdhficlass.c
client/cmdhflegic.c
client/cmdhfmf.c
client/cmdhfmfhard.c
client/cmdlfem4x.c
client/cmdlffdx.c
client/cmdlfhid.c
client/cmdlfti.c
client/cmdmain.c
client/flash.c
client/flasher.c
client/fpga_compress.c
client/mifarehost.c
client/nonce2key/crypto1_bs.c
client/nonce2key/nonce2key.c
client/proxmark3.h
client/reveng/poly.c
client/scripting.c
client/util.c
common/Makefile.common
tools/mfkey/mfkey32.c
tools/mfkey/mfkey32v2.c
tools/mfkey/mfkey64.c
tools/nonce2key/nonce2key.c
zlib/trees.c

index 3ba9dd68eb3b9ff8c4eb00a9aa5e166313fc7805..eea3857b078445805d62e05d4e3240e50403e9a3 100644 (file)
@@ -1229,6 +1229,26 @@ void UsbPacketReceived(uint8_t *packet, int len)
         case CMD_EMV_DUMP_CARD:
             EMVdumpcard();
                        break;
+/*                     
+       case CMD_EMV_READ_RECORD:
+            EMVReadRecord(c->arg[0], c->arg[1], NULL);
+            break; 
+        case CMD_EMV_TRANSACTION:
+            EMVTransaction(); 
+            break;
+        case CMD_EMV_CLONE:
+            EMVClone(c->arg[0], c->arg[1]);
+            break;
+       case CMD_EMV_SIM:
+            EMVSim();
+            break;
+        case CMD_EMV_TEST:
+            EMVTest();
+            break;
+        case CMD_EMV_FUZZ_RATS:
+            EMVFuzz_RATS(c->arg[0],c->d.asBytes);
+            break;
+                       */
 #endif
 #ifdef WITH_ICLASS
                // Makes use of ISO14443a FPGA Firmware
@@ -1303,7 +1323,7 @@ void UsbPacketReceived(uint8_t *packet, int len)
                        // arg0 = startindex
                        // arg1 = length bytes to transfer
                        // arg2 = RFU
-                       //Dbprintf("transfer to client parameters: %llu | %llu | %llu", c->arg[0], c->arg[1], c->arg[2]);
+                       //Dbprintf("transfer to client parameters: %" PRIu64 " | %" PRIu64 " | %" PRIu64, c->arg[0], c->arg[1], c->arg[2]);
                        
                        for(size_t i = 0; i < c->arg[1]; i += USB_CMD_DATA_SIZE) {
                                len = MIN( (c->arg[1] - i), USB_CMD_DATA_SIZE);
index efc8ae073cac934937acbe1f4a1a098d8d81416e..41f8543c879e7f25862ef33e2a2f854ec3794cff 100644 (file)
@@ -179,7 +179,7 @@ size_t enciphered_data_length (const desfiretag_t tag, const size_t nbytes, int
 void cmac_generate_subkeys (desfirekey_t key);
 void cmac (const desfirekey_t  key, uint8_t *ivect, const uint8_t *data, size_t len, uint8_t *cmac);
 
-/// iso15693.h
+// iso15693.h
 void RecordRawAdcSamplesIso15693(void);
 void AcquireRawAdcSamplesIso15693(void);
 void ReaderIso15693(uint32_t parameter);       // Simulate an ISO15693 reader - greg
@@ -188,7 +188,7 @@ void BruteforceIso15693Afi(uint32_t speed); // find an AFI of a tag - atrox
 void DirectTag15693Command(uint32_t datalen,uint32_t speed, uint32_t recv, uint8_t data[]); // send arbitrary commands from CLI - atrox 
 void SetDebugIso15693(uint32_t flag);
 
-/// iclass.h
+// iclass.h
 void RAMFUNC SnoopIClass(void);
 void SimulateIClass(uint32_t arg0, uint32_t arg1, uint32_t arg2, uint8_t *datain);
 void ReaderIClass(uint8_t arg0);
@@ -226,6 +226,18 @@ void EMVgetUDOL(void);
 void EMVloadvalue(uint32_t tag, uint8_t* datain);
 void EMVdumpcard(void);
 
+/*
+//void EMVSelect(uint8_t arg0, uint8_t arg1, uint8_t arg2, uint8_t *data);
+void EMVFuzz_RATS(uint8_t len, uint8_t* RATS);
+void EMVReadRecord(uint8_t arg0, uint8_t arg1,emvcard* inputcard);
+void EMVSelectPPSE();
+void EMVSelectAID(uint8_t *AID, uint8_t AIDlen, emvcard* inputcard);
+void EMVTransaction(); //perform an EMV transaction
+void EMVClone(uint8_t maxsfi, uint8_t maxrecord); //clone an EMV card.
+void EMVSim();
+void EMVTest(); //test function for emv stuff.
+*/
+
 #ifdef __cplusplus
 }
 #endif
index 4c1c74f54860747058f71fa6678c1c14da1fc32a..249fdebc0e5887385eda4c5faf16a92c8360c6a3 100644 (file)
@@ -39,13 +39,14 @@ int split(char *str, char *arr[MAX_ARGS]){
     int wordCnt = 0;
 
     while(1){
-        while(isspace(str[beginIndex])){
+        while(isspace(str[beginIndex])) {
             ++beginIndex;
         }
-        if(str[beginIndex] == '\0')
+        if(str[beginIndex] == '\0') {
             break;
+               }
         endIndex = beginIndex;
-        while (str[endIndex] && !isspace(str[endIndex])){
+        while (str[endIndex] && !isspace(str[endIndex])) {
             ++endIndex;
         }
         int len = endIndex - beginIndex;
@@ -151,7 +152,7 @@ int GetModels(char *Models[], int *count, uint8_t *width){
                 * searched.
                 */
                /* scan against preset models */
-               if(~uflags & C_FORCE) {
+               if (~uflags & C_FORCE) {
                        pass = 0;
                        Cnt = 0;
                        do {
@@ -161,34 +162,36 @@ int GetModels(char *Models[], int *count, uint8_t *width){
                                        mbynum(&pset, --psets);
                                        
                                        /* skip if different width, or refin or refout don't match */
-                               if(plen(pset.spoly) != width[0] || (model.flags ^ pset.flags) & (P_REFIN | P_REFOUT))
+                                       if( plen(pset.spoly) != width[0] || (model.flags ^ pset.flags) & (P_REFIN | P_REFOUT))
                                                continue;
                                        /* skip if the preset doesn't match specified parameters */
-                                       if(rflags & R_HAVEP && pcmp(&model.spoly, &pset.spoly))
+                                       if (rflags & R_HAVEP && pcmp(&model.spoly, &pset.spoly))
                                                continue;
-                                       if(rflags & R_HAVEI && psncmp(&model.init, &pset.init))
+                                       if (rflags & R_HAVEI && psncmp(&model.init, &pset.init))
                                                continue;
-                                       if(rflags & R_HAVEX && psncmp(&model.xorout, &pset.xorout))
+                                       if (rflags & R_HAVEX && psncmp(&model.xorout, &pset.xorout))
                                                continue;
                        
-                               //for additional args (not used yet, maybe future?)
+                                       //for additional args (not used yet, maybe future?)
                                        apoly = pclone(pset.xorout);
-                                       if(pset.flags & P_REFOUT)
+                                       
+                                       if (pset.flags & P_REFOUT)
                                                prev(&apoly);
-                               
-                                       for(qptr = apolys; qptr < pptr; ++qptr) {
+                                       
+                                       
+                                       for (qptr = apolys; qptr < pptr; ++qptr) {
                                                crc = pcrc(*qptr, pset.spoly, pset.init, apoly, 0);
-                                               if(ptst(crc)) {
+                                               if (ptst(crc)) {
                                                        pfree(&crc);
                                                        break;
-                                               } else
-                                                       pfree(&crc);
+                                               }
+                                               pfree(&crc);
                                        }
                                        pfree(&apoly);
-                                       if(qptr == pptr) {
+                                       
+                                       if (qptr == pptr) {
 
                                                /* the selected model solved all arguments */
-
                                                mcanon(&pset);
                                                
                                                size_t size = (pset.name && *pset.name) ? strlen(pset.name) : 6;
@@ -198,7 +201,7 @@ int GetModels(char *Models[], int *count, uint8_t *width){
                                                        PrintAndLog("out of memory?");
                                                        return 0;
                                                }
-                                       width[Cnt] = width[0];
+                                               width[Cnt] = width[0];
                                                memcpy(tmp, pset.name, size);
                                                Models[Cnt++] = tmp;
                                                *count = Cnt;
@@ -208,44 +211,50 @@ int GetModels(char *Models[], int *count, uint8_t *width){
                                mfree(&pset);
 
                                /* toggle refIn/refOut and reflect arguments */
-                               if(~rflags & R_HAVERI) {
+                               if (~rflags & R_HAVERI) {
                                        model.flags ^= P_REFIN | P_REFOUT;
-                                       for(qptr = apolys; qptr < pptr; ++qptr)
+                                       for (qptr = apolys; qptr < pptr; ++qptr) {
                                                prevch(qptr, ibperhx);
+                                       }
                                }
-                       } while(~rflags & R_HAVERI && ++pass < 2);
+                       } while (~rflags & R_HAVERI && ++pass < 2);
                }
                //got everything now free the memory...
 
-               if(uflags & C_RESULT) {
-                       for(qptr = apolys; qptr < pptr; ++qptr)
+               if (uflags & C_RESULT) {
+                       for (qptr = apolys; qptr < pptr; ++qptr) {
                                pfree(qptr);
+                       }
                }
-               if(!(model.flags & P_REFIN) != !(model.flags & P_REFOUT))
+               if (!(model.flags & P_REFIN) != !(model.flags & P_REFOUT))
                        return uerr("cannot search for crossed-endian models");
 
                pass = 0;
                do {
                        mptr = candmods = reveng(&model, qpoly, rflags, args, apolys);
-                       if(mptr && plen(mptr->spoly))
+                       if (mptr && plen(mptr->spoly)) {
                                uflags |= C_RESULT;
-                       while(mptr && plen(mptr->spoly)) {
+                       }
+                       while (mptr && plen(mptr->spoly)) {
                                mfree(mptr++);
                        }
                        free(candmods);
-                       if(~rflags & R_HAVERI) {
+                       if (~rflags & R_HAVERI) {
                                model.flags ^= P_REFIN | P_REFOUT;
-                               for(qptr = apolys; qptr < pptr; ++qptr)
+                               for (qptr = apolys; qptr < pptr; ++qptr) {
                                        prevch(qptr, ibperhx);
+                               }
                        }
-               } while(~rflags & R_HAVERI && ++pass < 2);
-               for(qptr = apolys; qptr < pptr; ++qptr)
+               } while (~rflags & R_HAVERI && ++pass < 2);
+               
+               for (qptr = apolys; qptr < pptr; ++qptr) {
                        pfree(qptr);
+               }
                free(apolys);
-               if(~uflags & C_RESULT)
+               if (~uflags & C_RESULT)
                        return uerr("no models found");
+               
                mfree(&model);
-
        }
        return 1;
 }
@@ -281,11 +290,11 @@ int RunModel(char *inModel, char *inHexStr, bool reverse, char endian, char *res
 
        SETBMP();
        //set model
-       if(!(c = mbynam(&model, inModel))) {
+       if (!(c = mbynam(&model, inModel))) {
                PrintAndLog("error: preset model '%s' not found.  Use reveng -D to list presets.", inModel);
                return 0;
        }
-       if(c < 0)
+       if (c < 0)
                return uerr("no preset models available");
 
        rflags |= R_HAVEP | R_HAVEI | R_HAVERI | R_HAVERO | R_HAVEX;
@@ -340,7 +349,7 @@ int RunModel(char *inModel, char *inHexStr, bool reverse, char endian, char *res
                 * Consequently Init is the mirror image of the
                 * one resulting from -V, and so we have:
                 */
-               if(~model.flags & P_REFOUT) {
+               if (~model.flags & P_REFOUT) {
                        prev(&model.init);
                        prev(&model.xorout);
                }
@@ -355,17 +364,17 @@ int RunModel(char *inModel, char *inHexStr, bool reverse, char endian, char *res
        /* in the Williams model, xorout is applied after the refout stage.
         * as refout is part of ptostr(), we reverse xorout here.
         */
-       if(model.flags & P_REFOUT)
+       if (model.flags & P_REFOUT)
                prev(&model.xorout);
 
        apoly = strtop(inHexStr, model.flags, ibperhx);
 
-       if(reverse)
+       if (reverse)
                prev(&apoly);
 
        crc = pcrc(apoly, model.spoly, model.init, model.xorout, model.flags);
 
-       if(reverse)
+       if (reverse)
                prev(&crc);
 
        string = ptostr(crc, model.flags, obperhx);
index fe22aa4bf1d498ec4ff4b434de84703ba309ed3a..6a5753c72a43426c79bb9c922cba7cbaeb714b07 100644 (file)
@@ -376,21 +376,21 @@ void printEM410x(uint32_t hi, uint64_t id)
                }
                if (hi){
                        //output 88 bit em id
-                       PrintAndLog("\nEM TAG ID      : %06X%016llX", hi, id);
+                       PrintAndLog("\nEM TAG ID      : %06X%016" PRIX64, hi, id);
                } else{
                        //output 40 bit em id
-                       PrintAndLog("\nEM TAG ID      : %010llX", id);
-                       PrintAndLog("Unique TAG ID  : %010llX",  id2lo);
+                       PrintAndLog("\nEM TAG ID      : %010" PRIX64, id);
+                       PrintAndLog("Unique TAG ID  : %010" PRIX64, id2lo);
                        PrintAndLog("\nPossible de-scramble patterns");
                        PrintAndLog("HoneyWell IdentKey {");
-                       PrintAndLog("DEZ 8          : %08lld",id & 0xFFFFFF);
-                       PrintAndLog("DEZ 10         : %010lld",id & 0xFFFFFFFF);
-                       PrintAndLog("DEZ 5.5        : %05lld.%05lld",(id>>16LL) & 0xFFFF,(id & 0xFFFF));
-                       PrintAndLog("DEZ 3.5A       : %03lld.%05lld",(id>>32ll),(id & 0xFFFF));
-                       PrintAndLog("DEZ 3.5B       : %03lld.%05lld",(id & 0xFF000000) >> 24,(id & 0xFFFF));
-                       PrintAndLog("DEZ 3.5C       : %03lld.%05lld",(id & 0xFF0000) >> 16,(id & 0xFFFF));
-                       PrintAndLog("DEZ 14/IK2     : %014lld",id);
-                       PrintAndLog("DEZ 15/IK3     : %015lld",id2lo);
+                       PrintAndLog("DEZ 8          : %08" PRIu64, id & 0xFFFFFF);
+                       PrintAndLog("DEZ 10         : %010" PRIu64, id & 0xFFFFFFFF);
+                       PrintAndLog("DEZ 5.5        : %05" PRIu64 ".%05" PRIu64, (id>>16LL) & 0xFFFF, (id & 0xFFFF));
+                       PrintAndLog("DEZ 3.5A       : %03" PRIu64 ".%05" PRIu64, (id>>32ll), (id & 0xFFFF));
+                       PrintAndLog("DEZ 3.5B       : %03" PRIu64 ".%05" PRIu64, (id & 0xFF000000) >> 24, (id & 0xFFFF));
+                       PrintAndLog("DEZ 3.5C       : %03" PRIu64 ".%05" PRIu64, (id & 0xFF0000) >> 16, (id & 0xFFFF));
+                       PrintAndLog("DEZ 14/IK2     : %014" PRIu64, id);
+                       PrintAndLog("DEZ 15/IK3     : %015" PRIu64, id2lo);
                        PrintAndLog("DEZ 20/ZK      : %02lld%02lld%02lld%02lld%02lld%02lld%02lld%02lld%02lld%02lld",
                            (id2lo & 0xf000000000) >> 36,
                            (id2lo & 0x0f00000000) >> 32,
@@ -404,8 +404,8 @@ void printEM410x(uint32_t hi, uint64_t id)
                            (id2lo & 0x000000000f)
                        );
                        uint64_t paxton = (((id>>32) << 24) | (id & 0xffffff))  + 0x143e00;
-                       PrintAndLog("}\nOther          : %05lld_%03lld_%08lld",(id&0xFFFF),((id>>16LL) & 0xFF),(id & 0xFFFFFF));  
-                       PrintAndLog("Pattern Paxton : %lld [0x%llX]", paxton, paxton);
+                       PrintAndLog("}\nOther          : %05" PRIu64 "_%03" PRIu64 "_%08" PRIu64, (id&0xFFFF), ((id>>16LL) & 0xFF), (id & 0xFFFFFF));  
+                       PrintAndLog("Pattern Paxton : %" PRIu64 " [0x%" PRIX64 "]", paxton, paxton);
 
                        uint32_t p1id = (id & 0xFFFFFF);
                        uint8_t arr[32] = {0x00};
@@ -1735,8 +1735,8 @@ int CmdFDXBdemodBI(const char *Cmd){
        if (g_debugMode) PrintAndLog("Raw ID Hex: %s", sprint_hex(raw,8));
 
        uint16_t calcCrc = crc16_ccitt_kermit(raw, 8);
-       PrintAndLog("Animal ID:     %04u-%012llu", countryCode, NationalCode);
-       PrintAndLog("National Code: %012llu", NationalCode);
+       PrintAndLog("Animal ID:     %04u-%012" PRIu64, countryCode, NationalCode);
+       PrintAndLog("National Code: %012" PRIu64, NationalCode);
        PrintAndLog("CountryCode:   %04u", countryCode);
 
        PrintAndLog("Reserved/RFU:      %u", reservedCode);
index 664c00c43410c8ff928cfff93ae713db5fc19b8d..bf92d53f38fed53a682af291db3551be5b3d9aad 100644 (file)
@@ -214,7 +214,7 @@ int CmdHfEmvSim(const char *Cmd) {
        if(errors) return usage_hf_emv_sim();   
        
        UsbCommand c = {CMD_SIMULATE_TAG_LEGIC_RF, {6,3,0}};
-       sscanf(Cmd, " %"lli" %"lli" %"lli, &c.arg[0], &c.arg[1], &c.arg[2]);
+       sscanf(Cmd, " %" SCNi64 " %" SCNi64 " %" SCNi64 , &c.arg[0], &c.arg[1], &c.arg[2]);
        clearCommandBuffer();
        SendCommand(&c);
        return 0;
index 179de05d223483da6e5a15d5e52d77ae113c8589..2f7ee7bc3fa04838b25b8d4d7079a10459efe133 100644 (file)
@@ -36,7 +36,7 @@ int CmdHFEPACollectPACENonces(const char *Cmd)
        m = m > 0 ? m : 1;
        n = n > 0 ? n : 1;
 
-       PrintAndLog("Collecting %u %"hhu"-byte nonces", n, m);
+       PrintAndLog("Collecting %u %byte nonces", n, m);
        PrintAndLog("Start: %u", time(NULL));
        // repeat n times
        for (unsigned int i = 0; i < n; i++) {
index 90856e919d7c85f30da20695749ae8ad69bc4775..3891d431c304698f6eff88f810d6d6baff228ac1 100644 (file)
@@ -1388,25 +1388,6 @@ int CmdHFiClassReadTagFile(const char *Cmd) {
        return 0;
 }
 
-/*
-uint64_t xorcheck(uint64_t sdiv,uint64_t hdiv) {
-       uint64_t new_div = 0x00;
-       new_div ^= sdiv;
-       new_div ^= hdiv;
-       return new_div;
-}
-
-uint64_t hexarray_to_uint64(uint8_t *key) {
-       char temp[17];
-       uint64_t uint_key;
-       for (int i = 0;i < 8;i++)
-               sprintf(&temp[(i *2)],"%02X",key[i]);
-       temp[16] = '\0';
-       if (sscanf(temp,"%016"llX,&uint_key) < 1)
-               return 0;
-       return uint_key;
-}
-*/
 void HFiClassCalcDivKey(uint8_t        *CSN, uint8_t   *KEY, uint8_t *div_key, bool elite){
        uint8_t keytable[128] = {0};
        uint8_t key_index[8] = {0};
index 62c43f0443eb9c296a20e5168a1a24c1e5ed55a6..4414efa1d2c2bd2ed979435030ce5a48b514e258 100644 (file)
@@ -527,7 +527,7 @@ int CmdLegicRdmem(const char *Cmd) {
 // int phase, int frame, int reqresp
 int CmdLegicRfSim(const char *Cmd) {
        UsbCommand c = {CMD_SIMULATE_TAG_LEGIC_RF, {6,3,0}};
-       sscanf(Cmd, " %"lli" %"lli" %"lli, &c.arg[0], &c.arg[1], &c.arg[2]);
+       sscanf(Cmd, " %" SCNi64 " %" SCNi64 " %" SCNi64 , &c.arg[0], &c.arg[1], &c.arg[2]);
        clearCommandBuffer();
        SendCommand(&c);
        return 0;
index e6568f59f64b70d8304bc35918d506b754b52fda..20bb59298630cebabff7bb686253830b7e714584 100644 (file)
@@ -226,7 +226,7 @@ start:
                        c.arg[0] = false;\r
                        goto start;\r
                } else {\r
-                       PrintAndLog("Found valid key: %012"llx" \n", r_key);\r
+                       PrintAndLog("Found valid key: %012" PRIx64 " \n", r_key);\r
                        goto END;\r
                }\r
        }\r
@@ -246,10 +246,10 @@ start:
                uint64_t key64 = 0;\r
                int res = mfCheckKeys(blockNo, keytype - 0x60 , false, 1, keyblock, &key64);\r
                if ( res > 0 ) {\r
-                       PrintAndLog("Candidate Key found (%012"llx") - Test authentication failed. [%d] Restarting darkside attack", r_key, res);       \r
+                       PrintAndLog("Candidate Key found (%012" PRIx64 ") - Test authentication failed. [%d] Restarting darkside attack", r_key, res);  \r
                        goto start;\r
                }\r
-               PrintAndLog("Found valid key: %012"llx" \n", r_key);\r
+               PrintAndLog("Found valid key: %012" PRIx64 " \n", r_key);\r
        }\r
 END:\r
        t1 = clock() - t1;\r
@@ -313,9 +313,7 @@ int CmdHF14AMfRdBl(const char *Cmd) {
        uint8_t blockNo = 0;\r
        uint8_t keyType = 0;\r
        uint8_t key[6] = {0, 0, 0, 0, 0, 0};\r
-       \r
-       char cmdp       = 0x00;\r
-\r
+       char cmdp = 0x00;\r
 \r
        if (strlen(Cmd)<3) {\r
                PrintAndLog("Usage:  hf mf rdbl    <block number> <key A/B> <key (12 hex symbols)>");\r
@@ -1207,7 +1205,7 @@ int CmdHF14AMfChk(const char *Cmd) {
                                        }\r
                                        memset(keyBlock + 6 * keycnt, 0, 6);\r
                                        num_to_bytes(strtoll(buf, NULL, 16), 6, keyBlock + 6*keycnt);\r
-                                       PrintAndLog("check key[%2d] %012"llx, keycnt, bytes_to_num(keyBlock + 6*keycnt, 6));\r
+                                       PrintAndLog("check key[%2d] %012" PRIx64, keycnt, bytes_to_num(keyBlock + 6*keycnt, 6));\r
                                        keycnt++;\r
                                        memset(buf, 0, sizeof(buf));\r
                                }\r
@@ -1400,7 +1398,7 @@ void readerAttack(nonces_t data, bool setEmulatorMem, bool verbose) {
                uint8_t sector = data.sector;\r
                uint8_t keytype = data.keytype;\r
 \r
-               PrintAndLog("Reader is trying authenticate with: Key %s, sector %02d: [%012"llx"]"\r
+               PrintAndLog("Reader is trying authenticate with: Key %s, sector %02d: [%012" PRIx64 "]"\r
                        , keytype ? "B" : "A"\r
                        , sector\r
                        , key\r
@@ -1707,7 +1705,7 @@ int CmdHF14AMfKeyBrute(const char *Cmd) {
        time(&start);\r
        \r
        if (mfKeyBrute( blockNo, keytype, key, &foundkey))\r
-               PrintAndLog("Found valid key: %012"llx" \n", foundkey);\r
+               PrintAndLog("Found valid key: %012" PRIx64 " \n", foundkey);\r
        else\r
                PrintAndLog("Key not found");\r
        \r
@@ -1725,7 +1723,7 @@ void printKeyTable( uint8_t sectorscnt, sector *e_sector ){
        PrintAndLog("|sec|key A           |res|key B           |res|");\r
        PrintAndLog("|---|----------------|---|----------------|---|");\r
        for (uint8_t i = 0; i < sectorscnt; ++i) {\r
-               PrintAndLog("|%03d|  %012"llx"  | %d |  %012"llx"  | %d |", i,\r
+               PrintAndLog("|%03d|  %012" PRIx64 "  | %d |  %012" PRIx64 "  | %d |", i,\r
                        e_sector[i].Key[0], e_sector[i].foundKey[0], \r
                        e_sector[i].Key[1], e_sector[i].foundKey[1]\r
                );\r
@@ -1774,7 +1772,6 @@ int CmdHF14AMfESet(const char *Cmd)
 {\r
        uint8_t memBlock[16];\r
        uint8_t blockNo = 0;\r
-\r
        memset(memBlock, 0x00, sizeof(memBlock));\r
 \r
        if (strlen(Cmd) < 3 || param_getchar(Cmd, 0) == 'h') {\r
@@ -2056,7 +2053,7 @@ int CmdHF14AMfEKeyPrn(const char *Cmd)
                }\r
                keyA = bytes_to_num(data, 6);\r
                keyB = bytes_to_num(data + 10, 6);\r
-               PrintAndLog("|%03d|  %012"llx"  |  %012"llx"  |", i, keyA, keyB);\r
+               PrintAndLog("|%03d|  %012" PRIx64 "  |  %012" PRIx64 "  |", i, keyA, keyB);\r
        }\r
        PrintAndLog("|---|----------------|----------------|");\r
        \r
index 3fed7c95b05e546c6a16de830ebb4775ddeee685..2e5046754e6cda8097ce2a96936a6191408ae0f9 100644 (file)
@@ -723,8 +723,8 @@ static void simulate_acquire_nonces()
        cuid = (rand() & 0xff) << 24 | (rand() & 0xff) << 16 | (rand() & 0xff) << 8 | (rand() & 0xff);
        known_target_key = ((uint64_t)rand() & 0xfff) << 36 | ((uint64_t)rand() & 0xfff) << 24 | ((uint64_t)rand() & 0xfff) << 12 | ((uint64_t)rand() & 0xfff);
        
-       printf("Simulating nonce acquisition for target key %012"llx", cuid %08x ...\n", known_target_key, cuid);
-       fprintf(fstats, "%012"llx";%08x;", known_target_key, cuid);
+       printf("Simulating nonce acquisition for target key %012" PRIx64 ", cuid %08x ...\n", known_target_key, cuid);
+       fprintf(fstats, "%012" PRIx64 ";%08x;", known_target_key, cuid);
        
        do {
                uint32_t nt_enc = 0;
@@ -1247,7 +1247,7 @@ static bool TestIfKeyExists(uint64_t key)
 
        uint32_t state_odd = pcs->odd & 0x00ffffff;
        uint32_t state_even = pcs->even & 0x00ffffff;
-       //printf("Tests: searching for key %llx after first byte 0x%02x (state_odd = 0x%06x, state_even = 0x%06x) ...\n", key, best_first_bytes[0], state_odd, state_even);
+       //printf("Tests: searching for key %" PRIx64 " after first byte 0x%02x (state_odd = 0x%06x, state_even = 0x%06x) ...\n", key, best_first_bytes[0], state_odd, state_even);
        printf("Validating key search space\n");
        uint64_t count = 0;
        for (statelist_t *p = candidates; p != NULL; p = p->next) {
@@ -1271,7 +1271,7 @@ static bool TestIfKeyExists(uint64_t key)
                count += (p_odd - p->states[ODD_STATE]) * (p_even - p->states[EVEN_STATE]);
                if (found_odd && found_even) {
                        if (known_target_key != -1) {
-                               PrintAndLog("Key Found after testing %llu (2^%1.1f) out of %lld (2^%1.1f) keys.", 
+                               PrintAndLog("Key Found after testing %" PRIu64 " (2^%1.1f) out of %lld (2^%1.1f) keys.", 
                                        count,
                                        log(count)/log(2), 
                                        maximum_states,
index 7cc62987ee27dc566ff2a29b8e3ce64106fd3a5b..e6db80261a6992277942ee64f96e0d836f738444 100644 (file)
@@ -147,7 +147,8 @@ int CmdEM410xWatch(const char *Cmd)
                }
                
                CmdLFRead("s");
-               getSamples("8201",true); //capture enough to get 2 complete preambles (4096*2+9)        
+               //getSamples("8201",true); //capture enough to get 2 complete preambles (4096*2+9)      
+               getSamples("6144",true);
        } while (!CmdEM410xRead(""));
 
        return 0;
@@ -159,7 +160,7 @@ int CmdEM410xWatchnSpoof(const char *Cmd)
 {
        // loops if the captured ID was in XL-format.
        CmdEM410xWatch(Cmd);
-       PrintAndLog("# Replaying captured ID: %llu", g_em410xid);
+       PrintAndLog("# Replaying captured ID: %" PRIu64 , g_em410xid);
        CmdLFaskSim("");
        return 0;
 }
@@ -593,8 +594,7 @@ int CmdEM4x50Dump(const char *Cmd){
 }
 
 #define EM_PREAMBLE_LEN 6
-// download samples from device
-// and copy them to Graphbuffer
+// download samples from device and copy to Graphbuffer
 bool downloadSamplesEM(){
        
        // 8 bit preamble + 32 bit word response (max clock (128) * 40bits = 5120 samples)
@@ -607,7 +607,8 @@ bool downloadSamplesEM(){
        setGraphBuf(got, sizeof(got));
        return TRUE;
 }
-//search for given preamble in given BitStream and return success=1 or fail=0 and startIndex
+
+// em_demod 
 bool doPreambleSearch(size_t *startIdx){
        
        // sanity check
@@ -615,26 +616,14 @@ bool doPreambleSearch(size_t *startIdx){
                if (g_debugMode) PrintAndLog("DEBUG: Error - EM4305 demodbuffer too small");
                return FALSE;
        }
-       
-       // skip first two 0 bits as they might have been missed in the demod 
-       uint8_t preamble[EM_PREAMBLE_LEN] = {0,0,1,0,1,0};
-       
-       // set size to 15 to only test first 4 positions for the preamble
-       size_t size = (15 > DemodBufferLen) ? DemodBufferLen : 15;
+
+       // set size to 20 to only test first 14 positions for the preamble
+       size_t size = (20 > DemodBufferLen) ? DemodBufferLen : 20;
        *startIdx = 0; 
-       uint8_t found = 0;
-       
-       // em only sends preamble once, so look for it once in the first x bits
-       for (int idx = 0; idx < size - EM_PREAMBLE_LEN; idx++){
-               if (memcmp(DemodBuffer+idx, preamble, EM_PREAMBLE_LEN) == 0){
-                       //first index found
-                       *startIdx = idx;
-                       found = 1;
-                       break;
-               }
-       }
+       // skip first two 0 bits as they might have been missed in the demod
+       uint8_t preamble[EM_PREAMBLE_LEN] = {0,0,1,0,1,0};
        
-       if ( !found) {
+       if ( !preambleSearchEx(DemodBuffer, preamble, EM_PREAMBLE_LEN, &size, startIdx, TRUE)) {
                if (g_debugMode) PrintAndLog("DEBUG: Error - EM4305 preamble not found :: %d", *startIdx);
                return FALSE;
        } 
@@ -714,12 +703,10 @@ bool setDemodBufferEM(uint32_t *word, size_t idx){
                return FALSE;
        }
        
-       size_t size = removeParity(DemodBuffer, idx + EM_PREAMBLE_LEN, 9, 0, 44);
-       if (!size) {
-               if (g_debugMode) PrintAndLog("DEBUG: Error - EM Parity not detected");
+       if (!removeParity(DemodBuffer, idx + EM_PREAMBLE_LEN, 9, 0, 44)) {
+               if (g_debugMode) PrintAndLog("DEBUG: Error - EM, failed removing parity");
                return FALSE;
        }
-       // set & copy to output
        setDemodBuf(DemodBuffer, 40, 0);
        *word = bytebits_to_byteLSBF(DemodBuffer, 32);
        return TRUE;
@@ -910,8 +897,7 @@ int CmdEM4x05Write(const char *Cmd) {
        if (!downloadSamplesEM())
                return -1;
 
-       //todo: check response for 00001010 then write data for write confirmation!
-       
+
        //attempt demod:
        //need 0 bits demoded (after preamble) to verify write cmd
        uint32_t dummy = 0;
index 292ebad6617e1a5472b5d7638688051121ace189..17f50ab148a227ab559329514dd6f975d3812654 100644 (file)
@@ -175,8 +175,8 @@ int CmdFdxDemod(const char *Cmd) {
        uint16_t calcCrc = crc16_ccitt_kermit(raw, 8);
        
        PrintAndLog("\nFDX-B / ISO 11784/5 Animal Tag ID Found:  Raw : %s", sprint_hex(raw, 8));
-       PrintAndLog("Animal ID          %04u-%012llu", countryCode, NationalCode);
-       PrintAndLog("National Code      %012llu (0x%llX)", NationalCode, NationalCode);
+       PrintAndLog("Animal ID          %04u-%012" PRIu64, countryCode, NationalCode);
+       PrintAndLog("National Code      %012" PRIu64 " (0x%" PRIx64 ")", NationalCode, NationalCode);
        PrintAndLog("Country Code       %04u", countryCode);
        PrintAndLog("Reserved/RFU       %u (0x04%X)", reservedCode,  reservedCode);
        PrintAndLog("");
index 3eb96422b6d3a5608442f690bc002ba51b080448..6ed6c4fd998706825fc4fea0623876775b92cb85 100644 (file)
@@ -341,7 +341,7 @@ int CmdHIDWiegand(const char *Cmd) {
                uint8_t shifts = 64-fmtlen[i];          
                wiegand >>= shifts;
                
-               PrintAndLog(" %u | %03u | %03u  | %llu  | %llX  |  %llX",
+               PrintAndLog(" %u | %03u | %03u  | %" PRIu64 "  | %" PRIX64 "  |  %" PRIX64 ,
                        fmtlen[i],
                        oem,
                        fc,
index 2e5cfbba03b983393fd581fbee19158d01432f54..65ffc12f8df802de246f761d21fe0a84eff6f28e 100644 (file)
@@ -280,7 +280,7 @@ int CmdTIWrite(const char *Cmd)
 {
        int res = 0;
        UsbCommand c = {CMD_WRITE_TI_TYPE};
-       res = sscanf(Cmd, "%012"llx" %012"llx" %012"llx"", &c.arg[0], &c.arg[1], &c.arg[2]);
+       res = sscanf(Cmd, "%012" SCNx64 " %012" SCNx64 " %012" SCNx64, &c.arg[0], &c.arg[1], &c.arg[2]);
 
        if (res == 2) c.arg[2]=0;
        if (res < 2) {
index dc44a55cb7769baf3e989f8f561818ff05022630..84d6b1b9b31b85b7ef2cb2fd1c5f89863ca61d63 100644 (file)
@@ -209,7 +209,7 @@ void UsbCommandReceived(UsbCommand *UC)
                        // arg1 = length bytes to transfer
                        // arg2 = bigbuff tracelength (?)
                        memcpy( sample_buf + (UC->arg[0]), UC->d.asBytes, UC->arg[1]);
-                       //printf("DBG:: Download from device. chunk %llu | size %llu | tracelen:%llu \n", UC->arg[0], UC->arg[1], UC->arg[2]);
+                       //printf("DBG:: Download from device. chunk %" PRIu64 " | size %" PRIu64 " | tracelen:%" PRIu64 " \n", UC->arg[0], UC->arg[1], UC->arg[2]);
                        break;
                }
                default: {
index c26dd3072edb5b17b608b5d3f5ea7e92e496f32f..37ee8fb0ddd2dc550085194ca576a4717ea29dc6 100644 (file)
@@ -302,7 +302,7 @@ static int get_proxmark_state(uint32_t *state)
                        *state = resp.arg[0];
                        break;
                default:
-                       fprintf(stderr, "Error: Couldn't get proxmark state, bad response type: 0x%04"llx"\n", resp.cmd);
+                       fprintf(stderr, "Error: Couldn't get proxmark state, bad response type: 0x%04" PRIx64 "\n", resp.cmd);
                        return -1;
                        break;
        }
@@ -360,7 +360,7 @@ static int wait_for_ack(UsbCommand *ack)
 {
        ReceiveCommand(ack);
        if (ack->cmd != CMD_ACK) {
-               printf("Error: Unexpected reply 0x%04"llx" %s (expected ACK)\n", ack->cmd, (ack->cmd==CMD_NACK)?"NACK":"");
+               printf("Error: Unexpected reply 0x%04" PRIx64 " %s (expected ACK)\n", ack->cmd, (ack->cmd==CMD_NACK)?"NACK":"");
                return -1;
        }
        return 0;
index 4e431658154dbdd3d74c99817bb7157e6479011f..fe3de3fe5ce36c5e38de371cc16b5b39ed533c31 100644 (file)
@@ -25,10 +25,10 @@ static char* serial_port_name;
 void cmd_debug(UsbCommand* UC) {
        //  Debug
        printf("UsbCommand length[len=%zd]\n",sizeof(UsbCommand));
-       printf("  cmd[len=%zd]: %016"llx"\n",sizeof(UC->cmd),UC->cmd);
-       printf(" arg0[len=%zd]: %016"llx"\n",sizeof(UC->arg[0]),UC->arg[0]);
-       printf(" arg1[len=%zd]: %016"llx"\n",sizeof(UC->arg[1]),UC->arg[1]);
-       printf(" arg2[len=%zd]: %016"llx"\n",sizeof(UC->arg[2]),UC->arg[2]);
+       printf("  cmd[len=%zd]: %016" PRIx64"\n",sizeof(UC->cmd),UC->cmd);
+       printf(" arg0[len=%zd]: %016" PRIx64"\n",sizeof(UC->arg[0]),UC->arg[0]);
+       printf(" arg1[len=%zd]: %016" PRIx64"\n",sizeof(UC->arg[1]),UC->arg[1]);
+       printf(" arg2[len=%zd]: %016" PRIx64"\n",sizeof(UC->arg[2]),UC->arg[2]);
        printf(" data[len=%zd]: ",sizeof(UC->d.asBytes));
 
        for (size_t i=0; i<16; i++)
index c67f676918c077c1e5ebcf0eb8f6f9e460fcce57..c13026941362b96603ac1cfc7d5f2da609027699 100644 (file)
@@ -14,6 +14,7 @@
 #include <string.h>
 #include <stdint.h>
 #include <stdbool.h>
+#include <inttypes.h>
 #include "zlib.h"
 
 #define MAX(a,b) ((a)>(b)?(a):(b))
@@ -140,7 +141,7 @@ int zlib_compress(FILE *infile[], uint8_t num_infiles, FILE *outfile)
                ret = deflate(&compressed_fpga_stream, Z_FINISH);
        }
        
-       fprintf(stderr, "compressed %u input bytes to %lu output bytes\n", i, compressed_fpga_stream.total_out);
+       fprintf(stderr, "compressed %u input bytes to %" PRIu32 " output bytes\n", i, compressed_fpga_stream.total_out);
 
        if (ret != Z_STREAM_END) {
                fprintf(stderr, "Error in deflate(): %d %s\n", ret, compressed_fpga_stream.msg);
index f9e058071437f05a96dae18a360cd15405b409d6..d1bfa69abba271feb6212f575429b5a3a0082195 100644 (file)
@@ -170,7 +170,7 @@ int mfnested(uint8_t blockNo, uint8_t keyType, uint8_t * key, uint8_t trgBlockNo
                free(statelists[1].head.slhead);\r
                num_to_bytes(key64, 6, resultKey);\r
 \r
-               PrintAndLog("UID: %08x target block:%3u key type: %c  -- Found key [%012"llx"]",\r
+               PrintAndLog("UID: %08x target block:%3u key type: %c  -- Found key [%012" PRIx64 "]",\r
                        uid,\r
                        (uint16_t)resp.arg[2] & 0xff,\r
                        (resp.arg[2] >> 8) ? 'B' : 'A',\r
@@ -627,7 +627,7 @@ int mfTraceDecode(uint8_t *data_src, int len, bool wantSaveToEmlFile) {
                        lfsr_rollback_word(revstate, nr_enc, 1);\r
                        lfsr_rollback_word(revstate, cuid ^ nt, 0);\r
                        crypto1_get_lfsr(revstate, &key);\r
-                       PrintAndLog("Found Key: [%012"llx"]", key);\r
+                       PrintAndLog("Found Key: [%012" PRIx64 "]", key);\r
                        \r
                        //if ( tryMfk64(cuid, nt, nr_enc, ar_enc, at_enc, &key) )\r
                        AddLogUint64(logHexFileName, "Found Key: ", key); \r
index 7fd1b715f90c042798b85303ef1c20ea40b14e4d..62d586dfdb82a74d12c0a17913f6a515869da442 100644 (file)
@@ -25,9 +25,6 @@ THE SOFTWARE.
 #include "crypto1_bs.h"
 #include <inttypes.h>
 #define __STDC_FORMAT_MACROS
-#define llx PRIx64
-#define lli PRIi64
-#define lu PRIu32
 
 // The following functions use this global or thread-local state
 // It is sized to fit exactly KEYSTREAM_SIZE more states next to the initial state
@@ -117,7 +114,7 @@ void crypto1_bs_print_states(bitslice_t bitsliced_states[]){
     state_t values[MAX_BITSLICES]  = {{0x00}};
     crypto1_bs_convert_states(bitsliced_states, values);
     for(slice_idx = 0; slice_idx < MAX_BITSLICES; slice_idx++){
-        printf("State %03zu: %012"llx"\n", slice_idx, values[slice_idx].value);
+        printf("State %03zu: %012" PRIx64 "\n", slice_idx, values[slice_idx].value);
     }
 }
 
index 64d3587303acdf6afd25dd43d4dd69971b01c853..3c3d3e198c7b91d97e47c1cc38d530b7b0c23296 100644 (file)
@@ -19,7 +19,7 @@ int nonce2key(uint32_t uid, uint32_t nt, uint32_t nr, uint64_t par_info, uint64_
        // Reset the last three significant bits of the reader nonce
        nr &= 0xffffff1f;
   
-       PrintAndLog("uid(%08x) nt(%08x) par(%016"llx") ks(%016"llx") nr(%08x)", uid, nt, par_info, ks_info, nr);
+       PrintAndLog("uid(%08x) nt(%08x) par(%016" PRIx64") ks(%016" PRIx64") nr(%08x)", uid, nt, par_info, ks_info, nr);
 
        for ( pos = 0; pos < 8; pos++ ) {
                ks3x[7-pos] = (ks_info >> (pos*8)) & 0x0f;
@@ -121,11 +121,11 @@ int nonce2key_ex(uint8_t blockno, uint8_t keytype, uint32_t uid, uint32_t nt, ui
                free(last_keylist);
                last_keylist = state_s;
                PrintAndLog("parity is all zero, testing special attack. First call, this attack needs at least two calls. Hold on...");                
-               PrintAndLog("uid(%08x) nt(%08x) ks(%016"llx") nr(%08x)", uid, nt, ks_info, nr);
+               PrintAndLog("uid(%08x) nt(%08x) ks(%016" PRIx64") nr(%08x)", uid, nt, ks_info, nr);
                return 1;
        }
 
-       PrintAndLog("uid(%08x) nt(%08x) ks(%016"llx") nr(%08x)", uid, nt, ks_info, nr);
+       PrintAndLog("uid(%08x) nt(%08x) ks(%016" PRIx64") nr(%08x)", uid, nt, ks_info, nr);
                
        //Create the intersection:
        int64_t *p1, *p2, *p3;
@@ -134,7 +134,12 @@ int nonce2key_ex(uint8_t blockno, uint8_t keytype, uint32_t uid, uint32_t nt, ui
                
        while ( *p1 != -1 && *p2 != -1 ) {
                if (compar_intA(p1, p2) == 0) {
-                       PrintAndLog("p1:%"llx" p2:%"llx" p3:%"llx" key:%012"llx,(uint64_t)(p1-last_keylist),(uint64_t)(p2-state_s),(uint64_t)(p3-last_keylist),*p1);
+                       PrintAndLog("p1:%" PRIx64" p2:%" PRIx64" p3:%" PRIx64" key:%012" PRIx64
+                               , (uint64_t)(p1-last_keylist)
+                               , (uint64_t)(p2-state_s)
+                               , (uint64_t)(p3-last_keylist)
+                               , *p1
+                       );
                        *p3++ = *p1++;
                        p2++;
                }
@@ -316,7 +321,7 @@ int tryMfk64(uint32_t uid, uint32_t nt, uint32_t nr_enc, uint32_t ar_enc, uint32
        lfsr_rollback_word(revstate, uid ^ nt, 0);
        crypto1_get_lfsr(revstate, &key);
 
-       PrintAndLog("Found Key: [%012"llx"]", key);
+       PrintAndLog("Found Key: [%012" PRIx64 "]", key);
        t1 = clock() - t1;
        if ( t1 > 0 ) PrintAndLog("Time in mfkey64: %.0f ticks", (float)t1);
 
index 9b10af1ae8a74f2aa083a6ee91a26c7b161a05f3..561212691cd6cbb9f975215caba8aa23900884f3 100644 (file)
@@ -8,7 +8,6 @@
 //-----------------------------------------------------------------------------
 // Main binary
 //-----------------------------------------------------------------------------
-
 #ifndef PROXMARK3_H__
 #define PROXMARK3_H__
 
 #include <inttypes.h>
 #include "usb_cmd.h"
 
+/*
 #define lu PRIu32
 #define lx  PRIx32
-#define llx PRIx64
-#define lli PRIi64
-#define llu PRIu64
-#define hhu PRIu8
+*/
 #define PROXPROMPT "pm3 --> "
 
 void SendCommand(UsbCommand *c);
-
-#endif
+#endif
\ No newline at end of file
index ed3118315033c10cdb3dfeff39e9dd50b6533a5f..35e38af3f71c1dc7e5a20d016b493e8e226f4493 100644 (file)
@@ -799,15 +799,15 @@ prev(poly_t *poly) {
        unsigned long fulllength = poly->length + ofs;
        bmp_t accu;
 
-       if(ofs)
+       if(ofs) {
                /* removable optimisation */
                if(poly->length < (unsigned long) BMP_BIT) {
                        *poly->bitmap = rev(*poly->bitmap >> ofs, (int) poly->length) << ofs;
                        return;
                }
-
-               /* claim remaining bits of last word (as we use public function pshift()) */
-               poly->length = fulllength;
+       }
+       /* claim remaining bits of last word (as we use public function pshift()) */
+       poly->length = fulllength;
 
        /* reverse and swap words in the array, leaving it right-justified */
        while(leftidx < rightidx) {
index 752edba6d0f9309b5d66724986ccf4f608924abf..f35707feab8a0112d4c79f5dfb0b03be04a36c1b 100644 (file)
@@ -145,7 +145,7 @@ static int l_nonce2key(lua_State *L){
     uint8_t dest_key[8];
     num_to_bytes(key,sizeof(dest_key),dest_key);
 
-    //printf("Pushing to lua stack: %012"llx"\n",key);
+    //printf("Pushing to lua stack: %012" PRIx64 "\n",key);
     lua_pushlstring(L,(const char *) dest_key,sizeof(dest_key));
 
     return 2; //Two return values
@@ -531,7 +531,7 @@ static int l_hardnested(lua_State *L){
     uint8_t dest_key[6];
     num_to_bytes(foundkey, sizeof(dest_key), dest_key);
 
-    //printf("Pushing to lua stack: %012"llx"\n",key);
+    //printf("Pushing to lua stack: %012" PRIx64 "\n",key);
     lua_pushlstring(L, (const char *) dest_key, sizeof(dest_key));
     return 2; //Two return values
 }
index fdbd2648c14fb8020762121fbc3d56a093750fd7..4adc4e701866f4d86628211a764da761e8734266 100644 (file)
@@ -75,7 +75,7 @@ void AddLogUint64(char *fileName, char *extData, const uint64_t data) {
        char buf[20] = {0};
        memset(buf, 0x00, sizeof(buf));
        //sprintf(buf, "%X%X", (unsigned int)((data & 0xFFFFFFFF00000000) >> 32), (unsigned int)(data & 0xFFFFFFFF));
-       sprintf(buf, "%012"llx"", data);
+       sprintf(buf, "%012" PRIx64 "", data);
        AddLogLine(fileName, extData, buf);
 }
 
index a13e32dd284035d13f03ca75873786b64c433b94..aa93433aac091af9eed992f3e9e3bed7a5e6c8e5 100644 (file)
@@ -59,15 +59,12 @@ DETECTED_OS=Windows
 
 endif
 
-#
 # uncomment these two; to enable EMV
-#
 #APP_CFLAGS += -DWITH_EMV
 #COMMON_FLAGS += -DWITH_EMV
-#
+
 # uncomment these two; to fix 256 vs 512kb PM3 devices
 # flashing bootrom -b is needed
-#
 APP_CFLAGS += -DHAS_512_FLASH
 COMMON_FLAGS += -DHAS_512_FLASH
 
index 43e5a094dab57627c51705cb25b2b776b4321758..3872e81dd7052a563e793ff191c675c7799eda82 100755 (executable)
@@ -5,8 +5,6 @@
 #include <stdlib.h>
 #include <time.h>
 
-#define llx PRIx64
-#define lli PRIi64
 int main (int argc, char *argv[]) {
        struct Crypto1State *s,*t;
        uint64_t key;     // recovered key
@@ -64,7 +62,7 @@ int main (int argc, char *argv[]) {
                crypto1_word(t, uid ^ nt, 0);
                crypto1_word(t, nr1_enc, 1);
                if (ar1_enc == (crypto1_word(t, 0, 0) ^ p64)) {
-                       printf("\nFound Key: [%012"llx"]\n\n",key);
+                       printf("\nFound Key: [%012" PRIx64 "]\n\n",key);
                        break;}
        }
        free(s);
index 92ac371fa383b20068991a25fdc1d95a0d23100d..d220566ee1f3c001a51d9a5f37fb6123f4064768 100644 (file)
@@ -4,9 +4,7 @@
 #include <stdio.h>
 #include <stdlib.h>
 #include <time.h>
-
-#define llx PRIx64
-#define lli PRIi64
 int main (int argc, char *argv[]) {
        struct Crypto1State *s,*t;
        uint64_t key;     // recovered key
@@ -71,7 +69,7 @@ int main (int argc, char *argv[]) {
                crypto1_word(t, uid ^ nt1, 0);
                crypto1_word(t, nr1_enc, 1);
                if (ar1_enc == (crypto1_word(t, 0, 0) ^ p64b)) {
-                       printf("\nFound Key: [%012"llx"]\n\n",key);
+                       printf("\nFound Key: [%012" PRIx64 "]\n\n",key);
                        break;}
        }
        free(s);
index 616c6f3d669594f18365e59b6d57cd803ac95133..6a7e78c04de5b09eb3527068822a526bc70ca3cf 100755 (executable)
@@ -5,9 +5,6 @@
 #include <inttypes.h>
 #include "crapto1.h"
 
-#define llx PRIx64
-#define lli PRIi64
-
 int main (int argc, char *argv[]) {
        struct Crypto1State *revstate;
        uint64_t key;     // recovered key
@@ -98,7 +95,7 @@ int main (int argc, char *argv[]) {
        lfsr_rollback_word(revstate, nr_enc, 1);
        lfsr_rollback_word(revstate, uid ^ nt, 0);
        crypto1_get_lfsr(revstate, &key);
-       printf("\nFound Key: [%012"llx"]\n\n", key);
+       printf("\nFound Key: [%012" PRIx64 "]\n\n", key);
        crypto1_destroy(revstate);
   
        t1 = clock() - t1;
index b08c5cd2774ff79d2d7dc002149e18e595234bfb..250691c1af28c0068c6f92e1d92617e9671fb49b 100644 (file)
@@ -1,7 +1,6 @@
 #include "crapto1.h"
 #define __STDC_FORMAT_MACROS
 #include <inttypes.h>
-#define llx PRIx64
 #include <stdio.h>
 #include <time.h>
 typedef unsigned char byte_t;
@@ -19,15 +18,15 @@ int main(const int argc, const char* argv[]) {
                printf("\nsyntax: %s <uid> <nt> <par> <ks>\n\n",argv[0]);
                return 1;
        }
-       sscanf(argv[1],"%08x",&uid);
-       sscanf(argv[2],"%08x",&nt);
-       sscanf(argv[3],"%016"llx,&par_info);
-       sscanf(argv[4],"%016"llx,&ks_info);
+       sscanf(argv[1],"%08x", &uid);
+       sscanf(argv[2],"%08x", &nt);
+       sscanf(argv[3],"%016" SCNx64 ,&par_info);
+       sscanf(argv[4],"%016" SCNx64 ,&ks_info);
   
        // Reset the last three significant bits of the reader nonce
        nr &= 0xffffff1f;
 
-       printf("\nuid(%08x) nt(%08x) par(%016"llx") ks(%016"llx")\n\n",uid,nt,par_info,ks_info);
+       printf("\nuid(%08x) nt(%08x) par(%016" PRIx64 ") ks(%016" PRIx64 ")\n\n", uid, nt, par_info, ks_info);
 
        for ( pos = 0; pos < 8; pos++ ) {
                ks3x[7-pos] = (ks_info >> (pos*8)) & 0x0f;
@@ -56,7 +55,7 @@ int main(const int argc, const char* argv[]) {
        state = lfsr_common_prefix(nr,rr,ks3x,par);
        lfsr_rollback_word(state,uid^nt,0);
        crypto1_get_lfsr(state,&key_recovered);
-       printf("\nkey recovered: %012"llx"\n\n",key_recovered);
+       printf("\nkey recovered: %012" PRIx64 "\n\n", key_recovered);
        crypto1_destroy(state);
   
        t1 = clock() - t1;
index dbfa49c9c7124bdcbd769362c1a0456e7266804e..49cce330aabe2f0a51b5b17087911fbd1cc6582b 100644 (file)
@@ -951,7 +951,7 @@ void ZLIB_INTERNAL _tr_flush_block(s, buf, stored_len, last)
         opt_lenb = (s->opt_len+3+7)>>3;
         static_lenb = (s->static_len+3+7)>>3;
 
-        Tracev((stderr, "\nopt %lu(%lu) stat %lu(%lu) stored %lu lit %u ",
+        Tracev((stderr, "\nopt %" PRIu32 "(%" PRIu32 ") stat %" PRIu32 "(%" PRIu32 ") stored %" PRIu32 " lit %u ",
                 opt_lenb, s->opt_len, static_lenb, s->static_len, stored_len,
                 s->last_lit));
 
Impressum, Datenschutz