wpa_supplicant / hostapd  2.5
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
wpa_auth_i.h
Go to the documentation of this file.
1 
5 #ifndef WPA_AUTH_I_H
6 #define WPA_AUTH_I_H
7 
8 /* max(dot11RSNAConfigGroupUpdateCount,dot11RSNAConfigPairwiseUpdateCount) */
9 #define RSNA_MAX_EAPOL_RETRIES 4
10 
11 struct wpa_group;
12 
14  struct wpa_stsl_negotiation *next;
15  u8 initiator[ETH_ALEN];
16  u8 peer[ETH_ALEN];
17 };
18 
19 
21  struct wpa_authenticator *wpa_auth;
22  struct wpa_group *group;
23 
24  u8 addr[ETH_ALEN];
25  u8 p2p_dev_addr[ETH_ALEN];
26 
27  enum {
28  WPA_PTK_INITIALIZE, WPA_PTK_DISCONNECT, WPA_PTK_DISCONNECTED,
29  WPA_PTK_AUTHENTICATION, WPA_PTK_AUTHENTICATION2,
30  WPA_PTK_INITPMK, WPA_PTK_INITPSK, WPA_PTK_PTKSTART,
31  WPA_PTK_PTKCALCNEGOTIATING, WPA_PTK_PTKCALCNEGOTIATING2,
32  WPA_PTK_PTKINITNEGOTIATING, WPA_PTK_PTKINITDONE
33  } wpa_ptk_state;
34 
35  enum {
36  WPA_PTK_GROUP_IDLE = 0,
37  WPA_PTK_GROUP_REKEYNEGOTIATING,
38  WPA_PTK_GROUP_REKEYESTABLISHED,
39  WPA_PTK_GROUP_KEYERROR
40  } wpa_ptk_group_state;
41 
42  Boolean Init;
43  Boolean DeauthenticationRequest;
44  Boolean AuthenticationRequest;
45  Boolean ReAuthenticationRequest;
46  Boolean Disconnect;
47  int TimeoutCtr;
48  int GTimeoutCtr;
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];
57  u8 alt_SNonce[WPA_NONCE_LEN];
58  u8 alt_replay_counter[WPA_REPLAY_COUNTER_LEN];
59  u8 PMK[PMK_LEN];
60  struct wpa_ptk PTK;
61  Boolean PTK_valid;
62  Boolean pairwise_set;
63  int keycount;
64  Boolean Pair;
66  u8 counter[WPA_REPLAY_COUNTER_LEN];
67  Boolean valid;
68  } key_replay[RSNA_MAX_EAPOL_RETRIES],
69  prev_key_replay[RSNA_MAX_EAPOL_RETRIES];
70  Boolean PInitAKeys; /* WPA only, not in IEEE 802.11i */
71  Boolean PTKRequest; /* not in IEEE 802.11i state machine */
72  Boolean has_GTK;
73  Boolean PtkGroupInit; /* init request for PTK Group state machine */
74 
75  u8 *last_rx_eapol_key; /* starting from IEEE 802.1X header */
76  size_t last_rx_eapol_key_len;
77 
78  unsigned int changed:1;
79  unsigned int in_step_loop:1;
80  unsigned int pending_deinit:1;
81  unsigned int started:1;
82  unsigned int mgmt_frame_prot:1;
83  unsigned int rx_eapol_key_secure:1;
84  unsigned int update_snonce:1;
85  unsigned int alt_snonce_valid:1;
86 #ifdef CONFIG_IEEE80211R
87  unsigned int ft_completed:1;
88  unsigned int pmk_r1_name_valid:1;
89 #endif /* CONFIG_IEEE80211R */
90  unsigned int is_wnmsleep:1;
91 
92  u8 req_replay_counter[WPA_REPLAY_COUNTER_LEN];
93  int req_replay_counter_used;
94 
95  u8 *wpa_ie;
96  size_t wpa_ie_len;
97 
98  enum {
99  WPA_VERSION_NO_WPA = 0 /* WPA not used */,
100  WPA_VERSION_WPA = 1 /* WPA / IEEE 802.11i/D3.0 */,
101  WPA_VERSION_WPA2 = 2 /* WPA2 / IEEE 802.11i */
102  } wpa;
103  int pairwise; /* Pairwise cipher suite, WPA_CIPHER_* */
104  int wpa_key_mgmt; /* the selected WPA_KEY_MGMT_* */
105  struct rsn_pmksa_cache_entry *pmksa;
106 
107  u32 dot11RSNAStatsTKIPLocalMICFailures;
108  u32 dot11RSNAStatsTKIPRemoteMICFailures;
109 
110 #ifdef CONFIG_IEEE80211R
111  u8 xxkey[PMK_LEN]; /* PSK or the second 256 bits of MSK */
112  size_t xxkey_len;
113  u8 pmk_r1_name[WPA_PMK_NAME_LEN]; /* PMKR1Name derived from FT Auth
114  * Request */
115  u8 r0kh_id[FT_R0KH_ID_MAX_LEN]; /* R0KH-ID from FT Auth Request */
116  size_t r0kh_id_len;
117  u8 sup_pmk_r1_name[WPA_PMK_NAME_LEN]; /* PMKR1Name from EAPOL-Key
118  * message 2/4 */
119  u8 *assoc_resp_ftie;
120 
121  void (*ft_pending_cb)(void *ctx, const u8 *dst, const u8 *bssid,
122  u16 auth_transaction, u16 status,
123  const u8 *ies, size_t ies_len);
124  void *ft_pending_cb_ctx;
125  struct wpabuf *ft_pending_req_ies;
126  u8 ft_pending_pull_nonce[FT_R0KH_R1KH_PULL_NONCE_LEN];
127  u8 ft_pending_auth_transaction;
128  u8 ft_pending_current_ap[ETH_ALEN];
129 #endif /* CONFIG_IEEE80211R */
130 
131  int pending_1_of_4_timeout;
132 
133 #ifdef CONFIG_P2P
134  u8 ip_addr[4];
135 #endif /* CONFIG_P2P */
136 };
137 
138 
139 /* per group key state machine data */
140 struct wpa_group {
141  struct wpa_group *next;
142  int vlan_id;
143 
144  Boolean GInit;
145  int GKeyDoneStations;
146  Boolean GTKReKey;
147  int GTK_len;
148  int GN, GM;
149  Boolean GTKAuthenticator;
150  u8 Counter[WPA_NONCE_LEN];
151 
152  enum {
153  WPA_GROUP_GTK_INIT = 0,
154  WPA_GROUP_SETKEYS, WPA_GROUP_SETKEYSDONE,
155  WPA_GROUP_FATAL_FAILURE
156  } wpa_group_state;
157 
158  u8 GMK[WPA_GMK_LEN];
159  u8 GTK[2][WPA_GTK_MAX_LEN];
160  u8 GNonce[WPA_NONCE_LEN];
161  Boolean changed;
162  Boolean first_sta_seen;
163  Boolean reject_4way_hs_for_entropy;
164 #ifdef CONFIG_IEEE80211W
165  u8 IGTK[2][WPA_IGTK_MAX_LEN];
166  int GN_igtk, GM_igtk;
167 #endif /* CONFIG_IEEE80211W */
168  /* Number of references except those in struct wpa_group->next */
169  unsigned int references;
170 };
171 
172 
173 struct wpa_ft_pmk_cache;
174 
175 /* per authenticator data */
177  struct wpa_group *group;
178 
179  unsigned int dot11RSNAStatsTKIPRemoteMICFailures;
180  u32 dot11RSNAAuthenticationSuiteSelected;
181  u32 dot11RSNAPairwiseCipherSelected;
182  u32 dot11RSNAGroupCipherSelected;
183  u8 dot11RSNAPMKIDUsed[PMKID_LEN];
184  u32 dot11RSNAAuthenticationSuiteRequested; /* FIX: update */
185  u32 dot11RSNAPairwiseCipherRequested; /* FIX: update */
186  u32 dot11RSNAGroupCipherRequested; /* FIX: update */
187  unsigned int dot11RSNATKIPCounterMeasuresInvoked;
188  unsigned int dot11RSNA4WayHandshakeFailures;
189 
190  struct wpa_stsl_negotiation *stsl_negotiations;
191 
192  struct wpa_auth_config conf;
193  struct wpa_auth_callbacks cb;
194 
195  u8 *wpa_ie;
196  size_t wpa_ie_len;
197 
198  u8 addr[ETH_ALEN];
199 
200  struct rsn_pmksa_cache *pmksa;
201  struct wpa_ft_pmk_cache *ft_pmk_cache;
202 
203 #ifdef CONFIG_P2P
204  struct bitfield *ip_pool;
205 #endif /* CONFIG_P2P */
206 };
207 
208 
209 int wpa_write_rsn_ie(struct wpa_auth_config *conf, u8 *buf, size_t len,
210  const u8 *pmkid);
211 void wpa_auth_logger(struct wpa_authenticator *wpa_auth, const u8 *addr,
212  logger_level level, const char *txt);
213 void wpa_auth_vlogger(struct wpa_authenticator *wpa_auth, const u8 *addr,
214  logger_level level, const char *fmt, ...);
215 void __wpa_send_eapol(struct wpa_authenticator *wpa_auth,
216  struct wpa_state_machine *sm, int key_info,
217  const u8 *key_rsc, const u8 *nonce,
218  const u8 *kde, size_t kde_len,
219  int keyidx, int encr, int force_version);
220 int wpa_auth_for_each_sta(struct wpa_authenticator *wpa_auth,
221  int (*cb)(struct wpa_state_machine *sm, void *ctx),
222  void *cb_ctx);
223 int wpa_auth_for_each_auth(struct wpa_authenticator *wpa_auth,
224  int (*cb)(struct wpa_authenticator *a, void *ctx),
225  void *cb_ctx);
226 
227 #ifdef CONFIG_PEERKEY
228 int wpa_stsl_remove(struct wpa_authenticator *wpa_auth,
229  struct wpa_stsl_negotiation *neg);
230 void wpa_smk_error(struct wpa_authenticator *wpa_auth,
231  struct wpa_state_machine *sm,
232  const u8 *key_data, size_t key_data_len);
233 void wpa_smk_m1(struct wpa_authenticator *wpa_auth,
234  struct wpa_state_machine *sm, struct wpa_eapol_key *key,
235  const u8 *key_data, size_t key_data_len);
236 void wpa_smk_m3(struct wpa_authenticator *wpa_auth,
237  struct wpa_state_machine *sm, struct wpa_eapol_key *key,
238  const u8 *key_data, size_t key_data_len);
239 #endif /* CONFIG_PEERKEY */
240 
241 #ifdef CONFIG_IEEE80211R
242 int wpa_write_mdie(struct wpa_auth_config *conf, u8 *buf, size_t len);
243 int wpa_write_ftie(struct wpa_auth_config *conf, const u8 *r0kh_id,
244  size_t r0kh_id_len,
245  const u8 *anonce, const u8 *snonce,
246  u8 *buf, size_t len, const u8 *subelem,
247  size_t subelem_len);
248 int wpa_auth_derive_ptk_ft(struct wpa_state_machine *sm, const u8 *pmk,
249  struct wpa_ptk *ptk);
250 struct wpa_ft_pmk_cache * wpa_ft_pmk_cache_init(void);
251 void wpa_ft_pmk_cache_deinit(struct wpa_ft_pmk_cache *cache);
252 void wpa_ft_install_ptk(struct wpa_state_machine *sm);
253 #endif /* CONFIG_IEEE80211R */
254 
255 #endif /* WPA_AUTH_I_H */
Definition: wpa_auth_i.h:13
Definition: wpa_auth.h:186
Definition: wpa_auth_i.h:20
Definition: wpabuf.h:16
Definition: pmksa_cache_auth.c:20
Definition: wpa_common.h:166
WPA Pairwise Transient Key IEEE Std 802.11i-2004 - 8.5.1.2 Pairwise key hierarchy.
Definition: wpa_common.h:205
Definition: wpa_auth_i.h:176
Definition: wpa_auth.h:125
PMKSA cache entry.
Definition: pmksa_cache_auth.h:14
Definition: wpa_auth_i.h:140
Definition: bitfield.c:11