[v6,15/17] nl80211: Extended Key ID support
diff mbox series

Message ID 20190915200837.196283-16-alexander@wetzel-home.de
State New
Headers show
Series
  • Support seamless PTK rekeys with Extended Key ID
Related show

Commit Message

Alexander Wetzel Sept. 15, 2019, 8:08 p.m. UTC
Nl80211 supports Extended Key ID. Make the required changes to the
hostapd nl80211 driver to use it.

Signed-off-by: Alexander Wetzel <alexander@wetzel-home.de>
---

This patch allows hostapd/wpa_supplicant to start using Extended Key ID.

Since so far only linux support Extended Key ID (and only via nl80211)
the other drivers can't be updated.

The patch is close to the end of the series to make sure bisecting still
generates working binaries regardless at which patch we split the
series.

 src/drivers/driver_nl80211.c      | 23 ++++++++++++++++++++---
 src/drivers/driver_nl80211_capa.c |  4 ++++
 2 files changed, 24 insertions(+), 3 deletions(-)

Patch
diff mbox series

diff --git a/src/drivers/driver_nl80211.c b/src/drivers/driver_nl80211.c
index f15f1e15f..65caa7f89 100644
--- a/src/drivers/driver_nl80211.c
+++ b/src/drivers/driver_nl80211.c
@@ -3045,7 +3045,11 @@  static int wpa_driver_nl80211_set_key(const char *ifname, struct i802_bss *bss,
 	if (!key_msg)
 		return -ENOBUFS;
 
-	if (alg == WPA_ALG_NONE) {
+	if (key_type == KEY_TYPE_SET_TX) {
+		msg = nl80211_ifindex_msg(drv, ifindex, 0, NL80211_CMD_SET_KEY);
+		if (!msg)
+			goto fail2;
+	} else if (alg == WPA_ALG_NONE) {
 		msg = nl80211_ifindex_msg(drv, ifindex, 0, NL80211_CMD_DEL_KEY);
 		if (!msg)
 			goto fail2;
@@ -3064,7 +3068,7 @@  static int wpa_driver_nl80211_set_key(const char *ifname, struct i802_bss *bss,
 		wpa_hexdump_key(MSG_DEBUG, "nl80211: KEY_DATA", key, key_len);
 	}
 
-	if (seq && seq_len) {
+	if (seq && seq_len && key_type != KEY_TYPE_SET_TX) {
 		if (nla_put(key_msg, NL80211_KEY_SEQ, seq_len, seq))
 			goto fail;
 		wpa_hexdump(MSG_DEBUG, "nl80211: KEY_SEQ", seq, seq_len);
@@ -3075,7 +3079,20 @@  static int wpa_driver_nl80211_set_key(const char *ifname, struct i802_bss *bss,
 		if (nla_put(msg, NL80211_ATTR_MAC, ETH_ALEN, addr))
 			goto fail;
 
-		if (alg != WPA_ALG_WEP && key_type != KEY_TYPE_PAIRWISE) {
+		if (key_type == KEY_TYPE_NO_AUTO_TX ||
+		    key_type == KEY_TYPE_SET_TX) {
+			wpa_printf(MSG_DEBUG, "nl80211: %s for "
+				   "keyid=%d addr=" MACSTR,
+				   key_type == KEY_TYPE_NO_AUTO_TX ?
+				   "KEY_TYPE_NO_AUTO_TX" : "KEY_TYPE_SET_TX",
+				   key_idx, MAC2STR(addr));
+			if (nla_put_u8(key_msg, NL80211_KEY_MODE,
+				       key_type == KEY_TYPE_NO_AUTO_TX ?
+				       NL80211_KEY_NO_TX :
+				       NL80211_KEY_SET_TX))
+				goto fail;
+		} else if (alg != WPA_ALG_WEP &&
+			   key_type != KEY_TYPE_PAIRWISE) {
 			wpa_printf(MSG_DEBUG, "   RSN IBSS RX GTK");
 			if (nla_put_u32(key_msg, NL80211_KEY_TYPE,
 					NL80211_KEYTYPE_GROUP))
diff --git a/src/drivers/driver_nl80211_capa.c b/src/drivers/driver_nl80211_capa.c
index 8318b10ab..b4d175f4e 100644
--- a/src/drivers/driver_nl80211_capa.c
+++ b/src/drivers/driver_nl80211_capa.c
@@ -417,6 +417,10 @@  static void wiphy_info_ext_feature_flags(struct wiphy_info_data *info,
 			      NL80211_EXT_FEATURE_DFS_OFFLOAD))
 		capa->flags |= WPA_DRIVER_FLAGS_DFS_OFFLOAD;
 
+	if (ext_feature_isset(ext_features, len,
+			      NL80211_EXT_FEATURE_EXT_KEY_ID))
+		capa->flags |= WPA_DRIVER_FLAGS_EXTENDED_KEY_ID;
+
 #ifdef CONFIG_MBO
 	if (ext_feature_isset(ext_features, len,
 			      NL80211_EXT_FEATURE_FILS_MAX_CHANNEL_TIME) &&