333-wifi-mac80211-extend-IEEE80211_KEY_FLAG_GENERATE_MMI.patch 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. From: Michael-CY Lee <[email protected]>
  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. Extend the flag IEEE80211_KEY_FLAG_GENERATE_MMIE to BIP-CMAC-256,
  6. BIP-GMAC-128 and BIP-GMAC-256 for the same reason and in the same
  7. way that the flag was added originally in commit a0b4496a4368
  8. ("mac80211: add IEEE80211_KEY_FLAG_GENERATE_MMIE to ieee80211_key_flags").
  9. Signed-off-by: Michael-CY Lee <[email protected]>
  10. Link: https://msgid.link/[email protected]
  11. Signed-off-by: Johannes Berg <[email protected]>
  12. ---
  13. --- a/include/net/mac80211.h
  14. +++ b/include/net/mac80211.h
  15. @@ -2032,8 +2032,8 @@ static inline bool lockdep_vif_mutex_hel
  16. * @IEEE80211_KEY_FLAG_GENERATE_MMIC on the same key.
  17. * @IEEE80211_KEY_FLAG_NO_AUTO_TX: Key needs explicit Tx activation.
  18. * @IEEE80211_KEY_FLAG_GENERATE_MMIE: This flag should be set by the driver
  19. - * for a AES_CMAC key to indicate that it requires sequence number
  20. - * generation only
  21. + * for a AES_CMAC or a AES_GMAC key to indicate that it requires sequence
  22. + * number generation only
  23. */
  24. enum ieee80211_key_flags {
  25. IEEE80211_KEY_FLAG_GENERATE_IV_MGMT = BIT(0),
  26. --- a/net/mac80211/wpa.c
  27. +++ b/net/mac80211/wpa.c
  28. @@ -882,7 +882,8 @@ ieee80211_crypto_aes_cmac_256_encrypt(st
  29. info = IEEE80211_SKB_CB(skb);
  30. - if (info->control.hw_key)
  31. + if (info->control.hw_key &&
  32. + !(key->conf.flags & IEEE80211_KEY_FLAG_GENERATE_MMIE))
  33. return TX_CONTINUE;
  34. if (WARN_ON(skb_tailroom(skb) < sizeof(*mmie)))
  35. @@ -898,6 +899,9 @@ ieee80211_crypto_aes_cmac_256_encrypt(st
  36. bip_ipn_set64(mmie->sequence_number, pn64);
  37. + if (info->control.hw_key)
  38. + return TX_CONTINUE;
  39. +
  40. bip_aad(skb, aad);
  41. /* MIC = AES-256-CMAC(IGTK, AAD || Management Frame Body || MMIE, 128)
  42. @@ -1027,7 +1031,8 @@ ieee80211_crypto_aes_gmac_encrypt(struct
  43. info = IEEE80211_SKB_CB(skb);
  44. - if (info->control.hw_key)
  45. + if (info->control.hw_key &&
  46. + !(key->conf.flags & IEEE80211_KEY_FLAG_GENERATE_MMIE))
  47. return TX_CONTINUE;
  48. if (WARN_ON(skb_tailroom(skb) < sizeof(*mmie)))
  49. @@ -1043,6 +1048,9 @@ ieee80211_crypto_aes_gmac_encrypt(struct
  50. bip_ipn_set64(mmie->sequence_number, pn64);
  51. + if (info->control.hw_key)
  52. + return TX_CONTINUE;
  53. +
  54. bip_aad(skb, aad);
  55. hdr = (struct ieee80211_hdr *)skb->data;