ADD: some defines to make headerfiles behave better.

CHG: syntax sugar
This commit is contained in:
iceman1001 2017-01-26 14:23:05 +01:00
commit 2d3f8e5fa7
7 changed files with 82 additions and 58 deletions

View file

@ -3,6 +3,8 @@
* your source which uses these given APIs. (This source is kept under * your source which uses these given APIs. (This source is kept under
* public domain) * public domain)
*/ */
#ifndef __AES_H
#define __AES_H
// AES context structure // AES context structure
typedef struct { typedef struct {
@ -28,3 +30,5 @@ typedef struct {
int AesCtxIni(AesCtx *pCtx, unsigned char *pIV, unsigned char *pKey, unsigned int KeyLen, unsigned char Mode); 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 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); int AesDecrypt(AesCtx *pCtx, unsigned char *pCipher, unsigned char *pData, unsigned int CipherLen);
#endif

View 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) void opt_successor(const uint8_t* k, State *s, bool y, State* successor)
{ {
uint8_t Tt = 1 & opt_T(s); uint8_t Tt = 1 & opt_T(s);
successor->t = (s->t >> 1); successor->t = (s->t >> 1);

View 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, // 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 // at your option, any later version. See the LICENSE.txt file for the text of
@ -7,6 +7,8 @@
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
// High frequency MIFARE Desfire commands // High frequency MIFARE Desfire commands
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
#ifndef __MFDESFIRE_H
#define __MFDESFIRE_H
int CmdHFMFDes(const char *Cmd); int CmdHFMFDes(const char *Cmd);
int CmdHF14ADesAuth(const char* cmd); int CmdHF14ADesAuth(const char* cmd);
@ -108,8 +110,7 @@ enum {
#define COMMAND_ABORTED 0xCA // Previous Command was not fully #define COMMAND_ABORTED 0xCA // Previous Command was not fully
// completed Not all Frames were // completed Not all Frames were
// requested or provided by PCD // requested or provided by PCD
#define PICC_DISABLED_ERROR 0xCD // [1] // PICC was disabled by an unre- #define PICC_DISABLED_ERROR 0xCD // [1] // PICC was disabled by an unrecoverable error
// coverable error
#define COUNT_ERROR 0xCE // Number of Applications limited #define COUNT_ERROR 0xCE // Number of Applications limited
// to 28, no additional // to 28, no additional
// CreateApplication possible // CreateApplication possible
@ -125,4 +126,6 @@ enum {
#define FILE_INTEGRITY_ERROR 0xF1 // [1] // Unrecoverable error within file, #define FILE_INTEGRITY_ERROR 0xF1 // [1] // Unrecoverable error within file,
// file will be disabled // file will be disabled
// //
// [1] These errors are not expected to appear during normal operation. | // [1] These errors are not expected to appear during normal operation
#endif

View file

@ -7,6 +7,8 @@
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
// High frequency ISO14443A commands // High frequency ISO14443A commands
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
#ifndef __MIFARE_HOST_H
#define __MIFARE_HOST_H
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
@ -15,13 +17,11 @@
#include <pthread.h> #include <pthread.h>
#include "proxmark3.h" // time_t #include "proxmark3.h" // time_t
//#include "radixsort.h"
#include "common.h" #include "common.h"
#include "cmdmain.h" #include "cmdmain.h"
#include "ui.h" #include "ui.h"
#include "data.h" #include "data.h"
#include "util.h" #include "util.h"
//#include "nonce2key/nonce2key.h"
#include "nonce2key/crapto1.h" #include "nonce2key/crapto1.h"
#include "iso14443crc.h" #include "iso14443crc.h"
#include "protocols.h" #include "protocols.h"
@ -84,3 +84,4 @@ int isBlockTrailer(int blockN);
int loadTraceCard(uint8_t *tuid, uint8_t uidlen); int loadTraceCard(uint8_t *tuid, uint8_t uidlen);
int saveTraceCard(void); int saveTraceCard(void);
int tryDecryptWord(uint32_t nt, uint32_t ar_enc, uint32_t at_enc, uint8_t *data, int len); int tryDecryptWord(uint32_t nt, uint32_t ar_enc, uint32_t at_enc, uint8_t *data, int len);
#endif

View file

@ -25,6 +25,9 @@ void PrintAndLog(char *fmt, ...)
va_list argptr, argptr2; va_list argptr, argptr2;
static FILE *logfile = NULL; static FILE *logfile = NULL;
static int logging = 1; 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 // lock this section to avoid interlacing prints from different threats
pthread_mutex_lock(&print_lock); pthread_mutex_lock(&print_lock);
@ -63,6 +66,16 @@ void PrintAndLog(char *fmt, ...)
} }
if (logging && logfile) { 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); vfprintf(logfile, fmt, argptr2);
fprintf(logfile,"\n"); fprintf(logfile,"\n");
fflush(logfile); fflush(logfile);

View file

@ -7,6 +7,8 @@
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
// utilities // utilities
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
#ifndef __UTIL_H_
#define __UTIL_H_
#include <stdio.h> #include <stdio.h>
#include <stdint.h> //included in data.h #include <stdint.h> //included in data.h
@ -141,3 +143,5 @@ void rol(uint8_t *data, const size_t len);
uint32_t SwapBits(uint32_t value, int nrbits); uint32_t SwapBits(uint32_t value, int nrbits);
uint32_t reflect(uint32_t v, int b); uint32_t reflect(uint32_t v, int b);
uint64_t HornerScheme(uint64_t num, uint64_t divider, uint64_t factor); uint64_t HornerScheme(uint64_t num, uint64_t divider, uint64_t factor);
#endif