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>
20 #include "des_internal.h"
25 #include "des_prototypes.h"
27 #define SWAP(x) swap_long_bytes_bit_number(swap_bit_pos_0_to_ansi(x))
29 void gen(FILE *stream)
33 /* clear the output */
34 fprintf(stream," L2 = 0; R2 = 0;\n");
37 fprintf(stream,"/* IP operations */\n/* first left to left */\n");
39 /* first list mapping from left to left */
40 for (i = 0; i <= 31; i++)
42 test_set(stream, "L1", SWAP(IP[i]), "L2", i);
44 /* now mapping from right to left */
45 fprintf(stream,"\n/* now from right to left */\n");
46 for (i = 0; i <= 31; i++)
48 test_set(stream, "R1", SWAP(IP[i]-32), "L2", i);
50 fprintf(stream,"\n/* now from left to right */\n");
51 /* list mapping from left to right */
52 for (i = 32; i <= 63; i++)
54 test_set(stream, "L1", SWAP(IP[i]), "R2", i-32);
56 /* now mapping from right to right */
57 fprintf(stream,"\n/* last from right to right */\n");
58 for (i = 32; i <= 63; i++)
60 test_set(stream, "R1", SWAP(IP[i]-32), "R2", i-32);