b2b4346a95f8860d39866720e416eb3aef14caad
[openwrt/staging/pepe2k.git] /
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
4 other ciphers
5
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").
10
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>
14 ---
15
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
23 - * generation only
24 + * for a AES_CMAC or a AES_GMAC key to indicate that it requires sequence
25 + * number generation only
26 */
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
32
33 info = IEEE80211_SKB_CB(skb);
34
35 - if (info->control.hw_key)
36 + if (info->control.hw_key &&
37 + !(key->conf.flags & IEEE80211_KEY_FLAG_GENERATE_MMIE))
38 return TX_CONTINUE;
39
40 if (WARN_ON(skb_tailroom(skb) < sizeof(*mmie)))
41 @@ -898,6 +899,9 @@ ieee80211_crypto_aes_cmac_256_encrypt(st
42
43 bip_ipn_set64(mmie->sequence_number, pn64);
44
45 + if (info->control.hw_key)
46 + return TX_CONTINUE;
47 +
48 bip_aad(skb, aad);
49
50 /* MIC = AES-256-CMAC(IGTK, AAD || Management Frame Body || MMIE, 128)
51 @@ -1027,7 +1031,8 @@ ieee80211_crypto_aes_gmac_encrypt(struct
52
53 info = IEEE80211_SKB_CB(skb);
54
55 - if (info->control.hw_key)
56 + if (info->control.hw_key &&
57 + !(key->conf.flags & IEEE80211_KEY_FLAG_GENERATE_MMIE))
58 return TX_CONTINUE;
59
60 if (WARN_ON(skb_tailroom(skb) < sizeof(*mmie)))
61 @@ -1043,6 +1048,9 @@ ieee80211_crypto_aes_gmac_encrypt(struct
62
63 bip_ipn_set64(mmie->sequence_number, pn64);
64
65 + if (info->control.hw_key)
66 + return TX_CONTINUE;
67 +
68 bip_aad(skb, aad);
69
70 hdr = (struct ieee80211_hdr *)skb->data;