2 * bcmwpa.h - interface definitions of shared WPA-related functions
4 * Copyright 2006, Broadcom Corporation
7 * This is UNPUBLISHED PROPRIETARY SOURCE CODE of Broadcom Corporation;
8 * the contents of this file may not be disclosed to third parties, copied
9 * or duplicated in any form, in whole or in part, without the prior
10 * written permission of Broadcom Corporation.
18 #include <proto/wpa.h>
19 #if defined(BCMWPA2) || defined(BCMSUP_PSK)
20 #include <proto/eapol.h>
22 #include <proto/802.11.h>
25 /* Field sizes for WPA key hierarchy */
26 #define WPA_MIC_KEY_LEN 16
27 #define WPA_ENCR_KEY_LEN 16
28 #define WPA_TEMP_ENCR_KEY_LEN 16
29 #define WPA_TEMP_TX_KEY_LEN 8
30 #define WPA_TEMP_RX_KEY_LEN 8
33 #define TKIP_PTK_LEN 64
34 #define TKIP_TK_LEN 32
35 #define AES_PTK_LEN 48
38 /* limits for pre-shared key lengths */
39 #define WPA_MIN_PSK_LEN 8
40 #define WPA_MAX_PSK_LEN 64
42 #define WLC_SW_KEYS(wlc) ((((wlc)->wsec_swkeys) || \
43 ((wlc)->bsscfg[0]->wsec & (WSEC_SWFLAG | FIPS_ENABLED))))
44 #define WLC_HW_KEYS(wlc) (!WLC_SW_KEYS(wlc))
46 #define WSEC_WEP_ENABLED(wsec) ((wsec) & WEP_ENABLED)
47 #define WSEC_TKIP_ENABLED(wsec) ((wsec) & TKIP_ENABLED)
48 #define WSEC_AES_ENABLED(wsec) ((wsec) & AES_ENABLED)
49 #define WSEC_ENABLED(wsec) ((wsec) & (WEP_ENABLED | TKIP_ENABLED | AES_ENABLED))
50 #define WSEC_SES_OW_ENABLED(wsec) ((wsec) & SES_OW_ENABLED)
52 #define IS_WPA_AUTH(auth) ((auth) == WPA_AUTH_NONE || \
53 (auth) == WPA_AUTH_UNSPECIFIED || \
54 (auth) == WPA_AUTH_PSK)
55 #define INCLUDES_WPA_AUTH(auth) \
56 ((auth) & (WPA_AUTH_NONE | WPA_AUTH_UNSPECIFIED | WPA_AUTH_PSK))
58 #define IS_WPA2_AUTH(auth) ((auth) == WPA2_AUTH_UNSPECIFIED || \
59 (auth) == WPA2_AUTH_PSK)
60 #define INCLUDES_WPA2_AUTH(auth) \
61 ((auth) & (WPA2_AUTH_UNSPECIFIED | WPA2_AUTH_PSK))
64 #define IS_WPA_AKM(akm) ((akm) == RSN_AKM_NONE || \
65 (akm) == RSN_AKM_UNSPECIFIED || \
68 #define IS_WPA2_AKM(akm) ((akm) == RSN_AKM_UNSPECIFIED || \
75 /* convert wsec to WPA mcast cipher. algo is needed only when WEP is enabled. */
76 #define WPA_MCAST_CIPHER(wsec, algo) (WSEC_WEP_ENABLED(wsec) ? \
77 ((algo) == CRYPTO_ALGO_WEP128 ? WPA_CIPHER_WEP_104 : WPA_CIPHER_WEP_40) : \
78 WSEC_TKIP_ENABLED(wsec) ? WPA_CIPHER_TKIP : \
79 WSEC_AES_ENABLED(wsec) ? WPA_CIPHER_AES_CCM : \
82 /* Return address of max or min array depending first argument.
83 * Return first array addr in case of a draw.
85 extern uint8
*BCMROMFN(wpa_array_cmp
)(int max_array
, uint8
*x
, uint8
*y
, uint len
);
87 /* Increment the array argument */
88 extern void BCMROMFN(wpa_incr_array
)(uint8
*array
, uint len
);
90 /* Convert WPA IE cipher suite to locally used value */
91 extern bool BCMROMFN(wpa_cipher
)(wpa_suite_t
*suite
, ushort
*cipher
, bool wep_ok
);
93 /* Look for a WPA IE; return it's address if found, NULL otherwise */
94 extern wpa_ie_fixed_t
*BCMROMFN(bcm_find_wpaie
)(uint8
*parse
, uint len
);
96 /* Check whether pointed-to IE looks like WPA. */
97 extern bool BCMROMFN(bcm_is_wpa_ie
)(uint8
*ie
, uint8
**tlvs
, uint
*tlvs_len
);
100 /* Convert WPA2 IE cipher suite to locally used value */
101 extern bool BCMROMFN(wpa2_cipher
)(wpa_suite_t
*suite
, ushort
*cipher
, bool wep_ok
);
103 /* Look for an encapsulated GTK; return it's address if found, NULL otherwise */
104 extern eapol_wpa2_encap_data_t
*BCMROMFN(wpa_find_gtk_encap
)(uint8
*parse
, uint len
);
106 /* Check whether pointed-to IE looks like an encapsulated GTK. */
107 extern bool BCMROMFN(wpa_is_gtk_encap
)(uint8
*ie
, uint8
**tlvs
, uint
*tlvs_len
);
109 /* Look for encapsulated key data; return it's address if found, NULL otherwise */
110 extern eapol_wpa2_encap_data_t
*BCMROMFN(wpa_find_kde
)(uint8
*parse
, uint len
, uint8 type
);
115 /* Calculate a pair-wise transient key */
116 extern void BCMROMFN(wpa_calc_ptk
)(struct ether_addr
*auth_ea
, struct ether_addr
*sta_ea
,
117 uint8
*anonce
, uint8
* snonce
, uint8
*pmk
, uint pmk_len
,
118 uint8
*ptk
, uint ptk_len
);
120 /* Compute Message Integrity Code (MIC) over EAPOL message */
121 extern bool BCMROMFN(wpa_make_mic
)(eapol_header_t
*eapol
, uint key_desc
, uint8
*mic_key
,
124 /* Check MIC of EAPOL message */
125 extern bool BCMROMFN(wpa_check_mic
)(eapol_header_t
*eapol
, uint key_desc
, uint8
*mic_key
);
128 /* Calculate PMKID */
129 extern void BCMROMFN(wpa_calc_pmkid
)(struct ether_addr
*auth_ea
, struct ether_addr
*sta_ea
,
130 uint8
*pmk
, uint pmk_len
, uint8
*pmkid
);
133 /* Decrypt key data from a WPA key message */
134 extern bool BCMROMFN(wpa_decr_key_data
)(eapol_wpa_key_header_t
*body
, uint16 key_info
,
135 uint8
*ekey
, uint8
*gtk
);
137 /* Decrypt a group transient key from a WPA key message */
138 extern bool BCMROMFN(wpa_decr_gtk
)(eapol_wpa_key_header_t
*body
, uint16 key_info
,
139 uint8
*ekey
, uint8
*gtk
);
140 #endif /* BCMSUP_PSK */
142 extern bool BCMROMFN(bcmwpa_akm2WPAauth
)(uint8
*akm
, uint32
*auth
);
143 extern bool BCMROMFN(bcmwpa_cipher2wsec
)(uint8
*cipher
, uint32
*wsec
);
145 #endif /* _BCMWPA_H_ */