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

« back to all changes in this revision

Viewing changes to eap_otp.c

  • Committer: Bazaar Package Importer
  • Author(s): Reinhard Tartler, Kel Modderman, Reinhard Tartler
  • Date: 2007-06-17 10:33:31 UTC
  • mfrom: (1.1.8 upstream)
  • Revision ID: james.westby@ubuntu.com-20070617103331-yeag0brnomq30kiu
Tags: 0.6.0-1
[Kel Modderman]
* New upstream release.
  - restructured source layout
* Adjust debian/wpasupplicant.examples, debian/wpagui.install,
  debian/wpasupplicant.install, debian/wpasupplicant.manpages, and
  debian/wpasupplicant.docs for new layout.
* Redjust debian/patches/30_dbus_policy.dpatch and
  debian/patches/40_debian_doc_examples.dpatch to apply against new layout.
* Drop debian/patches/10_config.dpatch and
  debian/patches/21_madwifi_includes.dpatch.
* Introduce makefile fragment for wpa_supplicant .config creation. Call it
  from debian/rules. It is named debian/dot.config.mk.
* Add WPADIR variable to debian/rules, adjust build and install targets to
  use WPADIR.
* Update madwifi_headers patch with code from current madwifi SVN trunk.
* Damage control: allow 'wpa-conf managed' to pass through without failure
  for those people who followed the poor example outlined in the hidden
  ssid's section of README.modes. Also remove the offending line from the
  documentaion. (Closes: #428137)

[Reinhard Tartler]
* Fix building wpagui.
* remove debian/wpasupplicant.preinst, since we don't support upgrades
  from oldstable. This way we don't need to look at /var/lib/dpkg/status
  anymore, which is unreliable anyway. Makes lintian happy.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/*
2
 
 * EAP peer method: EAP-OTP (RFC 3748)
3
 
 * Copyright (c) 2004-2006, Jouni Malinen <jkmaline@cc.hut.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
 
static void * eap_otp_init(struct eap_sm *sm)
22
 
{
23
 
        /* No need for private data. However, must return non-NULL to indicate
24
 
         * success. */
25
 
        return (void *) 1;
26
 
}
27
 
 
28
 
 
29
 
static void eap_otp_deinit(struct eap_sm *sm, void *priv)
30
 
{
31
 
}
32
 
 
33
 
 
34
 
static u8 * eap_otp_process(struct eap_sm *sm, void *priv,
35
 
                            struct eap_method_ret *ret,
36
 
                            const u8 *reqData, size_t reqDataLen,
37
 
                            size_t *respDataLen)
38
 
{
39
 
        const struct eap_hdr *req;
40
 
        struct eap_hdr *resp;
41
 
        const u8 *pos, *password;
42
 
        u8 *rpos;
43
 
        size_t password_len, len;
44
 
        int otp;
45
 
 
46
 
        pos = eap_hdr_validate(EAP_VENDOR_IETF, EAP_TYPE_OTP,
47
 
                               reqData, reqDataLen, &len);
48
 
        if (pos == NULL) {
49
 
                ret->ignore = TRUE;
50
 
                return NULL;
51
 
        }
52
 
        req = (const struct eap_hdr *) reqData;
53
 
        wpa_hexdump_ascii(MSG_MSGDUMP, "EAP-OTP: Request message",
54
 
                          pos, len);
55
 
 
56
 
        password = eap_get_config_otp(sm, &password_len);
57
 
        if (password)
58
 
                otp = 1;
59
 
        else {
60
 
                password = eap_get_config_password(sm, &password_len);
61
 
                otp = 0;
62
 
        }
63
 
 
64
 
        if (password == NULL) {
65
 
                wpa_printf(MSG_INFO, "EAP-OTP: Password not configured");
66
 
                eap_sm_request_otp(sm, (const char *) pos, len);
67
 
                ret->ignore = TRUE;
68
 
                return NULL;
69
 
        }
70
 
 
71
 
        ret->ignore = FALSE;
72
 
 
73
 
        ret->methodState = METHOD_DONE;
74
 
        ret->decision = DECISION_COND_SUCC;
75
 
        ret->allowNotifications = FALSE;
76
 
 
77
 
        resp = eap_msg_alloc(EAP_VENDOR_IETF, EAP_TYPE_OTP, respDataLen,
78
 
                             password_len, EAP_CODE_RESPONSE, req->identifier,
79
 
                             &rpos);
80
 
        if (resp == NULL)
81
 
                return NULL;
82
 
        os_memcpy(rpos, password, password_len);
83
 
        wpa_hexdump_ascii_key(MSG_MSGDUMP, "EAP-OTP: Response",
84
 
                              password, password_len);
85
 
 
86
 
        if (otp) {
87
 
                wpa_printf(MSG_DEBUG, "EAP-OTP: Forgetting used password");
88
 
                eap_clear_config_otp(sm);
89
 
        }
90
 
 
91
 
        return (u8 *) resp;
92
 
}
93
 
 
94
 
 
95
 
int eap_peer_otp_register(void)
96
 
{
97
 
        struct eap_method *eap;
98
 
        int ret;
99
 
 
100
 
        eap = eap_peer_method_alloc(EAP_PEER_METHOD_INTERFACE_VERSION,
101
 
                                    EAP_VENDOR_IETF, EAP_TYPE_OTP, "OTP");
102
 
        if (eap == NULL)
103
 
                return -1;
104
 
 
105
 
        eap->init = eap_otp_init;
106
 
        eap->deinit = eap_otp_deinit;
107
 
        eap->process = eap_otp_process;
108
 
 
109
 
        ret = eap_peer_method_register(eap);
110
 
        if (ret)
111
 
                eap_peer_method_free(eap);
112
 
        return ret;
113
 
}