]>
Commit | Line | Data |
---|---|---|
6fc6879b JM |
1 | /* |
2 | * hostapd - IEEE 802.11i-2004 / WPA Authenticator: Internal definitions | |
98cd3d1c | 3 | * Copyright (c) 2004-2015, Jouni Malinen <j@w1.fi> |
6fc6879b | 4 | * |
0f3d578e JM |
5 | * This software may be distributed under the terms of the BSD license. |
6 | * See README for more details. | |
6fc6879b JM |
7 | */ |
8 | ||
9 | #ifndef WPA_AUTH_I_H | |
10 | #define WPA_AUTH_I_H | |
11 | ||
22a299ee | 12 | /* max(dot11RSNAConfigGroupUpdateCount,dot11RSNAConfigPairwiseUpdateCount) */ |
bae61562 | 13 | #define RSNA_MAX_EAPOL_RETRIES 4 |
22a299ee | 14 | |
6fc6879b JM |
15 | struct wpa_group; |
16 | ||
17 | struct wpa_stsl_negotiation { | |
18 | struct wpa_stsl_negotiation *next; | |
19 | u8 initiator[ETH_ALEN]; | |
20 | u8 peer[ETH_ALEN]; | |
21 | }; | |
22 | ||
23 | ||
24 | struct wpa_state_machine { | |
25 | struct wpa_authenticator *wpa_auth; | |
26 | struct wpa_group *group; | |
27 | ||
28 | u8 addr[ETH_ALEN]; | |
94ddef3e | 29 | u8 p2p_dev_addr[ETH_ALEN]; |
6fc6879b JM |
30 | |
31 | enum { | |
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 | |
37 | } wpa_ptk_state; | |
38 | ||
39 | enum { | |
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; | |
45 | ||
46 | Boolean Init; | |
47 | Boolean DeauthenticationRequest; | |
48 | Boolean AuthenticationRequest; | |
49 | Boolean ReAuthenticationRequest; | |
50 | Boolean Disconnect; | |
51 | int TimeoutCtr; | |
52 | int GTimeoutCtr; | |
53 | Boolean TimeoutEvt; | |
54 | Boolean EAPOLKeyReceived; | |
55 | Boolean EAPOLKeyPairwise; | |
56 | Boolean EAPOLKeyRequest; | |
57 | Boolean MICVerified; | |
58 | Boolean GUpdateStationKeys; | |
59 | u8 ANonce[WPA_NONCE_LEN]; | |
60 | u8 SNonce[WPA_NONCE_LEN]; | |
f23c5b17 JM |
61 | u8 alt_SNonce[WPA_NONCE_LEN]; |
62 | u8 alt_replay_counter[WPA_REPLAY_COUNTER_LEN]; | |
207976f0 JM |
63 | u8 PMK[PMK_LEN_MAX]; |
64 | unsigned int pmk_len; | |
6fc6879b JM |
65 | struct wpa_ptk PTK; |
66 | Boolean PTK_valid; | |
67 | Boolean pairwise_set; | |
68 | int keycount; | |
69 | Boolean Pair; | |
68921e24 | 70 | struct wpa_key_replay_counter { |
22a299ee JM |
71 | u8 counter[WPA_REPLAY_COUNTER_LEN]; |
72 | Boolean valid; | |
68921e24 JM |
73 | } key_replay[RSNA_MAX_EAPOL_RETRIES], |
74 | prev_key_replay[RSNA_MAX_EAPOL_RETRIES]; | |
6fc6879b JM |
75 | Boolean PInitAKeys; /* WPA only, not in IEEE 802.11i */ |
76 | Boolean PTKRequest; /* not in IEEE 802.11i state machine */ | |
77 | Boolean has_GTK; | |
9663596f | 78 | Boolean PtkGroupInit; /* init request for PTK Group state machine */ |
6fc6879b JM |
79 | |
80 | u8 *last_rx_eapol_key; /* starting from IEEE 802.1X header */ | |
81 | size_t last_rx_eapol_key_len; | |
82 | ||
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; | |
0d442aff | 88 | unsigned int rx_eapol_key_secure:1; |
68921e24 | 89 | unsigned int update_snonce:1; |
f23c5b17 | 90 | unsigned int alt_snonce_valid:1; |
4ec1fd8e | 91 | #ifdef CONFIG_IEEE80211R_AP |
6fc6879b JM |
92 | unsigned int ft_completed:1; |
93 | unsigned int pmk_r1_name_valid:1; | |
4ec1fd8e | 94 | #endif /* CONFIG_IEEE80211R_AP */ |
d32d94db | 95 | unsigned int is_wnmsleep:1; |
6fc6879b JM |
96 | |
97 | u8 req_replay_counter[WPA_REPLAY_COUNTER_LEN]; | |
98 | int req_replay_counter_used; | |
99 | ||
100 | u8 *wpa_ie; | |
101 | size_t wpa_ie_len; | |
102 | ||
103 | enum { | |
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 */ | |
107 | } wpa; | |
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; | |
111 | ||
112 | u32 dot11RSNAStatsTKIPLocalMICFailures; | |
113 | u32 dot11RSNAStatsTKIPRemoteMICFailures; | |
114 | ||
4ec1fd8e | 115 | #ifdef CONFIG_IEEE80211R_AP |
6fc6879b JM |
116 | u8 xxkey[PMK_LEN]; /* PSK or the second 256 bits of MSK */ |
117 | size_t xxkey_len; | |
118 | u8 pmk_r1_name[WPA_PMK_NAME_LEN]; /* PMKR1Name derived from FT Auth | |
119 | * Request */ | |
120 | u8 r0kh_id[FT_R0KH_ID_MAX_LEN]; /* R0KH-ID from FT Auth Request */ | |
121 | size_t r0kh_id_len; | |
26e23750 JM |
122 | u8 sup_pmk_r1_name[WPA_PMK_NAME_LEN]; /* PMKR1Name from EAPOL-Key |
123 | * message 2/4 */ | |
0f857f43 | 124 | u8 *assoc_resp_ftie; |
692ec305 JM |
125 | |
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]; | |
4ec1fd8e | 134 | #endif /* CONFIG_IEEE80211R_AP */ |
e4bf4db9 JM |
135 | |
136 | int pending_1_of_4_timeout; | |
25ef8529 JM |
137 | |
138 | #ifdef CONFIG_P2P | |
139 | u8 ip_addr[4]; | |
140 | #endif /* CONFIG_P2P */ | |
c4fd6d8a JM |
141 | |
142 | #ifdef CONFIG_FILS | |
143 | u8 fils_key_auth_sta[FILS_MAX_KEY_AUTH_LEN]; | |
144 | u8 fils_key_auth_ap[FILS_MAX_KEY_AUTH_LEN]; | |
145 | size_t fils_key_auth_len; | |
07e0117d | 146 | unsigned int fils_completed:1; |
c4fd6d8a | 147 | #endif /* CONFIG_FILS */ |
6fc6879b JM |
148 | }; |
149 | ||
150 | ||
151 | /* per group key state machine data */ | |
152 | struct wpa_group { | |
153 | struct wpa_group *next; | |
154 | int vlan_id; | |
155 | ||
156 | Boolean GInit; | |
157 | int GKeyDoneStations; | |
158 | Boolean GTKReKey; | |
159 | int GTK_len; | |
160 | int GN, GM; | |
161 | Boolean GTKAuthenticator; | |
162 | u8 Counter[WPA_NONCE_LEN]; | |
163 | ||
164 | enum { | |
165 | WPA_GROUP_GTK_INIT = 0, | |
7d7f7be2 JM |
166 | WPA_GROUP_SETKEYS, WPA_GROUP_SETKEYSDONE, |
167 | WPA_GROUP_FATAL_FAILURE | |
6fc6879b JM |
168 | } wpa_group_state; |
169 | ||
170 | u8 GMK[WPA_GMK_LEN]; | |
171 | u8 GTK[2][WPA_GTK_MAX_LEN]; | |
172 | u8 GNonce[WPA_NONCE_LEN]; | |
173 | Boolean changed; | |
1bdb7ab3 | 174 | Boolean first_sta_seen; |
08704cd8 | 175 | Boolean reject_4way_hs_for_entropy; |
6fc6879b | 176 | #ifdef CONFIG_IEEE80211W |
8dd9f9cd | 177 | u8 IGTK[2][WPA_IGTK_MAX_LEN]; |
6fc6879b JM |
178 | int GN_igtk, GM_igtk; |
179 | #endif /* CONFIG_IEEE80211W */ | |
a0ad9e8c MB |
180 | /* Number of references except those in struct wpa_group->next */ |
181 | unsigned int references; | |
7cebc8e2 | 182 | unsigned int num_setup_iface; |
6fc6879b JM |
183 | }; |
184 | ||
185 | ||
186 | struct wpa_ft_pmk_cache; | |
187 | ||
188 | /* per authenticator data */ | |
189 | struct wpa_authenticator { | |
190 | struct wpa_group *group; | |
191 | ||
192 | unsigned int dot11RSNAStatsTKIPRemoteMICFailures; | |
193 | u32 dot11RSNAAuthenticationSuiteSelected; | |
194 | u32 dot11RSNAPairwiseCipherSelected; | |
195 | u32 dot11RSNAGroupCipherSelected; | |
196 | u8 dot11RSNAPMKIDUsed[PMKID_LEN]; | |
197 | u32 dot11RSNAAuthenticationSuiteRequested; /* FIX: update */ | |
198 | u32 dot11RSNAPairwiseCipherRequested; /* FIX: update */ | |
199 | u32 dot11RSNAGroupCipherRequested; /* FIX: update */ | |
200 | unsigned int dot11RSNATKIPCounterMeasuresInvoked; | |
201 | unsigned int dot11RSNA4WayHandshakeFailures; | |
202 | ||
203 | struct wpa_stsl_negotiation *stsl_negotiations; | |
204 | ||
205 | struct wpa_auth_config conf; | |
206 | struct wpa_auth_callbacks cb; | |
207 | ||
208 | u8 *wpa_ie; | |
209 | size_t wpa_ie_len; | |
210 | ||
211 | u8 addr[ETH_ALEN]; | |
212 | ||
213 | struct rsn_pmksa_cache *pmksa; | |
214 | struct wpa_ft_pmk_cache *ft_pmk_cache; | |
25ef8529 JM |
215 | |
216 | #ifdef CONFIG_P2P | |
217 | struct bitfield *ip_pool; | |
218 | #endif /* CONFIG_P2P */ | |
6fc6879b JM |
219 | }; |
220 | ||
221 | ||
222 | int wpa_write_rsn_ie(struct wpa_auth_config *conf, u8 *buf, size_t len, | |
223 | const u8 *pmkid); | |
224 | void wpa_auth_logger(struct wpa_authenticator *wpa_auth, const u8 *addr, | |
225 | logger_level level, const char *txt); | |
226 | void wpa_auth_vlogger(struct wpa_authenticator *wpa_auth, const u8 *addr, | |
227 | logger_level level, const char *fmt, ...); | |
228 | void __wpa_send_eapol(struct wpa_authenticator *wpa_auth, | |
229 | struct wpa_state_machine *sm, int key_info, | |
230 | const u8 *key_rsc, const u8 *nonce, | |
231 | const u8 *kde, size_t kde_len, | |
232 | int keyidx, int encr, int force_version); | |
233 | int wpa_auth_for_each_sta(struct wpa_authenticator *wpa_auth, | |
234 | int (*cb)(struct wpa_state_machine *sm, void *ctx), | |
235 | void *cb_ctx); | |
bf98f7f3 JM |
236 | int wpa_auth_for_each_auth(struct wpa_authenticator *wpa_auth, |
237 | int (*cb)(struct wpa_authenticator *a, void *ctx), | |
238 | void *cb_ctx); | |
6fc6879b JM |
239 | |
240 | #ifdef CONFIG_PEERKEY | |
241 | int wpa_stsl_remove(struct wpa_authenticator *wpa_auth, | |
242 | struct wpa_stsl_negotiation *neg); | |
243 | void wpa_smk_error(struct wpa_authenticator *wpa_auth, | |
5c6787a6 JM |
244 | struct wpa_state_machine *sm, |
245 | const u8 *key_data, size_t key_data_len); | |
6fc6879b | 246 | void wpa_smk_m1(struct wpa_authenticator *wpa_auth, |
5c6787a6 JM |
247 | struct wpa_state_machine *sm, struct wpa_eapol_key *key, |
248 | const u8 *key_data, size_t key_data_len); | |
6fc6879b | 249 | void wpa_smk_m3(struct wpa_authenticator *wpa_auth, |
5c6787a6 JM |
250 | struct wpa_state_machine *sm, struct wpa_eapol_key *key, |
251 | const u8 *key_data, size_t key_data_len); | |
6fc6879b JM |
252 | #endif /* CONFIG_PEERKEY */ |
253 | ||
4ec1fd8e | 254 | #ifdef CONFIG_IEEE80211R_AP |
6fc6879b | 255 | int wpa_write_mdie(struct wpa_auth_config *conf, u8 *buf, size_t len); |
86dfabb8 JM |
256 | int wpa_write_ftie(struct wpa_auth_config *conf, const u8 *r0kh_id, |
257 | size_t r0kh_id_len, | |
258 | const u8 *anonce, const u8 *snonce, | |
259 | u8 *buf, size_t len, const u8 *subelem, | |
260 | size_t subelem_len); | |
6fc6879b | 261 | int wpa_auth_derive_ptk_ft(struct wpa_state_machine *sm, const u8 *pmk, |
98cd3d1c | 262 | struct wpa_ptk *ptk); |
6fc6879b JM |
263 | struct wpa_ft_pmk_cache * wpa_ft_pmk_cache_init(void); |
264 | void wpa_ft_pmk_cache_deinit(struct wpa_ft_pmk_cache *cache); | |
0e84c254 | 265 | void wpa_ft_install_ptk(struct wpa_state_machine *sm); |
4ec1fd8e | 266 | #endif /* CONFIG_IEEE80211R_AP */ |
6fc6879b JM |
267 | |
268 | #endif /* WPA_AUTH_I_H */ |