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
12 * See README and COPYING for more details.
18 /* max(dot11RSNAConfigGroupUpdateCount,dot11RSNAConfigPairwiseUpdateCount) */
19 #define RSNA_MAX_EAPOL_RETRIES 4
23 struct wpa_stsl_negotiation
{
24 struct wpa_stsl_negotiation
*next
;
25 u8 initiator
[ETH_ALEN
];
30 struct wpa_state_machine
{
31 struct wpa_authenticator
*wpa_auth
;
32 struct wpa_group
*group
;
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
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
;
52 Boolean DeauthenticationRequest
;
53 Boolean AuthenticationRequest
;
54 Boolean ReAuthenticationRequest
;
59 Boolean EAPOLKeyReceived
;
60 Boolean EAPOLKeyPairwise
;
61 Boolean EAPOLKeyRequest
;
63 Boolean GUpdateStationKeys
;
64 u8 ANonce
[WPA_NONCE_LEN
];
65 u8 SNonce
[WPA_NONCE_LEN
];
72 struct wpa_key_replay_counter
{
73 u8 counter
[WPA_REPLAY_COUNTER_LEN
];
75 } key_replay
[RSNA_MAX_EAPOL_RETRIES
],
76 prev_key_replay
[RSNA_MAX_EAPOL_RETRIES
];
77 Boolean PInitAKeys
; /* WPA only, not in IEEE 802.11i */
78 Boolean PTKRequest
; /* not in IEEE 802.11i state machine */
80 Boolean PtkGroupInit
; /* init request for PTK Group state machine */
82 u8
*last_rx_eapol_key
; /* starting from IEEE 802.1X header */
83 size_t last_rx_eapol_key_len
;
85 unsigned int changed
:1;
86 unsigned int in_step_loop
:1;
87 unsigned int pending_deinit
:1;
88 unsigned int started
:1;
89 unsigned int mgmt_frame_prot
:1;
90 unsigned int rx_eapol_key_secure
:1;
91 unsigned int update_snonce
:1;
92 #ifdef CONFIG_IEEE80211R
93 unsigned int ft_completed
:1;
94 unsigned int pmk_r1_name_valid
:1;
95 #endif /* CONFIG_IEEE80211R */
97 u8 req_replay_counter
[WPA_REPLAY_COUNTER_LEN
];
98 int req_replay_counter_used
;
104 WPA_VERSION_NO_WPA
= 0 /* WPA not used */,
105 WPA_VERSION_WPA
= 1 /* WPA / IEEE 802.11i/D3.0 */,
106 WPA_VERSION_WPA2
= 2 /* WPA2 / IEEE 802.11i */
108 int pairwise
; /* Pairwise cipher suite, WPA_CIPHER_* */
109 int wpa_key_mgmt
; /* the selected WPA_KEY_MGMT_* */
110 struct rsn_pmksa_cache_entry
*pmksa
;
112 u32 dot11RSNAStatsTKIPLocalMICFailures
;
113 u32 dot11RSNAStatsTKIPRemoteMICFailures
;
115 #ifdef CONFIG_IEEE80211R
116 u8 xxkey
[PMK_LEN
]; /* PSK or the second 256 bits of MSK */
118 u8 pmk_r1_name
[WPA_PMK_NAME_LEN
]; /* PMKR1Name derived from FT Auth
120 u8 r0kh_id
[FT_R0KH_ID_MAX_LEN
]; /* R0KH-ID from FT Auth Request */
122 u8 sup_pmk_r1_name
[WPA_PMK_NAME_LEN
]; /* PMKR1Name from EAPOL-Key
125 #endif /* CONFIG_IEEE80211R */
127 int pending_1_of_4_timeout
;
131 /* per group key state machine data */
133 struct wpa_group
*next
;
137 int GKeyDoneStations
;
141 Boolean GTKAuthenticator
;
142 u8 Counter
[WPA_NONCE_LEN
];
145 WPA_GROUP_GTK_INIT
= 0,
146 WPA_GROUP_SETKEYS
, WPA_GROUP_SETKEYSDONE
150 u8 GTK
[2][WPA_GTK_MAX_LEN
];
151 u8 GNonce
[WPA_NONCE_LEN
];
153 Boolean first_sta_seen
;
154 Boolean reject_4way_hs_for_entropy
;
155 #ifdef CONFIG_IEEE80211W
156 u8 IGTK
[2][WPA_IGTK_LEN
];
157 int GN_igtk
, GM_igtk
;
158 #endif /* CONFIG_IEEE80211W */
162 struct wpa_ft_pmk_cache
;
164 /* per authenticator data */
165 struct wpa_authenticator
{
166 struct wpa_group
*group
;
168 unsigned int dot11RSNAStatsTKIPRemoteMICFailures
;
169 u32 dot11RSNAAuthenticationSuiteSelected
;
170 u32 dot11RSNAPairwiseCipherSelected
;
171 u32 dot11RSNAGroupCipherSelected
;
172 u8 dot11RSNAPMKIDUsed
[PMKID_LEN
];
173 u32 dot11RSNAAuthenticationSuiteRequested
; /* FIX: update */
174 u32 dot11RSNAPairwiseCipherRequested
; /* FIX: update */
175 u32 dot11RSNAGroupCipherRequested
; /* FIX: update */
176 unsigned int dot11RSNATKIPCounterMeasuresInvoked
;
177 unsigned int dot11RSNA4WayHandshakeFailures
;
179 struct wpa_stsl_negotiation
*stsl_negotiations
;
181 struct wpa_auth_config conf
;
182 struct wpa_auth_callbacks cb
;
189 struct rsn_pmksa_cache
*pmksa
;
190 struct wpa_ft_pmk_cache
*ft_pmk_cache
;
194 int wpa_write_rsn_ie(struct wpa_auth_config
*conf
, u8
*buf
, size_t len
,
196 void wpa_auth_logger(struct wpa_authenticator
*wpa_auth
, const u8
*addr
,
197 logger_level level
, const char *txt
);
198 void wpa_auth_vlogger(struct wpa_authenticator
*wpa_auth
, const u8
*addr
,
199 logger_level level
, const char *fmt
, ...);
200 void __wpa_send_eapol(struct wpa_authenticator
*wpa_auth
,
201 struct wpa_state_machine
*sm
, int key_info
,
202 const u8
*key_rsc
, const u8
*nonce
,
203 const u8
*kde
, size_t kde_len
,
204 int keyidx
, int encr
, int force_version
);
205 int wpa_auth_for_each_sta(struct wpa_authenticator
*wpa_auth
,
206 int (*cb
)(struct wpa_state_machine
*sm
, void *ctx
),
208 int wpa_auth_for_each_auth(struct wpa_authenticator
*wpa_auth
,
209 int (*cb
)(struct wpa_authenticator
*a
, void *ctx
),
212 #ifdef CONFIG_PEERKEY
213 int wpa_stsl_remove(struct wpa_authenticator
*wpa_auth
,
214 struct wpa_stsl_negotiation
*neg
);
215 void wpa_smk_error(struct wpa_authenticator
*wpa_auth
,
216 struct wpa_state_machine
*sm
, struct wpa_eapol_key
*key
);
217 void wpa_smk_m1(struct wpa_authenticator
*wpa_auth
,
218 struct wpa_state_machine
*sm
, struct wpa_eapol_key
*key
);
219 void wpa_smk_m3(struct wpa_authenticator
*wpa_auth
,
220 struct wpa_state_machine
*sm
, struct wpa_eapol_key
*key
);
221 #endif /* CONFIG_PEERKEY */
223 #ifdef CONFIG_IEEE80211R
224 int wpa_write_mdie(struct wpa_auth_config
*conf
, u8
*buf
, size_t len
);
225 int wpa_write_ftie(struct wpa_auth_config
*conf
, const u8
*r0kh_id
,
227 const u8
*anonce
, const u8
*snonce
,
228 u8
*buf
, size_t len
, const u8
*subelem
,
230 int wpa_auth_derive_ptk_ft(struct wpa_state_machine
*sm
, const u8
*pmk
,
231 struct wpa_ptk
*ptk
, size_t ptk_len
);
232 struct wpa_ft_pmk_cache
* wpa_ft_pmk_cache_init(void);
233 void wpa_ft_pmk_cache_deinit(struct wpa_ft_pmk_cache
*cache
);
234 void wpa_ft_install_ptk(struct wpa_state_machine
*sm
);
235 #endif /* CONFIG_IEEE80211R */
237 #endif /* WPA_AUTH_I_H */