Annotation of 43BSDReno/kerberosIV/make_s_table/make_s_table.c, revision 1.1.1.1

1.1       root        1: /*
                      2:  * $Source: /mit/kerberos/src/lib/des/RCS/make_s_table.c,v $
                      3:  * $Author: jtkohl $
                      4:  *
                      5:  * Copyright 1985, 1988 by the Massachusetts Institute of Technology.
                      6:  *
                      7:  * For copying and distribution information, please
                      8:  * see the file <mit-copyright.h>.
                      9:  */
                     10: 
                     11: #include <mit-copyright.h>
                     12: #include <stdio.h>
                     13: #include "des_internal.h"
                     14: #include "tables.h"
                     15: 
                     16: extern unsigned long swap_bit_pos_0();
                     17: extern unsigned long swap_six_bits_to_ansi();
                     18: extern unsigned long swap_four_bits_to_ansi();
                     19: char temp[8][64];
                     20: int des_debug;
                     21: 
                     22: void gen(stream)
                     23:     FILE *stream;
                     24: {
                     25:     register unsigned long i,j,k,l,m,n;
                     26: 
                     27:     /* rearrange the S table entries, and adjust for host bit order */
                     28: 
                     29:     fprintf(stream, "static unsigned char const S_adj[8][64] = {");
                     30:     fprintf(stream, "    /* adjusted */\n");
                     31: 
                     32:     for (i = 0; i<=7 ; i++) {
                     33:         for (j = 0; j <= 63; j++) {
                     34:             /*
                     35:              * figure out which one to put in the new S[i][j]
                     36:              *
                     37:              * start by assuming the value of the input bits is "j" in
                     38:              * host order, then figure out what it means in standard
                     39:              * form.
                     40:              */
                     41:             k = swap_six_bits_to_ansi(j);
                     42:             /* figure out the index for k */
                     43:             l = (((k >> 5) & 01) << 5)
                     44:                 + ((k & 01) <<4) + ((k >> 1) & 0xf);
                     45:             m = S[i][l];
                     46:             /* restore in host order */
                     47:             n = swap_four_bits_to_ansi(m);
                     48:             if (des_debug)
                     49:                 fprintf(stderr,
                     50:                 "i = %d, j = %d, k = %d, l = %d, m = %d, n = %d\n",
                     51:                         i,j,k,l,m,n);
                     52:             temp[i][j] = n;
                     53:         }
                     54:     }
                     55: 
                     56:     for (i = 0; i<=7; i++) {
                     57:         fprintf(stream,"\n");
                     58:         k =0;
                     59:         for (j = 0; j<= 3; j++) {
                     60:             fprintf(stream,"\n");
                     61:             for (m = 0; m <= 15; m++) {
                     62:                 fprintf(stream,"%2d",temp[i][k]);
                     63:                 if ((k++ != 63) || (i !=7)) {
                     64:                     fprintf(stream,", ");
                     65:                 }
                     66:             }
                     67:         }
                     68:     }
                     69: 
                     70:     fprintf(stream,"\n};\n");
                     71: }

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.