2 * hostapd - IEEE 802.11i-2004 / WPA Authenticator: Internal definitions
3 * Copyright (c) 2004-2007, 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];
67 struct wpa_key_replay_counter {
68 u8 counter[WPA_REPLAY_COUNTER_LEN];
70 } key_replay[RSNA_MAX_EAPOL_RETRIES],
71 prev_key_replay[RSNA_MAX_EAPOL_RETRIES];
72 Boolean PInitAKeys; /* WPA only, not in IEEE 802.11i */
73 Boolean PTKRequest; /* not in IEEE 802.11i state machine */
75 Boolean PtkGroupInit; /* init request for PTK Group state machine */
77 u8 *last_rx_eapol_key; /* starting from IEEE 802.1X header */
78 size_t last_rx_eapol_key_len;
80 unsigned int changed:1;
81 unsigned int in_step_loop:1;
82 unsigned int pending_deinit:1;
83 unsigned int started:1;
84 unsigned int mgmt_frame_prot:1;
85 unsigned int rx_eapol_key_secure:1;
86 unsigned int update_snonce:1;
87 #ifdef CONFIG_IEEE80211R
88 unsigned int ft_completed:1;
89 unsigned int pmk_r1_name_valid:1;
90 #endif /* CONFIG_IEEE80211R */
91 unsigned int is_wnmsleep:1;
93 u8 req_replay_counter[WPA_REPLAY_COUNTER_LEN];
94 int req_replay_counter_used;
100 WPA_VERSION_NO_WPA = 0 /* WPA not used */,
101 WPA_VERSION_WPA = 1 /* WPA / IEEE 802.11i/D3.0 */,
102 WPA_VERSION_WPA2 = 2 /* WPA2 / IEEE 802.11i */
104 int pairwise; /* Pairwise cipher suite, WPA_CIPHER_* */
105 int wpa_key_mgmt; /* the selected WPA_KEY_MGMT_* */
106 struct rsn_pmksa_cache_entry *pmksa;
108 u32 dot11RSNAStatsTKIPLocalMICFailures;
109 u32 dot11RSNAStatsTKIPRemoteMICFailures;
111 #ifdef CONFIG_IEEE80211R
112 u8 xxkey[PMK_LEN]; /* PSK or the second 256 bits of MSK */
114 u8 pmk_r1_name[WPA_PMK_NAME_LEN]; /* PMKR1Name derived from FT Auth
116 u8 r0kh_id[FT_R0KH_ID_MAX_LEN]; /* R0KH-ID from FT Auth Request */
118 u8 sup_pmk_r1_name[WPA_PMK_NAME_LEN]; /* PMKR1Name from EAPOL-Key
121 #endif /* CONFIG_IEEE80211R */
123 int pending_1_of_4_timeout;
127 #endif /* CONFIG_P2P */
131 /* per group key state machine data */
133 struct wpa_group *next;
137 int GKeyDoneStations;
141 Boolean GTKAuthenticator;
142 u8 Counter[WPA_NONCE_LEN];
145 WPA_GROUP_GTK_INIT = 0,
146 WPA_GROUP_SETKEYS, WPA_GROUP_SETKEYSDONE,
147 WPA_GROUP_FATAL_FAILURE
151 u8 GTK[2][WPA_GTK_MAX_LEN];
152 u8 GNonce[WPA_NONCE_LEN];
154 Boolean first_sta_seen;
155 Boolean reject_4way_hs_for_entropy;
156 #ifdef CONFIG_IEEE80211W
157 u8 IGTK[2][WPA_IGTK_LEN];
158 int GN_igtk, GM_igtk;
159 #endif /* CONFIG_IEEE80211W */
163 struct wpa_ft_pmk_cache;
165 /* per authenticator data */
166 struct wpa_authenticator {
167 struct wpa_group *group;
169 unsigned int dot11RSNAStatsTKIPRemoteMICFailures;
170 u32 dot11RSNAAuthenticationSuiteSelected;
171 u32 dot11RSNAPairwiseCipherSelected;
172 u32 dot11RSNAGroupCipherSelected;
173 u8 dot11RSNAPMKIDUsed[PMKID_LEN];
174 u32 dot11RSNAAuthenticationSuiteRequested; /* FIX: update */
175 u32 dot11RSNAPairwiseCipherRequested; /* FIX: update */
176 u32 dot11RSNAGroupCipherRequested; /* FIX: update */
177 unsigned int dot11RSNATKIPCounterMeasuresInvoked;
178 unsigned int dot11RSNA4WayHandshakeFailures;
180 struct wpa_stsl_negotiation *stsl_negotiations;
182 struct wpa_auth_config conf;
183 struct wpa_auth_callbacks cb;
190 struct rsn_pmksa_cache *pmksa;
191 struct wpa_ft_pmk_cache *ft_pmk_cache;
194 struct bitfield *ip_pool;
195 #endif /* CONFIG_P2P */
199 int wpa_write_rsn_ie(struct wpa_auth_config *conf, u8 *buf, size_t len,
201 void wpa_auth_logger(struct wpa_authenticator *wpa_auth, const u8 *addr,
202 logger_level level, const char *txt);
203 void wpa_auth_vlogger(struct wpa_authenticator *wpa_auth, const u8 *addr,
204 logger_level level, const char *fmt, ...);
205 void __wpa_send_eapol(struct wpa_authenticator *wpa_auth,
206 struct wpa_state_machine *sm, int key_info,
207 const u8 *key_rsc, const u8 *nonce,
208 const u8 *kde, size_t kde_len,
209 int keyidx, int encr, int force_version);
210 int wpa_auth_for_each_sta(struct wpa_authenticator *wpa_auth,
211 int (*cb)(struct wpa_state_machine *sm, void *ctx),
213 int wpa_auth_for_each_auth(struct wpa_authenticator *wpa_auth,
214 int (*cb)(struct wpa_authenticator *a, void *ctx),
217 #ifdef CONFIG_PEERKEY
218 int wpa_stsl_remove(struct wpa_authenticator *wpa_auth,
219 struct wpa_stsl_negotiation *neg);
220 void wpa_smk_error(struct wpa_authenticator *wpa_auth,
221 struct wpa_state_machine *sm, struct wpa_eapol_key *key);
222 void wpa_smk_m1(struct wpa_authenticator *wpa_auth,
223 struct wpa_state_machine *sm, struct wpa_eapol_key *key);
224 void wpa_smk_m3(struct wpa_authenticator *wpa_auth,
225 struct wpa_state_machine *sm, struct wpa_eapol_key *key);
226 #endif /* CONFIG_PEERKEY */
228 #ifdef CONFIG_IEEE80211R
229 int wpa_write_mdie(struct wpa_auth_config *conf, u8 *buf, size_t len);
230 int wpa_write_ftie(struct wpa_auth_config *conf, const u8 *r0kh_id,
232 const u8 *anonce, const u8 *snonce,
233 u8 *buf, size_t len, const u8 *subelem,
235 int wpa_auth_derive_ptk_ft(struct wpa_state_machine *sm, const u8 *pmk,
236 struct wpa_ptk *ptk, size_t ptk_len);
237 struct wpa_ft_pmk_cache * wpa_ft_pmk_cache_init(void);
238 void wpa_ft_pmk_cache_deinit(struct wpa_ft_pmk_cache *cache);
239 void wpa_ft_install_ptk(struct wpa_state_machine *sm);
240 #endif /* CONFIG_IEEE80211R */
242 #endif /* WPA_AUTH_I_H */