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

« back to all changes in this revision

Viewing changes to src/eap_server/eap_identity.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
 * hostapd / EAP-Identity
 
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
 
 
20
 
 
21
struct eap_identity_data {
 
22
        enum { CONTINUE, SUCCESS, FAILURE } state;
 
23
        int pick_up;
 
24
};
 
25
 
 
26
 
 
27
static void * eap_identity_init(struct eap_sm *sm)
 
28
{
 
29
        struct eap_identity_data *data;
 
30
 
 
31
        data = os_zalloc(sizeof(*data));
 
32
        if (data == NULL)
 
33
                return NULL;
 
34
        data->state = CONTINUE;
 
35
 
 
36
        return data;
 
37
}
 
38
 
 
39
 
 
40
static void * eap_identity_initPickUp(struct eap_sm *sm)
 
41
{
 
42
        struct eap_identity_data *data;
 
43
        data = eap_identity_init(sm);
 
44
        if (data) {
 
45
                data->pick_up = 1;
 
46
        }
 
47
        return data;
 
48
}
 
49
 
 
50
 
 
51
static void eap_identity_reset(struct eap_sm *sm, void *priv)
 
52
{
 
53
        struct eap_identity_data *data = priv;
 
54
        os_free(data);
 
55
}
 
56
 
 
57
 
 
58
static struct wpabuf * eap_identity_buildReq(struct eap_sm *sm, void *priv,
 
59
                                             u8 id)
 
60
{
 
61
        struct eap_identity_data *data = priv;
 
62
        struct wpabuf *req;
 
63
        const char *req_data;
 
64
        size_t req_data_len;
 
65
 
 
66
        if (sm->eapol_cb->get_eap_req_id_text) {
 
67
                req_data = sm->eapol_cb->get_eap_req_id_text(sm->eapol_ctx,
 
68
                                                             &req_data_len);
 
69
        } else {
 
70
                req_data = NULL;
 
71
                req_data_len = 0;
 
72
        }
 
73
        req = eap_msg_alloc(EAP_VENDOR_IETF, EAP_TYPE_IDENTITY, req_data_len,
 
74
                            EAP_CODE_REQUEST, id);
 
75
        if (req == NULL) {
 
76
                wpa_printf(MSG_ERROR, "EAP-Identity: Failed to allocate "
 
77
                           "memory for request");
 
78
                data->state = FAILURE;
 
79
                return NULL;
 
80
        }
 
81
 
 
82
        wpabuf_put_data(req, req_data, req_data_len);
 
83
 
 
84
        return req;
 
85
}
 
86
 
 
87
 
 
88
static Boolean eap_identity_check(struct eap_sm *sm, void *priv,
 
89
                                  struct wpabuf *respData)
 
90
{
 
91
        const u8 *pos;
 
92
        size_t len;
 
93
 
 
94
        pos = eap_hdr_validate(EAP_VENDOR_IETF, EAP_TYPE_IDENTITY,
 
95
                               respData, &len);
 
96
        if (pos == NULL) {
 
97
                wpa_printf(MSG_INFO, "EAP-Identity: Invalid frame");
 
98
                return TRUE;
 
99
        }
 
100
 
 
101
        return FALSE;
 
102
}
 
103
 
 
104
 
 
105
static void eap_identity_process(struct eap_sm *sm, void *priv,
 
106
                                 struct wpabuf *respData)
 
107
{
 
108
        struct eap_identity_data *data = priv;
 
109
        const u8 *pos;
 
110
        size_t len;
 
111
 
 
112
        if (data->pick_up) {
 
113
                if (eap_identity_check(sm, data, respData)) {
 
114
                        wpa_printf(MSG_DEBUG, "EAP-Identity: failed to pick "
 
115
                                   "up already started negotiation");
 
116
                        data->state = FAILURE;
 
117
                        return;
 
118
                }
 
119
                data->pick_up = 0;
 
120
        }
 
121
 
 
122
        pos = eap_hdr_validate(EAP_VENDOR_IETF, EAP_TYPE_IDENTITY,
 
123
                               respData, &len);
 
124
        if (pos == NULL)
 
125
                return; /* Should not happen - frame already validated */
 
126
 
 
127
        wpa_hexdump_ascii(MSG_DEBUG, "EAP-Identity: Peer identity", pos, len);
 
128
        os_free(sm->identity);
 
129
        sm->identity = os_malloc(len ? len : 1);
 
130
        if (sm->identity == NULL) {
 
131
                data->state = FAILURE;
 
132
        } else {
 
133
                os_memcpy(sm->identity, pos, len);
 
134
                sm->identity_len = len;
 
135
                data->state = SUCCESS;
 
136
        }
 
137
}
 
138
 
 
139
 
 
140
static Boolean eap_identity_isDone(struct eap_sm *sm, void *priv)
 
141
{
 
142
        struct eap_identity_data *data = priv;
 
143
        return data->state != CONTINUE;
 
144
}
 
145
 
 
146
 
 
147
static Boolean eap_identity_isSuccess(struct eap_sm *sm, void *priv)
 
148
{
 
149
        struct eap_identity_data *data = priv;
 
150
        return data->state == SUCCESS;
 
151
}
 
152
 
 
153
 
 
154
int eap_server_identity_register(void)
 
155
{
 
156
        struct eap_method *eap;
 
157
        int ret;
 
158
 
 
159
        eap = eap_server_method_alloc(EAP_SERVER_METHOD_INTERFACE_VERSION,
 
160
                                      EAP_VENDOR_IETF, EAP_TYPE_IDENTITY,
 
161
                                      "Identity");
 
162
        if (eap == NULL)
 
163
                return -1;
 
164
 
 
165
        eap->init = eap_identity_init;
 
166
        eap->initPickUp = eap_identity_initPickUp;
 
167
        eap->reset = eap_identity_reset;
 
168
        eap->buildReq = eap_identity_buildReq;
 
169
        eap->check = eap_identity_check;
 
170
        eap->process = eap_identity_process;
 
171
        eap->isDone = eap_identity_isDone;
 
172
        eap->isSuccess = eap_identity_isSuccess;
 
173
 
 
174
        ret = eap_server_method_register(eap);
 
175
        if (ret)
 
176
                eap_server_method_free(eap);
 
177
        return ret;
 
178
}