Reduce differences between our VKERNEL and VKERNEL64 configurations.
[dragonfly.git] / contrib / hostapd / hostapd / wpa_auth_i.h
blob925d3ee459ce17f7c3e99c35039bd2f3931cd07a
1 /*
2 * hostapd - IEEE 802.11i-2004 / WPA Authenticator: Internal definitions
3 * Copyright (c) 2004-2007, Jouni Malinen <j@w1.fi>
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.
9 * Alternatively, this software may be distributed under the terms of BSD
10 * license.
12 * See README and COPYING for more details.
15 #ifndef WPA_AUTH_I_H
16 #define WPA_AUTH_I_H
18 /* max(dot11RSNAConfigGroupUpdateCount,dot11RSNAConfigPairwiseUpdateCount) */
19 #define RSNA_MAX_EAPOL_RETRIES 4
21 struct wpa_group;
23 struct wpa_stsl_negotiation {
24 struct wpa_stsl_negotiation *next;
25 u8 initiator[ETH_ALEN];
26 u8 peer[ETH_ALEN];
30 struct wpa_state_machine {
31 struct wpa_authenticator *wpa_auth;
32 struct wpa_group *group;
34 u8 addr[ETH_ALEN];
36 enum {
37 WPA_PTK_INITIALIZE, WPA_PTK_DISCONNECT, WPA_PTK_DISCONNECTED,
38 WPA_PTK_AUTHENTICATION, WPA_PTK_AUTHENTICATION2,
39 WPA_PTK_INITPMK, WPA_PTK_INITPSK, WPA_PTK_PTKSTART,
40 WPA_PTK_PTKCALCNEGOTIATING, WPA_PTK_PTKCALCNEGOTIATING2,
41 WPA_PTK_PTKINITNEGOTIATING, WPA_PTK_PTKINITDONE
42 } wpa_ptk_state;
44 enum {
45 WPA_PTK_GROUP_IDLE = 0,
46 WPA_PTK_GROUP_REKEYNEGOTIATING,
47 WPA_PTK_GROUP_REKEYESTABLISHED,
48 WPA_PTK_GROUP_KEYERROR
49 } wpa_ptk_group_state;
51 Boolean Init;
52 Boolean DeauthenticationRequest;
53 Boolean AuthenticationRequest;
54 Boolean ReAuthenticationRequest;
55 Boolean Disconnect;
56 int TimeoutCtr;
57 int GTimeoutCtr;
58 Boolean TimeoutEvt;
59 Boolean EAPOLKeyReceived;
60 Boolean EAPOLKeyPairwise;
61 Boolean EAPOLKeyRequest;
62 Boolean MICVerified;
63 Boolean GUpdateStationKeys;
64 u8 ANonce[WPA_NONCE_LEN];
65 u8 SNonce[WPA_NONCE_LEN];
66 u8 PMK[PMK_LEN];
67 struct wpa_ptk PTK;
68 Boolean PTK_valid;
69 Boolean pairwise_set;
70 int keycount;
71 Boolean Pair;
72 struct {
73 u8 counter[WPA_REPLAY_COUNTER_LEN];
74 Boolean valid;
75 } key_replay[RSNA_MAX_EAPOL_RETRIES];
76 Boolean PInitAKeys; /* WPA only, not in IEEE 802.11i */
77 Boolean PTKRequest; /* not in IEEE 802.11i state machine */
78 Boolean has_GTK;
79 Boolean PtkGroupInit; /* init request for PTK Group state machine */
81 u8 *last_rx_eapol_key; /* starting from IEEE 802.1X header */
82 size_t last_rx_eapol_key_len;
84 unsigned int changed:1;
85 unsigned int in_step_loop:1;
86 unsigned int pending_deinit:1;
87 unsigned int started:1;
88 unsigned int mgmt_frame_prot:1;
89 #ifdef CONFIG_IEEE80211R
90 unsigned int ft_completed:1;
91 unsigned int pmk_r1_name_valid:1;
92 #endif /* CONFIG_IEEE80211R */
94 u8 req_replay_counter[WPA_REPLAY_COUNTER_LEN];
95 int req_replay_counter_used;
97 u8 *wpa_ie;
98 size_t wpa_ie_len;
100 enum {
101 WPA_VERSION_NO_WPA = 0 /* WPA not used */,
102 WPA_VERSION_WPA = 1 /* WPA / IEEE 802.11i/D3.0 */,
103 WPA_VERSION_WPA2 = 2 /* WPA2 / IEEE 802.11i */
104 } wpa;
105 int pairwise; /* Pairwise cipher suite, WPA_CIPHER_* */
106 int wpa_key_mgmt; /* the selected WPA_KEY_MGMT_* */
107 struct rsn_pmksa_cache_entry *pmksa;
109 u32 dot11RSNAStatsTKIPLocalMICFailures;
110 u32 dot11RSNAStatsTKIPRemoteMICFailures;
112 #ifdef CONFIG_IEEE80211R
113 u8 xxkey[PMK_LEN]; /* PSK or the second 256 bits of MSK */
114 size_t xxkey_len;
115 u8 pmk_r1_name[WPA_PMK_NAME_LEN]; /* PMKR1Name derived from FT Auth
116 * Request */
117 u8 r0kh_id[FT_R0KH_ID_MAX_LEN]; /* R0KH-ID from FT Auth Request */
118 size_t r0kh_id_len;
119 #endif /* CONFIG_IEEE80211R */
123 /* per group key state machine data */
124 struct wpa_group {
125 struct wpa_group *next;
126 int vlan_id;
128 Boolean GInit;
129 int GKeyDoneStations;
130 Boolean GTKReKey;
131 int GTK_len;
132 int GN, GM;
133 Boolean GTKAuthenticator;
134 u8 Counter[WPA_NONCE_LEN];
136 enum {
137 WPA_GROUP_GTK_INIT = 0,
138 WPA_GROUP_SETKEYS, WPA_GROUP_SETKEYSDONE
139 } wpa_group_state;
141 u8 GMK[WPA_GMK_LEN];
142 u8 GTK[2][WPA_GTK_MAX_LEN];
143 u8 GNonce[WPA_NONCE_LEN];
144 Boolean changed;
145 #ifdef CONFIG_IEEE80211W
146 u8 IGTK[2][WPA_IGTK_LEN];
147 int GN_igtk, GM_igtk;
148 #endif /* CONFIG_IEEE80211W */
152 struct wpa_ft_pmk_cache;
154 /* per authenticator data */
155 struct wpa_authenticator {
156 struct wpa_group *group;
158 unsigned int dot11RSNAStatsTKIPRemoteMICFailures;
159 u32 dot11RSNAAuthenticationSuiteSelected;
160 u32 dot11RSNAPairwiseCipherSelected;
161 u32 dot11RSNAGroupCipherSelected;
162 u8 dot11RSNAPMKIDUsed[PMKID_LEN];
163 u32 dot11RSNAAuthenticationSuiteRequested; /* FIX: update */
164 u32 dot11RSNAPairwiseCipherRequested; /* FIX: update */
165 u32 dot11RSNAGroupCipherRequested; /* FIX: update */
166 unsigned int dot11RSNATKIPCounterMeasuresInvoked;
167 unsigned int dot11RSNA4WayHandshakeFailures;
169 struct wpa_stsl_negotiation *stsl_negotiations;
171 struct wpa_auth_config conf;
172 struct wpa_auth_callbacks cb;
174 u8 *wpa_ie;
175 size_t wpa_ie_len;
177 u8 addr[ETH_ALEN];
179 struct rsn_pmksa_cache *pmksa;
180 struct wpa_ft_pmk_cache *ft_pmk_cache;
184 int wpa_write_rsn_ie(struct wpa_auth_config *conf, u8 *buf, size_t len,
185 const u8 *pmkid);
186 void wpa_auth_logger(struct wpa_authenticator *wpa_auth, const u8 *addr,
187 logger_level level, const char *txt);
188 void wpa_auth_vlogger(struct wpa_authenticator *wpa_auth, const u8 *addr,
189 logger_level level, const char *fmt, ...);
190 void __wpa_send_eapol(struct wpa_authenticator *wpa_auth,
191 struct wpa_state_machine *sm, int key_info,
192 const u8 *key_rsc, const u8 *nonce,
193 const u8 *kde, size_t kde_len,
194 int keyidx, int encr, int force_version);
195 int wpa_auth_for_each_sta(struct wpa_authenticator *wpa_auth,
196 int (*cb)(struct wpa_state_machine *sm, void *ctx),
197 void *cb_ctx);
198 int wpa_auth_for_each_auth(struct wpa_authenticator *wpa_auth,
199 int (*cb)(struct wpa_authenticator *a, void *ctx),
200 void *cb_ctx);
202 #ifdef CONFIG_PEERKEY
203 int wpa_stsl_remove(struct wpa_authenticator *wpa_auth,
204 struct wpa_stsl_negotiation *neg);
205 void wpa_smk_error(struct wpa_authenticator *wpa_auth,
206 struct wpa_state_machine *sm, struct wpa_eapol_key *key);
207 void wpa_smk_m1(struct wpa_authenticator *wpa_auth,
208 struct wpa_state_machine *sm, struct wpa_eapol_key *key);
209 void wpa_smk_m3(struct wpa_authenticator *wpa_auth,
210 struct wpa_state_machine *sm, struct wpa_eapol_key *key);
211 #endif /* CONFIG_PEERKEY */
213 #ifdef CONFIG_IEEE80211R
214 int wpa_write_mdie(struct wpa_auth_config *conf, u8 *buf, size_t len);
215 int wpa_auth_derive_ptk_ft(struct wpa_state_machine *sm, const u8 *pmk,
216 struct wpa_ptk *ptk, size_t ptk_len);
217 struct wpa_ft_pmk_cache * wpa_ft_pmk_cache_init(void);
218 void wpa_ft_pmk_cache_deinit(struct wpa_ft_pmk_cache *cache);
219 #endif /* CONFIG_IEEE80211R */
221 #endif /* WPA_AUTH_I_H */