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

1.1       root        1: /*
                      2:  * $Source: /mit/kerberos/src/lib/des/RCS/make_p.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:  * This routine generates the P permutation code for the DES.
                     11:  */
                     12: 
                     13: #include <mit-copyright.h>
                     14: #include <stdio.h>
                     15: #include "des_internal.h"
                     16: #include "tables.h"
                     17: 
                     18: void gen(stream)
                     19:     FILE *stream;
                     20: {
                     21:     /* P permutes 32 bit input R1 into 32 bit output R2 */     
                     22: 
                     23:     /* clear the output */
                     24:     fprintf(stream,"    L2 = 0;\n");
                     25: #ifndef        BIG
                     26:     fprintf(stream,"    R2 = 0;\n");
                     27:     fprintf(stream,
                     28:            "/* P operations */\n/* from right to right */\n");
                     29:     /* first list mapping from left to left */
                     30:     for (i = 0; i <=31; i++)
                     31:        if (P[i] < 32)
                     32:            fprintf(stream,
                     33:                    "    if (R1 & (1<<%d)) R2 |= 1<<%d;\n",P[i],i);
                     34: #else /* BIG */
                     35:     /* flip p into p_temp */
                     36:     fprintf(stream,"    P_temp = R1;\n");
                     37:     fprintf(stream,"    P_temp_p = (unsigned char *) &P_temp;\n");
                     38:  
                     39: #ifdef LSBFIRST
                     40:     fprintf(stream,"    R2 = P_prime[0][*P_temp_p++];\n");
                     41:     fprintf(stream,"    R2 |= P_prime[1][*P_temp_p++];\n");
                     42:     fprintf(stream,"    R2 |= P_prime[2][*P_temp_p++];\n");
                     43:     fprintf(stream,"    R2 |= P_prime[3][*P_temp_p];\n");
                     44: #else /* MSBFIRST */
                     45:     fprintf(stream,"    R2 = P_prime[3][*P_temp_p++];\n");
                     46:     fprintf(stream,"    R2 |= P_prime[2][*P_temp_p++];\n");
                     47:     fprintf(stream,"    R2 |= P_prime[1][*P_temp_p++];\n");
                     48:     fprintf(stream,"    R2 |= P_prime[0][*P_temp_p];\n");
                     49: #endif /* MSBFIRST */
                     50: #endif /* BIG */
                     51: }

unix.superglobalmegacorp.com

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