1 /* -*- mode: c; c-basic-offset: 4; indent-tabs-mode: nil -*- */
2 /*
3 * Copyright 1995 by Richard P. Basch. All Rights Reserved.
4 * Copyright 1995 by Lehman Brothers, Inc. All Rights Reserved.
5 *
6 * Export of this software from the United States of America may
7 * require a specific license from the United States Government.
8 * It is the responsibility of any person or organization contemplating
9 * export to obtain such a license before exporting.
10 *
11 * WITHIN THAT CONSTRAINT, permission to use, copy, modify, and
12 * distribute this software and its documentation for any purpose and
13 * without fee is hereby granted, provided that the above copyright
14 * notice appear in all copies and that both that copyright notice and
15 * this permission notice appear in supporting documentation, and that
16 * the name of Richard P. Basch, Lehman Brothers and M.I.T. not be used
17 * in advertising or publicity pertaining to distribution of the software
18 * without specific, written prior permission. Richard P. Basch,
19 * Lehman Brothers and M.I.T. make no representations about the suitability
20 * of this software for any purpose. It is provided "as is" without
21 * express or implied warranty.
22 */
23
24 #include "crypto_int.h"
25 #include "des_int.h"
26
27 #ifdef K5_BUILTIN_DES
28
29 int
mit_des3_key_sched(mit_des3_cblock k,mit_des3_key_schedule schedule)30 mit_des3_key_sched(mit_des3_cblock k, mit_des3_key_schedule schedule)
31 {
32 mit_des_make_key_sched(k[0],schedule[0]);
33 mit_des_make_key_sched(k[1],schedule[1]);
34 mit_des_make_key_sched(k[2],schedule[2]);
35
36 if (!mit_des_check_key_parity(k[0])) /* bad parity --> return -1 */
37 return(-1);
38 if (mit_des_is_weak_key(k[0]))
39 return(-2);
40
41 if (!mit_des_check_key_parity(k[1]))
42 return(-1);
43 if (mit_des_is_weak_key(k[1]))
44 return(-2);
45
46 if (!mit_des_check_key_parity(k[2]))
47 return(-1);
48 if (mit_des_is_weak_key(k[2]))
49 return(-2);
50
51 /* if key was good, return 0 */
52 return 0;
53 }
54
55 #endif /* K5_BUILTIN_DES */
56