2
* EAP peer method: EAP-OTP (RFC 3748)
3
* Copyright (c) 2004-2006, Jouni Malinen <j@w1.fi>
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.
9
* Alternatively, this software may be distributed under the terms of BSD
12
* See README and COPYING for more details.
21
static void * eap_otp_init(struct eap_sm *sm)
23
/* No need for private data. However, must return non-NULL to indicate
29
static void eap_otp_deinit(struct eap_sm *sm, void *priv)
34
static struct wpabuf * eap_otp_process(struct eap_sm *sm, void *priv,
35
struct eap_method_ret *ret,
36
const struct wpabuf *reqData)
39
const u8 *pos, *password;
40
size_t password_len, len;
43
pos = eap_hdr_validate(EAP_VENDOR_IETF, EAP_TYPE_OTP, reqData, &len);
48
wpa_hexdump_ascii(MSG_MSGDUMP, "EAP-OTP: Request message",
51
password = eap_get_config_otp(sm, &password_len);
55
password = eap_get_config_password(sm, &password_len);
59
if (password == NULL) {
60
wpa_printf(MSG_INFO, "EAP-OTP: Password not configured");
61
eap_sm_request_otp(sm, (const char *) pos, len);
68
ret->methodState = METHOD_DONE;
69
ret->decision = DECISION_COND_SUCC;
70
ret->allowNotifications = FALSE;
72
resp = eap_msg_alloc(EAP_VENDOR_IETF, EAP_TYPE_OTP, password_len,
73
EAP_CODE_RESPONSE, eap_get_id(reqData));
76
wpabuf_put_data(resp, password, password_len);
77
wpa_hexdump_ascii_key(MSG_MSGDUMP, "EAP-OTP: Response",
78
password, password_len);
81
wpa_printf(MSG_DEBUG, "EAP-OTP: Forgetting used password");
82
eap_clear_config_otp(sm);
89
int eap_peer_otp_register(void)
91
struct eap_method *eap;
94
eap = eap_peer_method_alloc(EAP_PEER_METHOD_INTERFACE_VERSION,
95
EAP_VENDOR_IETF, EAP_TYPE_OTP, "OTP");
99
eap->init = eap_otp_init;
100
eap->deinit = eap_otp_deinit;
101
eap->process = eap_otp_process;
103
ret = eap_peer_method_register(eap);
105
eap_peer_method_free(eap);