hf mf fchk - output style
[RRG-proxmark3.git] / tools / hitag2crack / common / ht2crackutils.h
blob1ce71af1d87e43700301a94ed55ba835f8ed6ef8
1 #ifndef HT2CRACKUTILS_H
2 #define HT2CRACKUTILS_H
4 #include <stdio.h>
5 #include <stdlib.h>
6 #include <stdint.h>
7 #include <unistd.h>
8 #include <string.h>
9 #ifndef __MINGW64__
10 # include <sys/mman.h>
11 #endif
12 #include <sys/types.h>
13 #include <sys/stat.h>
14 #include <fcntl.h>
15 #include <pthread.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);
28 int fnR(uint64_t x);
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);
33 int fnf(uint64_t s);
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 */