2 * Copyright 1989 by the Massachusetts Institute of Technology.
4 * For copying and distribution information, please see the file
7 * Under U.S. law, this software may not be exported outside the US
8 * without license from the U.S. Commerce department.
10 * These routines form the library interface to the DES facilities.
12 * Originally written 8/85 by Steve Miller, MIT Project Athena.
16 #include "des_internal.h"
19 * The following are the weak DES keys:
21 static const des_cblock weak[16] = {
23 {0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01},
24 {0xfe,0xfe,0xfe,0xfe,0xfe,0xfe,0xfe,0xfe},
25 {0x1f,0x1f,0x1f,0x1f,0x0e,0x0e,0x0e,0x0e},
26 {0xe0,0xe0,0xe0,0xe0,0xf1,0xf1,0xf1,0xf1},
29 {0x01,0xfe,0x01,0xfe,0x01,0xfe,0x01,0xfe},
30 {0xfe,0x01,0xfe,0x01,0xfe,0x01,0xfe,0x01},
32 {0x1f,0xe0,0x1f,0xe0,0x0e,0xf1,0x0e,0xf1},
33 {0xe0,0x1f,0xe0,0x1f,0xf1,0x0e,0xf1,0x0e},
35 {0x01,0xe0,0x01,0xe0,0x01,0xf1,0x01,0xf1},
36 {0xe0,0x01,0xe0,0x01,0xf1,0x01,0xf1,0x01},
38 {0x1f,0xfe,0x1f,0xfe,0x0e,0xfe,0x0e,0xfe},
39 {0xfe,0x1f,0xfe,0x1f,0xfe,0x0e,0xfe,0x0e},
41 {0x01,0x1f,0x01,0x1f,0x01,0x0e,0x01,0x0e},
42 {0x1f,0x01,0x1f,0x01,0x0e,0x01,0x0e,0x01},
44 {0xe0,0xfe,0xe0,0xfe,0xf1,0xfe,0xf1,0xfe},
45 {0xfe,0xe0,0xfe,0xe0,0xfe,0xf1,0xfe,0xf1}
49 * des_is_weak_key: returns true iff key is a [semi-]weak des key.
51 * Requires: key has correct odd parity.
58 const des_cblock *weak_p = weak;
60 for (i = 0; i < (sizeof(weak)/sizeof(des_cblock)); i++) {
61 if (!bcmp((char *)weak_p++,(char *)key,sizeof(des_cblock)))