wpa.h 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307
  1. /*
  2. * Fundamental types and constants relating to WPA
  3. *
  4. * Portions of this code are copyright (c) 2020 Cypress Semiconductor Corporation
  5. *
  6. * Copyright (C) 1999-2020, Broadcom Corporation
  7. *
  8. * Unless you and Broadcom execute a separate written software license
  9. * agreement governing use of this software, this software is licensed to you
  10. * under the terms of the GNU General Public License version 2 (the "GPL"),
  11. * available at http://www.broadcom.com/licenses/GPLv2.php, with the
  12. * following added to such license:
  13. *
  14. * As a special exception, the copyright holders of this software give you
  15. * permission to link this software with independent modules, and to copy and
  16. * distribute the resulting executable under terms of your choice, provided that
  17. * you also meet, for each linked independent module, the terms and conditions of
  18. * the license of that module. An independent module is a module which is not
  19. * derived from this software. The special exception does not apply to any
  20. * modifications of the software.
  21. *
  22. * Notwithstanding the above, under no circumstances may you combine this
  23. * software in any way with any other Broadcom software provided under a license
  24. * other than the GPL, without Broadcom's express prior written consent.
  25. *
  26. *
  27. * <<Broadcom-WL-IPTag/Open:>>
  28. *
  29. * $Id: wpa.h 715535 2019-05-24 18:39:58Z $
  30. */
  31. #ifndef _proto_wpa_h_
  32. #define _proto_wpa_h_
  33. #include <typedefs.h>
  34. #include <ethernet.h>
  35. /* This marks the start of a packed structure section. */
  36. #include <packed_section_start.h>
  37. /* Reason Codes */
  38. /* 13 through 23 taken from IEEE Std 802.11i-2004 */
  39. #define DOT11_RC_INVALID_WPA_IE 13 /* Invalid info. element */
  40. #define DOT11_RC_MIC_FAILURE 14 /* Michael failure */
  41. #define DOT11_RC_4WH_TIMEOUT 15 /* 4-way handshake timeout */
  42. #define DOT11_RC_GTK_UPDATE_TIMEOUT 16 /* Group key update timeout */
  43. #define DOT11_RC_WPA_IE_MISMATCH 17 /* WPA IE in 4-way handshake differs from
  44. * (re-)assoc. request/probe response
  45. */
  46. #define DOT11_RC_INVALID_MC_CIPHER 18 /* Invalid multicast cipher */
  47. #define DOT11_RC_INVALID_UC_CIPHER 19 /* Invalid unicast cipher */
  48. #define DOT11_RC_INVALID_AKMP 20 /* Invalid authenticated key management protocol */
  49. #define DOT11_RC_BAD_WPA_VERSION 21 /* Unsupported WPA version */
  50. #define DOT11_RC_INVALID_WPA_CAP 22 /* Invalid WPA IE capabilities */
  51. #define DOT11_RC_8021X_AUTH_FAIL 23 /* 802.1X authentication failure */
  52. #define WPA2_PMKID_LEN 16
  53. /* WPA IE fixed portion */
  54. typedef BWL_PRE_PACKED_STRUCT struct
  55. {
  56. uint8 tag; /* TAG */
  57. uint8 length; /* TAG length */
  58. uint8 oui[3]; /* IE OUI */
  59. uint8 oui_type; /* OUI type */
  60. BWL_PRE_PACKED_STRUCT struct {
  61. uint8 low;
  62. uint8 high;
  63. } BWL_POST_PACKED_STRUCT version; /* IE version */
  64. } BWL_POST_PACKED_STRUCT wpa_ie_fixed_t;
  65. #define WPA_IE_OUITYPE_LEN 4
  66. #define WPA_IE_FIXED_LEN 8
  67. #define WPA_IE_TAG_FIXED_LEN 6
  68. #define BIP_OUI_TYPE WPA2_OUI "\x06"
  69. typedef BWL_PRE_PACKED_STRUCT struct {
  70. uint8 tag; /* TAG */
  71. uint8 length; /* TAG length */
  72. BWL_PRE_PACKED_STRUCT struct {
  73. uint8 low;
  74. uint8 high;
  75. } BWL_POST_PACKED_STRUCT version; /* IE version */
  76. } BWL_POST_PACKED_STRUCT wpa_rsn_ie_fixed_t;
  77. #define WPA_RSN_IE_FIXED_LEN 4
  78. #define WPA_RSN_IE_TAG_FIXED_LEN 2
  79. typedef uint8 wpa_pmkid_t[WPA2_PMKID_LEN];
  80. #define WFA_OSEN_IE_FIXED_LEN 6
  81. /* WPA suite/multicast suite */
  82. typedef BWL_PRE_PACKED_STRUCT struct
  83. {
  84. uint8 oui[3];
  85. uint8 type;
  86. } BWL_POST_PACKED_STRUCT wpa_suite_t, wpa_suite_mcast_t;
  87. #define WPA_SUITE_LEN 4
  88. /* WPA unicast suite list/key management suite list */
  89. typedef BWL_PRE_PACKED_STRUCT struct
  90. {
  91. BWL_PRE_PACKED_STRUCT struct {
  92. uint8 low;
  93. uint8 high;
  94. } BWL_POST_PACKED_STRUCT count;
  95. wpa_suite_t list[1];
  96. } BWL_POST_PACKED_STRUCT wpa_suite_ucast_t, wpa_suite_auth_key_mgmt_t;
  97. #define WPA_IE_SUITE_COUNT_LEN 2
  98. typedef BWL_PRE_PACKED_STRUCT struct
  99. {
  100. BWL_PRE_PACKED_STRUCT struct {
  101. uint8 low;
  102. uint8 high;
  103. } BWL_POST_PACKED_STRUCT count;
  104. wpa_pmkid_t list[1];
  105. } BWL_POST_PACKED_STRUCT wpa_pmkid_list_t;
  106. /* WPA cipher suites */
  107. #define WPA_CIPHER_NONE 0 /* None */
  108. #define WPA_CIPHER_WEP_40 1 /* WEP (40-bit) */
  109. #define WPA_CIPHER_TKIP 2 /* TKIP: default for WPA */
  110. #define WPA_CIPHER_AES_OCB 3 /* AES (OCB) */
  111. #define WPA_CIPHER_AES_CCM 4 /* AES (CCM) */
  112. #define WPA_CIPHER_WEP_104 5 /* WEP (104-bit) */
  113. #define WPA_CIPHER_BIP 6 /* WEP (104-bit) */
  114. #define WPA_CIPHER_TPK 7 /* Group addressed traffic not allowed */
  115. #ifdef BCMCCX
  116. #define WPA_CIPHER_CKIP 8 /* KP with no MIC */
  117. #define WPA_CIPHER_CKIP_MMH 9 /* KP with MIC ("CKIP/MMH", "CKIP+CMIC") */
  118. #define WPA_CIPHER_WEP_MMH 10 /* MIC with no KP ("WEP/MMH", "CMIC") */
  119. #define IS_CCX_CIPHER(cipher) ((cipher) == WPA_CIPHER_CKIP || \
  120. (cipher) == WPA_CIPHER_CKIP_MMH || \
  121. (cipher) == WPA_CIPHER_WEP_MMH)
  122. #endif /* BCMCCX */
  123. #define WPA_CIPHER_AES_GCM 8 /* AES (GCM) */
  124. #define WPA_CIPHER_AES_GCM256 9 /* AES (GCM256) */
  125. #define WPA_CIPHER_CCMP_256 10 /* CCMP-256 */
  126. #define WPA_CIPHER_BIP_GMAC_128 11 /* BIP_GMAC_128 */
  127. #define WPA_CIPHER_BIP_GMAC_256 12 /* BIP_GMAC_256 */
  128. #define WPA_CIPHER_BIP_CMAC_256 13 /* BIP_CMAC_256 */
  129. #ifdef BCMWAPI_WAI
  130. #define WAPI_CIPHER_NONE WPA_CIPHER_NONE
  131. #define WAPI_CIPHER_SMS4 11
  132. #define WAPI_CSE_WPI_SMS4 1
  133. #endif /* BCMWAPI_WAI */
  134. #define IS_WPA_CIPHER(cipher) ((cipher) == WPA_CIPHER_NONE || \
  135. (cipher) == WPA_CIPHER_WEP_40 || \
  136. (cipher) == WPA_CIPHER_WEP_104 || \
  137. (cipher) == WPA_CIPHER_TKIP || \
  138. (cipher) == WPA_CIPHER_AES_OCB || \
  139. (cipher) == WPA_CIPHER_AES_CCM || \
  140. (cipher) == WPA_CIPHER_AES_GCM || \
  141. (cipher) == WPA_CIPHER_AES_GCM256 || \
  142. (cipher) == WPA_CIPHER_TPK)
  143. #ifdef BCMWAPI_WAI
  144. #define IS_WAPI_CIPHER(cipher) ((cipher) == WAPI_CIPHER_NONE || \
  145. (cipher) == WAPI_CSE_WPI_SMS4)
  146. /* convert WAPI_CSE_WPI_XXX to WAPI_CIPHER_XXX */
  147. #define WAPI_CSE_WPI_2_CIPHER(cse) ((cse) == WAPI_CSE_WPI_SMS4 ? \
  148. WAPI_CIPHER_SMS4 : WAPI_CIPHER_NONE)
  149. #define WAPI_CIPHER_2_CSE_WPI(cipher) ((cipher) == WAPI_CIPHER_SMS4 ? \
  150. WAPI_CSE_WPI_SMS4 : WAPI_CIPHER_NONE)
  151. #endif /* BCMWAPI_WAI */
  152. #define IS_VALID_AKM(akm) ((akm) == RSN_AKM_NONE || \
  153. (akm) == RSN_AKM_UNSPECIFIED || \
  154. (akm) == RSN_AKM_PSK || \
  155. (akm) == RSN_AKM_FBT_1X || \
  156. (akm) == RSN_AKM_FBT_PSK || \
  157. (akm) == RSN_AKM_MFP_1X || \
  158. (akm) == RSN_AKM_MFP_PSK || \
  159. (akm) == RSN_AKM_SHA256_1X || \
  160. (akm) == RSN_AKM_SHA256_PSK || \
  161. (akm) == RSN_AKM_TPK || \
  162. (akm) == RSN_AKM_SAE_PSK || \
  163. (akm) == RSN_AKM_SAE_FBT || \
  164. (akm) == RSN_AKM_FILS_SHA256 || \
  165. (akm) == RSN_AKM_FILS_SHA384 || \
  166. (akm) == RSN_AKM_OWE || \
  167. (akm) == RSN_AKM_SUITEB_SHA256_1X || \
  168. (akm) == RSN_AKM_SUITEB_SHA384_1X)
  169. #define IS_VALID_BIP_CIPHER(cipher) ((cipher) == WPA_CIPHER_BIP || \
  170. (cipher) == WPA_CIPHER_BIP_GMAC_128 || \
  171. (cipher) == WPA_CIPHER_BIP_GMAC_256 || \
  172. (cipher) == WPA_CIPHER_BIP_CMAC_256)
  173. #define WPA_IS_FT_AKM(akm) ((akm) == RSN_AKM_FBT_SHA256 || \
  174. (akm) == RSN_AKM_FBT_SHA384)
  175. #define WPA_IS_FILS_AKM(akm) ((akm) == RSN_AKM_FILS_SHA256 || \
  176. (akm) == RSN_AKM_FILS_SHA384)
  177. #define WPA_IS_FILS_FT_AKM(akm) ((akm) == RSN_AKM_FBT_SHA256_FILS || \
  178. (akm) == RSN_AKM_FBT_SHA384_FILS)
  179. /* WPA TKIP countermeasures parameters */
  180. #define WPA_TKIP_CM_DETECT 60 /* multiple MIC failure window (seconds) */
  181. #define WPA_TKIP_CM_BLOCK 60 /* countermeasures active window (seconds) */
  182. /* RSN IE defines */
  183. #define RSN_CAP_LEN 2 /* Length of RSN capabilities field (2 octets) */
  184. /* RSN Capabilities defined in 802.11i */
  185. #define RSN_CAP_PREAUTH 0x0001
  186. #define RSN_CAP_NOPAIRWISE 0x0002
  187. #define RSN_CAP_PTK_REPLAY_CNTR_MASK 0x000C
  188. #define RSN_CAP_PTK_REPLAY_CNTR_SHIFT 2
  189. #define RSN_CAP_GTK_REPLAY_CNTR_MASK 0x0030
  190. #define RSN_CAP_GTK_REPLAY_CNTR_SHIFT 4
  191. #define RSN_CAP_1_REPLAY_CNTR 0
  192. #define RSN_CAP_2_REPLAY_CNTRS 1
  193. #define RSN_CAP_4_REPLAY_CNTRS 2
  194. #define RSN_CAP_16_REPLAY_CNTRS 3
  195. #define RSN_CAP_MFPR 0x0040
  196. #define RSN_CAP_MFPC 0x0080
  197. #define RSN_CAP_SPPC 0x0400
  198. #define RSN_CAP_SPPR 0x0800
  199. /* WPA capabilities defined in 802.11i */
  200. #define WPA_CAP_4_REPLAY_CNTRS RSN_CAP_4_REPLAY_CNTRS
  201. #define WPA_CAP_16_REPLAY_CNTRS RSN_CAP_16_REPLAY_CNTRS
  202. #define WPA_CAP_REPLAY_CNTR_SHIFT RSN_CAP_PTK_REPLAY_CNTR_SHIFT
  203. #define WPA_CAP_REPLAY_CNTR_MASK RSN_CAP_PTK_REPLAY_CNTR_MASK
  204. /* WPA capabilities defined in 802.11zD9.0 */
  205. #define WPA_CAP_PEER_KEY_ENABLE (0x1 << 1) /* bit 9 */
  206. /* WPA Specific defines */
  207. #define WPA_CAP_LEN RSN_CAP_LEN /* Length of RSN capabilities in RSN IE (2 octets) */
  208. #define WPA_PMKID_CNT_LEN 2 /* Length of RSN PMKID count (2 octests) */
  209. #define WPA_CAP_WPA2_PREAUTH RSN_CAP_PREAUTH
  210. #define WPA2_PMKID_COUNT_LEN 2
  211. /* RSN dev type in rsn_info struct */
  212. typedef enum {
  213. DEV_NONE = 0,
  214. DEV_STA = 1,
  215. DEV_AP = 2
  216. } device_type_t;
  217. typedef uint32 rsn_akm_mask_t; /* RSN_AKM_... see 802.11.h */
  218. typedef uint8 rsn_cipher_t; /* WPA_CIPHER_xxx */
  219. typedef uint32 rsn_ciphers_t; /* mask of rsn_cipher_t */
  220. typedef uint8 rsn_akm_t;
  221. typedef uint8 auth_ie_type_mask_t;
  222. /* Old location for this structure. Moved to bcmwpa.h */
  223. #ifndef RSN_IE_INFO_STRUCT_RELOCATED
  224. typedef struct rsn_ie_info {
  225. uint8 version;
  226. rsn_cipher_t g_cipher;
  227. uint8 p_count;
  228. uint8 akm_count;
  229. uint8 pmkid_count;
  230. rsn_akm_t sta_akm; /* single STA akm */
  231. uint16 caps;
  232. rsn_ciphers_t p_ciphers;
  233. rsn_akm_mask_t akms;
  234. uint8 pmkids_offset; /* offset into the IE */
  235. rsn_cipher_t g_mgmt_cipher;
  236. device_type_t dev_type; /* AP or STA */
  237. rsn_cipher_t sta_cipher; /* single STA cipher */
  238. uint16 key_desc; /* key descriptor version as STA */
  239. int parse_status;
  240. uint16 mic_len; /* unused. keep for ROM compatibility. */
  241. auth_ie_type_mask_t auth_ie_type; /* bit field of WPA, WPA2 and (not yet) CCX WAPI */
  242. uint8 pmk_len; /* EAPOL PMK */
  243. uint8 kck_mic_len; /* EAPOL MIC (by KCK) */
  244. uint8 kck_len; /* EAPOL KCK */
  245. uint8 kek_len; /* EAPOL KEK */
  246. uint8 tk_len; /* EAPOL TK */
  247. uint8 ptk_len; /* EAPOL PTK */
  248. uint8 kck2_len; /* EAPOL KCK2 */
  249. uint8 kek2_len; /* EAPOL KEK2 */
  250. } rsn_ie_info_t;
  251. #endif /* RSN_IE_INFO_STRUCT_RELOCATED */
  252. #ifdef BCMWAPI_WAI
  253. #define WAPI_CAP_PREAUTH RSN_CAP_PREAUTH
  254. /* Other WAI definition */
  255. #define WAPI_WAI_REQUEST 0x00F1
  256. #define WAPI_UNICAST_REKEY 0x00F2
  257. #define WAPI_STA_AGING 0x00F3
  258. #define WAPI_MUTIL_REKEY 0x00F4
  259. #define WAPI_STA_STATS 0x00F5
  260. #define WAPI_USK_REKEY_COUNT 0x4000000 /* 0xA00000 */
  261. #define WAPI_MSK_REKEY_COUNT 0x4000000 /* 0xA00000 */
  262. #endif /* BCMWAPI_WAI */
  263. /* This marks the end of a packed structure section. */
  264. #include <packed_section_end.h>
  265. #endif /* _proto_wpa_h_ */