public inbox for iwd@lists.linux.dev
 help / color / mirror / Atom feed
From: Denis Kenzior <denkenz@gmail.com>
To: iwd@lists.linux.dev
Cc: Denis Kenzior <denkenz@gmail.com>
Subject: [PATCH 08/11] netdev: Move pairwise NEW_KEY builder to nl80211util
Date: Tue, 14 Nov 2023 11:14:31 -0600	[thread overview]
Message-ID: <20231114171455.1108856-8-denkenz@gmail.com> (raw)
In-Reply-To: <20231114171455.1108856-1-denkenz@gmail.com>

---
 src/netdev.c      | 27 +++------------------------
 src/nl80211util.c | 20 ++++++++++++++++++++
 src/nl80211util.h |  6 ++++++
 3 files changed, 29 insertions(+), 24 deletions(-)

diff --git a/src/netdev.c b/src/netdev.c
index 38fb759058c3..64d16d6dc8c6 100644
--- a/src/netdev.c
+++ b/src/netdev.c
@@ -1898,27 +1898,6 @@ error:
 	netdev_setting_keys_failed(nhs, err);
 }
 
-static struct l_genl_msg *netdev_build_cmd_new_key_pairwise(
-							struct netdev *netdev,
-							uint32_t cipher,
-							const uint8_t *aa,
-							const uint8_t *tk,
-							size_t tk_len,
-							uint8_t key_id)
-{
-	struct l_genl_msg *msg;
-
-	msg = l_genl_msg_new_sized(NL80211_CMD_NEW_KEY, 512);
-
-	l_genl_msg_append_attr(msg, NL80211_ATTR_KEY_DATA, tk_len, tk);
-	l_genl_msg_append_attr(msg, NL80211_ATTR_KEY_CIPHER, 4, &cipher);
-	l_genl_msg_append_attr(msg, NL80211_ATTR_MAC, ETH_ALEN, aa);
-	l_genl_msg_append_attr(msg, NL80211_ATTR_KEY_IDX, 1, &key_id);
-	l_genl_msg_append_attr(msg, NL80211_ATTR_IFINDEX, 4, &netdev->index);
-
-	return msg;
-}
-
 static struct l_genl_msg *netdev_build_cmd_new_rx_key_pairwise(
 							struct netdev *netdev,
 							uint32_t cipher,
@@ -2024,9 +2003,9 @@ static void netdev_set_tk(struct handshake_state *hs, uint8_t key_index,
 	if (!netdev_copy_tk(tk_buf, tk, cipher, hs->authenticator))
 		goto invalid_key;
 
-	msg = netdev_build_cmd_new_key_pairwise(netdev, cipher, addr, tk_buf,
-						crypto_cipher_key_len(cipher),
-						key_index);
+	msg = nl80211_build_new_key_pairwise(netdev->index, cipher, addr,
+					tk_buf, crypto_cipher_key_len(cipher),
+					key_index);
 	nhs->pairwise_new_key_cmd_id =
 		l_genl_family_send(nl80211, msg, netdev_new_pairwise_key_cb,
 						nhs, NULL);
diff --git a/src/nl80211util.c b/src/nl80211util.c
index 1d1d7099e575..437a52d55941 100644
--- a/src/nl80211util.c
+++ b/src/nl80211util.c
@@ -359,6 +359,26 @@ struct l_genl_msg *nl80211_build_new_key_group(uint32_t ifindex, uint32_t cipher
 	return msg;
 }
 
+struct l_genl_msg *nl80211_build_new_key_pairwise(uint32_t ifindex,
+						uint32_t cipher,
+						const uint8_t addr[static 6],
+						const uint8_t *tk,
+						size_t tk_len,
+						uint8_t key_id)
+{
+	struct l_genl_msg *msg;
+
+	msg = l_genl_msg_new_sized(NL80211_CMD_NEW_KEY, 512);
+
+	l_genl_msg_append_attr(msg, NL80211_ATTR_KEY_DATA, tk_len, tk);
+	l_genl_msg_append_attr(msg, NL80211_ATTR_KEY_CIPHER, 4, &cipher);
+	l_genl_msg_append_attr(msg, NL80211_ATTR_MAC, ETH_ALEN, addr);
+	l_genl_msg_append_attr(msg, NL80211_ATTR_KEY_IDX, 1, &key_id);
+	l_genl_msg_append_attr(msg, NL80211_ATTR_IFINDEX, 4, &ifindex);
+
+	return msg;
+}
+
 static struct l_genl_msg *nl80211_build_set_station(uint32_t ifindex,
 					const uint8_t *addr,
 					struct nl80211_sta_flag_update *flags)
diff --git a/src/nl80211util.h b/src/nl80211util.h
index 755133a37bb7..00d1ea852671 100644
--- a/src/nl80211util.h
+++ b/src/nl80211util.h
@@ -44,6 +44,12 @@ struct l_genl_msg *nl80211_build_new_key_group(uint32_t ifindex,
 					const uint8_t *key, size_t key_len,
 					const uint8_t *ctr, size_t ctr_len,
 					const uint8_t *addr);
+struct l_genl_msg *nl80211_build_new_key_pairwise(uint32_t ifindex,
+						uint32_t cipher,
+						const uint8_t addr[static 6],
+						const uint8_t *tk,
+						size_t tk_len,
+						uint8_t key_id);
 
 struct l_genl_msg *nl80211_build_set_station_authorized(uint32_t ifindex,
 							const uint8_t *addr);
-- 
2.42.0


  parent reply	other threads:[~2023-11-14 17:15 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-11-14 17:14 [PATCH 01/11] netdev: Fix obtaining reason code from deauth frames Denis Kenzior
2023-11-14 17:14 ` [PATCH 02/11] netdev: sa_query: Fix reason code handling Denis Kenzior
2023-11-14 17:14 ` [PATCH 03/11] netdev: Use CMD_DISCONNECT if OCI fails Denis Kenzior
2023-11-14 17:14 ` [PATCH 04/11] netdev: Don't unnecessarily call netdev_connect_failed Denis Kenzior
2023-11-14 17:14 ` [PATCH 05/11] netdev: Move CMD_DISCONNECT builder to nl80211util Denis Kenzior
2023-11-14 17:14 ` [PATCH 06/11] netdev: Move CMD_DEAUTHENTICATE " Denis Kenzior
2023-11-14 17:14 ` [PATCH 07/11] netdev: Move CMD_DEL_STATION " Denis Kenzior
2023-11-14 17:14 ` Denis Kenzior [this message]
2023-11-14 17:14 ` [PATCH 09/11] netdev: Move CMD_NEW_KEY RX-only " Denis Kenzior
2023-11-14 17:14 ` [PATCH 10/11] netdev: Move CMD_REKEY_OFFLOAD " Denis Kenzior
2023-11-14 17:14 ` [PATCH 11/11] netdev: disambiguate between disconnection types Denis Kenzior
2023-11-14 17:39   ` James Prestwood
2023-11-14 20:09     ` Denis Kenzior
2023-11-14 20:11       ` James Prestwood
2023-11-24 12:20   ` Alvin Šipraga
2023-11-24 16:25     ` Denis Kenzior
2023-11-25 20:57       ` Alvin Šipraga
2023-11-14 20:48 ` [PATCH 01/11] netdev: Fix obtaining reason code from deauth frames Denis Kenzior

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20231114171455.1108856-8-denkenz@gmail.com \
    --to=denkenz@gmail.com \
    --cc=iwd@lists.linux.dev \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox