2 * Copyright 1985, 1988 by the Massachusetts Institute of Technology.
4 * For copying and distribution information, please
5 * see the file <mit-cpyright.h>.
13 #include <mit-cpyright.h>
16 #include "des_internal.h"
17 #include "des_prototypes.h"
25 void gen(FILE *stream)
27 register afs_uint32 i,j,k,l,m,n;
29 /* rearrange the S table entries, and adjust for host bit order */
31 fprintf(stream, "static unsigned char const S_adj[8][64] = {");
32 fprintf(stream, " /* adjusted */\n");
34 for (i = 0; i<=7 ; i++) {
35 for (j = 0; j <= 63; j++) {
37 * figure out which one to put in the new S[i][j]
39 * start by assuming the value of the input bits is "j" in
40 * host order, then figure out what it means in standard
43 k = swap_six_bits_to_ansi(j);
44 /* figure out the index for k */
45 l = (((k >> 5) & 01) << 5)
46 + ((k & 01) <<4) + ((k >> 1) & 0xf);
48 /* restore in host order */
49 n = swap_four_bits_to_ansi(m);
52 "i = %ld, j = %ld, k = %ld, l = %ld, m = %ld, n = %ld\n",
53 (long) i,(long) j,(long) k,(long) l,(long) m,(long) n);
58 for (i = 0; i<=7; i++) {
59 fprintf(stream,"\n{ ");
61 for (j = 0; j<= 3; j++) {
63 for (m = 0; m <= 15; m++) {
64 fprintf(stream,"%2d",temp[i][k]);
67 fprintf(stream,"\n}");
69 if ((k++ != 63) || (i !=7)) {
76 fprintf(stream,"\n};\n");