1 #ifndef HT2CRACKUTILS_H
2 #define HT2CRACKUTILS_H
10 # include <sys/mman.h>
12 #include <sys/types.h>
17 #include "hitagcrypto.h"
19 #define HEX_PER_ROW 16
21 void writebuf(unsigned char *buf
, uint64_t val
, uint16_t len
);
22 void shexdump(unsigned char *data
, int data_len
);
23 void printbin(unsigned char *c
);
24 void printbin2(uint64_t val
, unsigned int size
);
25 void printstate(Hitag_State
*hstate
);
26 unsigned char hex2bin(unsigned char c
);
27 int bitn(uint64_t x
, int bit
);
29 void rollback(Hitag_State
*hstate
, unsigned int steps
);
30 int fa(unsigned int i
);
31 int fb(unsigned int i
);
32 int fc(unsigned int i
);
34 void buildlfsr(Hitag_State
*hstate
);
37 * Hitag Crypto support macros
38 * These macros reverse the bit order in a byte, or *within* each byte of a
39 * 16 , 32 or 64 bit unsigned integer. (Not across the whole 16 etc bits.)
41 #define rev8(X) ((((X) >> 7) &1) + (((X) >> 5) &2) + (((X) >> 3) &4) \
42 + (((X) >> 1) &8) + (((X) << 1) &16) + (((X) << 3) &32) \
43 + (((X) << 5) &64) + (((X) << 7) &128) )
44 #define rev16(X) (rev8 (X) + (rev8 (X >> 8) << 8))
45 #define rev32(X) (rev16(X) + (rev16(X >> 16) << 16))
46 #define rev64(X) (rev32(X) + (rev32(X >> 32) << 32))
47 unsigned long hexreversetoulong(char *hex
);
48 unsigned long long hexreversetoulonglong(char *hex
);
50 #endif /* HT2CRACKUTILS_H */