~ubuntu-branches/ubuntu/precise/krb5/precise-updates

« back to all changes in this revision

Viewing changes to src/lib/crypto/nss/des/weak_key.c

  • Committer: Package Import Robot
  • Author(s): Sam Hartman
  • Date: 2011-12-01 19:34:41 UTC
  • mfrom: (28.1.14 sid)
  • Revision ID: package-import@ubuntu.com-20111201193441-9tipg3aru1jsidyv
Tags: 1.10+dfsg~alpha1-6
* Fix segfault with unknown hostnames in krb5_sname_to_principal,
  Closes: #650671
* Indicate that this library breaks libsmbclient versions that depend on
  krb5_locate_kdc, Closes: #650603, #650611

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/* -*- mode: c; c-basic-offset: 4; indent-tabs-mode: nil -*- */
2
 
/*
3
 
 * lib/crypto/openssl/des/weak_key.c
4
 
 *
5
 
 * Copyright 1989,1990,2009 by the Massachusetts Institute of Technology.
6
 
 * All Rights Reserved.
7
 
 *
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.
12
 
 *
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.
26
 
 *
27
 
 *
28
 
 * Under U.S. law, this software may not be exported outside the US
29
 
 * without license from the U.S. Commerce department.
30
 
 *
31
 
 * These routines form the library interface to the DES facilities.
32
 
 *
33
 
 * Originally written 8/85 by Steve Miller, MIT Project Athena.
34
 
 */
35
 
 
36
 
#include "des_int.h"
37
 
 
38
 
/*
39
 
 * The following are the weak DES keys:
40
 
 */
41
 
static const mit_des_cblock weak[16] = {
42
 
    /* weak keys */
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},
47
 
 
48
 
    /* semi-weak */
49
 
    {0x01,0xfe,0x01,0xfe,0x01,0xfe,0x01,0xfe},
50
 
    {0xfe,0x01,0xfe,0x01,0xfe,0x01,0xfe,0x01},
51
 
 
52
 
    {0x1f,0xe0,0x1f,0xe0,0x0e,0xf1,0x0e,0xf1},
53
 
    {0xe0,0x1f,0xe0,0x1f,0xf1,0x0e,0xf1,0x0e},
54
 
 
55
 
    {0x01,0xe0,0x01,0xe0,0x01,0xf1,0x01,0xf1},
56
 
    {0xe0,0x01,0xe0,0x01,0xf1,0x01,0xf1,0x01},
57
 
 
58
 
    {0x1f,0xfe,0x1f,0xfe,0x0e,0xfe,0x0e,0xfe},
59
 
    {0xfe,0x1f,0xfe,0x1f,0xfe,0x0e,0xfe,0x0e},
60
 
 
61
 
    {0x01,0x1f,0x01,0x1f,0x01,0x0e,0x01,0x0e},
62
 
    {0x1f,0x01,0x1f,0x01,0x0e,0x01,0x0e,0x01},
63
 
 
64
 
    {0xe0,0xfe,0xe0,0xfe,0xf1,0xfe,0xf1,0xfe},
65
 
    {0xfe,0xe0,0xfe,0xe0,0xfe,0xf1,0xfe,0xf1}
66
 
};
67
 
 
68
 
/*
69
 
 * mit_des_is_weak_key: returns true iff key is a [semi-]weak des key.
70
 
 *
71
 
 * Requires: key has correct odd parity.
72
 
 */
73
 
int
74
 
mit_des_is_weak_key(mit_des_cblock key)
75
 
{
76
 
    unsigned int i;
77
 
    const mit_des_cblock *weak_p = weak;
78
 
 
79
 
    for (i = 0; i < (sizeof(weak)/sizeof(mit_des_cblock)); i++) {
80
 
        if (!memcmp(weak_p++,key,sizeof(mit_des_cblock)))
81
 
            return 1;
82
 
    }
83
 
    return 0;
84
 
}