Annotation of 43BSDReno/kerberosIV/make_odd/make_odd.c, revision 1.1

1.1     ! root        1: /*
        !             2:  * $Source: /mit/kerberos/src/lib/des/RCS/make_odd.c,v $
        !             3:  * $Author: steiner $
        !             4:  *
        !             5:  * Copyright 1988 by the Massachusetts Institute of Technology.
        !             6:  *
        !             7:  * For copying and distribution information, please see
        !             8:  * the file <mit-copyright.h>.
        !             9:  *
        !            10:  * This routine generates an odd-parity table for use in key generation.
        !            11:  */
        !            12: 
        !            13: #include <mit-copyright.h>
        !            14: #include <stdio.h>
        !            15: 
        !            16: void gen(stream)
        !            17:     FILE *stream;
        !            18: {
        !            19:     /*
        !            20:      * map a byte into its equivalent with odd parity, where odd
        !            21:      * parity is in the least significant bit
        !            22:      */
        !            23:     register i, j, k, odd;
        !            24: 
        !            25:     fprintf(stream,
        !            26:             "static unsigned char const odd_parity[256] = {\n");
        !            27: 
        !            28:     for (i = 0; i < 256; i++) {
        !            29:         odd = 0;
        !            30:         /* shift out the lsb parity bit */
        !            31:         k = i >> 1;
        !            32:         /* then count the other bits */
        !            33:         for (j = 0; j < 7; j++) {
        !            34:             odd ^= (k&1);
        !            35:             k = k >> 1;
        !            36:         }
        !            37:         k = i&~1;
        !            38:         if (!odd)
        !            39:             k |= 1;
        !            40:         fprintf(stream, "%3d", k);
        !            41:         if (i < 255)
        !            42:             fprintf(stream, ", ");
        !            43:         if (i%8 == 0)
        !            44:             fprintf(stream, "\n");
        !            45:     }
        !            46:     fprintf(stream, "};\n");
        !            47: }

unix.superglobalmegacorp.com

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