]> git.wh0rd.org - ICEs.git/blame - not-unused/des.i.1
more
[ICEs.git] / not-unused / des.i.1
CommitLineData
45516216 1typedef unsigned char __u_char;
2typedef __u_char u_char;
3typedef unsigned int u_int32_t __attribute__ ((__mode__(__SI__)));
4u_int32_t fp_maskl[8][256];
5u_int32_t fp_maskr[8][256];
6static u_int32_t saltbits;
7static const u_int32_t bits32[32] = {
8 0x80000000, 0x40000000, 0x20000000, 0x10000000, 0x08000000, 0x04000000,
9 0x02000000, 0x01000000, 0x00800000, 0x00400000, 0x00200000,
10 0x00100000, 0x00080000, 0x00040000, 0x00020000, 0x00010000,
11 0x00008000, 0x00004000, 0x00002000, 0x00001000, 0x00000800,
12 0x00000400, 0x00000200, 0x00000100, 0x00000080, 0x00000040,
13 0x00000020, 0x00000010, 0x00000008, 0x00000004, 0x00000002,
14 0x00000001
15};
16static int do_des(u_int32_t l_in, u_int32_t r_in, u_int32_t * l_out,
17 u_int32_t * r_out, int count)
18{
19 u_int32_t l, r, *kl, *kr, *kl1, *kr1;
20 u_int32_t f, r48l, r48r;
21 int round;
22 while (count--) {
23 while (round--) {
24 f = (r48l ^ r48r) & saltbits;
25 }
26 l = f;
27 }
28 *l_out =
29 fp_maskl[0][l >> 24] | fp_maskl[1][(l >> 16) & 0xff] |
30 fp_maskl[2][(l >> 8) & 0xff] | fp_maskl[3][l & 0xff] | fp_maskl[4][r
31 >>
32 24]
33 | fp_maskl[5][(r >> 16) & 0xff] | fp_maskl[6][(r >> 8) & 0xff] |
34 fp_maskl[7][r & 0xff];
35}
36void encrypt(char *block, int flag)
37{
38 u_int32_t io[2];
39 u_char *p;
40 int i, j;
41 for (i = 0; i < 2; i++) {
42 for (j = 0; j < 32; j++)
43 if (*p++ & 1)
44 io[i] |= bits32[j];
45 }
46 do_des(io[0], io[1], io, io + 1, flag ? -1 : 1);
47 for (i = 0; i < 2; j++)
48 block[(i << 5) | j] = (io[i] & bits32[j]) ? 1 : 0;
49}