From 8891ebdc1d5e9cd9f78d4e769fd2c3aded64787a Mon Sep 17 00:00:00 2001 From: Jouni Malinen Date: Sat, 20 Apr 2024 16:15:01 +0300 Subject: [PATCH] Use defined values for RSN PN length Make the code more readable by using a define for the PN length to avoid potential confusion of this 6 octet length with the MAC address length. In addition, Use ETH_ALEN more consistently for the latter. Signed-off-by: Jouni Malinen --- src/common/wpa_common.h | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/src/common/wpa_common.h b/src/common/wpa_common.h index 01efeea3a..404e571c0 100644 --- a/src/common/wpa_common.h +++ b/src/common/wpa_common.h @@ -17,6 +17,7 @@ #define PMK_LEN_SUITE_B_192 48 #define PMK_LEN_MAX 64 #define WPA_REPLAY_COUNTER_LEN 8 +#define RSN_PN_LEN 6 #define WPA_NONCE_LEN 32 #define WPA_KEY_RSC_LEN 8 #define WPA_GMK_LEN 32 @@ -343,47 +344,47 @@ struct rsn_error_kde { be16 error_type; } STRUCT_PACKED; -#define WPA_IGTK_KDE_PREFIX_LEN (2 + 6) +#define WPA_IGTK_KDE_PREFIX_LEN (2 + RSN_PN_LEN) struct wpa_igtk_kde { u8 keyid[2]; - u8 pn[6]; + u8 pn[RSN_PN_LEN]; u8 igtk[WPA_IGTK_MAX_LEN]; } STRUCT_PACKED; -#define WPA_BIGTK_KDE_PREFIX_LEN (2 + 6) +#define WPA_BIGTK_KDE_PREFIX_LEN (2 + RSN_PN_LEN) struct wpa_bigtk_kde { u8 keyid[2]; - u8 pn[6]; + u8 pn[RSN_PN_LEN]; u8 bigtk[WPA_BIGTK_MAX_LEN]; } STRUCT_PACKED; -#define RSN_MLO_GTK_KDE_PREFIX_LENGTH (1 + 6) +#define RSN_MLO_GTK_KDE_PREFIX_LENGTH (1 + RSN_PN_LEN) #define RSN_MLO_GTK_KDE_PREFIX0_KEY_ID_MASK 0x03 #define RSN_MLO_GTK_KDE_PREFIX0_TX 0x04 #define RSN_MLO_GTK_KDE_PREFIX0_LINK_ID_SHIFT 4 #define RSN_MLO_GTK_KDE_PREFIX0_LINK_ID_MASK 0xF0 -#define RSN_MLO_IGTK_KDE_PREFIX_LENGTH (2 + 6 + 1) +#define RSN_MLO_IGTK_KDE_PREFIX_LENGTH (2 + RSN_PN_LEN + 1) #define RSN_MLO_IGTK_KDE_PREFIX8_LINK_ID_SHIFT 4 #define RSN_MLO_IGTK_KDE_PREFIX8_LINK_ID_MASK 0xF0 struct rsn_mlo_igtk_kde { u8 keyid[2]; - u8 pn[6]; + u8 pn[RSN_PN_LEN]; u8 prefix8; u8 igtk[WPA_IGTK_MAX_LEN]; } STRUCT_PACKED; -#define RSN_MLO_BIGTK_KDE_PREFIX_LENGTH (2 + 6 + 1) +#define RSN_MLO_BIGTK_KDE_PREFIX_LENGTH (2 + RSN_PN_LEN + 1) #define RSN_MLO_BIGTK_KDE_PREFIX8_LINK_ID_SHIFT 4 #define RSN_MLO_BIGTK_KDE_PREFIX8_LINK_ID_MASK 0xF0 struct rsn_mlo_bigtk_kde { u8 keyid[2]; - u8 pn[6]; + u8 pn[RSN_PN_LEN]; u8 prefix8; u8 bigtk[WPA_BIGTK_MAX_LEN]; } STRUCT_PACKED; -#define RSN_MLO_LINK_KDE_FIXED_LENGTH (1 + 6) +#define RSN_MLO_LINK_KDE_FIXED_LENGTH (1 + ETH_ALEN) #define RSN_MLO_LINK_KDE_LINK_INFO_INDEX 0 #define RSN_MLO_LINK_KDE_LI_LINK_ID_SHIFT 0 #define RSN_MLO_LINK_KDE_LI_LINK_ID_MASK 0x0F