2 * Copyright 1988 by the Massachusetts Institute of Technology.
4 * For copying and distribution information,
5 * please see the file <mit-cpyright.h>.
7 * This file contains a generation routine for source code
8 * implementing the final permutation of the DES.
11 #include <afs/param.h>
12 #include <afsconfig.h>
16 #include <mit-cpyright.h>
18 #include "des_internal.h"
23 extern unsigned int swap_bit_pos_0_to_ansi PROTOTYPE((unsigned int));
24 extern afs_int32 swap_long_bytes();
25 extern afs_int32 swap_long_bytes_bit_number();
26 extern void test_set PROTOTYPE((FILE *, char const *, int,
34 /* clear the output */
35 fprintf(stream," L2 = 0; R2 = 0;\n");
38 * NOTE: As part of the final permutation, we also have to adjust
39 * for host bit order via "swap_bit_pos_0()". Since L2,R2 are
40 * the output from this, we adjust the bit positions written into
45 swap_long_bytes_bit_number(swap_bit_pos_0_to_ansi((unsigned)i)-j)
49 "/* FP operations */\n/* first left to left */\n");
51 /* first list mapping from left to left */
52 for (i = 0; i <= 31; i++)
54 test_set(stream, "L1", FP[i], "L2", SWAP(i,0));
56 /* now mapping from right to left */
57 fprintf(stream,"\n\n/* now from right to left */\n");
58 for (i = 0; i <= 31; i++)
60 test_set(stream, "R1", FP[i]-32, "L2", SWAP(i,0));
62 fprintf(stream,"\n/* now from left to right */\n");
64 /* list mapping from left to right */
65 for (i = 32; i <= 63; i++)
67 test_set(stream, "L1", FP[i], "R2", SWAP(i,32));
69 /* now mapping from right to right */
70 fprintf(stream,"\n/* last from right to right */\n");
71 for (i = 32; i <= 63; i++)
73 test_set(stream, "R1", FP[i]-32, "R2", SWAP(i,32));