2 * Copyright 1989 by the Massachusetts Institute of Technology.
4 * For copying and distribution information, please see the file
7 * These routines check and fix parity of encryption keys for the DES
10 * Under U.S. law, this software may not be exported outside the US
11 * without license from the U.S. Commerce department.
13 * These routines form the library interface to the DES facilities.
17 #include <afsconfig.h>
18 #include <afs/param.h>
22 #include <mit-cpyright.h>
25 #include "des_internal.h"
26 #include "des_prototypes.h"
28 #include "odd.h" /* Load compile-time generated odd_parity table */
31 * des_fixup_key_parity: Forces odd parity per byte; parity is bits
32 * 8,16,...64 in des order, implies 0, 8, 16, ...
35 void des_fixup_key_parity(register des_cblock key)
39 for (i=0; i<sizeof(des_cblock); i++)
40 key[i] = odd_parity[key[i]];
46 * des_check_key_parity: returns true iff key has the correct des parity.
47 * See des_fix_key_parity for the definition of
50 int des_check_key_parity(register des_cblock key)
54 for (i=0; i<sizeof(des_cblock); i++)
55 if (key[i] != odd_parity[key[i]])