1
/* -*- mode: c; c-basic-offset: 4; indent-tabs-mode: nil -*- */
3
* lib/crypto/openssl/des/weak_key.c
5
* Copyright 1989,1990,2009 by the Massachusetts Institute of Technology.
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. Furthermore if you modify this software you must label
21
* your software as modified software and not distribute it in such a
22
* fashion that it might be confused with the original M.I.T. software.
23
* M.I.T. makes no representations about the suitability of
24
* this software for any purpose. It is provided "as is" without express
25
* or implied warranty.
28
* Under U.S. law, this software may not be exported outside the US
29
* without license from the U.S. Commerce department.
31
* These routines form the library interface to the DES facilities.
33
* Originally written 8/85 by Steve Miller, MIT Project Athena.
39
* The following are the weak DES keys:
41
static const mit_des_cblock weak[16] = {
43
{0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01},
44
{0xfe,0xfe,0xfe,0xfe,0xfe,0xfe,0xfe,0xfe},
45
{0x1f,0x1f,0x1f,0x1f,0x0e,0x0e,0x0e,0x0e},
46
{0xe0,0xe0,0xe0,0xe0,0xf1,0xf1,0xf1,0xf1},
49
{0x01,0xfe,0x01,0xfe,0x01,0xfe,0x01,0xfe},
50
{0xfe,0x01,0xfe,0x01,0xfe,0x01,0xfe,0x01},
52
{0x1f,0xe0,0x1f,0xe0,0x0e,0xf1,0x0e,0xf1},
53
{0xe0,0x1f,0xe0,0x1f,0xf1,0x0e,0xf1,0x0e},
55
{0x01,0xe0,0x01,0xe0,0x01,0xf1,0x01,0xf1},
56
{0xe0,0x01,0xe0,0x01,0xf1,0x01,0xf1,0x01},
58
{0x1f,0xfe,0x1f,0xfe,0x0e,0xfe,0x0e,0xfe},
59
{0xfe,0x1f,0xfe,0x1f,0xfe,0x0e,0xfe,0x0e},
61
{0x01,0x1f,0x01,0x1f,0x01,0x0e,0x01,0x0e},
62
{0x1f,0x01,0x1f,0x01,0x0e,0x01,0x0e,0x01},
64
{0xe0,0xfe,0xe0,0xfe,0xf1,0xfe,0xf1,0xfe},
65
{0xfe,0xe0,0xfe,0xe0,0xfe,0xf1,0xfe,0xf1}
69
* mit_des_is_weak_key: returns true iff key is a [semi-]weak des key.
71
* Requires: key has correct odd parity.
74
mit_des_is_weak_key(mit_des_cblock key)
77
const mit_des_cblock *weak_p = weak;
79
for (i = 0; i < (sizeof(weak)/sizeof(mit_des_cblock)); i++) {
80
if (!memcmp(weak_p++,key,sizeof(mit_des_cblock)))