From patchwork Thu Sep 5 09:34:40 2019 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: 1158324 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) 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="Gna0rsU5"; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="gF3bcyDw"; 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 46PFs812p2z9sNf for ; Thu, 5 Sep 2019 19:34:52 +1000 (AEST) 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=qMwgksE2CeM3lnEmeMeNh9oFF/PUsVdF0MKQMLjMn8I=; b=Gna0rsU5hcOlA4 E4yQUiYH8Z/UT3o99OgeUtwBI1geD9EVnfH9cujkciRckg/YlV6Eigh+gE06C6PjTO6uKL8R1ilGg OR3j29JFjYBSTnhmFexwSTfMXKFRgmtpR55AErChBuWPX7tZ6I670I7Fc8goNWpDoHAH0dzrwov6D bmm+DQQxwmvNqhXy413I6aRnMVSdt17avA8qUltZ5cJsV0cb2cIMvtK6MSD6rl8mCu2HzHqfbxb41 zedd3kw+ok+9+LTZDzFV6MyK7j+xGpBaEITolUVSCOs+r2eWlHOzIuA5DmGCwvJjWZFvNc/Iu5jma 4UwMXYb+tfuuydR4GtFQ==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.92 #3 (Red Hat Linux)) id 1i5oAD-0003By-Hm; Thu, 05 Sep 2019 09:34:49 +0000 Received: from mail-wr1-x42c.google.com ([2a00:1450:4864:20::42c]) by bombadil.infradead.org with esmtps (Exim 4.92 #3 (Red Hat Linux)) id 1i5oAB-0003BE-42 for hostap@lists.infradead.org; Thu, 05 Sep 2019 09:34:48 +0000 Received: by mail-wr1-x42c.google.com with SMTP id u16so1923857wrr.0 for ; Thu, 05 Sep 2019 02:34:46 -0700 (PDT) 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=Zq9o7ApDfC9s6upGH+0TPynaFfSIYqr07lhZg6msYlo=; b=gF3bcyDwekViGa07qSlsohq9UZqYVcdyGgxlOMzflnw3yfdWXzBNDJgMOml6xDJHeb ZR6Q5fPYNv/hBQTGuDFgI/BuQr5k08kh8fi0pGij90uW2eaqtw8YQGVPQ8vmQYTaiah3 rDSGEp8yiaNF5B2hJ3Ox2GIDy2eQtYbhENWrEm9MjOtI4OaeNsyUUy2btCzd9MYNSXYi 5sUw7nTEBXEaKuvHE0m4hYprUwSSqshrbr/wKwvsdK2WYkV1EwKCd4zvWCG41K4deFR3 cTviYzf4ahaesGm+DukmqrCwwqDSABv+oQqQxk6coZbSbxoKdlYWPkypZtHsh82e/1S9 Zvjg== 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=Zq9o7ApDfC9s6upGH+0TPynaFfSIYqr07lhZg6msYlo=; b=R54SxKtN90tCiW0RatEmU4RqIvXEEtML6X8Ug77xX0fmw7A9LwiL2XrL6mRHdx4tin s2LY/xghQ5h/gvbGJsZURhHJ0vSy+8YtSUEXXHSL//ic7+SbZQpgVWYeT7FhFrqQYY3s jWmSS9zGpMHPOmWkneYzI1qQWVCiw/rC7m4GlyJCi4SJeOmbYl/+u4MQwQ2QDhdBMFwr JDA9bUnNfMzdNIgt6DZG8PTdX1SAtjmdZ3L7amXQhHZm0FaEEyslaRt/pXzSgdLgeDfx 5XIBaHUceSxireWGheVKMNaux+Q77EiJc0dTI7SWhTlKnxJIA9QonuylyLti5vMJDILK +mrQ== X-Gm-Message-State: APjAAAWBglWuar2PSqdU07Eu/I1kYqKGPtwuw5J1NWp2CFWHuqule8fs VWrBOsKTFofXOeXi+QwsyV6KWnMmsbw= X-Google-Smtp-Source: APXvYqw3noLlWXkCSMFxEqhHqfya4GEFy4UcPlU9Phir4f8G8Oc/d5DcXEwScGfexB6A2v7vG2rJ6Q== X-Received: by 2002:a5d:6703:: with SMTP id o3mr1714491wru.335.1567676085270; Thu, 05 Sep 2019 02:34:45 -0700 (PDT) Received: from bilal-desktop.test.airties.com ([91.220.65.2]) by smtp.gmail.com with ESMTPSA id j22sm3029896wre.45.2019.09.05.02.34.44 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 05 Sep 2019 02:34:44 -0700 (PDT) From: bilalhp@gmail.com To: hostap@lists.infradead.org Subject: [PATCH] Add application extension data to WPS IE Date: Thu, 5 Sep 2019 12:34:40 +0300 Message-Id: <1567676080-20016-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-20190905_023447_167392_9193030D X-CRM114-Status: GOOD ( 16.27 ) 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:42c listed in] [list.dnswl.org] 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail provider (bilalhp[at]gmail.com) -0.0 SPF_PASS SPF: sender matches SPF record 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_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 -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature 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.06 page 105. This patch makes hostapd add this application extension data to WPS IE if configured. The implementation is very similar to vendor extension. Signed-off-by: Veli Demirel Signed-off-by: Bilal Hatipoglu Signed-off-by: Veli Demirel Signed-off-by: Bilal Hatipoglu --- src/ap/ap_config.c | 2 ++ src/ap/ap_config.h | 1 + src/ap/wps_hostapd.c | 29 +++++++++++++++++++++++++++++ src/wps/wps.h | 5 +++++ src/wps/wps_dev_attr.c | 19 +++++++++++++++++++ src/wps/wps_registrar.c | 6 ++++-- 6 files changed, 60 insertions(+), 2 deletions(-) diff --git a/src/ap/ap_config.c b/src/ap/ap_config.c index 80a73d6..6fac2cf 100644 --- a/src/ap/ap_config.c +++ b/src/ap/ap_config.c @@ -768,6 +768,8 @@ 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]); + for (i = 0; i < MAX_WPS_APPLICATION_EXTENSIONS; i++) + wpabuf_free(conf->wps_application_ext[i]); 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 c49b48f..3719f94 100644 --- a/src/ap/ap_config.h +++ b/src/ap/ap_config.h @@ -501,6 +501,7 @@ struct hostapd_bss_config { char *model_url; char *upc; struct wpabuf *wps_vendor_ext[MAX_WPS_VENDOR_EXTENSIONS]; + struct wpabuf *wps_application_ext[MAX_WPS_APPLICATION_EXTENSIONS]; 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 2f1af11..5aaf33a 100644 --- a/src/ap/wps_hostapd.c +++ b/src/ap/wps_hostapd.c @@ -993,6 +993,31 @@ 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) +{ + int i; + + for (i = 0; i < MAX_WPS_APPLICATION_EXTENSIONS; i++) { + wpabuf_free(wps->dev.application_ext[i]); + wps->dev.application_ext[i] = NULL; + + if (hapd->conf->wps_application_ext[i] == NULL) + continue; + + wps->dev.application_ext[i] = + wpabuf_dup(hapd->conf->wps_application_ext[i]); + if (wps->dev.application_ext[i] == NULL) { + while (--i >= 0) + wpabuf_free(wps->dev.application_ext[i]); + return -1; + } + } + + return 0; +} + + static void hostapd_free_wps(struct wps_context *wps) { int i; @@ -1085,6 +1110,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) { @@ -1319,6 +1347,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..8605490 100644 --- a/src/wps/wps.h +++ b/src/wps/wps.h @@ -66,6 +66,10 @@ struct wps_credential { #define WPS_MAX_VENDOR_EXT_LEN 1024 /* maximum number of parsed WPS vendor extension attributes */ #define MAX_WPS_PARSE_VENDOR_EXT 10 +/* maximum number of advertised WPS application extension attributes */ +#define MAX_WPS_APPLICATION_EXTENSIONS 10 +/* maximum size of WPS application extension attribute */ +#define WPS_MAX_APPLICATION_EXT_LEN 1024 /** * struct wps_device_data - WPS Device Data @@ -98,6 +102,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[MAX_WPS_APPLICATION_EXTENSIONS]; int p2p; u8 multi_ap_ext; diff --git a/src/wps/wps_dev_attr.c b/src/wps/wps_dev_attr.c index b209fea..0cc312e 100644 --- a/src/wps/wps_dev_attr.c +++ b/src/wps/wps_dev_attr.c @@ -242,6 +242,25 @@ 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 i; + + for (i = 0; i < MAX_WPS_APPLICATION_EXTENSIONS; i++) { + if (dev->application_ext[i] == NULL) + continue; + wpa_hexdump(MSG_DEBUG, "WPS: * Application Extension", + wpabuf_head_u8(dev->application_ext[i]), + wpabuf_len(dev->application_ext[i])); + wpabuf_put_be16(msg, ATTR_APPLICATION_EXT); + wpabuf_put_be16(msg, wpabuf_len(dev->application_ext[i])); + wpabuf_put_buf(msg, dev->application_ext[i]); + } + + 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_registrar.c b/src/wps/wps_registrar.c index 0ac5b28..3de7736 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;