Skip to content

Commit 093a48d

Browse files
naerrerajmberg-intel
authored andcommitted
cfg80211: support bigger kek/kck key length
With some newer AKMs, the KCK and KEK are bigger, so allow that if the driver advertises support for it. In addition, add a new attribute for the AKM so we can use it for offloaded rekeying. Signed-off-by: Nathan Errera <[email protected]> [reword commit message] Link: https://lore.kernel.org/r/20200528212237.5eb58b00a5d1.I61b09d77c4f382e8d58a05dcca78096e99a6bc15@changeid Signed-off-by: Johannes Berg <[email protected]>
1 parent 07c12d6 commit 093a48d

File tree

3 files changed

+32
-7
lines changed

3 files changed

+32
-7
lines changed

include/net/cfg80211.h

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2936,12 +2936,17 @@ struct cfg80211_wowlan_wakeup {
29362936

29372937
/**
29382938
* struct cfg80211_gtk_rekey_data - rekey data
2939-
* @kek: key encryption key (NL80211_KEK_LEN bytes)
2940-
* @kck: key confirmation key (NL80211_KCK_LEN bytes)
2939+
* @kek: key encryption key (@kek_len bytes)
2940+
* @kck: key confirmation key (@kck_len bytes)
29412941
* @replay_ctr: replay counter (NL80211_REPLAY_CTR_LEN bytes)
2942+
* @kek_len: length of kek
2943+
* @kck_len length of kck
2944+
* @akm: akm (oui, id)
29422945
*/
29432946
struct cfg80211_gtk_rekey_data {
29442947
const u8 *kek, *kck, *replay_ctr;
2948+
u32 akm;
2949+
u8 kek_len, kck_len;
29452950
};
29462951

29472952
/**
@@ -4166,9 +4171,10 @@ struct cfg80211_ops {
41664171
* beaconing mode (AP, IBSS, Mesh, ...).
41674172
* @WIPHY_FLAG_HAS_STATIC_WEP: The device supports static WEP key installation
41684173
* before connection.
4174+
* @WIPHY_FLAG_SUPPORTS_EXT_KEK_KCK: The device supports bigger kek and kck keys
41694175
*/
41704176
enum wiphy_flags {
4171-
/* use hole at 0 */
4177+
WIPHY_FLAG_SUPPORTS_EXT_KEK_KCK = BIT(0),
41724178
/* use hole at 1 */
41734179
/* use hole at 2 */
41744180
WIPHY_FLAG_NETNS_OK = BIT(3),

include/uapi/linux/nl80211.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5396,6 +5396,8 @@ enum plink_actions {
53965396

53975397
#define NL80211_KCK_LEN 16
53985398
#define NL80211_KEK_LEN 16
5399+
#define NL80211_KCK_EXT_LEN 24
5400+
#define NL80211_KEK_EXT_LEN 32
53995401
#define NL80211_REPLAY_CTR_LEN 8
54005402

54015403
/**
@@ -5404,6 +5406,7 @@ enum plink_actions {
54045406
* @NL80211_REKEY_DATA_KEK: key encryption key (binary)
54055407
* @NL80211_REKEY_DATA_KCK: key confirmation key (binary)
54065408
* @NL80211_REKEY_DATA_REPLAY_CTR: replay counter (binary)
5409+
* @NL80211_REKEY_DATA_AKM: AKM data (OUI, suite type)
54075410
* @NUM_NL80211_REKEY_DATA: number of rekey attributes (internal)
54085411
* @MAX_NL80211_REKEY_DATA: highest rekey attribute (internal)
54095412
*/
@@ -5412,6 +5415,7 @@ enum nl80211_rekey_data {
54125415
NL80211_REKEY_DATA_KEK,
54135416
NL80211_REKEY_DATA_KCK,
54145417
NL80211_REKEY_DATA_REPLAY_CTR,
5418+
NL80211_REKEY_DATA_AKM,
54155419

54165420
/* keep last */
54175421
NUM_NL80211_REKEY_DATA,

net/wireless/nl80211.c

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -730,9 +730,16 @@ nl80211_coalesce_policy[NUM_NL80211_ATTR_COALESCE_RULE] = {
730730
/* policy for GTK rekey offload attributes */
731731
static const struct nla_policy
732732
nl80211_rekey_policy[NUM_NL80211_REKEY_DATA] = {
733-
[NL80211_REKEY_DATA_KEK] = NLA_POLICY_EXACT_LEN_WARN(NL80211_KEK_LEN),
734-
[NL80211_REKEY_DATA_KCK] = NLA_POLICY_EXACT_LEN_WARN(NL80211_KCK_LEN),
733+
[NL80211_REKEY_DATA_KEK] = {
734+
.type = NLA_BINARY,
735+
.len = NL80211_KEK_EXT_LEN
736+
},
737+
[NL80211_REKEY_DATA_KCK] = {
738+
.type = NLA_BINARY,
739+
.len = NL80211_KCK_EXT_LEN
740+
},
735741
[NL80211_REKEY_DATA_REPLAY_CTR] = NLA_POLICY_EXACT_LEN_WARN(NL80211_REPLAY_CTR_LEN),
742+
[NL80211_REKEY_DATA_AKM] = { .type = NLA_U32 },
736743
};
737744

738745
static const struct nla_policy
@@ -12347,14 +12354,22 @@ static int nl80211_set_rekey_data(struct sk_buff *skb, struct genl_info *info)
1234712354
return -EINVAL;
1234812355
if (nla_len(tb[NL80211_REKEY_DATA_REPLAY_CTR]) != NL80211_REPLAY_CTR_LEN)
1234912356
return -ERANGE;
12350-
if (nla_len(tb[NL80211_REKEY_DATA_KEK]) != NL80211_KEK_LEN)
12357+
if (nla_len(tb[NL80211_REKEY_DATA_KEK]) != NL80211_KEK_LEN &&
12358+
!(rdev->wiphy.flags & WIPHY_FLAG_SUPPORTS_EXT_KEK_KCK &&
12359+
nla_len(tb[NL80211_REKEY_DATA_KEK]) == NL80211_KEK_EXT_LEN))
1235112360
return -ERANGE;
12352-
if (nla_len(tb[NL80211_REKEY_DATA_KCK]) != NL80211_KCK_LEN)
12361+
if (nla_len(tb[NL80211_REKEY_DATA_KCK]) != NL80211_KCK_LEN &&
12362+
!(rdev->wiphy.flags & WIPHY_FLAG_SUPPORTS_EXT_KEK_KCK &&
12363+
nla_len(tb[NL80211_REKEY_DATA_KEK]) == NL80211_KCK_EXT_LEN))
1235312364
return -ERANGE;
1235412365

1235512366
rekey_data.kek = nla_data(tb[NL80211_REKEY_DATA_KEK]);
1235612367
rekey_data.kck = nla_data(tb[NL80211_REKEY_DATA_KCK]);
1235712368
rekey_data.replay_ctr = nla_data(tb[NL80211_REKEY_DATA_REPLAY_CTR]);
12369+
rekey_data.kek_len = nla_len(tb[NL80211_REKEY_DATA_KEK]);
12370+
rekey_data.kck_len = nla_len(tb[NL80211_REKEY_DATA_KCK]);
12371+
if (tb[NL80211_REKEY_DATA_AKM])
12372+
rekey_data.akm = nla_get_u32(tb[NL80211_REKEY_DATA_AKM]);
1235812373

1235912374
wdev_lock(wdev);
1236012375
if (!wdev->current_bss) {

0 commit comments

Comments
 (0)