]> git.ipfire.org Git - thirdparty/hostap.git/blame - src/ap/wpa_auth_i.h
FT: Convert r0_key_lifetime to seconds
[thirdparty/hostap.git] / src / ap / wpa_auth_i.h
CommitLineData
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
eefe8630
MB
12#include "utils/list.h"
13
22a299ee 14/* max(dot11RSNAConfigGroupUpdateCount,dot11RSNAConfigPairwiseUpdateCount) */
bae61562 15#define RSNA_MAX_EAPOL_RETRIES 4
22a299ee 16
6fc6879b
JM
17struct wpa_group;
18
6fc6879b
JM
19struct wpa_state_machine {
20 struct wpa_authenticator *wpa_auth;
21 struct wpa_group *group;
22
23 u8 addr[ETH_ALEN];
94ddef3e 24 u8 p2p_dev_addr[ETH_ALEN];
6fc6879b
JM
25
26 enum {
27 WPA_PTK_INITIALIZE, WPA_PTK_DISCONNECT, WPA_PTK_DISCONNECTED,
28 WPA_PTK_AUTHENTICATION, WPA_PTK_AUTHENTICATION2,
29 WPA_PTK_INITPMK, WPA_PTK_INITPSK, WPA_PTK_PTKSTART,
30 WPA_PTK_PTKCALCNEGOTIATING, WPA_PTK_PTKCALCNEGOTIATING2,
31 WPA_PTK_PTKINITNEGOTIATING, WPA_PTK_PTKINITDONE
32 } wpa_ptk_state;
33
34 enum {
35 WPA_PTK_GROUP_IDLE = 0,
36 WPA_PTK_GROUP_REKEYNEGOTIATING,
37 WPA_PTK_GROUP_REKEYESTABLISHED,
38 WPA_PTK_GROUP_KEYERROR
39 } wpa_ptk_group_state;
40
41 Boolean Init;
42 Boolean DeauthenticationRequest;
43 Boolean AuthenticationRequest;
44 Boolean ReAuthenticationRequest;
45 Boolean Disconnect;
567da5bb 46 u16 disconnect_reason; /* specific reason code to use with Disconnect */
41f140d3
GK
47 u32 TimeoutCtr;
48 u32 GTimeoutCtr;
6fc6879b
JM
49 Boolean TimeoutEvt;
50 Boolean EAPOLKeyReceived;
51 Boolean EAPOLKeyPairwise;
52 Boolean EAPOLKeyRequest;
53 Boolean MICVerified;
54 Boolean GUpdateStationKeys;
55 u8 ANonce[WPA_NONCE_LEN];
56 u8 SNonce[WPA_NONCE_LEN];
f23c5b17
JM
57 u8 alt_SNonce[WPA_NONCE_LEN];
58 u8 alt_replay_counter[WPA_REPLAY_COUNTER_LEN];
207976f0
JM
59 u8 PMK[PMK_LEN_MAX];
60 unsigned int pmk_len;
9d94e4bb 61 u8 pmkid[PMKID_LEN]; /* valid if pmkid_set == 1 */
6fc6879b
JM
62 struct wpa_ptk PTK;
63 Boolean PTK_valid;
64 Boolean pairwise_set;
0e3bd7ac 65 Boolean tk_already_set;
6fc6879b
JM
66 int keycount;
67 Boolean Pair;
68921e24 68 struct wpa_key_replay_counter {
22a299ee
JM
69 u8 counter[WPA_REPLAY_COUNTER_LEN];
70 Boolean valid;
68921e24
JM
71 } key_replay[RSNA_MAX_EAPOL_RETRIES],
72 prev_key_replay[RSNA_MAX_EAPOL_RETRIES];
6fc6879b
JM
73 Boolean PInitAKeys; /* WPA only, not in IEEE 802.11i */
74 Boolean PTKRequest; /* not in IEEE 802.11i state machine */
75 Boolean has_GTK;
9663596f 76 Boolean PtkGroupInit; /* init request for PTK Group state machine */
6fc6879b
JM
77
78 u8 *last_rx_eapol_key; /* starting from IEEE 802.1X header */
79 size_t last_rx_eapol_key_len;
80
81 unsigned int changed:1;
82 unsigned int in_step_loop:1;
83 unsigned int pending_deinit:1;
84 unsigned int started:1;
85 unsigned int mgmt_frame_prot:1;
0d442aff 86 unsigned int rx_eapol_key_secure:1;
68921e24 87 unsigned int update_snonce:1;
f23c5b17 88 unsigned int alt_snonce_valid:1;
4ec1fd8e 89#ifdef CONFIG_IEEE80211R_AP
6fc6879b
JM
90 unsigned int ft_completed:1;
91 unsigned int pmk_r1_name_valid:1;
4ec1fd8e 92#endif /* CONFIG_IEEE80211R_AP */
d32d94db 93 unsigned int is_wnmsleep:1;
9d94e4bb 94 unsigned int pmkid_set:1;
6fc6879b
JM
95
96 u8 req_replay_counter[WPA_REPLAY_COUNTER_LEN];
97 int req_replay_counter_used;
98
99 u8 *wpa_ie;
100 size_t wpa_ie_len;
101
102 enum {
103 WPA_VERSION_NO_WPA = 0 /* WPA not used */,
104 WPA_VERSION_WPA = 1 /* WPA / IEEE 802.11i/D3.0 */,
105 WPA_VERSION_WPA2 = 2 /* WPA2 / IEEE 802.11i */
106 } wpa;
107 int pairwise; /* Pairwise cipher suite, WPA_CIPHER_* */
108 int wpa_key_mgmt; /* the selected WPA_KEY_MGMT_* */
109 struct rsn_pmksa_cache_entry *pmksa;
110
111 u32 dot11RSNAStatsTKIPLocalMICFailures;
112 u32 dot11RSNAStatsTKIPRemoteMICFailures;
113
4ec1fd8e 114#ifdef CONFIG_IEEE80211R_AP
6fc6879b
JM
115 u8 xxkey[PMK_LEN]; /* PSK or the second 256 bits of MSK */
116 size_t xxkey_len;
117 u8 pmk_r1_name[WPA_PMK_NAME_LEN]; /* PMKR1Name derived from FT Auth
118 * Request */
119 u8 r0kh_id[FT_R0KH_ID_MAX_LEN]; /* R0KH-ID from FT Auth Request */
120 size_t r0kh_id_len;
26e23750
JM
121 u8 sup_pmk_r1_name[WPA_PMK_NAME_LEN]; /* PMKR1Name from EAPOL-Key
122 * message 2/4 */
0f857f43 123 u8 *assoc_resp_ftie;
692ec305
JM
124
125 void (*ft_pending_cb)(void *ctx, const u8 *dst, const u8 *bssid,
126 u16 auth_transaction, u16 status,
127 const u8 *ies, size_t ies_len);
128 void *ft_pending_cb_ctx;
129 struct wpabuf *ft_pending_req_ies;
245fc96e 130 u8 ft_pending_pull_nonce[FT_RRB_NONCE_LEN];
692ec305
JM
131 u8 ft_pending_auth_transaction;
132 u8 ft_pending_current_ap[ETH_ALEN];
3a46cf93 133 int ft_pending_pull_left_retries;
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 */
3d695328
JM
148
149#ifdef CONFIG_TESTING_OPTIONS
150 void (*eapol_status_cb)(void *ctx1, void *ctx2);
151 void *eapol_status_cb_ctx1;
152 void *eapol_status_cb_ctx2;
153#endif /* CONFIG_TESTING_OPTIONS */
6fc6879b
JM
154};
155
156
157/* per group key state machine data */
158struct wpa_group {
159 struct wpa_group *next;
160 int vlan_id;
161
162 Boolean GInit;
163 int GKeyDoneStations;
164 Boolean GTKReKey;
165 int GTK_len;
166 int GN, GM;
167 Boolean GTKAuthenticator;
168 u8 Counter[WPA_NONCE_LEN];
169
170 enum {
171 WPA_GROUP_GTK_INIT = 0,
7d7f7be2
JM
172 WPA_GROUP_SETKEYS, WPA_GROUP_SETKEYSDONE,
173 WPA_GROUP_FATAL_FAILURE
6fc6879b
JM
174 } wpa_group_state;
175
176 u8 GMK[WPA_GMK_LEN];
177 u8 GTK[2][WPA_GTK_MAX_LEN];
178 u8 GNonce[WPA_NONCE_LEN];
179 Boolean changed;
1bdb7ab3 180 Boolean first_sta_seen;
08704cd8 181 Boolean reject_4way_hs_for_entropy;
6fc6879b 182#ifdef CONFIG_IEEE80211W
8dd9f9cd 183 u8 IGTK[2][WPA_IGTK_MAX_LEN];
6fc6879b
JM
184 int GN_igtk, GM_igtk;
185#endif /* CONFIG_IEEE80211W */
a0ad9e8c
MB
186 /* Number of references except those in struct wpa_group->next */
187 unsigned int references;
7cebc8e2 188 unsigned int num_setup_iface;
6fc6879b
JM
189};
190
191
192struct wpa_ft_pmk_cache;
193
194/* per authenticator data */
195struct wpa_authenticator {
196 struct wpa_group *group;
197
198 unsigned int dot11RSNAStatsTKIPRemoteMICFailures;
199 u32 dot11RSNAAuthenticationSuiteSelected;
200 u32 dot11RSNAPairwiseCipherSelected;
201 u32 dot11RSNAGroupCipherSelected;
202 u8 dot11RSNAPMKIDUsed[PMKID_LEN];
203 u32 dot11RSNAAuthenticationSuiteRequested; /* FIX: update */
204 u32 dot11RSNAPairwiseCipherRequested; /* FIX: update */
205 u32 dot11RSNAGroupCipherRequested; /* FIX: update */
206 unsigned int dot11RSNATKIPCounterMeasuresInvoked;
207 unsigned int dot11RSNA4WayHandshakeFailures;
208
6fc6879b 209 struct wpa_auth_config conf;
cef8fac0
JB
210 const struct wpa_auth_callbacks *cb;
211 void *cb_ctx;
6fc6879b
JM
212
213 u8 *wpa_ie;
214 size_t wpa_ie_len;
215
216 u8 addr[ETH_ALEN];
217
218 struct rsn_pmksa_cache *pmksa;
219 struct wpa_ft_pmk_cache *ft_pmk_cache;
25ef8529
JM
220
221#ifdef CONFIG_P2P
222 struct bitfield *ip_pool;
223#endif /* CONFIG_P2P */
6fc6879b
JM
224};
225
226
eefe8630
MB
227#ifdef CONFIG_IEEE80211R_AP
228
229#define FT_REMOTE_SEQ_BACKLOG 16
230struct ft_remote_seq_rx {
231 u32 dom;
232 struct os_reltime time_offset; /* local time - offset = remote time */
233
234 /* accepted sequence numbers: (offset ... offset + 0x40000000]
235 * (except those in last)
236 * dropped sequence numbers: (offset - 0x40000000 ... offset]
237 * all others trigger SEQ_REQ message (except first message)
238 */
239 u32 last[FT_REMOTE_SEQ_BACKLOG];
240 unsigned int num_last;
241 u32 offsetidx;
242
243 struct dl_list queue; /* send nonces + rrb msgs awaiting seq resp */
244};
245
246struct ft_remote_seq_tx {
247 u32 dom; /* non zero if initialized */
248 u32 seq;
249};
250
251struct ft_remote_seq {
252 struct ft_remote_seq_rx rx;
253 struct ft_remote_seq_tx tx;
254};
255
256#endif /* CONFIG_IEEE80211R_AP */
257
258
6fc6879b
JM
259int wpa_write_rsn_ie(struct wpa_auth_config *conf, u8 *buf, size_t len,
260 const u8 *pmkid);
261void wpa_auth_logger(struct wpa_authenticator *wpa_auth, const u8 *addr,
262 logger_level level, const char *txt);
263void wpa_auth_vlogger(struct wpa_authenticator *wpa_auth, const u8 *addr,
264 logger_level level, const char *fmt, ...);
265void __wpa_send_eapol(struct wpa_authenticator *wpa_auth,
266 struct wpa_state_machine *sm, int key_info,
267 const u8 *key_rsc, const u8 *nonce,
268 const u8 *kde, size_t kde_len,
269 int keyidx, int encr, int force_version);
270int wpa_auth_for_each_sta(struct wpa_authenticator *wpa_auth,
271 int (*cb)(struct wpa_state_machine *sm, void *ctx),
272 void *cb_ctx);
bf98f7f3
JM
273int wpa_auth_for_each_auth(struct wpa_authenticator *wpa_auth,
274 int (*cb)(struct wpa_authenticator *a, void *ctx),
275 void *cb_ctx);
6fc6879b 276
4ec1fd8e 277#ifdef CONFIG_IEEE80211R_AP
6fc6879b 278int wpa_write_mdie(struct wpa_auth_config *conf, u8 *buf, size_t len);
86dfabb8
JM
279int wpa_write_ftie(struct wpa_auth_config *conf, const u8 *r0kh_id,
280 size_t r0kh_id_len,
281 const u8 *anonce, const u8 *snonce,
282 u8 *buf, size_t len, const u8 *subelem,
283 size_t subelem_len);
6fc6879b 284int wpa_auth_derive_ptk_ft(struct wpa_state_machine *sm, const u8 *pmk,
98cd3d1c 285 struct wpa_ptk *ptk);
6fc6879b
JM
286struct wpa_ft_pmk_cache * wpa_ft_pmk_cache_init(void);
287void wpa_ft_pmk_cache_deinit(struct wpa_ft_pmk_cache *cache);
0e84c254 288void wpa_ft_install_ptk(struct wpa_state_machine *sm);
8fed47e0
JM
289int wpa_ft_store_pmk_r0(struct wpa_authenticator *wpa_auth,
290 const u8 *spa, const u8 *pmk_r0,
291 const u8 *pmk_r0_name, int pairwise);
4ec1fd8e 292#endif /* CONFIG_IEEE80211R_AP */
6fc6879b
JM
293
294#endif /* WPA_AUTH_I_H */