123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382 |
- #ifndef WPA_COMMON_H
- #define WPA_COMMON_H
- #define WPA_MAX_SSID_LEN 32
- #define PMKID_LEN 16
- #define PMK_LEN 32
- #define WPA_REPLAY_COUNTER_LEN 8
- #define WPA_NONCE_LEN 32
- #define WPA_KEY_RSC_LEN 8
- #define WPA_GMK_LEN 32
- #define WPA_GTK_MAX_LEN 32
- #define WPA_SELECTOR_LEN 4
- #define WPA_VERSION 1
- #define RSN_SELECTOR_LEN 4
- #define RSN_VERSION 1
- #define RSN_SELECTOR(a, b, c, d) \
- ((((u32) (a)) << 24) | (((u32) (b)) << 16) | (((u32) (c)) << 8) | \
- (u32) (d))
- #define WPA_AUTH_KEY_MGMT_NONE RSN_SELECTOR(0x00, 0x50, 0xf2, 0)
- #define WPA_AUTH_KEY_MGMT_UNSPEC_802_1X RSN_SELECTOR(0x00, 0x50, 0xf2, 1)
- #define WPA_AUTH_KEY_MGMT_PSK_OVER_802_1X RSN_SELECTOR(0x00, 0x50, 0xf2, 2)
- #define WPA_CIPHER_SUITE_NONE RSN_SELECTOR(0x00, 0x50, 0xf2, 0)
- #define WPA_CIPHER_SUITE_WEP40 RSN_SELECTOR(0x00, 0x50, 0xf2, 1)
- #define WPA_CIPHER_SUITE_TKIP RSN_SELECTOR(0x00, 0x50, 0xf2, 2)
- #if 0
- #define WPA_CIPHER_SUITE_WRAP RSN_SELECTOR(0x00, 0x50, 0xf2, 3)
- #endif
- #define WPA_CIPHER_SUITE_CCMP RSN_SELECTOR(0x00, 0x50, 0xf2, 4)
- #define WPA_CIPHER_SUITE_WEP104 RSN_SELECTOR(0x00, 0x50, 0xf2, 5)
- #define RSN_AUTH_KEY_MGMT_UNSPEC_802_1X RSN_SELECTOR(0x00, 0x0f, 0xac, 1)
- #define RSN_AUTH_KEY_MGMT_PSK_OVER_802_1X RSN_SELECTOR(0x00, 0x0f, 0xac, 2)
- #ifdef CONFIG_IEEE80211R
- #define RSN_AUTH_KEY_MGMT_FT_802_1X RSN_SELECTOR(0x00, 0x0f, 0xac, 3)
- #define RSN_AUTH_KEY_MGMT_FT_PSK RSN_SELECTOR(0x00, 0x0f, 0xac, 4)
- #endif
- #define RSN_AUTH_KEY_MGMT_802_1X_SHA256 RSN_SELECTOR(0x00, 0x0f, 0xac, 5)
- #define RSN_AUTH_KEY_MGMT_PSK_SHA256 RSN_SELECTOR(0x00, 0x0f, 0xac, 6)
- #define RSN_AUTH_KEY_MGMT_TPK_HANDSHAKE RSN_SELECTOR(0x00, 0x0f, 0xac, 7)
- #define RSN_CIPHER_SUITE_NONE RSN_SELECTOR(0x00, 0x0f, 0xac, 0)
- #define RSN_CIPHER_SUITE_WEP40 RSN_SELECTOR(0x00, 0x0f, 0xac, 1)
- #define RSN_CIPHER_SUITE_TKIP RSN_SELECTOR(0x00, 0x0f, 0xac, 2)
- #if 0
- #define RSN_CIPHER_SUITE_WRAP RSN_SELECTOR(0x00, 0x0f, 0xac, 3)
- #endif
- #define RSN_CIPHER_SUITE_CCMP RSN_SELECTOR(0x00, 0x0f, 0xac, 4)
- #define RSN_CIPHER_SUITE_WEP104 RSN_SELECTOR(0x00, 0x0f, 0xac, 5)
- #ifdef CONFIG_IEEE80211W
- #define RSN_CIPHER_SUITE_AES_128_CMAC RSN_SELECTOR(0x00, 0x0f, 0xac, 6)
- #endif
- #define RSN_CIPHER_SUITE_NO_GROUP_ADDRESSED RSN_SELECTOR(0x00, 0x0f, 0xac, 7)
- #define RSN_CIPHER_SUITE_GCMP RSN_SELECTOR(0x00, 0x0f, 0xac, 8)
- #define RSN_KEY_DATA_GROUPKEY RSN_SELECTOR(0x00, 0x0f, 0xac, 1)
- #if 0
- #define RSN_KEY_DATA_STAKEY RSN_SELECTOR(0x00, 0x0f, 0xac, 2)
- #endif
- #define RSN_KEY_DATA_MAC_ADDR RSN_SELECTOR(0x00, 0x0f, 0xac, 3)
- #define RSN_KEY_DATA_PMKID RSN_SELECTOR(0x00, 0x0f, 0xac, 4)
- #ifdef CONFIG_PEERKEY
- #define RSN_KEY_DATA_SMK RSN_SELECTOR(0x00, 0x0f, 0xac, 5)
- #define RSN_KEY_DATA_NONCE RSN_SELECTOR(0x00, 0x0f, 0xac, 6)
- #define RSN_KEY_DATA_LIFETIME RSN_SELECTOR(0x00, 0x0f, 0xac, 7)
- #define RSN_KEY_DATA_ERROR RSN_SELECTOR(0x00, 0x0f, 0xac, 8)
- #endif
- #ifdef CONFIG_IEEE80211W
- #define RSN_KEY_DATA_IGTK RSN_SELECTOR(0x00, 0x0f, 0xac, 9)
- #endif
- #define RSN_KEY_DATA_KEYID RSN_SELECTOR(0x00, 0x0f, 0xac, 10)
- #define RSN_KEY_DATA_MULTIBAND_GTK RSN_SELECTOR(0x00, 0x0f, 0xac, 11)
- #define RSN_KEY_DATA_MULTIBAND_KEYID RSN_SELECTOR(0x00, 0x0f, 0xac, 12)
- #define WPA_OUI_TYPE RSN_SELECTOR(0x00, 0x50, 0xf2, 1)
- #define RSN_SELECTOR_PUT(a, val) WPA_PUT_BE32((u8 *) (a), (val))
- #define RSN_SELECTOR_GET(a) WPA_GET_BE32((const u8 *) (a))
- #define RSN_NUM_REPLAY_COUNTERS_1 0
- #define RSN_NUM_REPLAY_COUNTERS_2 1
- #define RSN_NUM_REPLAY_COUNTERS_4 2
- #define RSN_NUM_REPLAY_COUNTERS_16 3
- #ifdef _MSC_VER
- #pragma pack(push, 1)
- #endif
- #ifdef CONFIG_IEEE80211W
- #define WPA_IGTK_LEN 16
- #endif
- #define WPA_CAPABILITY_PREAUTH BIT(0)
- #define WPA_CAPABILITY_NO_PAIRWISE BIT(1)
- #define WPA_CAPABILITY_MFPR BIT(6)
- #define WPA_CAPABILITY_MFPC BIT(7)
- #define WPA_CAPABILITY_PEERKEY_ENABLED BIT(9)
- #define WPA_CAPABILITY_SPP_A_MSDU_CAPABLE BIT(10)
- #define WPA_CAPABILITY_SPP_A_MSDU_REQUIRED BIT(11)
- #define WPA_CAPABILITY_PBAC BIT(12)
- #define WPA_CAPABILITY_EXT_KEY_ID_FOR_UNICAST BIT(13)
- #define MOBILITY_DOMAIN_ID_LEN 2
- #define FT_R0KH_ID_MAX_LEN 48
- #define FT_R1KH_ID_LEN 6
- #define WPA_PMK_NAME_LEN 16
- #define WPA_KEY_INFO_TYPE_MASK ((u16) (BIT(0) | BIT(1) | BIT(2)))
- #define WPA_KEY_INFO_TYPE_HMAC_MD5_RC4 BIT(0)
- #define WPA_KEY_INFO_TYPE_HMAC_SHA1_AES BIT(1)
- #define WPA_KEY_INFO_TYPE_AES_128_CMAC 3
- #define WPA_KEY_INFO_KEY_TYPE BIT(3)
- #define WPA_KEY_INFO_KEY_INDEX_MASK (BIT(4) | BIT(5))
- #define WPA_KEY_INFO_KEY_INDEX_SHIFT 4
- #define WPA_KEY_INFO_INSTALL BIT(6)
- #define WPA_KEY_INFO_TXRX BIT(6)
- #define WPA_KEY_INFO_ACK BIT(7)
- #define WPA_KEY_INFO_MIC BIT(8)
- #define WPA_KEY_INFO_SECURE BIT(9)
- #define WPA_KEY_INFO_ERROR BIT(10)
- #define WPA_KEY_INFO_REQUEST BIT(11)
- #define WPA_KEY_INFO_ENCR_KEY_DATA BIT(12)
- #define WPA_KEY_INFO_SMK_MESSAGE BIT(13)
- struct wpa_eapol_key {
- u8 type;
-
- u8 key_info[2];
- u8 key_length[2];
- u8 replay_counter[WPA_REPLAY_COUNTER_LEN];
- u8 key_nonce[WPA_NONCE_LEN];
- u8 key_iv[16];
- u8 key_rsc[WPA_KEY_RSC_LEN];
- u8 key_id[8];
- u8 key_mic[16];
- u8 key_data_length[2];
-
- } STRUCT_PACKED;
- struct wpa_ptk {
- u8 kck[16];
- u8 kek[16];
- u8 tk1[16];
- union {
- u8 tk2[16];
- struct {
- u8 tx_mic_key[8];
- u8 rx_mic_key[8];
- } auth;
- } u;
- } STRUCT_PACKED;
- struct wpa_ie_hdr {
- u8 elem_id;
- u8 len;
- u8 oui[4];
- u8 version[2];
- } STRUCT_PACKED;
- struct rsn_ie_hdr {
- u8 elem_id;
- u8 len;
- u8 version[2];
- } STRUCT_PACKED;
- #ifdef CONFIG_PEERKEY
- enum {
- STK_MUI_4WAY_STA_AP = 1,
- STK_MUI_4WAY_STAT_STA = 2,
- STK_MUI_GTK = 3,
- STK_MUI_SMK = 4
- };
- enum {
- STK_ERR_STA_NR = 1,
- STK_ERR_STA_NRSN = 2,
- STK_ERR_CPHR_NS = 3,
- STK_ERR_NO_STSL = 4
- };
- #endif
- struct rsn_error_kde {
- be16 mui;
- be16 error_type;
- } STRUCT_PACKED;
- #ifdef CONFIG_IEEE80211W
- struct wpa_igtk_kde {
- u8 keyid[2];
- u8 pn[6];
- u8 igtk[WPA_IGTK_LEN];
- } STRUCT_PACKED;
- #endif
- #ifdef CONFIG_IEEE80211R
- struct rsn_mdie {
- u8 mobility_domain[MOBILITY_DOMAIN_ID_LEN];
- u8 ft_capab;
- } STRUCT_PACKED;
- #define RSN_FT_CAPAB_FT_OVER_DS BIT(0)
- #define RSN_FT_CAPAB_FT_RESOURCE_REQ_SUPP BIT(1)
- struct rsn_ftie {
- u8 mic_control[2];
- u8 mic[16];
- u8 anonce[WPA_NONCE_LEN];
- u8 snonce[WPA_NONCE_LEN];
-
- } STRUCT_PACKED;
- #define FTIE_SUBELEM_R1KH_ID 1
- #define FTIE_SUBELEM_GTK 2
- #define FTIE_SUBELEM_R0KH_ID 3
- #define FTIE_SUBELEM_IGTK 4
- struct rsn_rdie {
- u8 id;
- u8 descr_count;
- le16 status_code;
- } STRUCT_PACKED;
- #endif
- #ifdef _MSC_VER
- #pragma pack(pop)
- #endif
- int wpa_eapol_key_mic(const u8 *key, int ver, const u8 *buf, size_t len,
- u8 *mic);
- void wpa_pmk_to_ptk(const u8 *pmk, size_t pmk_len, const char *label,
- const u8 *addr1, const u8 *addr2,
- const u8 *nonce1, const u8 *nonce2,
- u8 *ptk, size_t ptk_len, int use_sha256);
- #ifdef CONFIG_IEEE80211R
- int wpa_ft_mic(const u8 *kck, const u8 *sta_addr, const u8 *ap_addr,
- u8 transaction_seqnum, const u8 *mdie, size_t mdie_len,
- const u8 *ftie, size_t ftie_len,
- const u8 *rsnie, size_t rsnie_len,
- const u8 *ric, size_t ric_len, u8 *mic);
- void wpa_derive_pmk_r0(const u8 *xxkey, size_t xxkey_len,
- const u8 *ssid, size_t ssid_len,
- const u8 *mdid, const u8 *r0kh_id, size_t r0kh_id_len,
- const u8 *s0kh_id, u8 *pmk_r0, u8 *pmk_r0_name);
- void wpa_derive_pmk_r1_name(const u8 *pmk_r0_name, const u8 *r1kh_id,
- const u8 *s1kh_id, u8 *pmk_r1_name);
- void wpa_derive_pmk_r1(const u8 *pmk_r0, const u8 *pmk_r0_name,
- const u8 *r1kh_id, const u8 *s1kh_id,
- u8 *pmk_r1, u8 *pmk_r1_name);
- void wpa_pmk_r1_to_ptk(const u8 *pmk_r1, const u8 *snonce, const u8 *anonce,
- const u8 *sta_addr, const u8 *bssid,
- const u8 *pmk_r1_name,
- u8 *ptk, size_t ptk_len, u8 *ptk_name);
- #endif
- struct wpa_ie_data {
- int proto;
- int pairwise_cipher;
- int group_cipher;
- int key_mgmt;
- int capabilities;
- size_t num_pmkid;
- const u8 *pmkid;
- int mgmt_group_cipher;
- };
- int wpa_parse_wpa_ie_rsn(const u8 *rsn_ie, size_t rsn_ie_len,
- struct wpa_ie_data *data);
- int wpa_parse_wpa_ie_wpa(const u8 *wpa_ie, size_t wpa_ie_len,
- struct wpa_ie_data *data);
- void rsn_pmkid(const u8 *pmk, size_t pmk_len, const u8 *aa, const u8 *spa,
- u8 *pmkid, int use_sha256);
- const char * wpa_cipher_txt(int cipher);
- const char * wpa_key_mgmt_txt(int key_mgmt, int proto);
- int wpa_compare_rsn_ie(int ft_initial_assoc,
- const u8 *ie1, size_t ie1len,
- const u8 *ie2, size_t ie2len);
- int wpa_insert_pmkid(u8 *ies, size_t ies_len, const u8 *pmkid);
- struct wpa_ft_ies {
- const u8 *mdie;
- size_t mdie_len;
- const u8 *ftie;
- size_t ftie_len;
- const u8 *r1kh_id;
- const u8 *gtk;
- size_t gtk_len;
- const u8 *r0kh_id;
- size_t r0kh_id_len;
- const u8 *rsn;
- size_t rsn_len;
- const u8 *rsn_pmkid;
- const u8 *tie;
- size_t tie_len;
- const u8 *igtk;
- size_t igtk_len;
- const u8 *ric;
- size_t ric_len;
- };
- int wpa_ft_parse_ies(const u8 *ies, size_t ies_len, struct wpa_ft_ies *parse);
- #endif
|