2 * hostapd - IEEE 802.11i-2004 / WPA Authenticator: Internal definitions
3 * Copyright (c) 2004-2015, Jouni Malinen <j@w1.fi>
5 * This software may be distributed under the terms of the BSD license.
6 * See README for more details.
12 /* max(dot11RSNAConfigGroupUpdateCount,dot11RSNAConfigPairwiseUpdateCount) */
13 #define RSNA_MAX_EAPOL_RETRIES 4
17 struct wpa_stsl_negotiation {
18 struct wpa_stsl_negotiation *next;
19 u8 initiator[ETH_ALEN];
24 struct wpa_state_machine {
25 struct wpa_authenticator *wpa_auth;
26 struct wpa_group *group;
29 u8 p2p_dev_addr[ETH_ALEN];
32 WPA_PTK_INITIALIZE, WPA_PTK_DISCONNECT, WPA_PTK_DISCONNECTED,
33 WPA_PTK_AUTHENTICATION, WPA_PTK_AUTHENTICATION2,
34 WPA_PTK_INITPMK, WPA_PTK_INITPSK, WPA_PTK_PTKSTART,
35 WPA_PTK_PTKCALCNEGOTIATING, WPA_PTK_PTKCALCNEGOTIATING2,
36 WPA_PTK_PTKINITNEGOTIATING, WPA_PTK_PTKINITDONE
40 WPA_PTK_GROUP_IDLE = 0,
41 WPA_PTK_GROUP_REKEYNEGOTIATING,
42 WPA_PTK_GROUP_REKEYESTABLISHED,
43 WPA_PTK_GROUP_KEYERROR
44 } wpa_ptk_group_state;
47 Boolean DeauthenticationRequest;
48 Boolean AuthenticationRequest;
49 Boolean ReAuthenticationRequest;
54 Boolean EAPOLKeyReceived;
55 Boolean EAPOLKeyPairwise;
56 Boolean EAPOLKeyRequest;
58 Boolean GUpdateStationKeys;
59 u8 ANonce[WPA_NONCE_LEN];
60 u8 SNonce[WPA_NONCE_LEN];
61 u8 alt_SNonce[WPA_NONCE_LEN];
62 u8 alt_replay_counter[WPA_REPLAY_COUNTER_LEN];
70 struct wpa_key_replay_counter {
71 u8 counter[WPA_REPLAY_COUNTER_LEN];
73 } key_replay[RSNA_MAX_EAPOL_RETRIES],
74 prev_key_replay[RSNA_MAX_EAPOL_RETRIES];
75 Boolean PInitAKeys; /* WPA only, not in IEEE 802.11i */
76 Boolean PTKRequest; /* not in IEEE 802.11i state machine */
78 Boolean PtkGroupInit; /* init request for PTK Group state machine */
80 u8 *last_rx_eapol_key; /* starting from IEEE 802.1X header */
81 size_t last_rx_eapol_key_len;
83 unsigned int changed:1;
84 unsigned int in_step_loop:1;
85 unsigned int pending_deinit:1;
86 unsigned int started:1;
87 unsigned int mgmt_frame_prot:1;
88 unsigned int rx_eapol_key_secure:1;
89 unsigned int update_snonce:1;
90 unsigned int alt_snonce_valid:1;
91 #ifdef CONFIG_IEEE80211R
92 unsigned int ft_completed:1;
93 unsigned int pmk_r1_name_valid:1;
94 #endif /* CONFIG_IEEE80211R */
95 unsigned int is_wnmsleep:1;
97 u8 req_replay_counter[WPA_REPLAY_COUNTER_LEN];
98 int req_replay_counter_used;
104 WPA_VERSION_NO_WPA = 0 /* WPA not used */,
105 WPA_VERSION_WPA = 1 /* WPA / IEEE 802.11i/D3.0 */,
106 WPA_VERSION_WPA2 = 2 /* WPA2 / IEEE 802.11i */
108 int pairwise; /* Pairwise cipher suite, WPA_CIPHER_* */
109 int wpa_key_mgmt; /* the selected WPA_KEY_MGMT_* */
110 struct rsn_pmksa_cache_entry *pmksa;
112 u32 dot11RSNAStatsTKIPLocalMICFailures;
113 u32 dot11RSNAStatsTKIPRemoteMICFailures;
115 #ifdef CONFIG_IEEE80211R
116 u8 xxkey[PMK_LEN]; /* PSK or the second 256 bits of MSK */
118 u8 pmk_r1_name[WPA_PMK_NAME_LEN]; /* PMKR1Name derived from FT Auth
120 u8 r0kh_id[FT_R0KH_ID_MAX_LEN]; /* R0KH-ID from FT Auth Request */
122 u8 sup_pmk_r1_name[WPA_PMK_NAME_LEN]; /* PMKR1Name from EAPOL-Key
126 void (*ft_pending_cb)(void *ctx, const u8 *dst, const u8 *bssid,
127 u16 auth_transaction, u16 status,
128 const u8 *ies, size_t ies_len);
129 void *ft_pending_cb_ctx;
130 struct wpabuf *ft_pending_req_ies;
131 u8 ft_pending_pull_nonce[FT_R0KH_R1KH_PULL_NONCE_LEN];
132 u8 ft_pending_auth_transaction;
133 u8 ft_pending_current_ap[ETH_ALEN];
134 #endif /* CONFIG_IEEE80211R */
136 int pending_1_of_4_timeout;
140 #endif /* CONFIG_P2P */
144 /* per group key state machine data */
146 struct wpa_group *next;
150 int GKeyDoneStations;
154 Boolean GTKAuthenticator;
155 u8 Counter[WPA_NONCE_LEN];
158 WPA_GROUP_GTK_INIT = 0,
159 WPA_GROUP_SETKEYS, WPA_GROUP_SETKEYSDONE,
160 WPA_GROUP_FATAL_FAILURE
164 u8 GTK[2][WPA_GTK_MAX_LEN];
165 u8 GNonce[WPA_NONCE_LEN];
167 Boolean first_sta_seen;
168 Boolean reject_4way_hs_for_entropy;
169 #ifdef CONFIG_IEEE80211W
170 u8 IGTK[2][WPA_IGTK_MAX_LEN];
171 int GN_igtk, GM_igtk;
172 #endif /* CONFIG_IEEE80211W */
173 /* Number of references except those in struct wpa_group->next */
174 unsigned int references;
175 unsigned int num_setup_iface;
179 struct wpa_ft_pmk_cache;
181 /* per authenticator data */
182 struct wpa_authenticator {
183 struct wpa_group *group;
185 unsigned int dot11RSNAStatsTKIPRemoteMICFailures;
186 u32 dot11RSNAAuthenticationSuiteSelected;
187 u32 dot11RSNAPairwiseCipherSelected;
188 u32 dot11RSNAGroupCipherSelected;
189 u8 dot11RSNAPMKIDUsed[PMKID_LEN];
190 u32 dot11RSNAAuthenticationSuiteRequested; /* FIX: update */
191 u32 dot11RSNAPairwiseCipherRequested; /* FIX: update */
192 u32 dot11RSNAGroupCipherRequested; /* FIX: update */
193 unsigned int dot11RSNATKIPCounterMeasuresInvoked;
194 unsigned int dot11RSNA4WayHandshakeFailures;
196 struct wpa_stsl_negotiation *stsl_negotiations;
198 struct wpa_auth_config conf;
199 struct wpa_auth_callbacks cb;
206 struct rsn_pmksa_cache *pmksa;
207 struct wpa_ft_pmk_cache *ft_pmk_cache;
210 struct bitfield *ip_pool;
211 #endif /* CONFIG_P2P */
215 int wpa_write_rsn_ie(struct wpa_auth_config *conf, u8 *buf, size_t len,
217 void wpa_auth_logger(struct wpa_authenticator *wpa_auth, const u8 *addr,
218 logger_level level, const char *txt);
219 void wpa_auth_vlogger(struct wpa_authenticator *wpa_auth, const u8 *addr,
220 logger_level level, const char *fmt, ...);
221 void __wpa_send_eapol(struct wpa_authenticator *wpa_auth,
222 struct wpa_state_machine *sm, int key_info,
223 const u8 *key_rsc, const u8 *nonce,
224 const u8 *kde, size_t kde_len,
225 int keyidx, int encr, int force_version);
226 int wpa_auth_for_each_sta(struct wpa_authenticator *wpa_auth,
227 int (*cb)(struct wpa_state_machine *sm, void *ctx),
229 int wpa_auth_for_each_auth(struct wpa_authenticator *wpa_auth,
230 int (*cb)(struct wpa_authenticator *a, void *ctx),
233 #ifdef CONFIG_PEERKEY
234 int wpa_stsl_remove(struct wpa_authenticator *wpa_auth,
235 struct wpa_stsl_negotiation *neg);
236 void wpa_smk_error(struct wpa_authenticator *wpa_auth,
237 struct wpa_state_machine *sm,
238 const u8 *key_data, size_t key_data_len);
239 void wpa_smk_m1(struct wpa_authenticator *wpa_auth,
240 struct wpa_state_machine *sm, struct wpa_eapol_key *key,
241 const u8 *key_data, size_t key_data_len);
242 void wpa_smk_m3(struct wpa_authenticator *wpa_auth,
243 struct wpa_state_machine *sm, struct wpa_eapol_key *key,
244 const u8 *key_data, size_t key_data_len);
245 #endif /* CONFIG_PEERKEY */
247 #ifdef CONFIG_IEEE80211R
248 int wpa_write_mdie(struct wpa_auth_config *conf, u8 *buf, size_t len);
249 int wpa_write_ftie(struct wpa_auth_config *conf, const u8 *r0kh_id,
251 const u8 *anonce, const u8 *snonce,
252 u8 *buf, size_t len, const u8 *subelem,
254 int wpa_auth_derive_ptk_ft(struct wpa_state_machine *sm, const u8 *pmk,
255 struct wpa_ptk *ptk);
256 struct wpa_ft_pmk_cache * wpa_ft_pmk_cache_init(void);
257 void wpa_ft_pmk_cache_deinit(struct wpa_ft_pmk_cache *cache);
258 void wpa_ft_install_ptk(struct wpa_state_machine *sm);
259 #endif /* CONFIG_IEEE80211R */
261 #endif /* WPA_AUTH_I_H */