1 /*
2 * hostapd - IEEE 802.11i-2004 / WPA Authenticator
3 * Copyright (c) 2004-2022, Jouni Malinen <j@w1.fi>
4 *
5 * This software may be distributed under the terms of the BSD license.
6 * See README for more details.
7 */
8
9 #ifndef WPA_AUTH_H
10 #define WPA_AUTH_H
11
12 #include "common/defs.h"
13 #include "common/eapol_common.h"
14 #include "common/wpa_common.h"
15 #include "common/ieee802_11_defs.h"
16
17 struct vlan_description;
18 struct mld_info;
19
20 #define MAX_OWN_IE_OVERRIDE 257
21
22 #ifdef _MSC_VER
23 #pragma pack(push, 1)
24 #endif /* _MSC_VER */
25
26 /* IEEE Std 802.11r-2008, 11A.10.3 - Remote request/response frame definition
27 */
28 struct ft_rrb_frame {
29 u8 frame_type; /* RSN_REMOTE_FRAME_TYPE_FT_RRB */
30 u8 packet_type; /* FT_PACKET_REQUEST/FT_PACKET_RESPONSE */
31 le16 action_length; /* little endian length of action_frame */
32 u8 ap_address[ETH_ALEN];
33 /*
34 * Followed by action_length bytes of FT Action frame (from Category
35 * field to the end of Action Frame body.
36 */
37 } STRUCT_PACKED;
38
39 #define RSN_REMOTE_FRAME_TYPE_FT_RRB 1
40
41 #define FT_PACKET_REQUEST 0
42 #define FT_PACKET_RESPONSE 1
43
44 /* Vendor-specific types for R0KH-R1KH protocol; not defined in 802.11r. These
45 * use OUI Extended EtherType as the encapsulating format. */
46 #define FT_PACKET_R0KH_R1KH_PULL 0x01
47 #define FT_PACKET_R0KH_R1KH_RESP 0x02
48 #define FT_PACKET_R0KH_R1KH_PUSH 0x03
49 #define FT_PACKET_R0KH_R1KH_SEQ_REQ 0x04
50 #define FT_PACKET_R0KH_R1KH_SEQ_RESP 0x05
51
52 /* packet layout
53 * IEEE 802 extended OUI ethertype frame header
54 * u16 authlen (little endian)
55 * multiple of struct ft_rrb_tlv (authenticated only, length = authlen)
56 * multiple of struct ft_rrb_tlv (AES-SIV encrypted, AES-SIV needs an extra
57 * blocksize length)
58 *
59 * AES-SIV AAD;
60 * source MAC address (6)
61 * authenticated-only TLVs (authlen)
62 * subtype (1; FT_PACKET_*)
63 */
64
65 #define FT_RRB_NONCE_LEN 16
66
67 #define FT_RRB_LAST_EMPTY 0 /* placeholder or padding */
68
69 #define FT_RRB_SEQ 1 /* struct ft_rrb_seq */
70 #define FT_RRB_NONCE 2 /* size FT_RRB_NONCE_LEN */
71 #define FT_RRB_TIMESTAMP 3 /* le32 unix seconds */
72
73 #define FT_RRB_R0KH_ID 4 /* FT_R0KH_ID_MAX_LEN */
74 #define FT_RRB_R1KH_ID 5 /* FT_R1KH_ID_LEN */
75 #define FT_RRB_S1KH_ID 6 /* ETH_ALEN */
76
77 #define FT_RRB_PMK_R0_NAME 7 /* WPA_PMK_NAME_LEN */
78 #define FT_RRB_PMK_R0 8 /* PMK_LEN */
79 #define FT_RRB_PMK_R1_NAME 9 /* WPA_PMK_NAME_LEN */
80 #define FT_RRB_PMK_R1 10 /* PMK_LEN */
81
82 #define FT_RRB_PAIRWISE 11 /* le16 */
83 #define FT_RRB_EXPIRES_IN 12 /* le16 seconds */
84
85 #define FT_RRB_VLAN_UNTAGGED 13 /* le16 */
86 #define FT_RRB_VLAN_TAGGED 14 /* n times le16 */
87
88 #define FT_RRB_IDENTITY 15
89 #define FT_RRB_RADIUS_CUI 16
90 #define FT_RRB_SESSION_TIMEOUT 17 /* le32 seconds */
91
92 struct ft_rrb_tlv {
93 le16 type;
94 le16 len;
95 /* followed by data of length len */
96 } STRUCT_PACKED;
97
98 struct ft_rrb_seq {
99 le32 dom;
100 le32 seq;
101 le32 ts;
102 } STRUCT_PACKED;
103
104 /* session TLVs:
105 * required: PMK_R1, PMK_R1_NAME, PAIRWISE
106 * optional: VLAN_UNTAGGED, VLAN_TAGGED, EXPIRES_IN, IDENTITY, RADIUS_CUI,
107 * SESSION_TIMEOUT
108 *
109 * pull frame TLVs:
110 * auth:
111 * required: SEQ, NONCE, R0KH_ID, R1KH_ID
112 * encrypted:
113 * required: PMK_R0_NAME, S1KH_ID
114 *
115 * response frame TLVs:
116 * auth:
117 * required: SEQ, NONCE, R0KH_ID, R1KH_ID
118 * encrypted:
119 * required: S1KH_ID
120 * optional: session TLVs
121 *
122 * push frame TLVs:
123 * auth:
124 * required: SEQ, R0KH_ID, R1KH_ID
125 * encrypted:
126 * required: S1KH_ID, PMK_R0_NAME, session TLVs
127 *
128 * sequence number request frame TLVs:
129 * auth:
130 * required: R0KH_ID, R1KH_ID, NONCE
131 *
132 * sequence number response frame TLVs:
133 * auth:
134 * required: SEQ, NONCE, R0KH_ID, R1KH_ID
135 */
136
137 #ifdef _MSC_VER
138 #pragma pack(pop)
139 #endif /* _MSC_VER */
140
141
142 /* per STA state machine data */
143
144 struct wpa_authenticator;
145 struct wpa_state_machine;
146 struct rsn_pmksa_cache_entry;
147 struct eapol_state_machine;
148 struct ft_remote_seq;
149 struct wpa_channel_info;
150
151
152 struct ft_remote_r0kh {
153 struct ft_remote_r0kh *next;
154 u8 addr[ETH_ALEN];
155 u8 id[FT_R0KH_ID_MAX_LEN];
156 size_t id_len;
157 u8 key[32];
158 struct ft_remote_seq *seq;
159 };
160
161
162 struct ft_remote_r1kh {
163 struct ft_remote_r1kh *next;
164 u8 addr[ETH_ALEN];
165 u8 id[FT_R1KH_ID_LEN];
166 u8 key[32];
167 struct ft_remote_seq *seq;
168 };
169
170
171 struct wpa_auth_config {
172 void *msg_ctx;
173 int wpa;
174 int extended_key_id;
175 int wpa_key_mgmt;
176 int rsn_override_key_mgmt;
177 int rsn_override_key_mgmt_2;
178 int wpa_pairwise;
179 int wpa_group;
180 int wpa_group_rekey;
181 int wpa_strict_rekey;
182 int wpa_gmk_rekey;
183 int wpa_ptk_rekey;
184 int wpa_deny_ptk0_rekey;
185 u32 wpa_group_update_count;
186 u32 wpa_pairwise_update_count;
187 int wpa_disable_eapol_key_retries;
188 int rsn_pairwise;
189 int rsn_override_pairwise;
190 int rsn_override_pairwise_2;
191 int rsn_preauth;
192 int eapol_version;
193 int wmm_enabled;
194 int wmm_uapsd;
195 int disable_pmksa_caching;
196 int okc;
197 int tx_status;
198 enum mfp_options ieee80211w;
199 enum mfp_options rsn_override_mfp;
200 enum mfp_options rsn_override_mfp_2;
201 int beacon_prot;
202 int group_mgmt_cipher;
203 int sae_require_mfp;
204 #ifdef CONFIG_OCV
205 int ocv; /* Operating Channel Validation */
206 #endif /* CONFIG_OCV */
207 u8 ssid[SSID_MAX_LEN];
208 size_t ssid_len;
209 #ifdef CONFIG_IEEE80211R_AP
210 u8 mobility_domain[MOBILITY_DOMAIN_ID_LEN];
211 u8 r0_key_holder[FT_R0KH_ID_MAX_LEN];
212 size_t r0_key_holder_len;
213 u8 r1_key_holder[FT_R1KH_ID_LEN];
214 u32 r0_key_lifetime; /* PMK-R0 lifetime seconds */
215 int rkh_pos_timeout;
216 int rkh_neg_timeout;
217 int rkh_pull_timeout; /* ms */
218 int rkh_pull_retries;
219 int r1_max_key_lifetime;
220 u32 reassociation_deadline;
221 struct ft_remote_r0kh **r0kh_list;
222 struct ft_remote_r1kh **r1kh_list;
223 int pmk_r1_push;
224 int ft_over_ds;
225 int ft_psk_generate_local;
226 #endif /* CONFIG_IEEE80211R_AP */
227 int disable_gtk;
228 int ap_mlme;
229 #ifdef CONFIG_TESTING_OPTIONS
230 double corrupt_gtk_rekey_mic_probability;
231 u8 own_ie_override[MAX_OWN_IE_OVERRIDE];
232 size_t own_ie_override_len;
233 bool rsne_override_set;
234 u8 rsne_override[MAX_OWN_IE_OVERRIDE];
235 size_t rsne_override_len;
236 bool rsnoe_override_set;
237 u8 rsnoe_override[MAX_OWN_IE_OVERRIDE];
238 size_t rsnoe_override_len;
239 bool rsno2e_override_set;
240 u8 rsno2e_override[MAX_OWN_IE_OVERRIDE];
241 size_t rsno2e_override_len;
242 bool rsnxe_override_set;
243 u8 rsnxe_override[MAX_OWN_IE_OVERRIDE];
244 size_t rsnxe_override_len;
245 bool rsnxoe_override_set;
246 u8 rsnxoe_override[MAX_OWN_IE_OVERRIDE];
247 size_t rsnxoe_override_len;
248 u8 rsne_override_eapol[MAX_OWN_IE_OVERRIDE];
249 size_t rsne_override_eapol_len;
250 u8 rsnxe_override_eapol[MAX_OWN_IE_OVERRIDE];
251 size_t rsnxe_override_eapol_len;
252 u8 rsne_override_ft[MAX_OWN_IE_OVERRIDE];
253 size_t rsne_override_ft_len;
254 u8 rsnxe_override_ft[MAX_OWN_IE_OVERRIDE];
255 size_t rsnxe_override_ft_len;
256 u8 gtk_rsc_override[WPA_KEY_RSC_LEN];
257 u8 igtk_rsc_override[WPA_KEY_RSC_LEN];
258 unsigned int rsne_override_eapol_set:1;
259 unsigned int rsnxe_override_eapol_set:1;
260 unsigned int rsne_override_ft_set:1;
261 unsigned int rsnxe_override_ft_set:1;
262 unsigned int gtk_rsc_override_set:1;
263 unsigned int igtk_rsc_override_set:1;
264 int ft_rsnxe_used;
265 bool delay_eapol_tx;
266 struct wpabuf *eapol_m1_elements;
267 struct wpabuf *eapol_m3_elements;
268 bool eapol_m3_no_encrypt;
269 bool eapol_key_reserved_random;
270 #endif /* CONFIG_TESTING_OPTIONS */
271 unsigned int oci_freq_override_eapol_m3;
272 unsigned int oci_freq_override_eapol_g1;
273 unsigned int oci_freq_override_ft_assoc;
274 unsigned int oci_freq_override_fils_assoc;
275 #ifdef CONFIG_P2P
276 u8 ip_addr_go[4];
277 u8 ip_addr_mask[4];
278 u8 ip_addr_start[4];
279 u8 ip_addr_end[4];
280 #endif /* CONFIG_P2P */
281 #ifdef CONFIG_FILS
282 unsigned int fils_cache_id_set:1;
283 u8 fils_cache_id[FILS_CACHE_ID_LEN];
284 #endif /* CONFIG_FILS */
285 enum sae_pwe sae_pwe;
286 bool sae_pk;
287 bool urnm_mfpr_x20;
288 bool urnm_mfpr;
289
290 unsigned int secure_ltf:1;
291 unsigned int secure_rtt:1;
292 unsigned int prot_range_neg:1;
293 #ifdef CONFIG_ENC_ASSOC
294 unsigned int assoc_frame_encryption:1;
295 unsigned int pmksa_caching_privacy:1;
296 unsigned int eap_using_authentication_frames:1;
297 #ifdef CONFIG_PASN
298 /* Whether to allow unauthenticated EPPKE (EPPKE without base AKM) */
299 bool eppke_unauth;
300 #endif /* CONFIG_PASN */
301 #endif /* CONFIG_ENC_ASSOC */
302
303 int owe_ptk_workaround;
304 u8 transition_disable;
305 #ifdef CONFIG_DPP2
306 int dpp_pfs;
307 #endif /* CONFIG_DPP2 */
308
309 /*
310 * If set Key Derivation Key should be derived as part of PMK to
311 * PTK derivation regardless of advertised capabilities.
312 */
313 bool force_kdk_derivation;
314
315 bool radius_psk;
316
317 bool no_disconnect_on_group_keyerror;
318
319 /* Pointer to Multi-BSSID transmitted BSS authenticator instance.
320 * Set only in nontransmitted BSSs, i.e., is NULL for transmitted BSS
321 * and in BSSs that are not part of a Multi-BSSID set. */
322 struct wpa_authenticator *tx_bss_auth;
323
324 #ifdef CONFIG_IEEE80211BE
325 const u8 *mld_addr;
326 int link_id;
327 struct wpa_authenticator *first_link_auth;
328 #endif /* CONFIG_IEEE80211BE */
329
330 bool ssid_protection;
331
332 int rsn_override_omit_rsnxe;
333 int rsn_override_mlo_compat;
334
335 bool spp_amsdu;
336
337 unsigned int sae_pw_id_num;
338 u8 sae_pw_id_key[32];
339 };
340
341 typedef enum {
342 LOGGER_DEBUG, LOGGER_INFO, LOGGER_WARNING
343 } logger_level;
344
345 typedef enum {
346 WPA_EAPOL_portEnabled, WPA_EAPOL_portValid, WPA_EAPOL_authorized,
347 WPA_EAPOL_portControl_Auto, WPA_EAPOL_keyRun, WPA_EAPOL_keyAvailable,
348 WPA_EAPOL_keyDone, WPA_EAPOL_inc_EapolFramesTx
349 } wpa_eapol_variable;
350
351 struct wpa_auth_ml_key_info {
352 unsigned int n_mld_links;
353 bool mgmt_frame_prot;
354 bool beacon_prot;
355
356 struct wpa_auth_ml_link_key_info {
357 u8 link_id;
358
359 u8 gtkidx;
360 u8 gtk_len;
361 u8 pn[6];
362 const u8 *gtk;
363
364 u8 igtkidx;
365 u8 igtk_len;
366 const u8 *igtk;
367 u8 ipn[6];
368
369 u8 bigtkidx;
370 const u8 *bigtk;
371 u8 bipn[6];
372 } links[MAX_NUM_MLD_LINKS];
373 };
374
375 struct wpa_auth_callbacks {
376 void (*logger)(void *ctx, const u8 *addr, logger_level level,
377 const char *txt);
378 void (*disconnect)(void *ctx, const u8 *addr, u16 reason);
379 int (*mic_failure_report)(void *ctx, const u8 *addr);
380 void (*psk_failure_report)(void *ctx, const u8 *addr);
381 void (*set_eapol)(void *ctx, const u8 *addr, wpa_eapol_variable var,
382 int value);
383 int (*get_eapol)(void *ctx, const u8 *addr, wpa_eapol_variable var);
384 const u8 * (*get_psk)(void *ctx, const u8 *addr, const u8 *p2p_dev_addr,
385 const u8 *prev_psk, size_t *psk_len,
386 int *vlan_id);
387 int (*get_msk)(void *ctx, const u8 *addr, u8 *msk, size_t *len);
388 int (*set_key)(void *ctx, int vlan_id, enum wpa_alg alg,
389 const u8 *addr, int idx, u8 *key, size_t key_len,
390 enum key_flag key_flag);
391 int (*get_seqnum)(void *ctx, const u8 *addr, int idx, u8 *seq);
392 int (*send_eapol)(void *ctx, const u8 *addr, const u8 *data,
393 size_t data_len, int encrypt);
394 int (*get_sta_count)(void *ctx);
395 int (*for_each_sta)(void *ctx, int (*cb)(struct wpa_state_machine *sm,
396 void *ctx), void *cb_ctx);
397 int (*for_each_auth)(void *ctx, int (*cb)(struct wpa_authenticator *a,
398 void *ctx), void *cb_ctx);
399 #ifdef CONFIG_IEEE80211BE
400 int (*for_each_partner_auth)(void *ctx,
401 int (*cb)(struct wpa_authenticator *a,
402 void *ctx),
403 void *cb_ctx);
404 #endif /* CONFIG_IEEE80211BE */
405 int (*send_ether)(void *ctx, const u8 *dst, u16 proto, const u8 *data,
406 size_t data_len);
407 int (*send_oui)(void *ctx, const u8 *dst, u8 oui_suffix, const u8 *data,
408 size_t data_len);
409 int (*channel_info)(void *ctx, struct wpa_channel_info *ci);
410 int (*update_vlan)(void *ctx, const u8 *addr, int vlan_id);
411 int (*get_sta_tx_params)(void *ctx, const u8 *addr,
412 int ap_max_chanwidth, int ap_seg1_idx,
413 int *bandwidth, int *seg1_idx);
414 void (*store_ptksa)(void *ctx, const u8 *addr, int cipher,
415 u32 life_time, const struct wpa_ptk *ptk);
416 void (*clear_ptksa)(void *ctx, const u8 *addr, int cipher);
417 void (*request_radius_psk)(void *ctx, const u8 *addr, int key_mgmt,
418 const u8 *anonce,
419 const u8 *eapol, size_t eapol_len);
420 #ifdef CONFIG_IEEE80211R_AP
421 struct wpa_state_machine * (*add_sta)(void *ctx, const u8 *sta_addr);
422 int (*add_sta_ft)(void *ctx, const u8 *sta_addr);
423 int (*set_vlan)(void *ctx, const u8 *sta_addr,
424 struct vlan_description *vlan);
425 int (*get_vlan)(void *ctx, const u8 *sta_addr,
426 struct vlan_description *vlan);
427 int (*set_identity)(void *ctx, const u8 *sta_addr,
428 const u8 *identity, size_t identity_len);
429 size_t (*get_identity)(void *ctx, const u8 *sta_addr, const u8 **buf);
430 int (*set_radius_cui)(void *ctx, const u8 *sta_addr,
431 const u8 *radius_cui, size_t radius_cui_len);
432 size_t (*get_radius_cui)(void *ctx, const u8 *sta_addr, const u8 **buf);
433 void (*set_session_timeout)(void *ctx, const u8 *sta_addr,
434 int session_timeout);
435 int (*get_session_timeout)(void *ctx, const u8 *sta_addr);
436
437 int (*send_ft_action)(void *ctx, const u8 *dst,
438 const u8 *data, size_t data_len);
439 #endif /* CONFIG_IEEE80211R_AP */
440 #ifdef CONFIG_MESH
441 int (*start_ampe)(void *ctx, const u8 *sta_addr);
442 #endif /* CONFIG_MESH */
443 #ifdef CONFIG_PASN
444 int (*set_ltf_keyseed)(void *ctx, const u8 *addr, const u8 *ltf_keyseed,
445 size_t ltf_keyseed_len);
446 #endif /* CONFIG_PASN */
447 #ifdef CONFIG_IEEE80211BE
448 int (*get_ml_key_info)(void *ctx, struct wpa_auth_ml_key_info *info,
449 bool rekey, int vlan_id);
450 struct wpa_authenticator * (*next_primary_auth)(void *ctx);
451 #endif /* CONFIG_IEEE80211BE */
452 int (*get_drv_flags)(void *ctx, u64 *drv_flags, u64 *drv_flags2);
453 int (*remove_pmkid)(void *ctx, const u8 *sta_addr, const u8 *pmkid);
454 bool (*first_sta_seen_mbssid)(void *ctx, int vlan_id);
455 };
456
457 struct wpa_authenticator * wpa_init(const u8 *addr,
458 struct wpa_auth_config *conf,
459 const struct wpa_auth_callbacks *cb,
460 void *cb_ctx);
461 int wpa_init_keys(struct wpa_authenticator *wpa_auth);
462 void wpa_deinit(struct wpa_authenticator *wpa_auth);
463 int wpa_reconfig(struct wpa_authenticator *wpa_auth,
464 struct wpa_auth_config *conf);
465
466 enum wpa_validate_result {
467 WPA_IE_OK, WPA_INVALID_IE, WPA_INVALID_GROUP, WPA_INVALID_PAIRWISE,
468 WPA_INVALID_AKMP, WPA_NOT_ENABLED, WPA_ALLOC_FAIL,
469 WPA_MGMT_FRAME_PROTECTION_VIOLATION, WPA_INVALID_MGMT_GROUP_CIPHER,
470 WPA_INVALID_MDIE, WPA_INVALID_PROTO, WPA_INVALID_PMKID,
471 WPA_DENIED_OTHER_REASON
472 };
473
474 enum wpa_validate_result
475 wpa_validate_wpa_ie(struct wpa_authenticator *wpa_auth,
476 struct wpa_state_machine *sm, int freq,
477 const u8 *wpa_ie, size_t wpa_ie_len,
478 const u8 *rsnxe, size_t rsnxe_len,
479 const u8 *mdie, size_t mdie_len,
480 const u8 *owe_dh, size_t owe_dh_len,
481 struct wpa_state_machine *assoc_sm,
482 bool is_ml);
483 int wpa_validate_osen(struct wpa_authenticator *wpa_auth,
484 struct wpa_state_machine *sm,
485 const u8 *osen_ie, size_t osen_ie_len);
486 int wpa_auth_uses_mfp(struct wpa_state_machine *sm);
487 int wpa_auth_uses_spp_amsdu(struct wpa_state_machine *sm);
488 void wpa_auth_set_ocv(struct wpa_state_machine *sm, int ocv);
489 int wpa_auth_uses_ocv(struct wpa_state_machine *sm);
490 struct wpa_state_machine *
491 wpa_auth_sta_init(struct wpa_authenticator *wpa_auth, const u8 *addr,
492 const u8 *p2p_dev_addr);
493 int wpa_auth_sta_associated(struct wpa_authenticator *wpa_auth,
494 struct wpa_state_machine *sm);
495 void wpa_auth_sta_no_wpa(struct wpa_state_machine *sm);
496 void wpa_auth_sta_deinit(struct wpa_state_machine *sm);
497 void wpa_receive(struct wpa_authenticator *wpa_auth,
498 struct wpa_state_machine *sm,
499 u8 *data, size_t data_len);
500 enum wpa_event {
501 WPA_AUTH, WPA_ASSOC, WPA_DISASSOC, WPA_DEAUTH, WPA_REAUTH,
502 WPA_REAUTH_EAPOL, WPA_ASSOC_FT, WPA_ASSOC_FILS, WPA_DRV_STA_REMOVED
503 };
504 void wpa_remove_ptk(struct wpa_state_machine *sm);
505 int wpa_auth_sm_event(struct wpa_state_machine *sm, enum wpa_event event);
506 void wpa_auth_sm_notify(struct wpa_state_machine *sm);
507 void wpa_gtk_rekey(struct wpa_authenticator *wpa_auth);
508 int wpa_get_mib(struct wpa_authenticator *wpa_auth, char *buf, size_t buflen);
509 int wpa_get_mib_sta(struct wpa_state_machine *sm, char *buf, size_t buflen);
510 void wpa_auth_countermeasures_start(struct wpa_authenticator *wpa_auth);
511 int wpa_auth_pairwise_set(struct wpa_state_machine *sm);
512 int wpa_auth_get_pairwise(struct wpa_state_machine *sm);
513 const u8 * wpa_auth_get_pmk(struct wpa_state_machine *sm, int *len);
514 const u8 * wpa_auth_get_dpp_pkhash(struct wpa_state_machine *sm);
515 int wpa_auth_sta_key_mgmt(struct wpa_state_machine *sm);
516 bool wpa_auth_get_first_sta_seen(struct wpa_authenticator *wpa_auth,
517 int vlan_id);
518 int wpa_auth_sta_wpa_version(struct wpa_state_machine *sm);
519 int wpa_auth_sta_ft_tk_already_set(struct wpa_state_machine *sm);
520 int wpa_auth_sta_fils_tk_already_set(struct wpa_state_machine *sm);
521 int wpa_auth_sta_clear_pmksa(struct wpa_state_machine *sm,
522 struct rsn_pmksa_cache_entry *entry);
523 struct rsn_pmksa_cache_entry *
524 wpa_auth_sta_get_pmksa(struct wpa_state_machine *sm);
525 void wpa_auth_sta_local_mic_failure_report(struct wpa_state_machine *sm);
526 const u8 * wpa_auth_get_wpa_ie(struct wpa_authenticator *wpa_auth,
527 size_t *len);
528 int wpa_auth_pmksa_add(struct wpa_state_machine *sm, const u8 *pmk,
529 unsigned int pmk_len,
530 int session_timeout, struct eapol_state_machine *eapol);
531 int wpa_auth_pmksa_add_preauth(struct wpa_authenticator *wpa_auth,
532 const u8 *pmk, size_t len, const u8 *sta_addr,
533 int session_timeout,
534 struct eapol_state_machine *eapol);
535 int wpa_auth_pmksa_add_sae(struct wpa_authenticator *wpa_auth, const u8 *addr,
536 const u8 *pmk, size_t pmk_len, const u8 *pmkid,
537 int akmp, bool is_ml, int vlan_id);
538 void wpa_auth_add_sae_pmkid(struct wpa_state_machine *sm, const u8 *pmkid);
539 int wpa_auth_pmksa_add2(struct wpa_authenticator *wpa_auth, const u8 *addr,
540 const u8 *pmk, size_t pmk_len, const u8 *pmkid,
541 int session_timeout, int akmp, const u8 *dpp_pkhash,
542 bool is_ml);
543 void wpa_auth_pmksa_remove(struct wpa_authenticator *wpa_auth,
544 const u8 *sta_addr);
545 int wpa_auth_pmksa_list(struct wpa_authenticator *wpa_auth, char *buf,
546 size_t len);
547 void wpa_auth_pmksa_flush(struct wpa_authenticator *wpa_auth);
548 int wpa_auth_pmksa_list_mesh(struct wpa_authenticator *wpa_auth, const u8 *addr,
549 char *buf, size_t len);
550 struct rsn_pmksa_cache_entry *
551 wpa_auth_pmksa_create_entry(const u8 *aa, const u8 *spa, const u8 *pmk,
552 size_t pmk_len, int akmp,
553 const u8 *pmkid, int expiration);
554 int wpa_auth_pmksa_add_entry(struct wpa_authenticator *wpa_auth,
555 struct rsn_pmksa_cache_entry *entry);
556 struct rsn_pmksa_cache *
557 wpa_auth_get_pmksa_cache(struct wpa_authenticator *wpa_auth, bool is_ml);
558 struct rsn_pmksa_cache_entry *
559 wpa_auth_pmksa_get(struct wpa_authenticator *wpa_auth, const u8 *sta_addr,
560 const u8 *pmkid);
561 int wpa_auth_pmksa_get_pmk(struct wpa_authenticator *wpa_auth,
562 const u8 *sta_addr, const u8 **pmk, size_t *pmk_len,
563 const u8 **pmkid);
564 struct rsn_pmksa_cache_entry *
565 wpa_auth_pmksa_get_fils_cache_id(struct wpa_authenticator *wpa_auth,
566 const u8 *sta_addr, const u8 *pmkid);
567 void wpa_auth_pmksa_set_to_sm(struct rsn_pmksa_cache_entry *pmksa,
568 struct wpa_state_machine *sm,
569 struct wpa_authenticator *wpa_auth,
570 u8 *pmkid, u8 *pmk, size_t *pmk_len);
571 int wpa_auth_sta_set_vlan(struct wpa_state_machine *sm,
572 struct wpa_authenticator *wpa_auth, int vlan_id);
573 void wpa_auth_eapol_key_tx_status(struct wpa_authenticator *wpa_auth,
574 struct wpa_state_machine *sm, int ack);
575 bool wpa_auth_ap_sta_support_pmkid_privacy(struct wpa_state_machine *sm);
576
577 #ifdef CONFIG_IEEE80211R_AP
578 u8 * wpa_sm_write_assoc_resp_ies(struct wpa_state_machine *sm, u8 *pos,
579 size_t max_len, int auth_alg,
580 const u8 *req_ies, size_t req_ies_len,
581 int omit_rsnxe, bool reassoc, int vlan_id);
582 void wpa_ft_process_auth(struct wpa_state_machine *sm,
583 u16 auth_transaction, const u8 *ies, size_t ies_len,
584 void (*cb)(void *ctx, const u8 *dst,
585 u16 auth_transaction, u16 resp,
586 const u8 *ies, size_t ies_len),
587 void *ctx);
588 int wpa_ft_validate_reassoc(struct wpa_state_machine *sm, const u8 *ies,
589 size_t ies_len);
590 int wpa_ft_action_rx(struct wpa_state_machine *sm, const u8 *data, size_t len);
591 int wpa_ft_rrb_rx(struct wpa_authenticator *wpa_auth, const u8 *src_addr,
592 const u8 *data, size_t data_len);
593 void wpa_ft_rrb_oui_rx(struct wpa_authenticator *wpa_auth, const u8 *src_addr,
594 const u8 *dst_addr, u8 oui_suffix, const u8 *data,
595 size_t data_len);
596 void wpa_ft_push_pmk_r1(struct wpa_authenticator *wpa_auth, const u8 *addr);
597 void wpa_ft_deinit(struct wpa_authenticator *wpa_auth);
598 void wpa_ft_sta_deinit(struct wpa_state_machine *sm);
599 int wpa_ft_fetch_pmk_r1(struct wpa_authenticator *wpa_auth,
600 const u8 *spa, const u8 *pmk_r1_name,
601 u8 *pmk_r1, size_t *pmk_r1_len, int *pairwise,
602 struct vlan_description *vlan,
603 const u8 **identity, size_t *identity_len,
604 const u8 **radius_cui, size_t *radius_cui_len,
605 int *session_timeout);
606
607 #endif /* CONFIG_IEEE80211R_AP */
608
609 void wpa_wnmsleep_rekey_gtk(struct wpa_state_machine *sm);
610 void wpa_set_wnmsleep(struct wpa_state_machine *sm, int flag);
611 int wpa_wnmsleep_gtk_subelem(struct wpa_state_machine *sm, u8 *pos);
612 int wpa_wnmsleep_igtk_subelem(struct wpa_state_machine *sm, u8 *pos);
613 int wpa_wnmsleep_bigtk_subelem(struct wpa_state_machine *sm, u8 *pos);
614
615 int wpa_auth_uses_sae(struct wpa_state_machine *sm);
616 int wpa_auth_uses_ft_sae(struct wpa_state_machine *sm);
617
618 int wpa_auth_get_ip_addr(struct wpa_state_machine *sm, u8 *addr);
619
620 struct radius_das_attrs;
621 int wpa_auth_radius_das_disconnect_pmksa(struct wpa_authenticator *wpa_auth,
622 struct radius_das_attrs *attr);
623 void wpa_auth_reconfig_group_keys(struct wpa_authenticator *wpa_auth);
624
625 int wpa_auth_ensure_group(struct wpa_authenticator *wpa_auth, int vlan_id);
626 int wpa_auth_release_group(struct wpa_authenticator *wpa_auth, int vlan_id);
627 int fils_auth_pmk_to_ptk(struct wpa_state_machine *sm, const u8 *pmk,
628 size_t pmk_len, const u8 *snonce, const u8 *anonce,
629 const u8 *dhss, size_t dhss_len,
630 struct wpabuf *g_sta, struct wpabuf *g_ap);
631 int fils_decrypt_assoc(struct wpa_state_machine *sm, const u8 *fils_session,
632 const struct ieee80211_mgmt *mgmt, size_t frame_len,
633 u8 *pos, size_t left);
634 int fils_encrypt_assoc(struct wpa_state_machine *sm, u8 *buf,
635 size_t current_len, size_t max_len,
636 const struct wpabuf *hlp);
637 int fils_set_tk(struct wpa_state_machine *sm);
638 u8 * hostapd_eid_assoc_fils_session(struct wpa_state_machine *sm, u8 *eid,
639 const u8 *fils_session,
640 struct wpabuf *fils_hlp_resp);
641 const u8 * wpa_fils_validate_fils_session(struct wpa_state_machine *sm,
642 const u8 *ies, size_t ies_len,
643 const u8 *fils_session);
644 int wpa_fils_validate_key_confirm(struct wpa_state_machine *sm, const u8 *ies,
645 size_t ies_len);
646
647 int get_sta_tx_parameters(struct wpa_state_machine *sm, int ap_max_chanwidth,
648 int ap_seg1_idx, int *bandwidth, int *seg1_idx);
649
650 int wpa_auth_write_fte(struct wpa_authenticator *wpa_auth,
651 struct wpa_state_machine *sm,
652 u8 *buf, size_t len);
653 void wpa_auth_get_fils_aead_params(struct wpa_state_machine *sm,
654 u8 *fils_anonce, u8 *fils_snonce,
655 u8 *fils_kek, size_t *fils_kek_len);
656 void wpa_auth_add_fils_pmk_pmkid(struct wpa_state_machine *sm, const u8 *pmk,
657 size_t pmk_len, const u8 *pmkid);
658 u8 * wpa_auth_write_assoc_resp_owe(struct wpa_state_machine *sm,
659 u8 *pos, size_t max_len);
660 u8 * wpa_auth_write_assoc_resp_fils(struct wpa_state_machine *sm,
661 u8 *pos, size_t max_len);
662 bool wpa_auth_write_fd_rsn_info(struct wpa_authenticator *wpa_auth,
663 u8 *fd_rsn_info);
664 void wpa_auth_set_auth_alg(struct wpa_state_machine *sm, u16 auth_alg);
665 void wpa_auth_set_hash_alg_sae_ext_key(struct wpa_state_machine *sm,
666 size_t pmk_len);
667 void wpa_auth_set_rsn_selection(struct wpa_state_machine *sm, const u8 *ie,
668 size_t len);
669 void wpa_auth_set_dpp_z(struct wpa_state_machine *sm, const struct wpabuf *z);
670 void wpa_auth_set_ssid_protection(struct wpa_state_machine *sm, bool val);
671 void wpa_auth_set_transition_disable(struct wpa_authenticator *wpa_auth,
672 u8 val);
673
674 u8 * wpa_auth_eid_key_delivery(u8 *eid, size_t max_len,
675 struct wpa_state_machine *sm,
676 bool is_ml);
677 u8 * wpa_auth_write_assoc_resp_eppke(struct wpa_state_machine *sm,
678 u8 *pos, size_t max_len, bool is_ml);
679 void wpa_store_eppke_pmk_ptk_sm(struct wpa_state_machine *sm,
680 const struct wpa_ptk *ptk, const u8 *pmk,
681 size_t pmk_len);
682 int wpa_auth_epp_derive_new_pmkid(const u8 *anonce, const u8 *snonce,
683 int akmp, size_t pmk_len, u8 *pmkid);
684 bool wpa_auth_ap_sta_support_assoc_enc(struct wpa_state_machine *sm);
685 void wpa_auth_ensure_group_init(struct wpa_state_machine *sm);
686
687 int wpa_auth_resend_m1(struct wpa_state_machine *sm, int change_anonce,
688 void (*cb)(void *ctx1, void *ctx2),
689 void *ctx1, void *ctx2);
690 int wpa_auth_resend_m3(struct wpa_state_machine *sm,
691 void (*cb)(void *ctx1, void *ctx2),
692 void *ctx1, void *ctx2);
693 int wpa_auth_resend_group_m1(struct wpa_state_machine *sm,
694 void (*cb)(void *ctx1, void *ctx2),
695 void *ctx1, void *ctx2);
696 int wpa_auth_rekey_ptk(struct wpa_authenticator *wpa_auth,
697 struct wpa_state_machine *sm);
698 int wpa_auth_rekey_gtk(struct wpa_authenticator *wpa_auth);
699 int hostapd_wpa_auth_send_eapol(void *ctx, const u8 *addr,
700 const u8 *data, size_t data_len,
701 int encrypt);
702 void wpa_auth_set_ptk_rekey_timer(struct wpa_state_machine *sm);
703 void wpa_auth_set_ft_rsnxe_used(struct wpa_authenticator *wpa_auth, int val);
704
705 enum wpa_auth_ocv_override_frame {
706 WPA_AUTH_OCV_OVERRIDE_EAPOL_M3,
707 WPA_AUTH_OCV_OVERRIDE_EAPOL_G1,
708 WPA_AUTH_OCV_OVERRIDE_FT_ASSOC,
709 WPA_AUTH_OCV_OVERRIDE_FILS_ASSOC,
710 };
711 void wpa_auth_set_ocv_override_freq(struct wpa_authenticator *wpa_auth,
712 enum wpa_auth_ocv_override_frame frame,
713 unsigned int freq);
714
715 void wpa_auth_sta_radius_psk_resp(struct wpa_state_machine *sm, bool success);
716
717 void wpa_auth_set_ml_info(struct wpa_state_machine *sm,
718 u8 mld_assoc_link_id, struct mld_info *info);
719 void wpa_auth_ml_get_key_info(struct wpa_authenticator *a,
720 struct wpa_auth_ml_link_key_info *info,
721 bool mgmt_frame_prot, bool beacon_prot,
722 bool rekey, int vlan_id);
723
724 void wpa_release_link_auth_ref(struct wpa_state_machine *sm, u8 link_id,
725 bool rejected);
726
727 size_t wpa_auth_ml_group_kdes_len(struct wpa_state_machine *sm, u16 req_links);
728 u8 * wpa_auth_ml_group_kdes(struct wpa_state_machine *sm, u8 *pos,
729 u16 req_links);
730 void wpa_reset_assoc_sm_info(struct wpa_state_machine *assoc_sm,
731 struct wpa_authenticator *wpa_auth,
732 u8 mld_assoc_link_id);
733
734 #define for_each_sm_auth(sm, link_id) \
735 for (link_id = 0; link_id < MAX_NUM_MLD_LINKS; link_id++) \
736 if (sm->mld_links[link_id].valid && \
737 sm->mld_links[link_id].wpa_auth && \
738 sm->wpa_auth != sm->mld_links[link_id].wpa_auth)
739
wpa_auth_pmf_enabled(struct wpa_auth_config * conf)740 static inline bool wpa_auth_pmf_enabled(struct wpa_auth_config *conf)
741 {
742 return conf->ieee80211w != NO_MGMT_FRAME_PROTECTION ||
743 conf->rsn_override_mfp != NO_MGMT_FRAME_PROTECTION ||
744 conf->rsn_override_mfp_2 != NO_MGMT_FRAME_PROTECTION;
745 }
746
747 bool wpa_auth_sm_known_sta_identification(struct wpa_state_machine *sm,
748 const u8 *timestamp,
749 const u8 *mic, size_t mic_len);
750 struct wpa_group * wpa_select_vlan_wpa_group(struct wpa_group *gsm,
751 int vlan_id);
752 void wpa_auth_set_sae_pw_id(struct wpa_state_machine *sm,
753 const struct wpabuf *pw_id,
754 unsigned int counter);
755
756 int wpa_auth_802_1x_get_msk(struct wpa_authenticator *wpa_auth,
757 const u8 *addr, u8 *msk, size_t *len);
758 int wpa_auth_802_1x_set_key(struct wpa_authenticator *wpa_auth,
759 enum wpa_alg alg, const u8 *addr,
760 u8 *key, size_t key_len);
761 bool wpa_auth_ap_support_secure_ltf(struct wpa_authenticator *wpa_auth);
762 int wpa_write_802_1x_rsne(struct wpa_authenticator *wpa_auth, u8 *buf,
763 size_t len, const u8 *pmkid, int akmp,
764 int pairwise_cipher, int group_cipher,
765 int group_mgmt_cipher, enum mfp_options mfp);
766 int wpa_write_eppke_rsne(const u8 *wpa_ie, size_t wpa_ie_len,
767 u8 *buf, size_t len,
768 const u8 *pmkid, int akmp,
769 int pairwise_cipher, enum mfp_options mfp);
770
771 #endif /* WPA_AUTH_H */
772