From patchwork Fri Jan 3 08:58:26 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?q?Bilal_Hatipo=C4=9Flu?= X-Patchwork-Id: 1217244 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (no SPF record) smtp.mailfrom=lists.infradead.org (client-ip=2607:7c80:54:e::133; helo=bombadil.infradead.org; envelope-from=hostap-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="LFeulyNz"; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="in5AvgJm"; dkim-atps=neutral Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:e::133]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 47pzN03BkSz9s29 for ; Fri, 3 Jan 2020 19:58:40 +1100 (AEDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:Message-Id:Date:Subject:To :From:Reply-To:Cc:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References: List-Owner; bh=Ex0GfU7SUojNVksd8Bz6mifo2Iem26MTUYwo3o2exCE=; b=LFeulyNz17Ic8D RL3mOUwD3oaFM/k9Ptos6l70RqT/KFRnQfLAgknXi/lKpL3euB6ovCW9E4TX4svPkKQukR98HyeVU QYYzFNazuzYbRzgrNiAE8rEDY/ENBBEihJ10YpaQsJxbAy0Yvasg/fYGZrpO4lszJK2OZd3XBZOI1 NUuH1a3ov/raRH5r/Nl0LFxnCxi6RXhb8vEd6DIHvHeGnLONMKppFZ4Rjm3Zozd7RqHLv+HmZ8sqI oe3OzA5LIvvfYBTlSgSKB+f3hahT9gcs3IiYwMoqOs6p99yyJ/YZlm+qeY8ziZjYdY2n+AYowqAES ScVg3EEbRbSOXkoDvqOQ==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1inImy-0007KN-Om; Fri, 03 Jan 2020 08:58:36 +0000 Received: from mail-lj1-x244.google.com ([2a00:1450:4864:20::244]) by bombadil.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1inImv-0007K3-PI for hostap@lists.infradead.org; Fri, 03 Jan 2020 08:58:35 +0000 Received: by mail-lj1-x244.google.com with SMTP id y4so28848812ljj.9 for ; Fri, 03 Jan 2020 00:58:33 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:subject:date:message-id:mime-version :content-transfer-encoding; bh=6NRCUO9/PhJUiyD81is2OZ/DQTDg2JWUTEwOmP+WuCA=; b=in5AvgJmWVCpttAs8rv0wlpDWNTiChM2lITdhqMdQkB1lt8iAdcaqKuE3wkvwGDlrC AiiEmOfROpvMexwiLJSHVqlfN54cpOfoooSO/bR11+VaPgiVABQYgdBYtUQ+6ImwFoJG ebFoBPCwlRhDB7JZ5QFK+GajT1mkGSKGYMTuWcFYhePwZy9vrazsvuCXFhwJ4w7rQotE a31Fso5JuA/LOlDqDZFR5hJ+4fKTUTZ7xNgVP72RHBUlXH4/9Eje3XJ+7/JNuh6x9nfZ 87UJsAA5NjpS/d8sJT3KYUaLxapTOv8H2a2AAiexFKYrCC2fSL+XMGY75ruj0gajmYPX U0sQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:mime-version :content-transfer-encoding; bh=6NRCUO9/PhJUiyD81is2OZ/DQTDg2JWUTEwOmP+WuCA=; b=Ukvev657ENjGFXEB6J6IGjU6EPP4WNi6M6O7PTc3f9Z0vBKDcdSnCC4HfkCgOnvZVZ kR0jQHN+E+iJTmGwgb5GrVSrOYAYKTblh/BfVXzVOwSjAaYP6GSdch80Bn/QIdCqfpVl zzm2H3h6Ft536VTlgY/+A+oL0dDbOyU6Oi16SwQ5kuvpZou4F4THzmG6Y9SPUztgGaC9 4s0SmwrFEleeeTtPkY6X7ROQONxsHLPVlBb0tTKsrIXiuUHDNVWS2P8Kq8BI0QO+MYBJ O4tx7BuwoYzX/PBgWBIIfhmcdTjgM4HQbDK1C9z9RTCo48O66b2GFdd4yiY4ZyI7bY3Q Fe3g== X-Gm-Message-State: APjAAAW2Pv3V7Qw4gdeb13U+zRmp1uckiOmrPC4vBNIDajL9uIjy3/cd AD5E8nFgDPbMZdcj5v5uv2m+xPdx X-Google-Smtp-Source: APXvYqyomvTB7hUDZBXnNzvSNG2WZYBtbbJlF0DdXeloqLtLFgWN2BH4I8OVzTTWyqVgJRBSROF2uA== X-Received: by 2002:a2e:884d:: with SMTP id z13mr52192154ljj.116.1578041911579; Fri, 03 Jan 2020 00:58:31 -0800 (PST) Received: from bilal-kubuntu-new.corp.airties.com ([91.220.65.3]) by smtp.gmail.com with ESMTPSA id e8sm28633660ljb.45.2020.01.03.00.58.30 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 03 Jan 2020 00:58:30 -0800 (PST) From: bilalhp@gmail.com To: hostap@lists.infradead.org Subject: [PATCH v5] Add application extension data to WPS IE Date: Fri, 3 Jan 2020 11:58:26 +0300 Message-Id: <1578041906-10980-1-git-send-email-bilalhp@gmail.com> X-Mailer: git-send-email 2.7.4 MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200103_005833_824108_EC1D5C76 X-CRM114-Status: GOOD ( 15.50 ) X-Spam-Score: -0.2 (/) X-Spam-Report: SpamAssassin version 3.4.2 on bombadil.infradead.org summary: Content analysis details: (-0.2 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [2a00:1450:4864:20:0:0:0:244 listed in] [list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail provider (bilalhp[at]gmail.com) 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid X-BeenThere: hostap@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "Hostap" Errors-To: hostap-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org From: Bilal Hatipoglu Application Extension attribute is defined in WPS Spec v2.07 page 104. This patch makes hostapd add this application extension data to WPS IE if configured. The implementation is very similar to vendor extension. A new optional entry called "wps_application_ext" is added to hostapd config file to configure this. Signed-off-by: Veli Demirel Signed-off-by: Bilal Hatipoglu --- hostapd/config_file.c | 3 +++ src/ap/ap_config.c | 1 + src/ap/ap_config.h | 1 + src/ap/wps_hostapd.c | 14 ++++++++++++++ src/wps/wps.h | 1 + src/wps/wps_dev_attr.c | 13 +++++++++++++ src/wps/wps_dev_attr.h | 1 + src/wps/wps_registrar.c | 6 ++++-- 8 files changed, 38 insertions(+), 2 deletions(-) diff --git a/hostapd/config_file.c b/hostapd/config_file.c index 21c9ab2..6a08116 100644 --- a/hostapd/config_file.c +++ b/hostapd/config_file.c @@ -3616,6 +3616,9 @@ static int hostapd_config_fill(struct hostapd_config *conf, } os_free(bss->device_name); bss->device_name = os_strdup(pos); + } else if (os_strcmp(buf, "wps_application_ext") == 0) { + wpabuf_free(bss->wps_application_ext); + bss->wps_application_ext = wpabuf_parse_bin(pos); } else if (os_strcmp(buf, "manufacturer") == 0) { if (os_strlen(pos) > 64) { wpa_printf(MSG_ERROR, "Line %d: Too long manufacturer", diff --git a/src/ap/ap_config.c b/src/ap/ap_config.c index 68af3c1..035c4bc 100644 --- a/src/ap/ap_config.c +++ b/src/ap/ap_config.c @@ -813,6 +813,7 @@ void hostapd_config_free_bss(struct hostapd_bss_config *conf) os_free(conf->upc); for (i = 0; i < MAX_WPS_VENDOR_EXTENSIONS; i++) wpabuf_free(conf->wps_vendor_ext[i]); + wpabuf_free(conf->wps_application_ext); wpabuf_free(conf->wps_nfc_dh_pubkey); wpabuf_free(conf->wps_nfc_dh_privkey); wpabuf_free(conf->wps_nfc_dev_pw); diff --git a/src/ap/ap_config.h b/src/ap/ap_config.h index 7e4b926..e97e616 100644 --- a/src/ap/ap_config.h +++ b/src/ap/ap_config.h @@ -498,6 +498,7 @@ struct hostapd_bss_config { char *model_url; char *upc; struct wpabuf *wps_vendor_ext[MAX_WPS_VENDOR_EXTENSIONS]; + struct wpabuf *wps_application_ext; int wps_nfc_pw_from_config; int wps_nfc_dev_pw_id; struct wpabuf *wps_nfc_dh_pubkey; diff --git a/src/ap/wps_hostapd.c b/src/ap/wps_hostapd.c index 175b9fc..e587e10 100644 --- a/src/ap/wps_hostapd.c +++ b/src/ap/wps_hostapd.c @@ -985,6 +985,16 @@ static int hostapd_wps_set_vendor_ext(struct hostapd_data *hapd, } +static int hostapd_wps_set_application_ext(struct hostapd_data *hapd, + struct wps_context *wps) +{ + wpabuf_free(wps->dev.application_ext); + wps->dev.application_ext = wpabuf_dup(hapd->conf->wps_application_ext); + + return 0; +} + + static void hostapd_free_wps(struct wps_context *wps) { int i; @@ -1077,6 +1087,9 @@ int hostapd_init_wps(struct hostapd_data *hapd, if (hostapd_wps_set_vendor_ext(hapd, wps) < 0) goto fail; + if (hostapd_wps_set_application_ext(hapd, wps) < 0) + goto fail; + wps->dev.os_version = WPA_GET_BE32(hapd->conf->os_version); if (conf->wps_rf_bands) { @@ -1311,6 +1324,7 @@ void hostapd_update_wps(struct hostapd_data *hapd) #endif /* CONFIG_WPS_UPNP */ hostapd_wps_set_vendor_ext(hapd, hapd->wps); + hostapd_wps_set_application_ext(hapd, hapd->wps); if (hapd->conf->wps_state) wps_registrar_update_ie(hapd->wps->registrar); diff --git a/src/wps/wps.h b/src/wps/wps.h index 9963c46..f42045e 100644 --- a/src/wps/wps.h +++ b/src/wps/wps.h @@ -98,6 +98,7 @@ struct wps_device_data { u16 config_methods; struct wpabuf *vendor_ext_m1; struct wpabuf *vendor_ext[MAX_WPS_VENDOR_EXTENSIONS]; + struct wpabuf *application_ext; int p2p; u8 multi_ap_ext; diff --git a/src/wps/wps_dev_attr.c b/src/wps/wps_dev_attr.c index b209fea..279307a 100644 --- a/src/wps/wps_dev_attr.c +++ b/src/wps/wps_dev_attr.c @@ -242,6 +242,19 @@ int wps_build_vendor_ext(struct wps_device_data *dev, struct wpabuf *msg) } +int wps_build_application_ext(struct wps_device_data *dev, struct wpabuf *msg) +{ + wpa_hexdump(MSG_DEBUG, "WPS: * Application Extension", + wpabuf_head_u8(dev->application_ext), + wpabuf_len(dev->application_ext)); + wpabuf_put_be16(msg, ATTR_APPLICATION_EXT); + wpabuf_put_be16(msg, wpabuf_len(dev->application_ext)); + wpabuf_put_buf(msg, dev->application_ext); + + return 0; +} + + static int wps_process_manufacturer(struct wps_device_data *dev, const u8 *str, size_t str_len) { diff --git a/src/wps/wps_dev_attr.h b/src/wps/wps_dev_attr.h index a4b4173..81fdd5f 100644 --- a/src/wps/wps_dev_attr.h +++ b/src/wps/wps_dev_attr.h @@ -33,6 +33,7 @@ void wps_process_vendor_ext_m1(struct wps_device_data *dev, const u8 ext); int wps_process_rf_bands(struct wps_device_data *dev, const u8 *bands); void wps_device_data_free(struct wps_device_data *dev); int wps_build_vendor_ext(struct wps_device_data *dev, struct wpabuf *msg); +int wps_build_application_ext(struct wps_device_data *dev, struct wpabuf *msg); int wps_build_req_dev_type(struct wps_device_data *dev, struct wpabuf *msg, unsigned int num_req_dev_types, const u8 *req_dev_types); diff --git a/src/wps/wps_registrar.c b/src/wps/wps_registrar.c index 671f5fe..da81d1a 100644 --- a/src/wps/wps_registrar.c +++ b/src/wps/wps_registrar.c @@ -1331,7 +1331,8 @@ static int wps_set_ie(struct wps_registrar *reg) wps_build_sel_pbc_reg_uuid_e(reg, beacon) || (reg->dualband && wps_build_rf_bands(®->wps->dev, beacon, 0)) || wps_build_wfa_ext(beacon, 0, auth_macs, count, 0) || - wps_build_vendor_ext(®->wps->dev, beacon)) { + wps_build_vendor_ext(®->wps->dev, beacon) || + wps_build_application_ext(®->wps->dev, beacon)) { wpabuf_free(beacon); wpabuf_free(probe); return -1; @@ -1361,7 +1362,8 @@ static int wps_set_ie(struct wps_registrar *reg) wps_build_probe_config_methods(reg, probe) || (reg->dualband && wps_build_rf_bands(®->wps->dev, probe, 0)) || wps_build_wfa_ext(probe, 0, auth_macs, count, 0) || - wps_build_vendor_ext(®->wps->dev, probe)) { + wps_build_vendor_ext(®->wps->dev, probe) || + wps_build_application_ext(®->wps->dev, probe)) { wpabuf_free(beacon); wpabuf_free(probe); return -1;