2 * lib/crypto/des/key_sched.c
4 * Copyright 1985, 1986, 1987, 1988, 1990 by the Massachusetts Institute
8 * Export of this software from the United States of America may
9 * require a specific license from the United States Government.
10 * It is the responsibility of any person or organization contemplating
11 * export to obtain such a license before exporting.
13 * WITHIN THAT CONSTRAINT, permission to use, copy, modify, and
14 * distribute this software and its documentation for any purpose and
15 * without fee is hereby granted, provided that the above copyright
16 * notice appear in all copies and that both that copyright notice and
17 * this permission notice appear in supporting documentation, and that
18 * the name of M.I.T. not be used in advertising or publicity pertaining
19 * to distribution of the software without specific, written prior
20 * permission. M.I.T. makes no representations about the suitability of
21 * this software for any purpose. It is provided "as is" without express
22 * or implied warranty.
25 * This routine computes the DES key schedule given a key. The
26 * permutations and shifts have been done at compile time, resulting
27 * in a direct one-step mapping from the input key to the key
30 * Also checks parity and weak keys.
32 * Watch out for the subscripts -- most effectively start at 1 instead
33 * of at zero. Maybe some bugs in that area.
35 * In case the user wants to cache the computed key schedule, it is
36 * passed as an arg. Also implies that caller has explicit control
37 * over zeroing both the key schedule and the key.
39 * Originally written 6/85 by Steve Miller, MIT Project Athena.
46 mit_des_key_sched(k,schedule)
48 mit_des_key_schedule schedule;
50 if (!mit_des_check_key_parity(k)) /* bad parity --> return -1 */
53 if (mit_des_is_weak_key(k))
56 make_key_sched(k,schedule);
58 /* if key was good, return 0 */