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 <afsconfig.h>
12 #include <afs/param.h>
16 #include <mit-cpyright.h>
18 #include "des_internal.h"
23 extern afs_int32 swap_bit_pos_0();
24 extern afs_int32 rev_swap_bit_pos_0();
25 extern void test_set PROTOTYPE((FILE *, char const *, int,
27 extern int swap_long_bytes_bit_number(int);
28 extern int swap_bit_pos_0_to_ansi(int);
30 #define SWAP(x) swap_long_bytes_bit_number(swap_bit_pos_0_to_ansi(x))
37 /* clear the output */
38 fprintf(stream," L2 = 0; R2 = 0;\n");
41 fprintf(stream,"/* IP operations */\n/* first left to left */\n");
43 /* first list mapping from left to left */
44 for (i = 0; i <= 31; i++)
46 test_set(stream, "L1", SWAP(IP[i]), "L2", i);
48 /* now mapping from right to left */
49 fprintf(stream,"\n/* now from right to left */\n");
50 for (i = 0; i <= 31; i++)
52 test_set(stream, "R1", SWAP(IP[i]-32), "L2", i);
54 fprintf(stream,"\n/* now from left to right */\n");
55 /* list mapping from left to right */
56 for (i = 32; i <= 63; i++)
58 test_set(stream, "L1", SWAP(IP[i]), "R2", i-32);
60 /* now mapping from right to right */
61 fprintf(stream,"\n/* last from right to right */\n");
62 for (i = 32; i <= 63; i++)
64 test_set(stream, "R1", SWAP(IP[i]-32), "R2", i-32);