Bump all minor nos. of libs in /usr/src/gnu/lib.
[unix-history] / kerberosIV / des / weak_key.c
CommitLineData
fdf53e02
GW
1/*
2 * $Source: /mit/kerberos/src/lib/des/RCS/weak_key.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 * Under U.S. law, this software may not be exported outside the US
11 * without license from the U.S. Commerce department.
12 *
13 * These routines form the library interface to the DES facilities.
14 *
15 * Originally written 8/85 by Steve Miller, MIT Project Athena.
16 */
17
18#ifndef lint
19static char rcsid_weak_key_c[] =
20"$Header: weak_key.c,v 4.3 89/01/22 12:16:41 jtkohl Exp $";
21#endif lint
22
23#include <des.h>
24#include "des_internal.h"
25
26/*
27 * The following are the weak DES keys:
28 */
29static des_cblock weak[16] = {
30 /* weak keys */
31 {0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01},
32 {0xfe,0xfe,0xfe,0xfe,0xfe,0xfe,0xfe,0xfe},
33 {0x1f,0x1f,0x1f,0x1f,0x0e,0x0e,0x0e,0x0e},
34 {0xe0,0xe0,0xe0,0xe0,0xf1,0xf1,0xf1,0xf1},
35
36 /* semi-weak */
37 {0x01,0xfe,0x01,0xfe,0x01,0xfe,0x01,0xfe},
38 {0xfe,0x01,0xfe,0x01,0xfe,0x01,0xfe,0x01},
39
40 {0x1f,0xe0,0x1f,0xe0,0x0e,0xf1,0x0e,0xf1},
41 {0xe0,0x1f,0xe0,0x1f,0xf1,0x0e,0xf1,0x0e},
42
43 {0x01,0xe0,0x01,0xe0,0x01,0xf1,0x01,0xf1},
44 {0xe0,0x01,0xe0,0x01,0xf1,0x01,0xf1,0x01},
45
46 {0x1f,0xfe,0x1f,0xfe,0x0e,0xfe,0x0e,0xfe},
47 {0xfe,0x1f,0xfe,0x1f,0xfe,0x0e,0xfe,0x0e},
48
49 {0x01,0x1f,0x01,0x1f,0x01,0x0e,0x01,0x0e},
50 {0x1f,0x01,0x1f,0x01,0x0e,0x01,0x0e,0x01},
51
52 {0xe0,0xfe,0xe0,0xfe,0xf1,0xfe,0xf1,0xfe},
53 {0xfe,0xe0,0xfe,0xe0,0xfe,0xf1,0xfe,0xf1}
54};
55
56/*
57 * des_is_weak_key: returns true iff key is a [semi-]weak des key.
58 *
59 * Requires: key has correct odd parity.
60 */
61int
62des_is_weak_key(key)
63 des_cblock key;
64{
65 int i;
66 des_cblock *weak_p = weak;
67
68 for (i = 0; i < (sizeof(weak)/sizeof(des_cblock)); i++) {
69 if (!bcmp((char *)weak_p++,(char *)key,sizeof(des_cblock)))
70 return 1;
71 }
72
73 return 0;
74}