]> git.ipfire.org Git - thirdparty/hostap.git/blame - src/ap/wpa_auth.h
AP: Reorder WPA/Beacon initialization
[thirdparty/hostap.git] / src / ap / wpa_auth.h
CommitLineData
6fc6879b
JM
1/*
2 * hostapd - IEEE 802.11i-2004 / WPA Authenticator
3 * Copyright (c) 2004-2007, Jouni Malinen <j@w1.fi>
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License version 2 as
7 * published by the Free Software Foundation.
8 *
9 * Alternatively, this software may be distributed under the terms of BSD
10 * license.
11 *
12 * See README and COPYING for more details.
13 */
14
15#ifndef WPA_AUTH_H
16#define WPA_AUTH_H
17
90973fb2
JM
18#include "common/defs.h"
19#include "common/eapol_common.h"
20#include "common/wpa_common.h"
6fc6879b
JM
21
22#ifdef _MSC_VER
23#pragma pack(push, 1)
24#endif /* _MSC_VER */
25
c1e033b0
JM
26/* IEEE Std 802.11r-2008, 11A.10.3 - Remote request/response frame definition
27 */
6fc6879b
JM
28struct ft_rrb_frame {
29 u8 frame_type; /* RSN_REMOTE_FRAME_TYPE_FT_RRB */
30 u8 packet_type; /* FT_PACKET_REQUEST/FT_PACKET_RESPONSE */
2eba45c8 31 le16 action_length; /* little endian length of action_frame */
6fc6879b
JM
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/* Vendor-specific types for R0KH-R1KH protocol; not defined in 802.11r */
44#define FT_PACKET_R0KH_R1KH_PULL 200
45#define FT_PACKET_R0KH_R1KH_RESP 201
46#define FT_PACKET_R0KH_R1KH_PUSH 202
47
6fc6879b
JM
48#define FT_R0KH_R1KH_PULL_DATA_LEN 44
49#define FT_R0KH_R1KH_RESP_DATA_LEN 76
1b484d60 50#define FT_R0KH_R1KH_PUSH_DATA_LEN 88
6fc6879b
JM
51
52struct ft_r0kh_r1kh_pull_frame {
53 u8 frame_type; /* RSN_REMOTE_FRAME_TYPE_FT_RRB */
54 u8 packet_type; /* FT_PACKET_R0KH_R1KH_PULL */
2eba45c8 55 le16 data_length; /* little endian length of data (44) */
6fc6879b
JM
56 u8 ap_address[ETH_ALEN];
57
58 u8 nonce[16];
59 u8 pmk_r0_name[WPA_PMK_NAME_LEN];
60 u8 r1kh_id[FT_R1KH_ID_LEN];
61 u8 s1kh_id[ETH_ALEN];
62 u8 pad[4]; /* 8-octet boundary for AES key wrap */
63 u8 key_wrap_extra[8];
64} STRUCT_PACKED;
65
66struct ft_r0kh_r1kh_resp_frame {
67 u8 frame_type; /* RSN_REMOTE_FRAME_TYPE_FT_RRB */
68 u8 packet_type; /* FT_PACKET_R0KH_R1KH_RESP */
2eba45c8 69 le16 data_length; /* little endian length of data (76) */
6fc6879b
JM
70 u8 ap_address[ETH_ALEN];
71
72 u8 nonce[16]; /* copied from pull */
73 u8 r1kh_id[FT_R1KH_ID_LEN]; /* copied from pull */
74 u8 s1kh_id[ETH_ALEN]; /* copied from pull */
75 u8 pmk_r1[PMK_LEN];
76 u8 pmk_r1_name[WPA_PMK_NAME_LEN];
1b484d60
JM
77 le16 pairwise;
78 u8 pad[2]; /* 8-octet boundary for AES key wrap */
6fc6879b
JM
79 u8 key_wrap_extra[8];
80} STRUCT_PACKED;
81
82struct ft_r0kh_r1kh_push_frame {
83 u8 frame_type; /* RSN_REMOTE_FRAME_TYPE_FT_RRB */
84 u8 packet_type; /* FT_PACKET_R0KH_R1KH_PUSH */
1b484d60 85 le16 data_length; /* little endian length of data (88) */
6fc6879b
JM
86 u8 ap_address[ETH_ALEN];
87
88 /* Encrypted with AES key-wrap */
89 u8 timestamp[4]; /* current time in seconds since unix epoch, little
90 * endian */
91 u8 r1kh_id[FT_R1KH_ID_LEN];
92 u8 s1kh_id[ETH_ALEN];
93 u8 pmk_r0_name[WPA_PMK_NAME_LEN];
94 u8 pmk_r1[PMK_LEN];
95 u8 pmk_r1_name[WPA_PMK_NAME_LEN];
1b484d60
JM
96 le16 pairwise;
97 u8 pad[6]; /* 8-octet boundary for AES key wrap */
6fc6879b
JM
98 u8 key_wrap_extra[8];
99} STRUCT_PACKED;
100
101#ifdef _MSC_VER
102#pragma pack(pop)
103#endif /* _MSC_VER */
104
105
106/* per STA state machine data */
107
108struct wpa_authenticator;
109struct wpa_state_machine;
110struct rsn_pmksa_cache_entry;
111struct eapol_state_machine;
112
113
114struct ft_remote_r0kh {
115 struct ft_remote_r0kh *next;
116 u8 addr[ETH_ALEN];
117 u8 id[FT_R0KH_ID_MAX_LEN];
118 size_t id_len;
119 u8 key[16];
120};
121
122
123struct ft_remote_r1kh {
124 struct ft_remote_r1kh *next;
125 u8 addr[ETH_ALEN];
126 u8 id[FT_R1KH_ID_LEN];
127 u8 key[16];
128};
129
130
131struct wpa_auth_config {
132 int wpa;
133 int wpa_key_mgmt;
134 int wpa_pairwise;
135 int wpa_group;
136 int wpa_group_rekey;
137 int wpa_strict_rekey;
138 int wpa_gmk_rekey;
581a8cde 139 int wpa_ptk_rekey;
6fc6879b
JM
140 int rsn_pairwise;
141 int rsn_preauth;
142 int eapol_version;
143 int peerkey;
3ae0800c 144 int wmm_enabled;
721abef9 145 int wmm_uapsd;
cb465555 146 int disable_pmksa_caching;
bf98f7f3 147 int okc;
e4bf4db9 148 int tx_status;
6fc6879b 149#ifdef CONFIG_IEEE80211W
70f8cc8e 150 enum mfp_options ieee80211w;
6fc6879b
JM
151#endif /* CONFIG_IEEE80211W */
152#ifdef CONFIG_IEEE80211R
153#define SSID_LEN 32
154 u8 ssid[SSID_LEN];
155 size_t ssid_len;
156 u8 mobility_domain[MOBILITY_DOMAIN_ID_LEN];
157 u8 r0_key_holder[FT_R0KH_ID_MAX_LEN];
158 size_t r0_key_holder_len;
159 u8 r1_key_holder[FT_R1KH_ID_LEN];
160 u32 r0_key_lifetime;
161 u32 reassociation_deadline;
162 struct ft_remote_r0kh *r0kh_list;
163 struct ft_remote_r1kh *r1kh_list;
164 int pmk_r1_push;
d7956add 165 int ft_over_ds;
6fc6879b
JM
166#endif /* CONFIG_IEEE80211R */
167};
168
169typedef enum {
170 LOGGER_DEBUG, LOGGER_INFO, LOGGER_WARNING
171} logger_level;
172
173typedef enum {
174 WPA_EAPOL_portEnabled, WPA_EAPOL_portValid, WPA_EAPOL_authorized,
175 WPA_EAPOL_portControl_Auto, WPA_EAPOL_keyRun, WPA_EAPOL_keyAvailable,
176 WPA_EAPOL_keyDone, WPA_EAPOL_inc_EapolFramesTx
177} wpa_eapol_variable;
178
179struct wpa_auth_callbacks {
180 void *ctx;
181 void (*logger)(void *ctx, const u8 *addr, logger_level level,
182 const char *txt);
183 void (*disconnect)(void *ctx, const u8 *addr, u16 reason);
184 void (*mic_failure_report)(void *ctx, const u8 *addr);
185 void (*set_eapol)(void *ctx, const u8 *addr, wpa_eapol_variable var,
186 int value);
187 int (*get_eapol)(void *ctx, const u8 *addr, wpa_eapol_variable var);
188 const u8 * (*get_psk)(void *ctx, const u8 *addr, const u8 *prev_psk);
189 int (*get_msk)(void *ctx, const u8 *addr, u8 *msk, size_t *len);
71934751
JM
190 int (*set_key)(void *ctx, int vlan_id, enum wpa_alg alg,
191 const u8 *addr, int idx, u8 *key, size_t key_len);
6fc6879b 192 int (*get_seqnum)(void *ctx, const u8 *addr, int idx, u8 *seq);
6fc6879b
JM
193 int (*send_eapol)(void *ctx, const u8 *addr, const u8 *data,
194 size_t data_len, int encrypt);
195 int (*for_each_sta)(void *ctx, int (*cb)(struct wpa_state_machine *sm,
196 void *ctx), void *cb_ctx);
bf98f7f3
JM
197 int (*for_each_auth)(void *ctx, int (*cb)(struct wpa_authenticator *a,
198 void *ctx), void *cb_ctx);
6fc6879b
JM
199 int (*send_ether)(void *ctx, const u8 *dst, u16 proto, const u8 *data,
200 size_t data_len);
201#ifdef CONFIG_IEEE80211R
202 struct wpa_state_machine * (*add_sta)(void *ctx, const u8 *sta_addr);
203 int (*send_ft_action)(void *ctx, const u8 *dst,
204 const u8 *data, size_t data_len);
205#endif /* CONFIG_IEEE80211R */
206};
207
208struct wpa_authenticator * wpa_init(const u8 *addr,
209 struct wpa_auth_config *conf,
210 struct wpa_auth_callbacks *cb);
bdffdc5d 211int wpa_init_keys(struct wpa_authenticator *wpa_auth);
6fc6879b
JM
212void wpa_deinit(struct wpa_authenticator *wpa_auth);
213int wpa_reconfig(struct wpa_authenticator *wpa_auth,
214 struct wpa_auth_config *conf);
215
216enum {
217 WPA_IE_OK, WPA_INVALID_IE, WPA_INVALID_GROUP, WPA_INVALID_PAIRWISE,
218 WPA_INVALID_AKMP, WPA_NOT_ENABLED, WPA_ALLOC_FAIL,
219 WPA_MGMT_FRAME_PROTECTION_VIOLATION, WPA_INVALID_MGMT_GROUP_CIPHER,
2100a768 220 WPA_INVALID_MDIE, WPA_INVALID_PROTO
6fc6879b
JM
221};
222
223int wpa_validate_wpa_ie(struct wpa_authenticator *wpa_auth,
224 struct wpa_state_machine *sm,
225 const u8 *wpa_ie, size_t wpa_ie_len,
226 const u8 *mdie, size_t mdie_len);
f3f7540e 227int wpa_auth_uses_mfp(struct wpa_state_machine *sm);
6fc6879b
JM
228struct wpa_state_machine *
229wpa_auth_sta_init(struct wpa_authenticator *wpa_auth, const u8 *addr);
6f9b5d16
JM
230int wpa_auth_sta_associated(struct wpa_authenticator *wpa_auth,
231 struct wpa_state_machine *sm);
a8d05fca 232void wpa_auth_sta_no_wpa(struct wpa_state_machine *sm);
6fc6879b
JM
233void wpa_auth_sta_deinit(struct wpa_state_machine *sm);
234void wpa_receive(struct wpa_authenticator *wpa_auth,
235 struct wpa_state_machine *sm,
236 u8 *data, size_t data_len);
237typedef enum {
238 WPA_AUTH, WPA_ASSOC, WPA_DISASSOC, WPA_DEAUTH, WPA_REAUTH,
239 WPA_REAUTH_EAPOL, WPA_ASSOC_FT
240} wpa_event;
241void wpa_remove_ptk(struct wpa_state_machine *sm);
6f9b5d16 242int wpa_auth_sm_event(struct wpa_state_machine *sm, wpa_event event);
6fc6879b
JM
243void wpa_auth_sm_notify(struct wpa_state_machine *sm);
244void wpa_gtk_rekey(struct wpa_authenticator *wpa_auth);
245int wpa_get_mib(struct wpa_authenticator *wpa_auth, char *buf, size_t buflen);
246int wpa_get_mib_sta(struct wpa_state_machine *sm, char *buf, size_t buflen);
247void wpa_auth_countermeasures_start(struct wpa_authenticator *wpa_auth);
248int wpa_auth_pairwise_set(struct wpa_state_machine *sm);
ff36ff00 249int wpa_auth_get_pairwise(struct wpa_state_machine *sm);
6fc6879b
JM
250int wpa_auth_sta_key_mgmt(struct wpa_state_machine *sm);
251int wpa_auth_sta_wpa_version(struct wpa_state_machine *sm);
252int wpa_auth_sta_clear_pmksa(struct wpa_state_machine *sm,
253 struct rsn_pmksa_cache_entry *entry);
254struct rsn_pmksa_cache_entry *
255wpa_auth_sta_get_pmksa(struct wpa_state_machine *sm);
256void wpa_auth_sta_local_mic_failure_report(struct wpa_state_machine *sm);
257const u8 * wpa_auth_get_wpa_ie(struct wpa_authenticator *wpa_auth,
258 size_t *len);
259int wpa_auth_pmksa_add(struct wpa_state_machine *sm, const u8 *pmk,
260 int session_timeout, struct eapol_state_machine *eapol);
261int wpa_auth_pmksa_add_preauth(struct wpa_authenticator *wpa_auth,
262 const u8 *pmk, size_t len, const u8 *sta_addr,
263 int session_timeout,
264 struct eapol_state_machine *eapol);
265int wpa_auth_sta_set_vlan(struct wpa_state_machine *sm, int vlan_id);
e4bf4db9
JM
266void wpa_auth_eapol_key_tx_status(struct wpa_authenticator *wpa_auth,
267 struct wpa_state_machine *sm, int ack);
6fc6879b
JM
268
269#ifdef CONFIG_IEEE80211R
270u8 * wpa_sm_write_assoc_resp_ies(struct wpa_state_machine *sm, u8 *pos,
f238cf9f
JM
271 size_t max_len, int auth_alg,
272 const u8 *req_ies, size_t req_ies_len);
6fc6879b
JM
273void wpa_ft_process_auth(struct wpa_state_machine *sm, const u8 *bssid,
274 u16 auth_transaction, const u8 *ies, size_t ies_len,
275 void (*cb)(void *ctx, const u8 *dst, const u8 *bssid,
276 u16 auth_transaction, u16 resp,
277 const u8 *ies, size_t ies_len),
278 void *ctx);
279u16 wpa_ft_validate_reassoc(struct wpa_state_machine *sm, const u8 *ies,
280 size_t ies_len);
281int wpa_ft_action_rx(struct wpa_state_machine *sm, const u8 *data, size_t len);
282int wpa_ft_rrb_rx(struct wpa_authenticator *wpa_auth, const u8 *src_addr,
283 const u8 *data, size_t data_len);
284void wpa_ft_push_pmk_r1(struct wpa_authenticator *wpa_auth, const u8 *addr);
285#endif /* CONFIG_IEEE80211R */
286
287#endif /* WPA_AUTH_H */