Skip to contentSkip to conversation

netdev: unify ft/auth_proto authenticate builders

PATCH In review James Prestwood 2 participants 3 messages May 7, 2020 – May 11, 2020

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/2 netdev: unify ft/auth_proto authenticate builders

build_cmd_ft_authenticate and build_cmd_authenticate were virtually identical. These have been unified into a single builder.

We were also incorrectly including ATTR_IE to every authenticate command, which violates the spec for certain protocols, This was removed and any auth protocols will now add any IEs that they require.

---
 src/netdev.c | 46 ++++++++--------------------------------------
 1 file changed, 8 insertions(+), 38 deletions(-)
src/netdev.c +8 -38
index b3c3bf73..e469fb1c 100644
@@ -2129,8 +2129,7 @@ static void netdev_cmd_connect_cb(struct l_genl_msg *msg, void *user_data)
 }
 
 static struct l_genl_msg *netdev_build_cmd_authenticate(struct netdev *netdev,
-							uint32_t auth_type,
-							const uint8_t *addr)
+							uint32_t auth_type)
 {
 	struct handshake_state *hs = netdev->handshake;
 	struct l_genl_msg *msg;
@@ -2139,13 +2138,11 @@ static struct l_genl_msg *netdev_build_cmd_authenticate(struct netdev *netdev,
 	l_genl_msg_append_attr(msg, NL80211_ATTR_IFINDEX, 4, &netdev->index);
 	l_genl_msg_append_attr(msg, NL80211_ATTR_WIPHY_FREQ,
 						4, &netdev->frequency);
-	l_genl_msg_append_attr(msg, NL80211_ATTR_MAC, ETH_ALEN, addr);
+	l_genl_msg_append_attr(msg, NL80211_ATTR_MAC, ETH_ALEN,
+				netdev->handshake->aa);
 	l_genl_msg_append_attr(msg, NL80211_ATTR_SSID, hs->ssid_len, hs->ssid);
 	l_genl_msg_append_attr(msg, NL80211_ATTR_AUTH_TYPE, 4, &auth_type);
 
-	l_genl_msg_append_attr(msg, NL80211_ATTR_IE, hs->supplicant_ie[1] + 2,
-					hs->supplicant_ie);
-
 	return msg;
 }
 
@@ -2181,8 +2178,7 @@ static void netdev_sae_tx_authenticate(const uint8_t *body,
 	struct netdev *netdev = user_data;
 	struct l_genl_msg *msg;
 
-	msg = netdev_build_cmd_authenticate(netdev, NL80211_AUTHTYPE_SAE,
-						netdev->handshake->aa);
+	msg = netdev_build_cmd_authenticate(netdev, NL80211_AUTHTYPE_SAE);
 
 	l_genl_msg_append_attr(msg, NL80211_ATTR_AUTH_DATA, body_len, body);
 
@@ -2228,8 +2224,7 @@ static void netdev_owe_tx_authenticate(void *user_data)
 	struct l_genl_msg *msg;
 
 	msg = netdev_build_cmd_authenticate(netdev,
-						NL80211_AUTHTYPE_OPEN_SYSTEM,
-						netdev->handshake->aa);
+						NL80211_AUTHTYPE_OPEN_SYSTEM);
 
 	if (!l_genl_family_send(nl80211, msg, netdev_auth_cb,
 							netdev, NULL)) {
@@ -2265,8 +2260,7 @@ static void netdev_fils_tx_authenticate(const uint8_t *body,
 	struct netdev *netdev = user_data;
 	struct l_genl_msg *msg;
 
-	msg = netdev_build_cmd_authenticate(netdev, NL80211_AUTHTYPE_FILS_SK,
-						netdev->handshake->aa);
+	msg = netdev_build_cmd_authenticate(netdev, NL80211_AUTHTYPE_FILS_SK);
 
 	l_genl_msg_append_attr(msg, NL80211_ATTR_AUTH_DATA, body_len, body);
 
@@ -2941,30 +2935,6 @@ static uint32_t netdev_send_action_frame(struct netdev *netdev,
 	return netdev_send_action_framev(netdev, to, iov, 1, freq, callback);
 }
 
-/*
- * Build an FT Authentication Request frame according to 12.5.2 / 12.5.4:
- * RSN or non-RSN Over-the-air FT Protocol, with the IE contents
- * according to 12.8.2: FT authentication sequence: contents of first message.
- */
-static struct l_genl_msg *netdev_build_cmd_ft_authenticate(
-					struct netdev *netdev,
-					const struct handshake_state *hs)
-{
-	uint32_t auth_type = NL80211_AUTHTYPE_FT;
-	struct l_genl_msg *msg;
-
-	msg = l_genl_msg_new_sized(NL80211_CMD_AUTHENTICATE, 512);
-	l_genl_msg_append_attr(msg, NL80211_ATTR_IFINDEX, 4, &netdev->index);
-	l_genl_msg_append_attr(msg, NL80211_ATTR_WIPHY_FREQ,
-						4, &netdev->frequency);
-	l_genl_msg_append_attr(msg, NL80211_ATTR_MAC, ETH_ALEN, hs->aa);
-	l_genl_msg_append_attr(msg, NL80211_ATTR_SSID, hs->ssid_len, hs->ssid);
-	l_genl_msg_append_attr(msg, NL80211_ATTR_AUTH_TYPE, 4, &auth_type);
-
-	return msg;
-
-}
-
 static void netdev_cmd_authenticate_ft_cb(struct l_genl_msg *msg,
 						void *user_data)
 {
@@ -2984,8 +2954,8 @@ static void netdev_ft_tx_authenticate(struct iovec *iov,
 	struct netdev *netdev = user_data;
 	struct l_genl_msg *cmd_authenticate;
 
-	cmd_authenticate = netdev_build_cmd_ft_authenticate(netdev,
-							netdev->handshake);
+	cmd_authenticate = netdev_build_cmd_authenticate(netdev,
+							NL80211_AUTHTYPE_FT);
 	if (!cmd_authenticate)
 		goto restore_snonce;
 
Signature · 1 line
2.21.1
#1 lore raw

PATCH v2 2/2 fils: include RSNE in authenticate

802.11ai mandates that the RSN element is included during authentication for FILS. This previously was happening by chance since supplicant_ie was being included with CMD_AUTHENTICATE. This included more than just the RSNE so that was removed in an earlier commit. Now FILS builds the RSNE itself and includes this with CMD_AUTHENTICATE.

---
 src/fils.c | 11 +++++++++++
 1 file changed, 11 insertions(+)
src/fils.c +11 -0
index 2d2a0913..acead506 100644
@@ -91,6 +91,8 @@ static void fils_erp_tx_func(const uint8_t *eap_data, size_t len,
 	uint8_t data[256];
 	uint8_t *ptr = data;
 	unsigned int tlv_len;
+	struct ie_rsn_info rsn_info;
+	uint8_t *rsne;
 
 	l_getrandom(fils->nonce, 16);
 	l_getrandom(fils->session, 8);
@@ -106,6 +108,15 @@ static void fils_erp_tx_func(const uint8_t *eap_data, size_t len,
 
 	ie_tlv_builder_init(&builder, ptr, sizeof(data) - 4);
 
+	ie_parse_rsne_from_data(fils->hs->supplicant_ie,
+				fils->hs->supplicant_ie[1] + 2,
+				&rsn_info);
+	rsne = alloca(256);
+	ie_build_rsne(&rsn_info, rsne);
+
+	ie_tlv_builder_next(&builder, IE_TYPE_RSN);
+	ie_tlv_builder_set_data(&builder, rsne + 2, rsne[1]);
+
 	ie_tlv_builder_next(&builder, IE_TYPE_FILS_NONCE);
 	ie_tlv_builder_set_data(&builder, fils->nonce, sizeof(fils->nonce));
 
Signature · 1 line
2.21.1
#2 lore raw
In reply to James Prestwood

Hi James,

Quoted 10 lines · James Prestwood

build_cmd_ft_authenticate and build_cmd_authenticate were virtually identical. These have been unified into a single builder.

We were also incorrectly including ATTR_IE to every authenticate command, which violates the spec for certain protocols, This was removed and any auth protocols will now add any IEs that they require.

---
  src/netdev.c | 46 ++++++++--------------------------------------
  1 file changed, 8 insertions(+), 38 deletions(-)

Both applied, thanks.

Regards,
-Denis