tk_schedule.h 765 Bytes
Newer Older
Alexandre Adomnicai committed
1 2 3
#ifndef TK_SCHEDULE_H_
#define TK_SCHEDULE_H_

Alexandre Adomnicai committed
4 5 6
#include <stdint.h>
typedef uint8_t 	u8;
typedef uint32_t 	u32;
Alexandre Adomnicai committed
7 8 9 10 11 12

void packing(u32* out, const u8* in);
void unpacking(u8* out, u32 *in);
void precompute_rtk2_3(u32* rtk, const u8* tk2, const u8* tk3);
void precompute_rtk1(u32* rtk1, const u8* tk1);

Alexandre Adomnicai committed
13
#define ROR(x,y) 	(((x) >> (y)) | ((x) << (32 - (y))))
Alexandre Adomnicai committed
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33
	
#define SWAPMOVE(a, b, mask, n)	({	\
	tmp = (b ^ (a >> n)) & mask;	\
	b ^= tmp;						\
	a ^= (tmp << n);				\
})

#define LE_LOAD(x, y) 				\
	*(x) = (((u32)(y)[3] << 24) | 	\
		((u32)(y)[2] << 16) 	| 	\
		((u32)(y)[1] << 8) 		| 	\
		(y)[0]);

#define LE_STORE(x, y)				\
	(x)[0] = (y) & 0xff; 			\
	(x)[1] = ((y) >> 8) & 0xff; 	\
	(x)[2] = ((y) >> 16) & 0xff; 	\
	(x)[3] = (y) >> 24;

#endif  // TK_SCHEDULE_H_