1 From: Michael-CY Lee <michael-cy.lee@mediatek.com>
2 Date: Tue, 26 Mar 2024 08:30:36 +0800
3 Subject: [PATCH] wifi: mac80211: extend IEEE80211_KEY_FLAG_GENERATE_MMIE to
6 Extend the flag IEEE80211_KEY_FLAG_GENERATE_MMIE to BIP-CMAC-256,
7 BIP-GMAC-128 and BIP-GMAC-256 for the same reason and in the same
8 way that the flag was added originally in commit a0b4496a4368
9 ("mac80211: add IEEE80211_KEY_FLAG_GENERATE_MMIE to ieee80211_key_flags").
11 Signed-off-by: Michael-CY Lee <michael-cy.lee@mediatek.com>
12 Link: https://msgid.link/20240326003036.15215-1-michael-cy.lee@mediatek.com
13 Signed-off-by: Johannes Berg <johannes.berg@intel.com>
16 --- a/include/net/mac80211.h
17 +++ b/include/net/mac80211.h
18 @@ -2037,8 +2037,8 @@ static inline bool lockdep_vif_mutex_hel
19 * @IEEE80211_KEY_FLAG_GENERATE_MMIC on the same key.
20 * @IEEE80211_KEY_FLAG_NO_AUTO_TX: Key needs explicit Tx activation.
21 * @IEEE80211_KEY_FLAG_GENERATE_MMIE: This flag should be set by the driver
22 - * for a AES_CMAC key to indicate that it requires sequence number
24 + * for a AES_CMAC or a AES_GMAC key to indicate that it requires sequence
25 + * number generation only
27 enum ieee80211_key_flags {
28 IEEE80211_KEY_FLAG_GENERATE_IV_MGMT = BIT(0),
29 --- a/net/mac80211/wpa.c
30 +++ b/net/mac80211/wpa.c
31 @@ -882,7 +882,8 @@ ieee80211_crypto_aes_cmac_256_encrypt(st
33 info = IEEE80211_SKB_CB(skb);
35 - if (info->control.hw_key)
36 + if (info->control.hw_key &&
37 + !(key->conf.flags & IEEE80211_KEY_FLAG_GENERATE_MMIE))
40 if (WARN_ON(skb_tailroom(skb) < sizeof(*mmie)))
41 @@ -898,6 +899,9 @@ ieee80211_crypto_aes_cmac_256_encrypt(st
43 bip_ipn_set64(mmie->sequence_number, pn64);
45 + if (info->control.hw_key)
50 /* MIC = AES-256-CMAC(IGTK, AAD || Management Frame Body || MMIE, 128)
51 @@ -1027,7 +1031,8 @@ ieee80211_crypto_aes_gmac_encrypt(struct
53 info = IEEE80211_SKB_CB(skb);
55 - if (info->control.hw_key)
56 + if (info->control.hw_key &&
57 + !(key->conf.flags & IEEE80211_KEY_FLAG_GENERATE_MMIE))
60 if (WARN_ON(skb_tailroom(skb) < sizeof(*mmie)))
61 @@ -1043,6 +1048,9 @@ ieee80211_crypto_aes_gmac_encrypt(struct
63 bip_ipn_set64(mmie->sequence_number, pn64);
65 + if (info->control.hw_key)
70 hdr = (struct ieee80211_hdr *)skb->data;