]> git.zerfleddert.de Git - proxmark3-svn/commitdiff
CHG: fiddled with the headerfiles... and makefile... Tried to make them behave...
authoriceman1001 <iceman@iuse.se>
Tue, 24 Jan 2017 23:33:03 +0000 (00:33 +0100)
committericeman1001 <iceman@iuse.se>
Tue, 24 Jan 2017 23:33:03 +0000 (00:33 +0100)
Added a lot of #ifndef ,   extern C,
Move inside from ARMSRC -> THUMBS,  which made the compiled image smaller.. I don't know if it broke anything.
Moved MF_DBGLEVEL definitions into common.h
Moved print_result from util.c into appmain.c
Also split up some struct typedef  into header files so they could be reused in other code places.

''' danger '''  this might have broken stuff...

27 files changed:
armsrc/BigBuf.h
armsrc/Makefile
armsrc/appmain.c
armsrc/apps.h
armsrc/des.c
armsrc/des.h
armsrc/desfire_crypto.c
armsrc/desfire_crypto.h
armsrc/desfire_key.h
armsrc/emvcmd.c
armsrc/emvcmd.h
armsrc/emvdataels.c
armsrc/emvdataels.h
armsrc/emvutil.c
armsrc/emvutil.h
armsrc/iclass.c
armsrc/iso14443a.h
armsrc/iso14443b.h
armsrc/lfsampling.c
armsrc/lfsampling.h
armsrc/mifaredesfire.h
armsrc/mifareutil.c
armsrc/mifareutil.h
armsrc/start.c
armsrc/util.c
armsrc/util.h
include/common.h

index 61e82b865a29ee135b72a5c92ee1a24dc544b707..c3a7503f8e820c121e7ea291cc29e22038f92637 100644 (file)
@@ -13,8 +13,8 @@
 #define __BIGBUF_H
 
 #include "proxmark3.h"
-#include "apps.h"
 #include "string.h"
+#include "ticks.h"
 
 #define BIGBUF_SIZE                            40000
 #define MAX_FRAME_SIZE                 256             // maximum allowed ISO14443 frame
index 07227a2d55e343b8aa6a45f0c12a6ad7bd5f34f6..bde50f0ec519624a19030a718b168c942e5f3d07 100644 (file)
@@ -19,11 +19,13 @@ APP_CFLAGS  = -DWITH_ISO14443a_StandAlone -DWITH_LF \
 #SRC_LCD = fonts.c LCD.c
 SRC_LF = lfops.c hitag2.c hitagS.c lfsampling.c pcf7931.c lfdemod.c protocols.c
 SRC_ISO15693 = iso15693.c iso15693tools.c
-SRC_ISO14443a = epa.c iso14443a.c mifareutil.c mifarecmd.c mifaresniff.c
+SRC_ISO14443a = iso14443a.c mifareutil.c mifarecmd.c mifaresniff.c epa.c
 SRC_ISO14443b = iso14443b.c
 SRC_CRAPTO1 = crapto1.c crypto1.c des.c aes.c desfire_key.c desfire_crypto.c mifaredesfire.c
 SRC_CRC = iso14443crc.c crc.c crc16.c crc32.c 
 SRC_EMV = tlv.c emvdataels.c emvutil.c emvcmd.c                                                                         
+SRC_ICLASS = iclass.c optimized_cipher.c
+SRC_LEGIC = legicrf.c legic_prng.c
 
 #the FPGA bitstream files. Note: order matters!
 FPGA_BITSTREAMS = fpga_lf.bit fpga_hf.bit
@@ -45,28 +47,30 @@ THUMBSRC = start.c \
        $(SRC_ISO15693) \
        $(SRC_LF) \
        $(SRC_ZLIB) \
+       $(SRC_LEGIC) \
+       $(SRC_ISO14443b) \
+       $(SRC_ICLASS) \
        appmain.c \
        printf.c \
        util.c \
        string.c \
        usb_cdc.c \
        cmd.c \
-       ticks.c
+       BigBuf.c \
+       ticks.c \
+       hfsnoop.c
 
 # These are to be compiled in ARM mode
 ARMSRC = fpgaloader.c \
-       legicrf.c \
-       $(SRC_ISO14443a) \
-       $(SRC_ISO14443b) \
-       $(SRC_CRAPTO1) \
        $(SRC_CRC) \
-       legic_prng.c \
-       iclass.c \
-       BigBuf.c \
-       optimized_cipher.c \
-       hfsnoop.c \
+       $(SRC_CRAPTO1) \
+       $(SRC_ISO14443a) \
        parity.c
-#  $(SRC_EMV)
+#      $(SRC_ISO14443b) \
+#      $(SRC_ICLASS) \
+#  $(SRC_EMV) \
+       #BigBuf.c \
+
 
 # Do not move this inclusion before the definition of {THUMB,ASM,ARM}SRC
 include ../common/Makefile.common
index 4eabb319170c1e0390c8f8f531d4f7483317d35d..d4b22465eb3d51670ac703cc11805f693d16bddd 100644 (file)
 // executes.
 //-----------------------------------------------------------------------------
 #include "usb_cdc.h"
-//#include "cmd.h"
 #include "proxmark3.h"
 #include "apps.h"
 #include "util.h"
 #include "printf.h"
 #include "string.h"
-#include <stdarg.h>
 #include "legicrf.h"
-#include "hitag2.h"
-#include "hitagS.h"
 #include "lfsampling.h"
 #include "BigBuf.h"
 #include "mifareutil.h"
-#include "pcf7931.h"
 
 #ifdef WITH_LCD
  #include "LCD.h"
@@ -76,6 +71,28 @@ void PrintToSendBuffer(void){
        Dbhexdump(ToSendMax, ToSend, 0);
 }
 
+void print_result(char *name, uint8_t *buf, size_t len) {
+       uint8_t *p = buf;
+
+       if ( len % 16 == 0 ) {
+               for(; p-buf < len; p += 16)
+                       Dbprintf("[%s:%d/%d] %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x",
+                               name,
+                               p-buf,
+                               len,
+                               p[0], p[1], p[2], p[3], p[4], p[5], p[6], p[7],p[8], p[9], p[10], p[11], p[12], p[13], p[14], p[15]
+                       );
+       }
+       else {
+               for(; p-buf < len; p += 8)
+                       Dbprintf("[%s:%d/%d] %02x %02x %02x %02x %02x %02x %02x %02x",
+                               name,
+                               p-buf,
+                               len,
+                               p[0], p[1], p[2], p[3], p[4], p[5], p[6], p[7]);
+       }
+}
+
 //=============================================================================
 // Debug print functions, to go out over USB, to the usual PC-side client.
 //=============================================================================
@@ -1025,19 +1042,15 @@ void UsbPacketReceived(uint8_t *packet, int len)
                case CMD_RECORD_RAW_ADC_SAMPLES_ISO_15693:
                        RecordRawAdcSamplesIso15693();
                        break;
-                       
                case CMD_ISO_15693_COMMAND:
                        DirectTag15693Command(c->arg[0],c->arg[1],c->arg[2],c->d.asBytes);
                        break;
-                                       
                case CMD_ISO_15693_FIND_AFI:
                        BruteforceIso15693Afi(c->arg[0]);
                        break;  
-                       
                case CMD_ISO_15693_DEBUG:
                        SetDebugIso15693(c->arg[0]);
                        break;
-
                case CMD_READER_ISO_15693:
                        ReaderIso15693(c->arg[0]);
                        break;
index d119d2396c60ca9388cb64f15457e8f68a9c434b..6289223b04f808ac9a50ad36b0b5513653557fd7 100644 (file)
 #ifndef __APPS_H
 #define __APPS_H
 
-#include <stdint.h>
-#include <stddef.h>
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 #include <stdlib.h>
-//#include <sys/types.h> 
+#include <stdarg.h>
 #include "common.h"
+#include "usb_cdc.h"
 #include "crc32.h"
 #include "lfdemod.h"
 #include "BigBuf.h"
 #include "fpgaloader.h"
-#include "usb_cdc.h"
 #include "hitag2.h"
 #include "hitagS.h"
 #include "mifare.h"
 #include "pcf7931.h"
-//#include "des.h"
-//#include "aes.h"
 #include "desfire.h"
 #include "iso14443b.h"
 
-extern const uint8_t OddByteParity[256];
 extern int rsamples;   // = 0;
 extern int tracing;    // = TRUE;
 extern uint8_t trigger;
@@ -55,6 +54,7 @@ void Dbhexdump(int len, uint8_t *d, bool bAsci);
 #define MAX_ADC_LF_VOLTAGE 140800
 int AvgAdc(int ch);
 
+void print_result(char *name, uint8_t *buf, size_t len);
 void PrintToSendBuffer(void);
 void ToSendStuffBit(int b);
 void ToSendReset(void);
@@ -105,6 +105,9 @@ void AcquireRawAdcSamplesIso14443b(uint32_t parameter);
 void ReadSTMemoryIso14443b(uint8_t numofblocks);
 void RAMFUNC SnoopIso14443b(void);
 void SendRawCommand14443B(uint32_t, uint32_t, uint8_t, uint8_t[]);
+void SendRawCommand14443B_Ex(UsbCommand *c);
+void AppendCrc14443b(uint8_t* data, int len);
+void ClearFpgaShiftingRegisters(void);
 
 // iso14443a.h
 void RAMFUNC SniffIso14443a(uint8_t param);
@@ -163,7 +166,6 @@ size_t CreateAPDU( uint8_t *datain, size_t len, uint8_t *dataout);
 void OnSuccess();
 void OnError(uint8_t reason);
 
-
 // desfire_crypto.h
 void *mifare_cryto_preprocess_data (desfiretag_t tag, void *data, size_t *nbytes, size_t offset, int communication_settings);
 void *mifare_cryto_postprocess_data (desfiretag_t tag, void *data, size_t *nbytes, int communication_settings);
@@ -223,4 +225,8 @@ void EMVgetUDOL(void);
 void EMVloadvalue(uint32_t tag, uint8_t* datain);
 void EMVdumpcard(void);
 
+#ifdef __cplusplus
+}
+#endif
+
 #endif
index 6b3bea9b77ed5f14f0b181aa625f2ddd597fcfca..513f89bfeb9c17124361aafc047074cd0ba08519 100644 (file)
@@ -25,8 +25,8 @@
  * \license     GPLv3 or later
  * 
  */
-#include <stdint.h>
-#include <string.h>
+
+#include "des.h"
 
 const uint8_t sbox[256]  = {
   /* S-box 1 */
index 3379463a612ce5fd3062a941fdced0d3df16a6ac..03b9f646947e1d27fcc599ef02c21099e9f5b9a3 100644 (file)
  * \license    GPLv3 or later
  * 
  */
-#ifndef DES_H_
-#define DES_H_
+#ifndef __DES_H_
+#define __DES_H_
+
+#include <stdint.h>
+#include <string.h>
 
 /* the FIPS 46-3 (1999-10-25) name for triple DES is triple data encryption algorithm so TDEA.
  * Also we only implement the three key mode  */
@@ -67,7 +70,8 @@ void des_enc(void* out, const void* in, const void* key);
  * \param in  pointer to the block (64 bit = 8 byte) where the ciphertext is read from
  * \param key pointer to the key (64 bit = 8 byte)
  */
-void des_dec(void* out, const void* in, const void* key);
+//void des_dec(void* out, const void* in, const void* key);
+void des_dec(void* out, const void* in, const uint8_t* key);
 
 /** \fn void tdes_enc(void* out, const void* in, const void* key)
  * \brief encrypt a block with Tripple-DES
@@ -81,7 +85,8 @@ void des_dec(void* out, const void* in, const void* key);
  * \param in  pointer to the block (64 bit = 8 byte) where the plaintext is read from
  * \param key pointer to the key (192 bit = 24 byte)
  */
-void tdes_enc(void* out, const void* in, const void* key);
+//void tdes_enc(void* out, const void* in, const void* key);
+void tdes_enc(void* out, void* in, const void* key);
 
 /** \fn void tdes_dec(void* out, const void* in, const void* key)
  * \brief decrypt a block with Tripple-DES
@@ -95,19 +100,16 @@ void tdes_enc(void* out, const void* in, const void* key);
  * \param in  pointer to the block (64 bit = 8 byte) where the ciphertext is read from
  * \param key pointer to the key (192 bit = 24 byte)
  */
- void tdes_dec(void* out, const void* in, const void* key);
+ //void tdes_dec(void* out, const void* in, const void* key);
+ void tdes_dec(void* out, void* in, const uint8_t* key);
  
  void tdes_2key_enc(void* out, const void* in, size_t length, const void* key, unsigned char iv[8]);
  void tdes_2key_dec(void* out, const void* in, size_t length, const void* key, unsigned char iv[8]);
 
- void tdes_2key_enc(void* out, const void* in, size_t length, const void* key, unsigned char iv[8]);
- void tdes_2key_dec(void* out, const void* in, size_t length, const void* key, unsigned char iv[8]);
-
-#endif /*DES_H_*/
-
 // Copied from des.h in desfire imp.
 typedef unsigned long DES_KS[16][2];   /* Single-key DES key schedule */
 typedef unsigned long DES3_KS[48][2];  /* Triple-DES key schedule */
 
-
 extern int Asmversion; /* 1 if we're linked with an asm version, 0 if C */
+
+#endif /*DES_H_*/
index e7eceb3ccf59f89ac70157ddfcdb6aa3f1f3ee09..fdb0677118e49681e487159f8fde2ebd16aa7a3b 100644 (file)
@@ -89,7 +89,6 @@ void cmac (const desfirekey_t key, uint8_t *ivect, const uint8_t *data, size_t l
 
 size_t key_block_size (const desfirekey_t key) {
     size_t block_size = 8;
-
     switch (key->type) {
                case T_DES:
                case T_3DES:
@@ -100,7 +99,6 @@ size_t key_block_size (const desfirekey_t key) {
                        block_size = 16;
                        break;
     }
-
     return block_size;
 }
 
@@ -109,7 +107,6 @@ size_t key_block_size (const desfirekey_t key) {
  */
 static size_t key_macing_length (const desfirekey_t key) {
     size_t mac_length = MAC_LENGTH;
-
     switch (key->type) {
     case T_DES:
     case T_3DES:
@@ -120,7 +117,6 @@ static size_t key_macing_length (const desfirekey_t key) {
         mac_length = CMAC_LENGTH;
         break;
     }
-
     return mac_length;
 }
 
@@ -459,7 +455,7 @@ void* mifare_cryto_postprocess_data (desfiretag_t tag, void *data, size_t *nbyte
                 break;
             case AS_NEW:
                 end_crc_pos = crc_pos + 4;
-                crc32 (res, end_crc_pos, (uint8_t *)&crc);
+                crc32_ex (res, end_crc_pos, (uint8_t *)&crc);
                 break;
             }
             if (!crc) {
index df5a6887786957199fc42bb30f8a3f437ea55a3d..7be85bfbad331dd21c38291334550a878b868fc4 100644 (file)
@@ -1,12 +1,19 @@
 #ifndef __DESFIRE_CRYPTO_H
 #define __DESFIRE_CRYPTO_H
 
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 #include <string.h>
-#include <stdarg.h>
+//#include "apps.h"
+#include "crc32.h"
 #include "printf.h"
+#include "desfire.h"
 #include "iso14443a.h"
-#include "../common/desfire.h"
-#include "des.h"
-//#include "aes.h"
+
+#ifdef __cplusplus
+}
+#endif
 
 #endif
index df932643f8df8bb199ae54734b3d5d8b08562e9d..4e6fdaea92b24d8eecbe043df87b8388cbd0ec2e 100644 (file)
@@ -3,8 +3,9 @@
 
 #include <stdlib.h>
 #include <stdint.h>
+#include "iso14443a.h"
 #include "desfire.h"
-#include "iso14443a.h" //test
+//#include "mifare.h" // iso14a_card_select_t struct
 void           Desfire_des_key_new (const uint8_t value[8], desfirekey_t key);
 void           Desfire_3des_key_new (const uint8_t value[16], desfirekey_t key);
 void           Desfire_des_key_new_with_version (const uint8_t value[8], desfirekey_t key);
index 3549d0e3d105ae0c6e075efee45c6d925dd3568e..4a58e25af98b05f0c33400d5e34b02286f2c69e5 100644 (file)
@@ -8,13 +8,7 @@
 //--------------------------------------------------------------------------------
 //Routines to support EMV transactions
 //--------------------------------------------------------------------------------
-
-#include "mifare.h"
-#include "iso14443a.h"
-#include "emvutil.h"
 #include "emvcmd.h"
-#include "apps.h"
-#include "emvdataels.h"
 
 static emvtags currentcard; //use to hold emv tags for the reader/card during communications
 static tUart Uart;
index 070eb586ccb644d6a4dd550d92fc7a85a70ef338..811953421359210ebe540b90e3978a39204c73f0 100644 (file)
 #ifndef __EMVCMD_H
 #define __EMVCMD_H
 
+
 #include "proxmark3.h"
+#include "common.h"
 #include "apps.h"
 #include "util.h"
 #include "string.h"
-
 #include "iso14443crc.h"
 #include "iso14443a.h"
-#include "common.h"
+#include "mifare.h"
+#include "emvcmd.h"
 #include "emvutil.h"
+#include "emvdataels.h"
 #include "emvcard.h"
 
 #define VISA_DCVV           0
index 3db9ee78274af31ff0d1430cb869c624729cbad7..da64a6f4705041f4b9af1f750eedc7fd38d7f6a5 100644 (file)
@@ -1,16 +1,13 @@
 // ICEMAN 2017, this file looks similar to emvdataels.h headerfile. 
-
 //Data elements for EMV transactions.
 
-#ifndef __EMVDATAELS_H
-#define __EMVDATAELS_H
 #include "emvdataels.h"
-//Known AIDs
 
-typedef struct{
-uint8_t tag[2];
-char description[255];
-} tagdescription;
+//Known AIDs
+struct tagdescription {
+       uint8_t tag[2];
+       char description[255];
+};
 
 const uint8_t AID_VISA[]    =   {0xa0,0x00,0x00,0x00,0x03};
 const uint8_t AID_VISA_DB[] =   {0xa0,0x00,0x00,0x00,0x03,0x10,0x10};
@@ -111,18 +108,3 @@ const tagdescription EMV_TAG_LIST[] = {
     {"\x9f\x66","card production life cycle"},
     {"\xbf\x0c","file control information (fci) issuer discretionary data"}
 };
-
-//AIP bitmasks details
-#define AIP_CHIP_SUPPORTED 0x80
-#define AIP_MSR_SUPPORTED 0x40
-
-#define AIP_SDA_SUPPORTED 0x40
-#define AIP_DDA_SUPPORTED 0x20
-#define AIP_CARDHOLDER_VERIFICATION 0x10
-#define AIP_TERMINAL_RISK 0x08
-#define AIP_ISSUER_AUTH 0x04
-#define AIP_CDA_SUPPORTED 0x01
-//human readable error messages
-
-#endif //__EMVDATAELS_H
index d88b8797ed6c723aa9917ed0fae57f8ecf2dd351..ad46e9f4b731247c4c97a78edb1861b1fc67fbc1 100644 (file)
@@ -4,6 +4,8 @@
 
 #include <stdint.h>
 
+typedef struct tagdescription tagdescription;
+
 //Known AIDs
 extern const uint8_t AID_VISA[5];
 extern const uint8_t AID_VISA_DB[7] ;
@@ -25,12 +27,6 @@ extern const uint8_t AID_ALIAS[7];
 
 //Master data file for PSE
 extern const uint8_t DF_PSE[];
-
-typedef struct{
-    uint8_t tag[2];
-    char description[255];
-} tagdescription;
-
 extern const tagdescription EMV_TAG_LIST[62]; //SW1 return values
 extern const uint8_t SW1_RESPONSE_BYTES[]; 
 extern const uint8_t SW1_WRONG_LENGTH[] ; 
index e35cb1efed69e80db071120a649f0edf1777baf4..c4c296133a55f5e31aa08fe1d887b6a3e2f35826 100644 (file)
@@ -8,19 +8,7 @@
 //-----------------------------------------------------------------------------
 // various EMV related functions.
 //-----------------------------------------------------------------------------
-#include <stdarg.h>
-#include "proxmark3.h"
-#include "apps.h"
-#include "util.h"
-#include "string.h"
-
-#include "BigBuf.h"
-
-#include "iso14443crc.h"
-#include "iso14443a.h"
 #include "emvutil.h"
-#include "emvdataels.h" //EMV data elements 
-#include "emvtags.h" //EMV card structure
 
 #define DUMP(varname) Dbprintf("%s=", #varname);
 
index 6fe748ddf0428a789455a1f89683de67a7b6b8cb..bd5ec4fef745fdb555700cbd4400edab8aa73814 100644 (file)
 //-----------------------------------------------------------------------------
 #ifndef __EMVUTIL_H
 #define __EMVUTIL_H
+
 #include <stdarg.h>
 #include <stdint.h>
-#include "iso14443a.h"
+#include "proxmark3.h"
+#include "apps.h"
 #include "tlv.h"
-#include "emvtags.h"
-#include "emvdataels.h"
+#include "util.h"
+#include "string.h"
+#include "BigBuf.h"
+#include "iso14443crc.h"
+#include "iso14443a.h"
+#include "emvutil.h"
+#include "emvdataels.h" //EMV data elements 
+#include "emvtags.h" //EMV card structure
+
 // mifare 4bit card answers
 // reader voltage field detector
 #define EMV_MINFIELDV      4000
index 01693dcad4c0d6979068a1347c039f17885b43ca..f5e821cb3a8a3dabc83c9f4454b5c12a2760c7bc 100644 (file)
 //
 //-----------------------------------------------------------------------------
 
-#include "proxmark3.h"
 #include "apps.h"
-#include "util.h"
-#include "string.h"
-#include "common.h"
 #include "cmd.h"
 // Needed for CRC in emulation mode;
 // same construction as in ISO 14443;
@@ -52,7 +48,6 @@
 
 static int timeout = 4096;
 
-
 static int SendIClassAnswer(uint8_t *resp, int respLen, int delay);
 
 //-----------------------------------------------------------------------------
@@ -63,7 +58,7 @@ static struct {
     enum {
         STATE_UNSYNCD,
         STATE_START_OF_COMMUNICATION,
-       STATE_RECEIVING
+               STATE_RECEIVING
     }       state;
     uint16_t    shiftReg;
     int     bitCnt;
index 3dec6122263fd53093b7781772f444451168c0a0..2128f6ec5c1e8d79e88bcaf12b6a80b6789d2731 100644 (file)
 
 #ifndef __ISO14443A_H
 #define __ISO14443A_H
-#include "common.h"
-#include "proxmark3.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include "cmd.h"
 #include "apps.h"
 #include "util.h"
 #include "string.h"
-#include "cmd.h"
 #include "iso14443crc.h"
 #include "mifaresniff.h"
-#include "iso14443b.h"
 #include "crapto1.h"
 #include "mifareutil.h"
-#include "BigBuf.h"
 #include "parity.h"
 
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-
 typedef struct {
        enum {
                DEMOD_UNSYNCD,
index f2cf74a565fa2cd8a9456327d62695b21e4f65d1..885d8730cc6b5973794f254694810c697f22de4c 100644 (file)
 #ifndef __ISO14443B_H
 #define __ISO14443B_H
 
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 #include "proxmark3.h"
-#include "common.h"
+#include "common.h"    // access to global variable: MF_DBGLEVEL
 #include "apps.h"
 #include "util.h"
 #include "string.h"
 
 #include "mifare.h"
 #include "protocols.h"
-#include "mifareutil.h"                // access to global variable: MF_DBGLEVEL
-
-#ifdef __cplusplus
-extern "C" {
-#endif
+//#include "mifareutil.h"      
 
 extern void AppendCrc14443b(uint8_t *data, int len);
 void SendRawCommand14443B_Ex(UsbCommand *c);
index 94ddc7274d9ae98add2e56ca01158724b4bc9acc..02c0cd4a7708fbe60f1378fc0d308887812eb145 100644 (file)
@@ -48,11 +48,11 @@ sample_config* getSamplingConfig() {
        return &config;
 }
 
-typedef struct {
+struct BitstreamOut {
        uint8_t * buffer;
        uint32_t numbits;
        uint32_t position;
-} BitstreamOut;
+};
 
 /**
  * @brief Pushes bit onto the stream
@@ -259,7 +259,7 @@ void doT55x7Acquisition(size_t sample_size) {
        while(!BUTTON_PRESS() && !usb_poll_validate_length() && skipCnt < 1000 && (i < bufsize) ) {
                WDT_HIT();              
                if (AT91C_BASE_SSC->SSC_SR & AT91C_SSC_TXRDY) {
-                       AT91C_BASE_SSC->SSC_THR = 0x43;
+                       AT91C_BASE_SSC->SSC_THR = 0x43; //43
                        LED_D_ON();
                }
                if (AT91C_BASE_SSC->SSC_SR & AT91C_SSC_RXRDY) {
@@ -275,7 +275,7 @@ void doT55x7Acquisition(size_t sample_size) {
                                skipCnt++;
                                continue;
                        }
-                       // skip until the first Low sample below threshold
+                       // skip until the first low sample below threshold
                        if (!startFound && curSample < T55xx_READ_LOWER_THRESHOLD) {
                                //if (curSample > lastSample) 
                                lastSample = curSample;
index cf1bb45dae46b7e1c6e771f351edad41c19426f2..b37b786eb6962b40dccd783cbaf956ec02cefa30 100644 (file)
@@ -1,5 +1,5 @@
-#ifndef LFSAMPLING_H
-#define LFSAMPLING_H
+#ifndef __LFSAMPLING_H
+#define __LFSAMPLING_H
 
 #include "proxmark3.h"
 #include "apps.h"
@@ -8,6 +8,8 @@
 #include "usb_cdc.h"   // for usb_poll_validate_length
 #include "ticks.h"             // for StartTicks
 
+typedef struct BitstreamOut BitstreamOut;
+
 /**
 * acquisition of T55x7 LF signal. Similart to other LF, but adjusted with @marshmellows thresholds
 * the data is collected in BigBuf.
@@ -72,4 +74,4 @@ sample_config * getSamplingConfig();
 void printConfig();
 
 
-#endif // LFSAMPLING_H
+#endif // __LFSAMPLING_H
index c17ad1b4b8ca0b853fc45722ce2e6bb1b1a927d1..40c623ef96c6497f836aefdb4364d008bc39373d 100644 (file)
@@ -1,16 +1,14 @@
 #ifndef __MIFAREDESFIRE_H
 #define __MIFAREDESFIRE_H
 
+#include "common.h"
 #include "proxmark3.h"
 #include "apps.h"
-#include "util.h"
 #include "string.h"
 #include "BigBuf.h"
 #include "iso14443crc.h"
 #include "iso14443a.h"
 #include "desfire_key.h"
 #include "mifareutil.h"
-#include "common.h"
 #include "des.h"
-
 #endif
index 5dfeeab0a76eae5cb0fd374d40ce9dfe8f5c1e6b..4795a7ec4cfa3ce7a9009947c138a425db3e6c57 100644 (file)
@@ -8,7 +8,6 @@
 //-----------------------------------------------------------------------------\r
 // Work with mifare cards.\r
 //-----------------------------------------------------------------------------\r
-\r
 #include "mifareutil.h"\r
 \r
 int MF_DBGLEVEL = MF_DBG_ALL;\r
@@ -277,7 +276,7 @@ int mifare_ultra_auth(uint8_t *keybytes){
        memcpy(enc_random_b,resp+1,8);\r
 \r
        // decrypt nonce.\r
-       tdes_2key_dec(random_b, enc_random_b, sizeof(random_b), key, IV );\r
+       tdes_2key_dec((void*)random_b, (void*)enc_random_b, sizeof(random_b), (const void*)key, IV );\r
        rol(random_b,8);\r
        memcpy(rnd_ab  ,random_a,8);\r
        memcpy(rnd_ab+8,random_b,8);\r
index f59ab8068e1fe04c83f8d1d867bbd1953631b925..041da2126f0e0928499665c1aaf6e50696e78174 100644 (file)
 #ifndef __MIFAREUTIL_H\r
 #define __MIFAREUTIL_H\r
 \r
-\r
 #include "proxmark3.h"\r
 #include "apps.h"\r
+#include "parity.h"\r
 #include "util.h"\r
 #include "string.h"\r
 #include "iso14443crc.h"\r
 #include "iso14443a.h"\r
 #include "crapto1.h"\r
-#include "parity.h"\r
-//#include "des.h"\r
+#include "des.h"\r
 \r
 // mifare authentication\r
 #define CRYPT_NONE    0\r
 #define AUTH_FIRST    0        \r
 #define AUTH_NESTED   2\r
 \r
-// reader voltage field detector\r
-#define MF_MINFIELDV      4000\r
-\r
-// debug\r
-// 0 - no debug messages 1 - error messages 2 - all messages 4 - extended debug mode\r
-#define MF_DBG_NONE          0\r
-#define MF_DBG_ERROR         1\r
-#define MF_DBG_ALL           2\r
-#define MF_DBG_EXTENDED      4\r
-\r
-extern int MF_DBGLEVEL;\r
-\r
 //mifare emulator states\r
 #define MFEMUL_NOFIELD      0\r
 #define MFEMUL_IDLE         1\r
index f1e58ab0ed9359e80714c4be2fd146494b9fa4d4..d2e4ed4c4acad81b1e895abab674c8eed8f7109c 100644 (file)
@@ -9,6 +9,9 @@
 // with the linker script.
 //-----------------------------------------------------------------------------
 
+#ifndef __START_H
+#define __START_H
+
 #include "proxmark3.h"
 #include "apps.h"
 #include "zlib.h"
@@ -18,7 +21,6 @@ static uint8_t *next_free_memory;
 extern struct common_area common_area;
 extern char __data_src_start__, __data_start__, __data_end__, __bss_start__, __bss_end__;
 
-
 static voidpf inflate_malloc(voidpf opaque, uInt items, uInt size)
 {
        uint8_t *allocated_memory;
@@ -28,11 +30,9 @@ static voidpf inflate_malloc(voidpf opaque, uInt items, uInt size)
        return allocated_memory;
 }
 
-
 static void inflate_free(voidpf opaque, voidpf address)
 {
        // nothing to do
-       
 }
 
 static void uncompress_data_section(void)
@@ -60,7 +60,6 @@ static void uncompress_data_section(void)
        common_area.arg1 = data_section.total_in;
 }
 
-
 void __attribute__((section(".startos"))) Vector(void)
 {
        /* Stack should have been set up by the bootloader */
@@ -80,6 +79,6 @@ void __attribute__((section(".startos"))) Vector(void)
        // end = &__data_end__;
        // while(dst < end) *dst++ = *src++;
 
-
        AppMain();
 }
+#endif
\ No newline at end of file
index 10c056559411e43d96114943650836cac9021876..cef643576b4eaf26c0b323d2cdf14bd0a8bca4ae 100644 (file)
@@ -9,28 +9,6 @@
 //-----------------------------------------------------------------------------
 #include "util.h"
 
-void print_result(char *name, uint8_t *buf, size_t len) {
-       uint8_t *p = buf;
-
-       if ( len % 16 == 0 ) {
-               for(; p-buf < len; p += 16)
-                       Dbprintf("[%s:%d/%d] %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x",
-                               name,
-                               p-buf,
-                               len,
-                               p[0], p[1], p[2], p[3], p[4], p[5], p[6], p[7],p[8], p[9], p[10], p[11], p[12], p[13], p[14], p[15]
-                       );
-       }
-       else {
-               for(; p-buf < len; p += 8)
-                       Dbprintf("[%s:%d/%d] %02x %02x %02x %02x %02x %02x %02x %02x",
-                               name,
-                               p-buf,
-                               len,
-                               p[0], p[1], p[2], p[3], p[4], p[5], p[6], p[7]);
-       }
-}
-
 size_t nbytes(size_t nbits) {
        return (nbits >> 3)+((nbits % 8) > 0);
 }
index d323529226e71993d9518e2a1dd97264a1b30d1f..12840d6b009dca05fce3fe42eaa9e199f152ace3 100644 (file)
 #ifndef __UTIL_H
 #define __UTIL_H
 
-#include <stddef.h>
-#include <stdint.h>
 #include "common.h"
+#include "proxmark3.h"
 #include "string.h"
-#include "apps.h"
 #include "BigBuf.h"
-#include "proxmark3.h"
 #include "ticks.h"
 
 #define BYTEx(x, n) (((x) >> (n * 8)) & 0xff )
@@ -42,7 +39,6 @@
 # define ARRAYLEN(x) (sizeof(x)/sizeof((x)[0]))
 #endif
 
-void print_result(char *name, uint8_t *buf, size_t len);
 size_t nbytes(size_t nbits);
 uint32_t SwapBits(uint32_t value, int nrbits);
 uint32_t reflect(uint32_t v, int b);
index 2a67bd879c360c3c9363cfc26b098cdc697396d2..3a253b9ca078e600339ed648284ffbfa7746c60c 100644 (file)
 #include <at91sam7s512.h>
 typedef unsigned char byte_t;
 
+// debug
+// 0 - no debug messages 1 - error messages 2 - all messages 4 - extended debug mode
+#define MF_DBG_NONE          0
+#define MF_DBG_ERROR         1
+#define MF_DBG_ALL           2
+#define MF_DBG_EXTENDED      4
+extern int MF_DBGLEVEL;
+
+// reader voltage field detector
+#define MF_MINFIELDV      4000
+
+
 #ifndef MIN
 # define MIN(a, b) (((a) < (b)) ? (a) : (b))
 #endif
Impressum, Datenschutz