]> cvs.zerfleddert.de Git - proxmark3-svn/commitdiff
ADD: some defines to make headerfiles behave better.
authoriceman1001 <iceman@iuse.se>
Thu, 26 Jan 2017 13:23:05 +0000 (14:23 +0100)
committericeman1001 <iceman@iuse.se>
Thu, 26 Jan 2017 13:23:05 +0000 (14:23 +0100)
CHG: syntax sugar

armsrc/aes.h
armsrc/optimized_cipher.c
client/cmdhfmfdes.h
client/lualibs/read14a.lua
client/mifarehost.h
client/ui.c
client/util.h

index 8594487355663a592d3b7c9c54e5abc0a23ad752..6934d690cee7b664bf0c0f988975d17cc75e9d62 100644 (file)
@@ -3,6 +3,8 @@
 * your source which uses these given APIs. (This source is kept under
 * public domain)
 */
+#ifndef __AES_H
+#define __AES_H
 
 // AES context structure
 typedef struct {
@@ -27,4 +29,6 @@ typedef struct {
 
 int AesCtxIni(AesCtx *pCtx, unsigned char *pIV, unsigned char *pKey, unsigned int KeyLen, unsigned char Mode);
 int AesEncrypt(AesCtx *pCtx, unsigned char *pData, unsigned char *pCipher, unsigned int DataLen);
-int AesDecrypt(AesCtx *pCtx, unsigned char *pCipher, unsigned char *pData, unsigned int CipherLen);
\ No newline at end of file
+int AesDecrypt(AesCtx *pCtx, unsigned char *pCipher, unsigned char *pData, unsigned int CipherLen);
+
+#endif
\ No newline at end of file
index 285403ab8beba30a41dabe9436a86b57c2d3890c..8557a21d6fe489e2005b82eb399ecc88b08dbbbd 100644 (file)
@@ -98,7 +98,6 @@ uint8_t xopt__select(bool x, bool y, uint8_t r)
 
 void opt_successor(const uint8_t* k, State *s, bool y, State* successor)
 {
-
        uint8_t Tt = 1 & opt_T(s);
 
        successor->t = (s->t >> 1);
@@ -212,26 +211,26 @@ void opt_doReaderMAC(uint8_t *cc_nr_p, uint8_t *div_key_p, uint8_t mac[4])
 {
        static uint8_t cc_nr[12];
 
-       opt_reverse_arraybytecpy(cc_nr, cc_nr_p,12);
+       opt_reverse_arraybytecpy(cc_nr, cc_nr_p, 12);
        uint8_t dest []= {0,0,0,0,0,0,0,0};
-       opt_MAC(div_key_p,cc_nr, dest);
+       opt_MAC(div_key_p, cc_nr, dest);
        //The output MAC must also be reversed
-       opt_reverse_arraybytecpy(mac, dest,4);
+       opt_reverse_arraybytecpy(mac, dest, 4);
        return;
 }
 void opt_doTagMAC(uint8_t *cc_p, const uint8_t *div_key_p, uint8_t mac[4])
 {
        static uint8_t cc_nr[8+4+4];
-       opt_reverse_arraybytecpy(cc_nr, cc_p,12);
+       opt_reverse_arraybytecpy(cc_nr, cc_p, 12);
        State _init  =  {
                        ((div_key_p[0] ^ 0x4c) + 0xEC) & 0xFF,// l
                        ((div_key_p[0] ^ 0x4c) + 0x21) & 0xFF,// r
                        0x4c, // b
                        0xE012 // t
                        };
-       opt_suc(div_key_p,&_init,cc_nr, 12,true);
+       opt_suc(div_key_p, &_init, cc_nr, 12, true);
        uint8_t dest []= {0,0,0,0};
-       opt_output(div_key_p,&_init, dest);
+       opt_output(div_key_p, &_init, dest);
        //The output MAC must also be reversed
        opt_reverse_arraybytecpy(mac, dest,4);
        return;
@@ -248,14 +247,14 @@ void opt_doTagMAC(uint8_t *cc_p, const uint8_t *div_key_p, uint8_t mac[4])
 State opt_doTagMAC_1(uint8_t *cc_p, const uint8_t *div_key_p)
 {
        static uint8_t cc_nr[8];
-       opt_reverse_arraybytecpy(cc_nr, cc_p,8);
+       opt_reverse_arraybytecpy(cc_nr, cc_p, 8);
        State _init  =  {
                        ((div_key_p[0] ^ 0x4c) + 0xEC) & 0xFF,// l
                        ((div_key_p[0] ^ 0x4c) + 0x21) & 0xFF,// r
                        0x4c, // b
                        0xE012 // t
                        };
-       opt_suc(div_key_p,&_init,cc_nr, 8,false);
+       opt_suc(div_key_p, &_init, cc_nr, 8, false);
        return _init;
 }
 /**
@@ -271,10 +270,10 @@ void opt_doTagMAC_2(State _init,  uint8_t* nr, uint8_t mac[4], const uint8_t* di
 {
        static uint8_t _nr [4];
        opt_reverse_arraybytecpy(_nr, nr, 4);
-       opt_suc(div_key_p,&_init,_nr, 4, true);
-       //opt_suc(div_key_p,&_init,nr, 4, false);
+       opt_suc(div_key_p, &_init,_nr, 4, true);
+       //opt_suc(div_key_p, &_init,nr, 4, false);
        uint8_t dest []= {0,0,0,0};
-       opt_output(div_key_p,&_init, dest);
+       opt_output(div_key_p, &_init, dest);
        //The output MAC must also be reversed
        opt_reverse_arraybytecpy(mac, dest,4);
        return;
index 5979113d83929b23a0b9c3f781db17301133f2df..18594075c8486eb2f1a015b1ff5f4262d6fe13bd 100644 (file)
@@ -1,5 +1,5 @@
 //-----------------------------------------------------------------------------
-// Copyright (C) 2014 Iceman
+// Iceman, 2014
 //
 // This code is licensed to you under the terms of the GNU GPL, version 2 or,
 // at your option, any later version. See the LICENSE.txt file for the text of
@@ -7,6 +7,8 @@
 //-----------------------------------------------------------------------------
 // High frequency MIFARE Desfire commands
 //-----------------------------------------------------------------------------
+#ifndef __MFDESFIRE_H
+#define __MFDESFIRE_H
 
 int CmdHFMFDes(const char *Cmd);
 int CmdHF14ADesAuth(const char* cmd);
@@ -30,42 +32,42 @@ enum  {
 } CmdOptions ;
 
 
-#define  CREATE_APPLICATION                     0xca
-#define  DELETE_APPLICATION                     0xda
-#define  GET_APPLICATION_IDS                    0x6a
-#define      SELECT_APPLICATION                 0x5a
-#define      FORMAT_PICC                                0xfc
-#define      GET_VERSION                                0x60
-#define      READ_DATA                                          0xbd
-#define      WRITE_DATA                                         0x3d
-#define      GET_VALUE                                          0x6c
-#define      CREDIT                                     0x0c
-#define      DEBIT                                              0xdc
-#define      LIMITED_CREDIT                     0x1c
-#define      WRITE_RECORD                               0x3b
-#define      READ_RECORDS                               0xbb
-#define     CLEAR_RECORD_FILE                   0xeb
-#define      COMMIT_TRANSACTION                 0xc7
-#define      ABORT_TRANSACTION                          0xa7
-#define      GET_FREE_MEMORY             0x6e
-#define        GET_FILE_IDS                             0x6f
-#define        GET_ISOFILE_IDS                          0x61
-#define     GET_FILE_SETTINGS                   0xf5
-#define     CHANGE_FILE_SETTINGS                0x5f
-#define     CREATE_STD_DATA_FILE                0xcd
-#define     CREATE_BACKUP_DATA_FILE     0xcb
-#define     CREATE_VALUE_FILE                   0xcc
-#define     CREATE_LINEAR_RECORD_FILE   0xc1
-#define     CREATE_CYCLIC_RECORD_FILE   0xc0
-#define     DELETE_FILE                                 0xdf
-#define     AUTHENTICATE                                0x0a  // AUTHENTICATE_NATIVE
-#define        AUTHENTICATE_ISO                         0x1a  // AUTHENTICATE_STANDARD
-#define        AUTHENTICATE_AES                         0xaa
-#define     CHANGE_KEY_SETTINGS                 0x54
-#define     GET_KEY_SETTINGS                    0x45
-#define     CHANGE_KEY                                          0xc4
-#define     GET_KEY_VERSION                     0x64
-#define     AUTHENTICATION_FRAME                0xAF
+#define  CREATE_APPLICATION             0xca
+#define  DELETE_APPLICATION             0xda
+#define  GET_APPLICATION_IDS            0x6a
+#define  SELECT_APPLICATION             0x5a
+#define  FORMAT_PICC                            0xfc
+#define  GET_VERSION                            0x60
+#define  READ_DATA                                      0xbd
+#define  WRITE_DATA                                     0x3d
+#define  GET_VALUE                                      0x6c
+#define  CREDIT                                         0x0c
+#define  DEBIT                                                  0xdc
+#define  LIMITED_CREDIT                         0x1c
+#define  WRITE_RECORD                           0x3b
+#define  READ_RECORDS                           0xbb
+#define  CLEAR_RECORD_FILE                      0xeb
+#define  COMMIT_TRANSACTION             0xc7
+#define  ABORT_TRANSACTION                      0xa7
+#define  GET_FREE_MEMORY             0x6e
+#define  GET_FILE_IDS                           0x6f
+#define  GET_ISOFILE_IDS                        0x61
+#define  GET_FILE_SETTINGS                      0xf5
+#define  CHANGE_FILE_SETTINGS           0x5f
+#define  CREATE_STD_DATA_FILE           0xcd
+#define  CREATE_BACKUP_DATA_FILE        0xcb
+#define  CREATE_VALUE_FILE                      0xcc
+#define  CREATE_LINEAR_RECORD_FILE      0xc1
+#define  CREATE_CYCLIC_RECORD_FILE      0xc0
+#define  DELETE_FILE                            0xdf
+#define  AUTHENTICATE                           0x0a  // AUTHENTICATE_NATIVE
+#define  AUTHENTICATE_ISO                       0x1a  // AUTHENTICATE_STANDARD
+#define  AUTHENTICATE_AES                       0xaa
+#define  CHANGE_KEY_SETTINGS            0x54
+#define  GET_KEY_SETTINGS                       0x45
+#define  CHANGE_KEY                             0xc4
+#define  GET_KEY_VERSION                        0x64
+#define  AUTHENTICATION_FRAME           0xAF
 
 #define MAX_NUM_KEYS 0x0F
 #define MAX_APPLICATION_COUNT 28
@@ -108,8 +110,7 @@ enum  {
 #define COMMAND_ABORTED                        0xCA            // Previous Command was not fully
                                                                                        //  completed Not all Frames were
                                                                                        //  requested or provided by PCD
-#define PICC_DISABLED_ERROR            0xCD // [1] // PICC was disabled by an unre-
-                                                                                       //  coverable error
+#define PICC_DISABLED_ERROR            0xCD // [1] // PICC was disabled by an unrecoverable error
 #define COUNT_ERROR                            0xCE            // Number of Applications limited
                                                                                        //  to 28, no additional
                                                                                        //  CreateApplication possible
@@ -125,4 +126,6 @@ enum  {
 #define FILE_INTEGRITY_ERROR   0xF1 // [1]     // Unrecoverable error within file,
                                                                                        //  file will be disabled
 //
-// [1] These errors are not expected to appear during normal operation.        |
\ No newline at end of file
+// [1] These errors are not expected to appear during normal operation
+
+#endif
\ No newline at end of file
index 8d2d431fb2c272027519aadc498b7ffa0a2815ef..5134fa94180f08ca477905a893c59c6f4cdc3bda 100644 (file)
@@ -86,7 +86,7 @@ local function sendToDevice(command, ignoreresponse)
        end
        if ignoreresponse then return nil,nil end
 
-       local response = core.WaitForResponseTimeout(cmds.CMD_ACK,TIMEOUT)
+       local response = core.WaitForResponseTimeout(cmds.CMD_ACK, TIMEOUT)
        return response,nil
 end
 
index 754cc4839eb5e4a367c7ef85c1309149d245ecc9..4f6b984a9026e3dd77bec23ef0f9246699e277bb 100644 (file)
@@ -7,6 +7,8 @@
 //-----------------------------------------------------------------------------\r
 // High frequency ISO14443A commands\r
 //-----------------------------------------------------------------------------\r
+#ifndef __MIFARE_HOST_H\r
+#define __MIFARE_HOST_H\r
 \r
 #include <stdio.h>\r
 #include <stdlib.h>\r
 #include <pthread.h>\r
 \r
 #include "proxmark3.h" // time_t\r
-//#include "radixsort.h"\r
 #include "common.h"\r
 #include "cmdmain.h"\r
 #include "ui.h"\r
 #include "data.h"\r
 #include "util.h"\r
-//#include "nonce2key/nonce2key.h"\r
 #include "nonce2key/crapto1.h"\r
 #include "iso14443crc.h"\r
 #include "protocols.h"\r
@@ -84,3 +84,4 @@ int isBlockTrailer(int blockN);
 int loadTraceCard(uint8_t *tuid, uint8_t uidlen);\r
 int saveTraceCard(void);\r
 int tryDecryptWord(uint32_t nt, uint32_t ar_enc, uint32_t at_enc, uint8_t *data, int len);\r
+#endif
\ No newline at end of file
index 6819f649f0b47b3f0ad398f5ae61c0801007b72c..87fede08d149b0f3afe30ead07d88b48d7ff4968 100644 (file)
@@ -25,7 +25,10 @@ void PrintAndLog(char *fmt, ...)
        va_list argptr, argptr2;
        static FILE *logfile = NULL;
        static int logging = 1;
-
+       // time_t current_time;
+       // struct tm* tm_info;
+       // char buffer[26] = {0};
+               
        // lock this section to avoid interlacing prints from different threats
        pthread_mutex_lock(&print_lock);
   
@@ -63,6 +66,16 @@ void PrintAndLog(char *fmt, ...)
        }
        
        if (logging && logfile) {
+
+               /*
+               // Obtain current time.
+               current_time = time(NULL);
+               // Convert to local time format.
+               tm_info = localtime(&current_time);             
+               strftime(buffer, 26, "%Y-%m-%d %H:%M:%S", tm_info);
+               fprintf(logfile, "%s  ", buffer);
+               */
+               
                vfprintf(logfile, fmt, argptr2);
                fprintf(logfile,"\n");
                fflush(logfile);
index b158ec0aa6c02b4647cc31ca8221a05564fbd76d..593c9af7f7207effa056227b9a847f10d295a07b 100644 (file)
@@ -7,6 +7,8 @@
 //-----------------------------------------------------------------------------
 // utilities
 //-----------------------------------------------------------------------------
+#ifndef __UTIL_H_
+#define __UTIL_H_
 
 #include <stdio.h>
 #include <stdint.h>            //included in data.h
@@ -140,4 +142,6 @@ uint32_t PackBits(uint8_t start, uint8_t len, uint8_t* bits);
 void rol(uint8_t *data, const size_t len);
 uint32_t SwapBits(uint32_t value, int nrbits);
 uint32_t reflect(uint32_t v, int b);
-uint64_t HornerScheme(uint64_t num, uint64_t divider, uint64_t factor);
\ No newline at end of file
+uint64_t HornerScheme(uint64_t num, uint64_t divider, uint64_t factor);
+
+#endif
\ No newline at end of file
Impressum, Datenschutz