From: James Prestwood <prestwoj@gmail.com>
To: iwd@lists.linux.dev
Cc: James Prestwood <prestwoj@gmail.com>
Subject: [PATCH 03/17] ap: add profile settings PairwiseCiphers/GroupCipher
Date: Tue, 1 Nov 2022 13:17:33 -0700 [thread overview]
Message-ID: <20221101201747.143379-3-prestwoj@gmail.com> (raw)
In-Reply-To: <20221101201747.143379-1-prestwoj@gmail.com>
These can now be optionally provided in an AP profile and provide a
way to limit what ciphers can be chosen. This still is dependent on
what the hardware supports.
---
src/ap.c | 75 +++++++++++++++++++++++++++++++++++++++++++++++++++-----
1 file changed, 69 insertions(+), 6 deletions(-)
diff --git a/src/ap.c b/src/ap.c
index 2939a9c1..834fa089 100644
--- a/src/ap.c
+++ b/src/ap.c
@@ -3132,12 +3132,38 @@ static bool ap_load_psk(struct ap_state *ap, const struct l_settings *config)
return true;
}
+/*
+ * Note: only PTK/GTK ciphers are supported here since this is all these are
+ * used for.
+ */
+static enum ie_rsn_cipher_suite ap_string_to_cipher(const char *str)
+{
+ if (!strcmp(str, "UseGroupCipher"))
+ return IE_RSN_CIPHER_SUITE_USE_GROUP_CIPHER;
+ else if (!strcmp(str, "TKIP"))
+ return IE_RSN_CIPHER_SUITE_TKIP;
+ else if (!strcmp(str, "CCMP-128") || !strcmp(str, "CCMP"))
+ return IE_RSN_CIPHER_SUITE_CCMP;
+ else if (!strcmp(str, "GCMP-128") || !strcmp(str, "GCMP"))
+ return IE_RSN_CIPHER_SUITE_GCMP;
+ else if (!strcmp(str, "GCMP-256"))
+ return IE_RSN_CIPHER_SUITE_GCMP_256;
+ else if (!strcmp(str, "CCMP-256"))
+ return IE_RSN_CIPHER_SUITE_CCMP_256;
+ else
+ return 0;
+}
+
static int ap_load_config(struct ap_state *ap, const struct l_settings *config,
bool *out_cck_rates)
{
+ struct wiphy *wiphy = netdev_get_wiphy(ap->netdev);
size_t len;
L_AUTO_FREE_VAR(char *, strval) = NULL;
+ _auto_(l_strv_free) char **ciphers_str;
+ uint16_t cipher_mask;
int err;
+ int i;
strval = l_settings_get_string(config, "General", "SSID");
if (L_WARN_ON(!strval))
@@ -3212,6 +3238,8 @@ static int ap_load_config(struct ap_state *ap, const struct l_settings *config,
l_error("AP [WSC].PrimaryDeviceType format unknown");
return -EINVAL;
}
+
+ l_free(l_steal_ptr(strval));
} else {
/* Make ourselves a WFA standard PC by default */
ap->wsc_primary_device_type.category = 1;
@@ -3260,6 +3288,47 @@ static int ap_load_config(struct ap_state *ap, const struct l_settings *config,
} else
*out_cck_rates = true;
+ cipher_mask = wiphy_get_supported_ciphers(wiphy, IE_PAIRWISE_CIPHERS);
+ ciphers_str = l_settings_get_string_list(config, "Security",
+ "PairwiseCiphers", ',');
+ for (i = 0; ciphers_str && ciphers_str[i]; i++) {
+ enum ie_rsn_cipher_suite cipher =
+ ap_string_to_cipher(ciphers_str[i]);
+
+ /*
+ * Constrain list to only values in both supported ciphers and
+ * the cipher list provided.
+ */
+ if (!cipher || !(cipher & cipher_mask)) {
+ l_error("Unsupported or unknown cipher %s",
+ ciphers_str[i]);
+ return -ENOTSUP;
+ }
+
+ ap->ciphers |= cipher;
+ }
+
+ /* No list provided, just set to all supported ciphers */
+ if (!ap->ciphers)
+ ap->ciphers = cipher_mask;
+
+ cipher_mask = wiphy_get_supported_ciphers(wiphy, IE_GROUP_CIPHERS);
+
+ strval = l_settings_get_string(config, "Security", "GroupCipher");
+ if (strval) {
+ enum ie_rsn_cipher_suite cipher = ap_string_to_cipher(strval);
+
+ if (!cipher || !(cipher & cipher_mask)) {
+ l_error("Unsupported or unknown cipher %s", strval);
+ return -ENOTSUP;
+ }
+
+ ap->group_cipher = cipher;
+
+ l_free(l_steal_ptr(strval));
+ } else
+ ap->group_cipher = wiphy_select_cipher(wiphy, cipher_mask);
+
return 0;
}
@@ -3302,12 +3371,6 @@ struct ap_state *ap_start(struct netdev *netdev, struct l_settings *config,
err = -EINVAL;
- /* TODO: Add all ciphers supported by wiphy */
- ap->ciphers = wiphy_select_cipher(wiphy, IE_RSN_CIPHER_SUITE_TKIP |
- IE_RSN_CIPHER_SUITE_CCMP);
- ap->group_cipher = wiphy_select_cipher(wiphy,
- IE_RSN_CIPHER_SUITE_TKIP |
- IE_RSN_CIPHER_SUITE_CCMP);
ap->beacon_interval = 100;
ap->networks = l_queue_new();
--
2.34.3
next prev parent reply other threads:[~2022-11-01 20:17 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-11-01 20:17 [PATCH 01/17] wiphy: add wiphy_get_supported_ciphers James Prestwood
2022-11-01 20:17 ` [PATCH 02/17] ie: add group/pairwise lists of supported ciphers James Prestwood
2022-11-01 20:17 ` James Prestwood [this message]
2022-11-01 20:17 ` [PATCH 04/17] p2p: limit ciphers to CCMP/TKIP James Prestwood
2022-11-01 20:17 ` [PATCH 05/17] doc: document PairwiseCiphers/GroupCiphers AP settings James Prestwood
2022-11-01 20:17 ` [PATCH 06/17] ap: add frequency to AP interface James Prestwood
2022-11-01 20:50 ` Denis Kenzior
2022-11-01 20:17 ` [PATCH 07/17] client: show frequency with ap show James Prestwood
2022-11-01 20:17 ` [PATCH 08/17] ap: add PairwiseCiphers/GroupCipher to dbus interface James Prestwood
2022-11-01 20:17 ` [PATCH 09/17] client: add ap support for PairwiseCiphers/GroupCipher James Prestwood
2022-11-01 20:17 ` [PATCH 10/17] hwsim: add remaining ciphers to supported list James Prestwood
2022-11-01 20:51 ` Denis Kenzior
2022-11-01 20:17 ` [PATCH 11/17] auto-t: test AP fails to start with unsupported ciphers James Prestwood
2022-11-01 20:17 ` [PATCH 12/17] auto-t: fix testAP-no-support disabled ciphers James Prestwood
2022-11-01 20:52 ` Denis Kenzior
2022-11-01 20:17 ` [PATCH 13/17] netdev: add more info to key setting debug messages James Prestwood
2022-11-01 20:53 ` Denis Kenzior
2022-11-01 20:17 ` [PATCH 14/17] netdev: fix key setting for authenticators James Prestwood
2022-11-01 20:17 ` [PATCH 15/17] nl80211util: add key type/idx to nl80211_parse_attrs James Prestwood
2022-11-01 20:56 ` Denis Kenzior
2022-11-01 20:17 ` [PATCH 16/17] netdev: parse michael MIC failure message James Prestwood
2022-11-01 20:17 ` [PATCH 17/17] auto-t: add AP test for all pairwise/group cipher combos James Prestwood
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=20221101201747.143379-3-prestwoj@gmail.com \
--to=prestwoj@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