2015-12-04 14:47:52 +00:00
|
|
|
/**
|
|
|
|
* Author......: Jens Steube <jens.steube@gmail.com>
|
|
|
|
* License.....: MIT
|
|
|
|
*/
|
|
|
|
|
2016-09-06 16:44:05 +00:00
|
|
|
#ifndef _CPU_DES_H
|
|
|
|
#define _CPU_DES_H
|
2016-09-05 19:47:26 +00:00
|
|
|
|
|
|
|
#define PERM_OP(a,b,tt,n,m) \
|
|
|
|
{ \
|
|
|
|
tt = a >> n; \
|
|
|
|
tt = tt ^ b; \
|
|
|
|
tt = tt & m; \
|
|
|
|
b = b ^ tt; \
|
|
|
|
tt = tt << n; \
|
|
|
|
a = a ^ tt; \
|
|
|
|
}
|
|
|
|
|
|
|
|
#define HPERM_OP(a,tt,n,m) \
|
|
|
|
{ \
|
|
|
|
tt = a << (16 + n); \
|
|
|
|
tt = tt ^ a; \
|
|
|
|
tt = tt & m; \
|
|
|
|
a = a ^ tt; \
|
|
|
|
tt = tt >> (16 + n); \
|
|
|
|
a = a ^ tt; \
|
|
|
|
}
|
|
|
|
|
|
|
|
#define IP(l,r,tt) \
|
|
|
|
{ \
|
|
|
|
PERM_OP (r, l, tt, 4, 0x0f0f0f0f); \
|
|
|
|
PERM_OP (l, r, tt, 16, 0x0000ffff); \
|
|
|
|
PERM_OP (r, l, tt, 2, 0x33333333); \
|
|
|
|
PERM_OP (l, r, tt, 8, 0x00ff00ff); \
|
|
|
|
PERM_OP (r, l, tt, 1, 0x55555555); \
|
|
|
|
}
|
|
|
|
|
|
|
|
#define FP(l,r,tt) \
|
|
|
|
{ \
|
|
|
|
PERM_OP (l, r, tt, 1, 0x55555555); \
|
|
|
|
PERM_OP (r, l, tt, 8, 0x00ff00ff); \
|
|
|
|
PERM_OP (l, r, tt, 2, 0x33333333); \
|
|
|
|
PERM_OP (r, l, tt, 16, 0x0000ffff); \
|
|
|
|
PERM_OP (l, r, tt, 4, 0x0f0f0f0f); \
|
|
|
|
}
|
|
|
|
|
2016-09-06 13:28:56 +00:00
|
|
|
void _des_keysetup (u32 data[2], u32 Kc[16], u32 Kd[16]);
|
|
|
|
void _des_encrypt (u32 data[2], u32 Kc[16], u32 Kd[16]);
|
2016-09-06 16:44:05 +00:00
|
|
|
|
|
|
|
#endif // _CPU_DES_H
|