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.
19 #include "config_ssid.h"
22 static void * eap_otp_init(struct eap_sm *sm)
24 /* No need for private data. However, must return non-NULL to indicate
30 static void eap_otp_deinit(struct eap_sm *sm, void *priv)
35 static u8 * eap_otp_process(struct eap_sm *sm, void *priv,
36 struct eap_method_ret *ret,
37 const u8 *reqData, size_t reqDataLen,
40 const struct eap_hdr *req;
42 const u8 *pos, *password;
44 size_t password_len, len;
47 pos = eap_hdr_validate(EAP_VENDOR_IETF, EAP_TYPE_OTP,
48 reqData, reqDataLen, &len);
53 req = (const struct eap_hdr *) reqData;
54 wpa_hexdump_ascii(MSG_MSGDUMP, "EAP-OTP: Request message",
57 password = eap_get_config_otp(sm, &password_len);
61 password = eap_get_config_password(sm, &password_len);
65 if (password == NULL) {
66 wpa_printf(MSG_INFO, "EAP-OTP: Password not configured");
67 eap_sm_request_otp(sm, (const char *) pos, len);
74 ret->methodState = METHOD_DONE;
75 ret->decision = DECISION_COND_SUCC;
76 ret->allowNotifications = FALSE;
78 resp = eap_msg_alloc(EAP_VENDOR_IETF, EAP_TYPE_OTP, respDataLen,
79 password_len, EAP_CODE_RESPONSE, req->identifier,
83 os_memcpy(rpos, password, password_len);
84 wpa_hexdump_ascii_key(MSG_MSGDUMP, "EAP-OTP: Response",
85 password, password_len);
88 wpa_printf(MSG_DEBUG, "EAP-OTP: Forgetting used password");
89 eap_clear_config_otp(sm);
96 int eap_peer_otp_register(void)
98 struct eap_method *eap;
101 eap = eap_peer_method_alloc(EAP_PEER_METHOD_INTERFACE_VERSION,
102 EAP_VENDOR_IETF, EAP_TYPE_OTP, "OTP");
106 eap->init = eap_otp_init;
107 eap->deinit = eap_otp_deinit;
108 eap->process = eap_otp_process;
110 ret = eap_peer_method_register(eap);
112 eap_peer_method_free(eap);