2 * Copyright 1987, 1988 by the Massachusetts Institute of Technology.
4 * For copying and distribution information, please see the file
7 * This routine generates source code implementing the initial
8 * permutation of the DES.
11 #include <mit-cpyright.h>
13 #include "des_internal.h"
18 extern afs_int32 swap_bit_pos_0();
19 extern afs_int32 rev_swap_bit_pos_0();
20 extern void test_set PROTOTYPE((FILE *, char const *, int,
22 extern int swap_long_bytes_bit_number(int);
23 extern int swap_bit_pos_0_to_ansi(int);
25 #define SWAP(x) swap_long_bytes_bit_number(swap_bit_pos_0_to_ansi(x))
32 /* clear the output */
33 fprintf(stream," L2 = 0; R2 = 0;\n");
36 fprintf(stream,"/* IP operations */\n/* first left to left */\n");
38 /* first list mapping from left to left */
39 for (i = 0; i <= 31; i++)
41 test_set(stream, "L1", SWAP(IP[i]), "L2", i);
43 /* now mapping from right to left */
44 fprintf(stream,"\n/* now from right to left */\n");
45 for (i = 0; i <= 31; i++)
47 test_set(stream, "R1", SWAP(IP[i]-32), "L2", i);
49 fprintf(stream,"\n/* now from left to right */\n");
50 /* list mapping from left to right */
51 for (i = 32; i <= 63; i++)
53 test_set(stream, "L1", SWAP(IP[i]), "R2", i-32);
55 /* now mapping from right to right */
56 fprintf(stream,"\n/* last from right to right */\n");
57 for (i = 32; i <= 63; i++)
59 test_set(stream, "R1", SWAP(IP[i]-32), "R2", i-32);