2 * hostapd - IEEE 802.11i-2004 / WPA Authenticator: Internal definitions
3 * Copyright (c) 2004-2007, Jouni Malinen <j@w1.fi>
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License version 2 as
7 * published by the Free Software Foundation.
9 * Alternatively, this software may be distributed under the terms of BSD
12 * See README and COPYING for more details.
20 struct wpa_stsl_negotiation {
21 struct wpa_stsl_negotiation *next;
22 u8 initiator[ETH_ALEN];
27 struct wpa_state_machine {
28 struct wpa_authenticator *wpa_auth;
29 struct wpa_group *group;
34 WPA_PTK_INITIALIZE, WPA_PTK_DISCONNECT, WPA_PTK_DISCONNECTED,
35 WPA_PTK_AUTHENTICATION, WPA_PTK_AUTHENTICATION2,
36 WPA_PTK_INITPMK, WPA_PTK_INITPSK, WPA_PTK_PTKSTART,
37 WPA_PTK_PTKCALCNEGOTIATING, WPA_PTK_PTKCALCNEGOTIATING2,
38 WPA_PTK_PTKINITNEGOTIATING, WPA_PTK_PTKINITDONE
42 WPA_PTK_GROUP_IDLE = 0,
43 WPA_PTK_GROUP_REKEYNEGOTIATING,
44 WPA_PTK_GROUP_REKEYESTABLISHED,
45 WPA_PTK_GROUP_KEYERROR
46 } wpa_ptk_group_state;
49 Boolean DeauthenticationRequest;
50 Boolean AuthenticationRequest;
51 Boolean ReAuthenticationRequest;
56 Boolean EAPOLKeyReceived;
57 Boolean EAPOLKeyPairwise;
58 Boolean EAPOLKeyRequest;
60 Boolean GUpdateStationKeys;
61 u8 ANonce[WPA_NONCE_LEN];
62 u8 SNonce[WPA_NONCE_LEN];
69 u8 key_replay_counter[WPA_REPLAY_COUNTER_LEN];
70 Boolean key_replay_counter_valid;
71 Boolean PInitAKeys; /* WPA only, not in IEEE 802.11i */
72 Boolean PTKRequest; /* not in IEEE 802.11i state machine */
74 Boolean PtkGroupInit; /* init request for PTK Group state machine */
76 u8 *last_rx_eapol_key; /* starting from IEEE 802.1X header */
77 size_t last_rx_eapol_key_len;
79 unsigned int changed:1;
80 unsigned int in_step_loop:1;
81 unsigned int pending_deinit:1;
82 unsigned int started:1;
83 unsigned int mgmt_frame_prot:1;
84 #ifdef CONFIG_IEEE80211R
85 unsigned int ft_completed:1;
86 unsigned int pmk_r1_name_valid:1;
87 #endif /* CONFIG_IEEE80211R */
89 u8 req_replay_counter[WPA_REPLAY_COUNTER_LEN];
90 int req_replay_counter_used;
96 WPA_VERSION_NO_WPA = 0 /* WPA not used */,
97 WPA_VERSION_WPA = 1 /* WPA / IEEE 802.11i/D3.0 */,
98 WPA_VERSION_WPA2 = 2 /* WPA2 / IEEE 802.11i */
100 int pairwise; /* Pairwise cipher suite, WPA_CIPHER_* */
101 int wpa_key_mgmt; /* the selected WPA_KEY_MGMT_* */
102 struct rsn_pmksa_cache_entry *pmksa;
104 u32 dot11RSNAStatsTKIPLocalMICFailures;
105 u32 dot11RSNAStatsTKIPRemoteMICFailures;
107 #ifdef CONFIG_IEEE80211R
108 u8 xxkey[PMK_LEN]; /* PSK or the second 256 bits of MSK */
110 u8 pmk_r1_name[WPA_PMK_NAME_LEN]; /* PMKR1Name derived from FT Auth
112 u8 r0kh_id[FT_R0KH_ID_MAX_LEN]; /* R0KH-ID from FT Auth Request */
114 #endif /* CONFIG_IEEE80211R */
118 /* per group key state machine data */
120 struct wpa_group *next;
124 int GKeyDoneStations;
128 Boolean GTKAuthenticator;
129 u8 Counter[WPA_NONCE_LEN];
132 WPA_GROUP_GTK_INIT = 0,
133 WPA_GROUP_SETKEYS, WPA_GROUP_SETKEYSDONE
137 u8 GTK[2][WPA_GTK_MAX_LEN];
138 u8 GNonce[WPA_NONCE_LEN];
140 #ifdef CONFIG_IEEE80211W
141 u8 IGTK[2][WPA_IGTK_LEN];
142 int GN_igtk, GM_igtk;
143 #endif /* CONFIG_IEEE80211W */
147 struct wpa_ft_pmk_cache;
149 /* per authenticator data */
150 struct wpa_authenticator {
151 struct wpa_group *group;
153 unsigned int dot11RSNAStatsTKIPRemoteMICFailures;
154 u32 dot11RSNAAuthenticationSuiteSelected;
155 u32 dot11RSNAPairwiseCipherSelected;
156 u32 dot11RSNAGroupCipherSelected;
157 u8 dot11RSNAPMKIDUsed[PMKID_LEN];
158 u32 dot11RSNAAuthenticationSuiteRequested; /* FIX: update */
159 u32 dot11RSNAPairwiseCipherRequested; /* FIX: update */
160 u32 dot11RSNAGroupCipherRequested; /* FIX: update */
161 unsigned int dot11RSNATKIPCounterMeasuresInvoked;
162 unsigned int dot11RSNA4WayHandshakeFailures;
164 struct wpa_stsl_negotiation *stsl_negotiations;
166 struct wpa_auth_config conf;
167 struct wpa_auth_callbacks cb;
174 struct rsn_pmksa_cache *pmksa;
175 struct wpa_ft_pmk_cache *ft_pmk_cache;
179 int wpa_write_rsn_ie(struct wpa_auth_config *conf, u8 *buf, size_t len,
181 void wpa_auth_logger(struct wpa_authenticator *wpa_auth, const u8 *addr,
182 logger_level level, const char *txt);
183 void wpa_auth_vlogger(struct wpa_authenticator *wpa_auth, const u8 *addr,
184 logger_level level, const char *fmt, ...);
185 void __wpa_send_eapol(struct wpa_authenticator *wpa_auth,
186 struct wpa_state_machine *sm, int key_info,
187 const u8 *key_rsc, const u8 *nonce,
188 const u8 *kde, size_t kde_len,
189 int keyidx, int encr, int force_version);
190 int wpa_auth_for_each_sta(struct wpa_authenticator *wpa_auth,
191 int (*cb)(struct wpa_state_machine *sm, void *ctx),
193 int wpa_auth_for_each_auth(struct wpa_authenticator *wpa_auth,
194 int (*cb)(struct wpa_authenticator *a, void *ctx),
197 #ifdef CONFIG_PEERKEY
198 int wpa_stsl_remove(struct wpa_authenticator *wpa_auth,
199 struct wpa_stsl_negotiation *neg);
200 void wpa_smk_error(struct wpa_authenticator *wpa_auth,
201 struct wpa_state_machine *sm, struct wpa_eapol_key *key);
202 void wpa_smk_m1(struct wpa_authenticator *wpa_auth,
203 struct wpa_state_machine *sm, struct wpa_eapol_key *key);
204 void wpa_smk_m3(struct wpa_authenticator *wpa_auth,
205 struct wpa_state_machine *sm, struct wpa_eapol_key *key);
206 #endif /* CONFIG_PEERKEY */
208 #ifdef CONFIG_IEEE80211R
209 int wpa_write_mdie(struct wpa_auth_config *conf, u8 *buf, size_t len);
210 int wpa_auth_derive_ptk_ft(struct wpa_state_machine *sm, const u8 *pmk,
211 struct wpa_ptk *ptk);
212 struct wpa_ft_pmk_cache * wpa_ft_pmk_cache_init(void);
213 void wpa_ft_pmk_cache_deinit(struct wpa_ft_pmk_cache *cache);
214 #endif /* CONFIG_IEEE80211R */
216 #endif /* WPA_AUTH_I_H */