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>
15 #include "des_internal.h"
20 extern afs_uint32 swap_bit_pos_0();
21 extern afs_uint32 swap_six_bits_to_ansi();
22 extern afs_uint32 swap_four_bits_to_ansi();
29 register afs_uint32 i,j,k,l,m,n;
31 /* rearrange the S table entries, and adjust for host bit order */
33 fprintf(stream, "static unsigned char const S_adj[8][64] = {");
34 fprintf(stream, " /* adjusted */\n");
36 for (i = 0; i<=7 ; i++) {
37 for (j = 0; j <= 63; j++) {
39 * figure out which one to put in the new S[i][j]
41 * start by assuming the value of the input bits is "j" in
42 * host order, then figure out what it means in standard
45 k = swap_six_bits_to_ansi(j);
46 /* figure out the index for k */
47 l = (((k >> 5) & 01) << 5)
48 + ((k & 01) <<4) + ((k >> 1) & 0xf);
50 /* restore in host order */
51 n = swap_four_bits_to_ansi(m);
54 "i = %ld, j = %ld, k = %ld, l = %ld, m = %ld, n = %ld\n",
60 for (i = 0; i<=7; i++) {
61 fprintf(stream,"\n{ ");
63 for (j = 0; j<= 3; j++) {
65 for (m = 0; m <= 15; m++) {
66 fprintf(stream,"%2d",temp[i][k]);
69 fprintf(stream,"\n}");
71 if ((k++ != 63) || (i !=7)) {
78 fprintf(stream,"\n};\n");