Annotation of 43BSDReno/kerberosIV/des/key_parity.c, revision 1.1.1.1

1.1       root        1: /*
                      2:  * $Source: /mit/kerberos/src/lib/des/RCS/key_parity.c,v $
                      3:  * $Author: jtkohl $
                      4:  *
                      5:  * Copyright 1989 by the Massachusetts Institute of Technology.
                      6:  *
                      7:  * For copying and distribution information, please see the file
                      8:  * <mit-copyright.h>.
                      9:  *
                     10:  * These routines check and fix parity of encryption keys for the DES
                     11:  * algorithm.
                     12:  *
                     13:  * Under U.S. law, this software may not be exported outside the US
                     14:  * without license from the U.S. Commerce department.
                     15:  *
                     16:  * These routines form the library interface to the DES facilities.
                     17:  *
                     18:  */
                     19: 
                     20: #ifndef        lint
                     21: static char rcsid_key_parity_c[] =
                     22: "$Header: key_parity.c,v 4.0 89/01/22 11:45:12 jtkohl Exp $";
                     23: #endif lint
                     24: 
                     25: #include <mit-copyright.h>
                     26: #include <des.h>
                     27: #include "des_internal.h"
                     28: 
                     29: #include "odd.h"          /* Load compile-time generated odd_parity table */
                     30: 
                     31: /*
                     32:  * des_fixup_key_parity: Forces odd parity per byte; parity is bits
                     33:  *                       8,16,...64 in des order, implies 0, 8, 16, ...
                     34:  *                       vax order.
                     35:  */
                     36: void
                     37: des_fixup_key_parity(key)
                     38:      register des_cblock key;
                     39: {
                     40:     int i;
                     41: 
                     42:     for (i=0; i<sizeof(des_cblock); i++)
                     43:       key[i] = odd_parity[key[i]];
                     44: 
                     45:     return;
                     46: }
                     47: 
                     48: /*
                     49:  * des_check_key_parity: returns true iff key has the correct des parity.
                     50:  *                       See des_fix_key_parity for the definition of
                     51:  *                       correct des parity.
                     52:  */
                     53: int
                     54: des_check_key_parity(key)
                     55:      register des_cblock key;
                     56: {
                     57:     int i;
                     58: 
                     59:     for (i=0; i<sizeof(des_cblock); i++)
                     60:       if (key[i] != odd_parity[key[i]])
                     61:        return(0);
                     62: 
                     63:     return(1);
                     64: }

unix.superglobalmegacorp.com

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