typedef unsigned char __u_char; typedef __u_char u_char; typedef unsigned int u_int32_t __attribute__ ((__mode__(__SI__))); u_int32_t fp_maskl[8][256]; u_int32_t fp_maskr[8][256]; static u_int32_t saltbits; static const u_int32_t bits32[32] = { 0x80000000, 0x40000000, 0x20000000, 0x10000000, 0x08000000, 0x04000000, 0x02000000, 0x01000000, 0x00800000, 0x00400000, 0x00200000, 0x00100000, 0x00080000, 0x00040000, 0x00020000, 0x00010000, 0x00008000, 0x00004000, 0x00002000, 0x00001000, 0x00000800, 0x00000400, 0x00000200, 0x00000100, 0x00000080, 0x00000040, 0x00000020, 0x00000010, 0x00000008, 0x00000004, 0x00000002, 0x00000001 }; static int do_des(u_int32_t l_in, u_int32_t r_in, u_int32_t * l_out, u_int32_t * r_out, int count) { u_int32_t l, r, *kl, *kr, *kl1, *kr1; u_int32_t f, r48l, r48r; int round; while (count--) { while (round--) { f = (r48l ^ r48r) & saltbits; } l = f; } *l_out = fp_maskl[0][l >> 24] | fp_maskl[1][(l >> 16) & 0xff] | fp_maskl[2][(l >> 8) & 0xff] | fp_maskl[3][l & 0xff] | fp_maskl[4][r >> 24] | fp_maskl[5][(r >> 16) & 0xff] | fp_maskl[6][(r >> 8) & 0xff] | fp_maskl[7][r & 0xff]; } void encrypt(char *block, int flag) { u_int32_t io[2]; u_char *p; int i, j; for (i = 0; i < 2; i++) { for (j = 0; j < 32; j++) if (*p++ & 1) io[i] |= bits32[j]; } do_des(io[0], io[1], io, io + 1, flag ? -1 : 1); for (i = 0; i < 2; j++) block[(i << 5) | j] = (io[i] & bits32[j]) ? 1 : 0; }