Home | History | Annotate | Download | only in ap

Lines Matching refs:wps

2  * hostapd / WPS integration
21 #include "wps/wps.h"
22 #include "wps/wps_defs.h"
23 #include "wps/wps_dev_attr.h"
24 #include "wps/wps_attr_parse.h"
34 #include "wps/wps_upnp.h"
36 struct wps_context *wps);
94 wpa_printf(MSG_DEBUG, "Received new WPA/WPA2-PSK from WPS for STA "
157 wpa_printf(MSG_DEBUG, "WPS: PIN needed for E-UUID %s", uuid);
197 if (hapd != data->current_hapd && hapd->wps != NULL)
198 wps_registrar_complete(hapd->wps->registrar, data->uuid_e,
259 wpa_printf(MSG_DEBUG, "WPS: Reload configuration data");
262 wpa_printf(MSG_WARNING, "WPS: Failed to reload the updated "
292 if (hapd->wps == NULL)
295 wpa_hexdump_key(MSG_DEBUG, "WPS: Received Credential attribute",
298 wpa_printf(MSG_DEBUG, "WPS: Received new AP Settings");
299 wpa_hexdump_ascii(MSG_DEBUG, "WPS: SSID", cred->ssid, cred->ssid_len);
300 wpa_printf(MSG_DEBUG, "WPS: Authentication Type 0x%x",
302 wpa_printf(MSG_DEBUG, "WPS: Encryption Type 0x%x", cred->encr_type);
303 wpa_printf(MSG_DEBUG, "WPS: Network Key Index %d", cred->key_idx);
304 wpa_hexdump_key(MSG_DEBUG, "WPS: Network Key",
306 wpa_printf(MSG_DEBUG, "WPS: MAC Address " MACSTR,
326 os_memcpy(hapd->wps->ssid, cred->ssid, cred->ssid_len);
327 hapd->wps->ssid_len = cred->ssid_len;
328 hapd->wps->encr_types = cred->encr_type;
329 hapd->wps->auth_types = cred->auth_type;
331 os_free(hapd->wps->network_key);
332 hapd->wps->network_key = NULL;
333 hapd->wps->network_key_len = 0;
335 if (hapd->wps->network_key == NULL ||
336 hapd->wps->network_key_len < cred->key_len) {
337 hapd->wps->network_key_len = 0;
338 os_free(hapd->wps->network_key);
339 hapd->wps->network_key = os_malloc(cred->key_len);
340 if (hapd->wps->network_key == NULL)
343 hapd->wps->network_key_len = cred->key_len;
344 os_memcpy(hapd->wps->network_key, cred->key, cred->key_len);
346 hapd->wps->wps_state = WPS_STATE_CONFIGURED;
358 wpa_printf(MSG_WARNING, "WPS: Could not open current "
366 wpa_printf(MSG_WARNING, "WPS: Could not write updated "
373 fprintf(nconf, "# WPS configuration - START\n");
435 wpa_printf(MSG_WARNING, "WPS: Invalid key length %lu "
469 fprintf(nconf, "# WPS configuration - END\n");
488 fprintf(nconf, "#WPS# %s", buf);
497 wpa_printf(MSG_WARNING, "WPS: Failed to rename the updated "
511 wpa_printf(MSG_DEBUG, "WPS: AP configuration updated");
533 wpa_printf(MSG_DEBUG, "WPS: Re-enable AP PIN");
535 hapd->wps->ap_setup_locked = 0;
536 wps_registrar_update_ie(hapd->wps->registrar);
544 if (!data->enrollee || hapd->conf->ap_pin == NULL || hapd->wps == NULL)
554 wpa_printf(MSG_DEBUG, "WPS: AP PIN authentication failure number %u "
561 hapd->wps->ap_setup_locked = 1;
563 wps_registrar_update_ie(hapd->wps->registrar);
572 wpa_printf(MSG_DEBUG, "WPS: AP PIN disabled indefinitely");
580 wpa_printf(MSG_DEBUG, "WPS: Disable AP PIN for %u seconds",
601 if (hapd->conf->ap_pin == NULL || hapd->wps == NULL)
607 wpa_printf(MSG_DEBUG, "WPS: Clear consecutive AP PIN failure counter "
711 if (hapd->wps && !is_nil_uuid(hapd->wps->uuid)) {
712 *uuid = hapd->wps->uuid;
755 struct wps_context *wps)
760 wpabuf_free(wps->dev.vendor_ext[i]);
761 wps->dev.vendor_ext[i] = NULL;
766 wps->dev.vendor_ext[i] =
768 if (wps->dev.vendor_ext[i] == NULL) {
770 wpabuf_free(wps->dev.vendor_ext[i]);
782 struct wps_context *wps;
790 wps = os_zalloc(sizeof(*wps));
791 if (wps == NULL)
794 wps->cred_cb = hostapd_wps_cred_cb;
795 wps->event_cb = hostapd_wps_event_cb;
796 wps->cb_ctx = hapd;
799 wps->wps_state = hapd->conf->wps_state;
800 wps->ap_setup_locked = hapd->conf->ap_setup_locked;
805 os_memcpy(wps->uuid, uuid, UUID_LEN);
806 wpa_hexdump(MSG_DEBUG, "WPS: Clone UUID from another "
807 "interface", wps->uuid, UUID_LEN);
809 uuid_gen_mac_addr(hapd->own_addr, wps->uuid);
810 wpa_hexdump(MSG_DEBUG, "WPS: UUID based on MAC "
811 "address", wps->uuid, UUID_LEN);
814 os_memcpy(wps->uuid, hapd->conf->uuid, UUID_LEN);
815 wpa_hexdump(MSG_DEBUG, "WPS: Use configured UUID",
816 wps->uuid, UUID_LEN);
818 wps->ssid_len = hapd->conf->ssid.ssid_len;
819 os_memcpy(wps->ssid, hapd->conf->ssid.ssid, wps->ssid_len);
820 wps->ap = 1;
821 os_memcpy(wps->dev.mac_addr, hapd->own_addr, ETH_ALEN);
822 wps->dev.device_name = hapd->conf->device_name ?
824 wps->dev.manufacturer = hapd->conf->manufacturer ?
826 wps->dev.model_name = hapd->conf->model_name ?
828 wps->dev.model_number = hapd->conf->model_number ?
830 wps->dev.serial_number = hapd->conf->serial_number ?
832 wps->config_methods =
835 if ((wps->config_methods &
838 wpa_printf(MSG_INFO, "WPS: Converting display to "
839 "virtual_display for WPS 2.0 compliance");
840 wps->config_methods |= WPS_CONFIG_VIRT_DISPLAY;
842 if ((wps->config_methods &
845 wpa_printf(MSG_INFO, "WPS: Converting push_button to "
846 "virtual_push_button for WPS 2.0 compliance");
847 wps->config_methods |= WPS_CONFIG_VIRT_PUSHBUTTON;
850 os_memcpy(wps->dev.pri_dev_type, hapd->conf->device_type,
853 if (hostapd_wps_set_vendor_ext(hapd, wps) < 0) {
854 os_free(wps);
858 wps->dev.os_version = WPA_GET_BE32(hapd->conf->os_version);
861 wps->dev.rf_bands = conf->wps_rf_bands;
863 wps->dev.rf_bands =
870 wps->auth_types |= WPS_AUTH_WPA2PSK;
872 wps->auth_types |= WPS_AUTH_WPA2;
875 wps->encr_types |= WPS_ENCR_AES;
877 wps->encr_types |= WPS_ENCR_TKIP;
882 wps->auth_types |= WPS_AUTH_WPAPSK;
884 wps->auth_types |= WPS_AUTH_WPA;
887 wps->encr_types |= WPS_ENCR_AES;
889 wps->encr_types |= WPS_ENCR_TKIP;
893 wps->encr_types |= WPS_ENCR_NONE;
894 wps->auth_types |= WPS_AUTH_OPEN;
896 wps->encr_types |= WPS_ENCR_WEP;
898 wps->auth_types |= WPS_AUTH_OPEN;
900 wps->auth_types |= WPS_AUTH_SHARED;
902 wps->auth_types |= WPS_AUTH_OPEN;
904 wps->encr_types |= WPS_ENCR_WEP;
906 wps->encr_types |= WPS_ENCR_NONE;
912 wps->network_key = (u8 *) os_strdup(conf->ssid.wpa_passphrase);
913 wps->network_key_len = os_strlen(conf->ssid.wpa_passphrase);
915 wps->network_key = os_malloc(2 * PMK_LEN + 1);
916 if (wps->network_key == NULL) {
917 os_free(wps);
920 wpa_snprintf_hex((char *) wps->network_key, 2 * PMK_LEN + 1,
922 wps->network_key_len = 2 * PMK_LEN;
924 wps->network_key = os_malloc(conf->ssid.wep.len[0]);
925 if (wps->network_key == NULL) {
926 os_free(wps);
929 os_memcpy(wps->network_key, conf->ssid.wep.key[0],
931 wps->network_key_len = conf->ssid.wep.len[0];
935 os_memcpy(wps->psk, conf->ssid.wpa_psk->psk, PMK_LEN);
936 wps->psk_set = 1;
941 wps->auth_types = WPS_AUTH_WPA2PSK | WPS_AUTH_WPAPSK;
942 wps->encr_types = WPS_ENCR_AES | WPS_ENCR_TKIP;
945 wps->ap_settings = conf->ap_settings;
946 wps->ap_settings_len = conf->ap_settings_len;
963 wpa_printf(MSG_DEBUG, "WPS: Dualband AP");
965 wps->registrar = wps_registrar_init(wps, &cfg);
966 if (wps->registrar == NULL) {
967 wpa_printf(MSG_ERROR, "Failed to initialize WPS Registrar");
968 os_free(wps->network_key);
969 os_free(wps);
974 wps->friendly_name = hapd->conf->friendly_name;
975 wps->manufacturer_url = hapd->conf->manufacturer_url;
976 wps->model_description = hapd->conf->model_description;
977 wps->model_url = hapd->conf->model_url;
978 wps->upc = hapd->conf->upc;
983 hapd->wps = wps;
991 struct wps_context *wps = hapd->wps;
993 if (wps == NULL)
997 if (hostapd_wps_upnp_init(hapd, wps) < 0) {
998 wpa_printf(MSG_ERROR, "Failed to initialize WPS UPnP");
999 wps_registrar_deinit(wps->registrar);
1000 os_free(wps->network_key);
1001 os_free(wps);
1002 hapd->wps = NULL;
1011 static void hostapd_wps_nfc_clear(struct wps_context *wps)
1014 wps->ap_nfc_dev_pw_id = 0;
1015 wpabuf_free(wps->ap_nfc_dh_pubkey);
1016 wps->ap_nfc_dh_pubkey = NULL;
1017 wpabuf_free(wps->ap_nfc_dh_privkey);
1018 wps->ap_nfc_dh_privkey = NULL;
1019 wpabuf_free(wps->ap_nfc_dev_pw);
1020 wps->ap_nfc_dev_pw = NULL;
1029 if (hapd->wps == NULL)
1034 wps_registrar_deinit(hapd->wps->registrar);
1035 os_free(hapd->wps->network_key);
1036 wps_device_data_free(&hapd->wps->dev);
1037 wpabuf_free(hapd->wps->dh_pubkey);
1038 wpabuf_free(hapd->wps->dh_privkey);
1039 wpabuf_free(hapd->wps->oob_conf.pubkey_hash);
1040 wpabuf_free(hapd->wps->oob_conf.dev_password);
1041 wps_free_pending_msgs(hapd->wps->upnp_msgs);
1042 hostapd_wps_nfc_clear(hapd->wps);
1043 os_free(hapd->wps);
1044 hapd->wps = NULL;
1051 if (hapd->wps == NULL)
1055 hapd->wps->friendly_name = hapd->conf->friendly_name;
1056 hapd->wps->manufacturer_url = hapd->conf->manufacturer_url;
1057 hapd->wps->model_description = hapd->conf->model_description;
1058 hapd->wps->model_url = hapd->conf->model_url;
1059 hapd->wps->upc = hapd->conf->upc;
1062 hostapd_wps_set_vendor_ext(hapd, hapd->wps);
1065 wps_registrar_update_ie(hapd->wps->registrar);
1086 if (hapd->wps == NULL)
1088 ret = wps_registrar_add_pin(hapd->wps->registrar, data->addr,
1126 if (hapd->wps == NULL)
1128 return wps_registrar_button_pushed(hapd->wps->registrar, p2p_dev_addr);
1142 if (hapd->wps == NULL)
1145 wps_registrar_wps_cancel(hapd->wps->registrar);
1162 struct wps_context *wps = hapd->wps;
1170 wps->oob_conf.oob_method = wps_get_oob_method(method);
1172 if (wps->oob_conf.oob_method == OOB_METHOD_DEV_PWD_R) {
1177 wpabuf_free(wps->dh_pubkey);
1178 wpabuf_free(wps->dh_privkey);
1179 wps->dh_privkey = NULL;
1180 wps->dh_pubkey = dh_init(dh_groups_get(WPS_DH_GROUP),
1181 &wps->dh_privkey);
1182 wps->dh_pubkey = wpabuf_zeropad(wps->dh_pubkey, 192);
1183 if (wps->dh_pubkey == NULL) {
1184 wpa_printf(MSG_ERROR, "WPS: Failed to initialize "
1190 if (wps_process_oob(wps, oob_dev, 1) < 0)
1193 if ((wps->oob_conf.oob_method == OOB_METHOD_DEV_PWD_E ||
1194 wps->oob_conf.oob_method == OOB_METHOD_DEV_PWD_R) &&
1196 wpabuf_head(wps->oob_conf.dev_password), 0) <
1203 wpabuf_free(wps->dh_pubkey);
1204 wps->dh_pubkey = NULL;
1205 wpabuf_free(wps->dh_privkey);
1206 wps->dh_privkey = NULL;
1221 if (hapd->wps == NULL)
1225 wpa_printf(MSG_DEBUG, "WPS: Could not parse ProbeReq from "
1252 wps_registrar_probe_req_rx(hapd->wps->registrar, addr, wps_ie,
1256 * WPS attributes? Full ProbeReq frame? */
1281 wpa_printf(MSG_DEBUG, "WPS UPnP: PutWLANResponse ev_type=%d mac_addr="
1283 wpa_hexdump(MSG_MSGDUMP, "WPS UPnP: PutWLANResponse NewMessage",
1286 wpa_printf(MSG_DEBUG, "WPS UPnP: Ignored unexpected "
1292 * EAP response to ongoing to WPS Registration. Send it to EAP-WSC
1301 * Pick STA that is in an ongoing WPS registration without
1304 wpa_printf(MSG_DEBUG, "WPS UPnP: No matching STA found based "
1314 wpa_printf(MSG_DEBUG, "WPS UPnP: No matching STA found");
1324 p->next = hapd->wps->upnp_msgs;
1325 hapd->wps->upnp_msgs = p;
1332 struct wps_context *wps)
1346 hapd->wps_upnp = upnp_wps_device_init(ctx, wps, hapd,
1350 wps->wps_upnp = hapd->wps_upnp;
1367 if (hapd->wps == NULL)
1369 return wps_registrar_get_info(hapd->wps->registrar, addr, buf, buflen);
1376 wpa_printf(MSG_DEBUG, "WPS: AP PIN timed out");
1384 wpa_printf(MSG_DEBUG, "WPS: Enabling AP PIN (timeout=%d)", timeout);
1388 if (hapd->wps->ap_setup_locked) {
1390 hapd->wps->ap_setup_locked = 0;
1391 wps_registrar_update_ie(hapd->wps->registrar);
1414 wpa_printf(MSG_DEBUG, "WPS: Disabling AP PIN");
1473 if (hapd->wps)
1474 wps_registrar_update_ie(hapd->wps->registrar);
1530 return wps_registrar_config_ap(hapd->wps->registrar, &cred);
1548 if (hapd->wps == NULL)
1550 ret = wps_registrar_add_nfc_password_token(hapd->wps->registrar,
1574 const struct wpabuf *wps)
1578 wpa_hexdump_buf(MSG_DEBUG, "WPS: Received NFC tag payload", wps);
1580 if (wps_parse_msg(wps, &attr)) {
1581 wpa_printf(MSG_DEBUG, "WPS: Ignore invalid data from NFC tag");
1588 wpa_printf(MSG_DEBUG, "WPS: Ignore unrecognized NFC tag");
1596 const struct wpabuf *wps = data;
1607 wpa_printf(MSG_DEBUG, "WPS: Could not parse NDEF");
1610 wps = tmp;
1613 ret = hostapd_wps_nfc_tag_process(hapd, wps);
1624 if (hapd->wps == NULL)
1627 ret = wps_get_oob_cred(hapd->wps);
1652 struct wps_context *wps = hapd->wps;
1654 if (wps == NULL)
1663 hostapd_wps_nfc_clear(wps);
1664 wps->ap_nfc_dev_pw_id = hapd->conf->wps_nfc_dev_pw_id;
1665 wps->ap_nfc_dh_pubkey = wpabuf_dup(hapd->conf->wps_nfc_dh_pubkey);
1666 wps->ap_nfc_dh_privkey = wpabuf_dup(hapd->conf->wps_nfc_dh_privkey);
1667 wps->ap_nfc_dev_pw = wpabuf_dup(hapd->conf->wps_nfc_dev_pw);
1669 if (!wps->ap_nfc_dh_pubkey || !wps->ap_nfc_dh_privkey ||
1670 !wps->ap_nfc_dev_pw) {
1671 hostapd_wps_nfc_clear(wps);
1681 hostapd_wps_nfc_clear(hapd->wps);