~ubuntu-branches/ubuntu/gutsy/wpasupplicant/gutsy

« back to all changes in this revision

Viewing changes to src/eap_server/eap_mschapv2.c

  • Committer: Bazaar Package Importer
  • Author(s): Reinhard Tartler, Alexander Sack
  • Date: 2007-08-26 16:06:57 UTC
  • mfrom: (1.1.9 upstream)
  • Revision ID: james.westby@ubuntu.com-20070826160657-2m8pxoweuxe8f93t
Tags: 0.6.0+0.5.8-0ubuntu1
* New upstream release
* remove patch 11_erroneous_manpage_ref, applied upstream
* remove patch 25_wpas_dbus_unregister_iface_fix, applied upstream

[ Alexander Sack ]
* bumping upstream version to replace development version 0.6.0 with
  this package from stable release branch.
* attempt to fix wierd timeout and high latency issues by going
  back to stable upstream version (0.5.9) (LP: #140763,
  LP: #141233).

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/*
2
 
 * hostapd / EAP-MSCHAPv2 (draft-kamath-pppext-eap-mschapv2-00.txt) server
3
 
 * Copyright (c) 2004-2007, 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 "ms_funcs.h"
20
 
 
21
 
 
22
 
struct eap_mschapv2_hdr {
23
 
        u8 op_code; /* MSCHAPV2_OP_* */
24
 
        u8 mschapv2_id; /* must be changed for challenges, but not for
25
 
                         * success/failure */
26
 
        u8 ms_length[2]; /* Note: misaligned; length - 5 */
27
 
        /* followed by data */
28
 
} STRUCT_PACKED;
29
 
 
30
 
#define MSCHAPV2_OP_CHALLENGE 1
31
 
#define MSCHAPV2_OP_RESPONSE 2
32
 
#define MSCHAPV2_OP_SUCCESS 3
33
 
#define MSCHAPV2_OP_FAILURE 4
34
 
#define MSCHAPV2_OP_CHANGE_PASSWORD 7
35
 
 
36
 
#define MSCHAPV2_RESP_LEN 49
37
 
 
38
 
#define ERROR_RESTRICTED_LOGON_HOURS 646
39
 
#define ERROR_ACCT_DISABLED 647
40
 
#define ERROR_PASSWD_EXPIRED 648
41
 
#define ERROR_NO_DIALIN_PERMISSION 649
42
 
#define ERROR_AUTHENTICATION_FAILURE 691
43
 
#define ERROR_CHANGING_PASSWORD 709
44
 
 
45
 
#define PASSWD_CHANGE_CHAL_LEN 16
46
 
#define MSCHAPV2_KEY_LEN 16
47
 
 
48
 
 
49
 
#define CHALLENGE_LEN 16
50
 
 
51
 
struct eap_mschapv2_data {
52
 
        u8 auth_challenge[CHALLENGE_LEN];
53
 
        u8 auth_response[20];
54
 
        enum { CHALLENGE, SUCCESS_REQ, FAILURE_REQ, SUCCESS, FAILURE } state;
55
 
        u8 resp_mschapv2_id;
56
 
        u8 master_key[16];
57
 
        int master_key_valid;
58
 
};
59
 
 
60
 
 
61
 
static void * eap_mschapv2_init(struct eap_sm *sm)
62
 
{
63
 
        struct eap_mschapv2_data *data;
64
 
 
65
 
        data = os_zalloc(sizeof(*data));
66
 
        if (data == NULL)
67
 
                return NULL;
68
 
        data->state = CHALLENGE;
69
 
 
70
 
        return data;
71
 
}
72
 
 
73
 
 
74
 
static void eap_mschapv2_reset(struct eap_sm *sm, void *priv)
75
 
{
76
 
        struct eap_mschapv2_data *data = priv;
77
 
        free(data);
78
 
}
79
 
 
80
 
 
81
 
static u8 * eap_mschapv2_build_challenge(struct eap_sm *sm,
82
 
                                         struct eap_mschapv2_data *data,
83
 
                                         int id, size_t *reqDataLen)
84
 
{
85
 
        struct eap_hdr *req;
86
 
        struct eap_mschapv2_hdr *ms;
87
 
        u8 *pos;
88
 
        char *name = "hostapd"; /* TODO: make this configurable */
89
 
        size_t ms_len;
90
 
 
91
 
        if (hostapd_get_rand(data->auth_challenge, CHALLENGE_LEN)) {
92
 
                wpa_printf(MSG_ERROR, "EAP-MSCHAPV2: Failed to get random "
93
 
                           "data");
94
 
                data->state = FAILURE;
95
 
                return NULL;
96
 
        }
97
 
 
98
 
        ms_len = sizeof(*ms) + 1 + CHALLENGE_LEN + strlen(name);
99
 
        req = eap_msg_alloc(EAP_VENDOR_IETF, EAP_TYPE_MSCHAPV2, reqDataLen,
100
 
                            ms_len, EAP_CODE_REQUEST, id, &pos);
101
 
        if (req == NULL) {
102
 
                wpa_printf(MSG_ERROR, "EAP-MSCHAPV2: Failed to allocate memory"
103
 
                           " for request");
104
 
                data->state = FAILURE;
105
 
                return NULL;
106
 
        }
107
 
 
108
 
        ms = (struct eap_mschapv2_hdr *) pos;
109
 
        ms->op_code = MSCHAPV2_OP_CHALLENGE;
110
 
        ms->mschapv2_id = id;
111
 
        WPA_PUT_BE16(ms->ms_length, ms_len);
112
 
 
113
 
        pos = (u8 *) (ms + 1);
114
 
        *pos++ = CHALLENGE_LEN;
115
 
        memcpy(pos, data->auth_challenge, CHALLENGE_LEN);
116
 
        wpa_hexdump(MSG_MSGDUMP, "EAP-MSCHAPV2: Challenge", pos,
117
 
                    CHALLENGE_LEN);
118
 
        pos += CHALLENGE_LEN;
119
 
        memcpy(pos, name, strlen(name));
120
 
 
121
 
        return (u8 *) req;
122
 
}
123
 
 
124
 
 
125
 
static u8 * eap_mschapv2_build_success_req(struct eap_sm *sm,
126
 
                                           struct eap_mschapv2_data *data,
127
 
                                           int id, size_t *reqDataLen)
128
 
{
129
 
        struct eap_hdr *req;
130
 
        struct eap_mschapv2_hdr *ms;
131
 
        u8 *pos, *msg;
132
 
        char *message = "OK";
133
 
        size_t ms_len;
134
 
 
135
 
        ms_len = sizeof(*ms) + 2 + 2 * sizeof(data->auth_response) + 1 + 2 +
136
 
                strlen(message);
137
 
        req = eap_msg_alloc(EAP_VENDOR_IETF, EAP_TYPE_MSCHAPV2, reqDataLen,
138
 
                            ms_len, EAP_CODE_REQUEST, id, &pos);
139
 
        if (req == NULL) {
140
 
                wpa_printf(MSG_ERROR, "EAP-MSCHAPV2: Failed to allocate memory"
141
 
                           " for request");
142
 
                data->state = FAILURE;
143
 
                return NULL;
144
 
        }
145
 
 
146
 
        ms = (struct eap_mschapv2_hdr *) pos;
147
 
        ms->op_code = MSCHAPV2_OP_SUCCESS;
148
 
        ms->mschapv2_id = data->resp_mschapv2_id;
149
 
        WPA_PUT_BE16(ms->ms_length, ms_len);
150
 
 
151
 
        msg = pos = (u8 *) (ms + 1);
152
 
        *pos++ = 'S';
153
 
        *pos++ = '=';
154
 
        pos += wpa_snprintf_hex_uppercase((char *) pos,
155
 
                                          sizeof(data->auth_response) * 2 + 1,
156
 
                                          data->auth_response,
157
 
                                          sizeof(data->auth_response));
158
 
        *pos++ = ' ';
159
 
        *pos++ = 'M';
160
 
        *pos++ = '=';
161
 
        memcpy(pos, message, strlen(message));
162
 
 
163
 
        wpa_hexdump_ascii(MSG_MSGDUMP, "EAP-MSCHAPV2: Success Request Message",
164
 
                          msg, ms_len - sizeof(*ms));
165
 
 
166
 
        return (u8 *) req;
167
 
}
168
 
 
169
 
 
170
 
static u8 * eap_mschapv2_build_failure_req(struct eap_sm *sm,
171
 
                                           struct eap_mschapv2_data *data,
172
 
                                           int id, size_t *reqDataLen)
173
 
{
174
 
        struct eap_hdr *req;
175
 
        struct eap_mschapv2_hdr *ms;
176
 
        u8 *pos;
177
 
        char *message = "E=691 R=0 C=00000000000000000000000000000000 V=3 "
178
 
                "M=FAILED";
179
 
        size_t ms_len;
180
 
 
181
 
        ms_len = sizeof(*ms) + strlen(message);
182
 
        req = eap_msg_alloc(EAP_VENDOR_IETF, EAP_TYPE_MSCHAPV2, reqDataLen,
183
 
                            ms_len, EAP_CODE_REQUEST, id, &pos);
184
 
        if (req == NULL) {
185
 
                wpa_printf(MSG_ERROR, "EAP-MSCHAPV2: Failed to allocate memory"
186
 
                           " for request");
187
 
                data->state = FAILURE;
188
 
                return NULL;
189
 
        }
190
 
 
191
 
        ms = (struct eap_mschapv2_hdr *) pos;
192
 
        ms->op_code = MSCHAPV2_OP_FAILURE;
193
 
        ms->mschapv2_id = data->resp_mschapv2_id;
194
 
        WPA_PUT_BE16(ms->ms_length, ms_len);
195
 
 
196
 
        memcpy((u8 *) (ms + 1), message, strlen(message));
197
 
 
198
 
        wpa_hexdump_ascii(MSG_MSGDUMP, "EAP-MSCHAPV2: Failure Request Message",
199
 
                          (u8 *) message, strlen(message));
200
 
 
201
 
        return (u8 *) req;
202
 
}
203
 
 
204
 
 
205
 
static u8 * eap_mschapv2_buildReq(struct eap_sm *sm, void *priv, int id,
206
 
                                  size_t *reqDataLen)
207
 
{
208
 
        struct eap_mschapv2_data *data = priv;
209
 
 
210
 
        switch (data->state) {
211
 
        case CHALLENGE:
212
 
                return eap_mschapv2_build_challenge(sm, data, id, reqDataLen);
213
 
        case SUCCESS_REQ:
214
 
                return eap_mschapv2_build_success_req(sm, data, id,
215
 
                                                      reqDataLen);
216
 
        case FAILURE_REQ:
217
 
                return eap_mschapv2_build_failure_req(sm, data, id,
218
 
                                                      reqDataLen);
219
 
        default:
220
 
                wpa_printf(MSG_DEBUG, "EAP-MSCHAPV2: Unknown state %d in "
221
 
                           "buildReq", data->state);
222
 
                break;
223
 
        }
224
 
        return NULL;
225
 
}
226
 
 
227
 
 
228
 
static Boolean eap_mschapv2_check(struct eap_sm *sm, void *priv,
229
 
                                  u8 *respData, size_t respDataLen)
230
 
{
231
 
        struct eap_mschapv2_data *data = priv;
232
 
        struct eap_mschapv2_hdr *resp;
233
 
        const u8 *pos;
234
 
        size_t len;
235
 
 
236
 
        pos = eap_hdr_validate(EAP_VENDOR_IETF, EAP_TYPE_MSCHAPV2,
237
 
                               respData, respDataLen, &len);
238
 
        if (pos == NULL || len < 1) {
239
 
                wpa_printf(MSG_INFO, "EAP-MSCHAPV2: Invalid frame");
240
 
                return TRUE;
241
 
        }
242
 
 
243
 
        resp = (struct eap_mschapv2_hdr *) pos;
244
 
        if (data->state == CHALLENGE &&
245
 
            resp->op_code != MSCHAPV2_OP_RESPONSE) {
246
 
                wpa_printf(MSG_DEBUG, "EAP-MSCHAPV2: Expected Response - "
247
 
                           "ignore op %d", resp->op_code);
248
 
                return TRUE;
249
 
        }
250
 
 
251
 
        if (data->state == SUCCESS_REQ &&
252
 
            resp->op_code != MSCHAPV2_OP_SUCCESS &&
253
 
            resp->op_code != MSCHAPV2_OP_FAILURE) {
254
 
                wpa_printf(MSG_DEBUG, "EAP-MSCHAPV2: Expected Success or "
255
 
                           "Failure - ignore op %d", resp->op_code);
256
 
                return TRUE;
257
 
        }
258
 
 
259
 
        if (data->state == FAILURE_REQ &&
260
 
            resp->op_code != MSCHAPV2_OP_FAILURE) {
261
 
                wpa_printf(MSG_DEBUG, "EAP-MSCHAPV2: Expected Failure "
262
 
                           "- ignore op %d", resp->op_code);
263
 
                return TRUE;
264
 
        }
265
 
 
266
 
        return FALSE;
267
 
}
268
 
 
269
 
 
270
 
static void eap_mschapv2_process_response(struct eap_sm *sm,
271
 
                                          struct eap_mschapv2_data *data,
272
 
                                          u8 *respData, size_t respDataLen)
273
 
{
274
 
        struct eap_mschapv2_hdr *resp;
275
 
        const u8 *pos, *end, *peer_challenge, *nt_response, *name;
276
 
        u8 flags;
277
 
        size_t len, name_len, i;
278
 
        u8 expected[24];
279
 
        const u8 *username, *user;
280
 
        size_t username_len, user_len;
281
 
 
282
 
        pos = eap_hdr_validate(EAP_VENDOR_IETF, EAP_TYPE_MSCHAPV2,
283
 
                               respData, respDataLen, &len);
284
 
        if (pos == NULL || len < 1)
285
 
                return; /* Should not happen - frame already validated */
286
 
 
287
 
        end = pos + len;
288
 
        resp = (struct eap_mschapv2_hdr *) pos;
289
 
        pos = (u8 *) (resp + 1);
290
 
 
291
 
        if (len < sizeof(*resp) + 1 + 49 ||
292
 
            resp->op_code != MSCHAPV2_OP_RESPONSE ||
293
 
            pos[0] != 49) {
294
 
                wpa_hexdump(MSG_DEBUG, "EAP-MSCHAPV2: Invalid response",
295
 
                            respData, respDataLen);
296
 
                data->state = FAILURE;
297
 
                return;
298
 
        }
299
 
        data->resp_mschapv2_id = resp->mschapv2_id;
300
 
        pos++;
301
 
        peer_challenge = pos;
302
 
        pos += 16 + 8;
303
 
        nt_response = pos;
304
 
        pos += 24;
305
 
        flags = *pos++;
306
 
        name = pos;
307
 
        name_len = end - name;
308
 
 
309
 
        wpa_hexdump(MSG_MSGDUMP, "EAP-MSCHAPV2: Peer-Challenge",
310
 
                    peer_challenge, 16);
311
 
        wpa_hexdump(MSG_MSGDUMP, "EAP-MSCHAPV2: NT-Response", nt_response, 24);
312
 
        wpa_printf(MSG_MSGDUMP, "EAP-MSCHAPV2: Flags 0x%x", flags);
313
 
        wpa_hexdump_ascii(MSG_MSGDUMP, "EAP-MSCHAPV2: Name", name, name_len);
314
 
 
315
 
        /* MSCHAPv2 does not include optional domain name in the
316
 
         * challenge-response calculation, so remove domain prefix
317
 
         * (if present). */
318
 
        username = sm->identity;
319
 
        username_len = sm->identity_len;
320
 
        for (i = 0; i < username_len; i++) {
321
 
                if (username[i] == '\\') {
322
 
                        username_len -= i + 1;
323
 
                        username += i + 1;
324
 
                        break;
325
 
                }
326
 
        }
327
 
 
328
 
        user = name;
329
 
        user_len = name_len;
330
 
        for (i = 0; i < user_len; i++) {
331
 
                if (user[i] == '\\') {
332
 
                        user_len -= i + 1;
333
 
                        user += i + 1;
334
 
                        break;
335
 
                }
336
 
        }
337
 
 
338
 
        if (username_len != user_len ||
339
 
            memcmp(username, user, username_len) != 0) {
340
 
                wpa_printf(MSG_DEBUG, "EAP-MSCHAPV2: Mismatch in user names");
341
 
                wpa_hexdump_ascii(MSG_DEBUG, "EAP-MSCHAPV2: Expected user "
342
 
                                  "name", username, username_len);
343
 
                wpa_hexdump_ascii(MSG_DEBUG, "EAP-MSCHAPV2: Received user "
344
 
                                  "name", user, user_len);
345
 
                data->state = FAILURE;
346
 
                return;
347
 
        }
348
 
 
349
 
        wpa_hexdump_ascii(MSG_MSGDUMP, "EAP-MSCHAPV2: User name",
350
 
                          username, username_len);
351
 
 
352
 
        if (sm->user->password_hash) {
353
 
                generate_nt_response_pwhash(data->auth_challenge,
354
 
                                            peer_challenge,
355
 
                                            username, username_len,
356
 
                                            sm->user->password,
357
 
                                            expected);
358
 
        } else {
359
 
                generate_nt_response(data->auth_challenge, peer_challenge,
360
 
                                     username, username_len,
361
 
                                     sm->user->password,
362
 
                                     sm->user->password_len,
363
 
                                     expected);
364
 
        }
365
 
 
366
 
        if (memcmp(nt_response, expected, 24) == 0) {
367
 
                const u8 *pw_hash;
368
 
                u8 pw_hash_buf[16], pw_hash_hash[16];
369
 
 
370
 
                wpa_printf(MSG_DEBUG, "EAP-MSCHAPV2: Correct NT-Response");
371
 
                data->state = SUCCESS_REQ;
372
 
 
373
 
                /* Authenticator response is not really needed yet, but
374
 
                 * calculate it here so that peer_challenge and username need
375
 
                 * not be saved. */
376
 
                if (sm->user->password_hash) {
377
 
                        pw_hash = sm->user->password;
378
 
                        generate_authenticator_response_pwhash(
379
 
                                sm->user->password, peer_challenge,
380
 
                                data->auth_challenge, username, username_len,
381
 
                                nt_response, data->auth_response);
382
 
                } else {
383
 
                        nt_password_hash(sm->user->password,
384
 
                                         sm->user->password_len,
385
 
                                         pw_hash_buf);
386
 
                        pw_hash = pw_hash_buf;
387
 
                        generate_authenticator_response(sm->user->password,
388
 
                                                        sm->user->password_len,
389
 
                                                        peer_challenge,
390
 
                                                        data->auth_challenge,
391
 
                                                        username, username_len,
392
 
                                                        nt_response,
393
 
                                                        data->auth_response);
394
 
                }
395
 
 
396
 
                hash_nt_password_hash(pw_hash, pw_hash_hash);
397
 
                get_master_key(pw_hash_hash, nt_response, data->master_key);
398
 
                data->master_key_valid = 1;
399
 
                wpa_hexdump_key(MSG_DEBUG, "EAP-MSCHAPV2: Derived Master Key",
400
 
                                data->master_key, MSCHAPV2_KEY_LEN);
401
 
        } else {
402
 
                wpa_hexdump(MSG_MSGDUMP, "EAP-MSCHAPV2: Expected NT-Response",
403
 
                            expected, 24);
404
 
                wpa_printf(MSG_DEBUG, "EAP-MSCHAPV2: Invalid NT-Response");
405
 
                data->state = FAILURE_REQ;
406
 
        }
407
 
}
408
 
 
409
 
 
410
 
static void eap_mschapv2_process_success_resp(struct eap_sm *sm,
411
 
                                              struct eap_mschapv2_data *data,
412
 
                                              u8 *respData, size_t respDataLen)
413
 
{
414
 
        struct eap_mschapv2_hdr *resp;
415
 
        const u8 *pos;
416
 
        size_t len;
417
 
 
418
 
        pos = eap_hdr_validate(EAP_VENDOR_IETF, EAP_TYPE_MSCHAPV2,
419
 
                               respData, respDataLen, &len);
420
 
        if (pos == NULL || len < 1)
421
 
                return; /* Should not happen - frame already validated */
422
 
 
423
 
        resp = (struct eap_mschapv2_hdr *) pos;
424
 
 
425
 
        if (resp->op_code == MSCHAPV2_OP_SUCCESS) {
426
 
                wpa_printf(MSG_DEBUG, "EAP-MSCHAPV2: Received Success Response"
427
 
                           " - authentication completed successfully");
428
 
                data->state = SUCCESS;
429
 
        } else {
430
 
                wpa_printf(MSG_DEBUG, "EAP-MSCHAPV2: Did not receive Success "
431
 
                           "Response - peer rejected authentication");
432
 
                data->state = FAILURE;
433
 
        }
434
 
}
435
 
 
436
 
 
437
 
static void eap_mschapv2_process_failure_resp(struct eap_sm *sm,
438
 
                                              struct eap_mschapv2_data *data,
439
 
                                              u8 *respData, size_t respDataLen)
440
 
{
441
 
        struct eap_mschapv2_hdr *resp;
442
 
        const u8 *pos;
443
 
        size_t len;
444
 
 
445
 
        pos = eap_hdr_validate(EAP_VENDOR_IETF, EAP_TYPE_MSCHAPV2,
446
 
                               respData, respDataLen, &len);
447
 
        if (pos == NULL || len < 1)
448
 
                return; /* Should not happen - frame already validated */
449
 
 
450
 
        resp = (struct eap_mschapv2_hdr *) pos;
451
 
 
452
 
        if (resp->op_code == MSCHAPV2_OP_FAILURE) {
453
 
                wpa_printf(MSG_DEBUG, "EAP-MSCHAPV2: Received Failure Response"
454
 
                           " - authentication failed");
455
 
        } else {
456
 
                wpa_printf(MSG_DEBUG, "EAP-MSCHAPV2: Did not receive Failure "
457
 
                           "Response - authentication failed");
458
 
        }
459
 
 
460
 
        data->state = FAILURE;
461
 
}
462
 
 
463
 
 
464
 
static void eap_mschapv2_process(struct eap_sm *sm, void *priv,
465
 
                                 u8 *respData, size_t respDataLen)
466
 
{
467
 
        struct eap_mschapv2_data *data = priv;
468
 
 
469
 
        if (sm->user == NULL || sm->user->password == NULL) {
470
 
                wpa_printf(MSG_INFO, "EAP-MSCHAPV2: Password not configured");
471
 
                data->state = FAILURE;
472
 
                return;
473
 
        }
474
 
 
475
 
        switch (data->state) {
476
 
        case CHALLENGE:
477
 
                eap_mschapv2_process_response(sm, data, respData, respDataLen);
478
 
                break;
479
 
        case SUCCESS_REQ:
480
 
                eap_mschapv2_process_success_resp(sm, data, respData,
481
 
                                                  respDataLen);
482
 
                break;
483
 
        case FAILURE_REQ:
484
 
                eap_mschapv2_process_failure_resp(sm, data, respData,
485
 
                                                  respDataLen);
486
 
                break;
487
 
        default:
488
 
                wpa_printf(MSG_DEBUG, "EAP-MSCHAPV2: Unknown state %d in "
489
 
                           "process", data->state);
490
 
                break;
491
 
        }
492
 
}
493
 
 
494
 
 
495
 
static Boolean eap_mschapv2_isDone(struct eap_sm *sm, void *priv)
496
 
{
497
 
        struct eap_mschapv2_data *data = priv;
498
 
        return data->state == SUCCESS || data->state == FAILURE;
499
 
}
500
 
 
501
 
 
502
 
static u8 * eap_mschapv2_getKey(struct eap_sm *sm, void *priv, size_t *len)
503
 
{
504
 
        struct eap_mschapv2_data *data = priv;
505
 
        u8 *key;
506
 
 
507
 
        if (data->state != SUCCESS || !data->master_key_valid)
508
 
                return NULL;
509
 
 
510
 
        *len = 2 * MSCHAPV2_KEY_LEN;
511
 
        key = malloc(*len);
512
 
        if (key == NULL)
513
 
                return NULL;
514
 
        get_asymetric_start_key(data->master_key, key, MSCHAPV2_KEY_LEN, 0, 0);
515
 
        get_asymetric_start_key(data->master_key, key + MSCHAPV2_KEY_LEN,
516
 
                                MSCHAPV2_KEY_LEN, 1, 0);
517
 
        wpa_hexdump_key(MSG_DEBUG, "EAP-MSCHAPV2: Derived key", key, *len);
518
 
 
519
 
        return key;
520
 
}
521
 
 
522
 
 
523
 
static Boolean eap_mschapv2_isSuccess(struct eap_sm *sm, void *priv)
524
 
{
525
 
        struct eap_mschapv2_data *data = priv;
526
 
        return data->state == SUCCESS;
527
 
}
528
 
 
529
 
 
530
 
int eap_server_mschapv2_register(void)
531
 
{
532
 
        struct eap_method *eap;
533
 
        int ret;
534
 
 
535
 
        eap = eap_server_method_alloc(EAP_SERVER_METHOD_INTERFACE_VERSION,
536
 
                                      EAP_VENDOR_IETF, EAP_TYPE_MSCHAPV2,
537
 
                                      "MSCHAPV2");
538
 
        if (eap == NULL)
539
 
                return -1;
540
 
 
541
 
        eap->init = eap_mschapv2_init;
542
 
        eap->reset = eap_mschapv2_reset;
543
 
        eap->buildReq = eap_mschapv2_buildReq;
544
 
        eap->check = eap_mschapv2_check;
545
 
        eap->process = eap_mschapv2_process;
546
 
        eap->isDone = eap_mschapv2_isDone;
547
 
        eap->getKey = eap_mschapv2_getKey;
548
 
        eap->isSuccess = eap_mschapv2_isSuccess;
549
 
 
550
 
        ret = eap_server_method_register(eap);
551
 
        if (ret)
552
 
                eap_server_method_free(eap);
553
 
        return ret;
554
 
}