~ubuntu-branches/ubuntu/vivid/wpasupplicant/vivid

« back to all changes in this revision

Viewing changes to eap_md5.c

  • Committer: Bazaar Package Importer
  • Author(s): Kel Modderman
  • Date: 2008-03-12 20:03:04 UTC
  • mfrom: (1.1.10 upstream)
  • mto: This revision was merged to the branch mainline in revision 4.
  • Revision ID: james.westby@ubuntu.com-20080312200304-4331y9wj46pdd34z
Tags: 0.6.3-1
* New upstream release.
* Drop patches applied upstream:
  - debian/patches/30_wpa_gui_qt4_eventhistoryui_rework.patch
  - debian/patches/31_wpa_gui_qt4_eventhistory_always_scrollbar.patch
  - debian/patches/32_wpa_gui_qt4_eventhistory_scroll_with_events.patch
  - debian/patches/40_dbus_ssid_data.patch
* Tidy up the clean target of debian/rules. Now that the madwifi headers are
  handled differently we no longer need to do any cleanup.
* Fix formatting error in debian/ifupdown/wpa_action.8 to make lintian
  quieter.
* Add patch to fix formatting errors in manpages build from sgml source. Use
  <emphasis> tags to hightlight keywords instead of surrounding them in
  strong quotes.
  - debian/patches/41_manpage_format_fixes.patch
* wpasupplicant binary package no longer suggests pcscd, guessnet, iproute
  or wireless-tools, nor does it recommend dhcp3-client. These are not
  needed.
* Add debian/patches/10_silence_siocsiwauth_icotl_failure.patch to disable
  ioctl failure messages that occur under normal conditions.
* Cherry pick two upstream git commits concerning the dbus interface:
  - debian/patches/11_avoid_dbus_version_namespace.patch
  - debian/patches/12_fix_potential_use_after_free.patch
* Add debian/patches/42_manpage_explain_available_drivers.patch to explain
  that not all of the driver backends are available in the provided
  wpa_supplicant binary, and that the canonical list of supported driver
  backends can be retrieved from the wpa_supplicant -h (help) output.
  (Closes: #466910)
* Add debian/patches/20_wpa_gui_qt4_disable_link_prl.patch to remove
  link_prl CONFIG compile flag added by qmake-qt4 >= 4.3.4-2 to avoid excess
  linking.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/*
2
 
 * EAP peer method: EAP-MD5 (RFC 3748 and RFC 1994)
3
 
 * Copyright (c) 2004-2006, Jouni Malinen <j@w1.fi>
4
 
 *
5
 
 * This program is free software; you can redistribute it and/or modify
6
 
 * it under the terms of the GNU General Public License version 2 as
7
 
 * published by the Free Software Foundation.
8
 
 *
9
 
 * Alternatively, this software may be distributed under the terms of BSD
10
 
 * license.
11
 
 *
12
 
 * See README and COPYING for more details.
13
 
 */
14
 
 
15
 
#include "includes.h"
16
 
 
17
 
#include "common.h"
18
 
#include "eap_i.h"
19
 
#include "md5.h"
20
 
#include "crypto.h"
21
 
 
22
 
 
23
 
static void * eap_md5_init(struct eap_sm *sm)
24
 
{
25
 
        /* No need for private data. However, must return non-NULL to indicate
26
 
         * success. */
27
 
        return (void *) 1;
28
 
}
29
 
 
30
 
 
31
 
static void eap_md5_deinit(struct eap_sm *sm, void *priv)
32
 
{
33
 
}
34
 
 
35
 
 
36
 
static u8 * eap_md5_process(struct eap_sm *sm, void *priv,
37
 
                            struct eap_method_ret *ret,
38
 
                            const u8 *reqData, size_t reqDataLen,
39
 
                            size_t *respDataLen)
40
 
{
41
 
        const struct eap_hdr *req;
42
 
        struct eap_hdr *resp;
43
 
        const u8 *pos, *challenge, *password;
44
 
        u8 *rpos;
45
 
        size_t len, challenge_len, password_len;
46
 
        const u8 *addr[3];
47
 
        size_t elen[3];
48
 
 
49
 
        password = eap_get_config_password(sm, &password_len);
50
 
        if (password == NULL) {
51
 
                wpa_printf(MSG_INFO, "EAP-MD5: Password not configured");
52
 
                eap_sm_request_password(sm);
53
 
                ret->ignore = TRUE;
54
 
                return NULL;
55
 
        }
56
 
 
57
 
        pos = eap_hdr_validate(EAP_VENDOR_IETF, EAP_TYPE_MD5,
58
 
                               reqData, reqDataLen, &len);
59
 
        if (pos == NULL || len == 0) {
60
 
                wpa_printf(MSG_INFO, "EAP-MD5: Invalid frame (pos=%p len=%lu)",
61
 
                           pos, (unsigned long) len);
62
 
                ret->ignore = TRUE;
63
 
                return NULL;
64
 
        }
65
 
 
66
 
        /*
67
 
         * CHAP Challenge:
68
 
         * Value-Size (1 octet) | Value(Challenge) | Name(optional)
69
 
         */
70
 
        req = (const struct eap_hdr *) reqData;
71
 
        challenge_len = *pos++;
72
 
        if (challenge_len == 0 || challenge_len > len - 1) {
73
 
                wpa_printf(MSG_INFO, "EAP-MD5: Invalid challenge "
74
 
                           "(challenge_len=%lu len=%lu)",
75
 
                           (unsigned long) challenge_len, (unsigned long) len);
76
 
                ret->ignore = TRUE;
77
 
                return NULL;
78
 
        }
79
 
        ret->ignore = FALSE;
80
 
        challenge = pos;
81
 
        wpa_hexdump(MSG_MSGDUMP, "EAP-MD5: Challenge",
82
 
                    challenge, challenge_len);
83
 
 
84
 
        wpa_printf(MSG_DEBUG, "EAP-MD5: Generating Challenge Response");
85
 
        ret->methodState = METHOD_DONE;
86
 
        ret->decision = DECISION_UNCOND_SUCC;
87
 
        ret->allowNotifications = TRUE;
88
 
 
89
 
        resp = eap_msg_alloc(EAP_VENDOR_IETF, EAP_TYPE_MD5, respDataLen,
90
 
                             1 + MD5_MAC_LEN, EAP_CODE_RESPONSE,
91
 
                             req->identifier, &rpos);
92
 
        if (resp == NULL)
93
 
                return NULL;
94
 
 
95
 
        /*
96
 
         * CHAP Response:
97
 
         * Value-Size (1 octet) | Value(Response) | Name(optional)
98
 
         */
99
 
        *rpos++ = MD5_MAC_LEN;
100
 
 
101
 
        addr[0] = &resp->identifier;
102
 
        elen[0] = 1;
103
 
        addr[1] = password;
104
 
        elen[1] = password_len;
105
 
        addr[2] = challenge;
106
 
        elen[2] = challenge_len;
107
 
        md5_vector(3, addr, elen, rpos);
108
 
        wpa_hexdump(MSG_MSGDUMP, "EAP-MD5: Response", rpos, MD5_MAC_LEN);
109
 
 
110
 
        return (u8 *) resp;
111
 
}
112
 
 
113
 
 
114
 
int eap_peer_md5_register(void)
115
 
{
116
 
        struct eap_method *eap;
117
 
        int ret;
118
 
 
119
 
        eap = eap_peer_method_alloc(EAP_PEER_METHOD_INTERFACE_VERSION,
120
 
                                    EAP_VENDOR_IETF, EAP_TYPE_MD5, "MD5");
121
 
        if (eap == NULL)
122
 
                return -1;
123
 
 
124
 
        eap->init = eap_md5_init;
125
 
        eap->deinit = eap_md5_deinit;
126
 
        eap->process = eap_md5_process;
127
 
 
128
 
        ret = eap_peer_method_register(eap);
129
 
        if (ret)
130
 
                eap_peer_method_free(eap);
131
 
        return ret;
132
 
}