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.
20 struct wpa_stsl_negotiation
{
21 struct wpa_stsl_negotiation
*next
;
22 u8 initiator
[ETH_ALEN
];
27 struct wpa_state_machine
{
28 struct wpa_authenticator
*wpa_auth
;
29 struct wpa_group
*group
;
34 WPA_PTK_INITIALIZE
, WPA_PTK_DISCONNECT
, WPA_PTK_DISCONNECTED
,
35 WPA_PTK_AUTHENTICATION
, WPA_PTK_AUTHENTICATION2
,
36 WPA_PTK_INITPMK
, WPA_PTK_INITPSK
, WPA_PTK_PTKSTART
,
37 WPA_PTK_PTKCALCNEGOTIATING
, WPA_PTK_PTKCALCNEGOTIATING2
,
38 WPA_PTK_PTKINITNEGOTIATING
, WPA_PTK_PTKINITDONE
42 WPA_PTK_GROUP_IDLE
= 0,
43 WPA_PTK_GROUP_REKEYNEGOTIATING
,
44 WPA_PTK_GROUP_REKEYESTABLISHED
,
45 WPA_PTK_GROUP_KEYERROR
46 } wpa_ptk_group_state
;
49 Boolean DeauthenticationRequest
;
50 Boolean AuthenticationRequest
;
51 Boolean ReAuthenticationRequest
;
56 Boolean EAPOLKeyReceived
;
57 Boolean EAPOLKeyPairwise
;
58 Boolean EAPOLKeyRequest
;
60 Boolean GUpdateStationKeys
;
61 u8 ANonce
[WPA_NONCE_LEN
];
62 u8 SNonce
[WPA_NONCE_LEN
];
69 u8 key_replay_counter
[WPA_REPLAY_COUNTER_LEN
];
70 Boolean key_replay_counter_valid
;
71 Boolean PInitAKeys
; /* WPA only, not in IEEE 802.11i */
72 Boolean PTKRequest
; /* not in IEEE 802.11i state machine */
75 u8
*last_rx_eapol_key
; /* starting from IEEE 802.1X header */
76 size_t last_rx_eapol_key_len
;
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 #ifdef CONFIG_IEEE80211R
84 unsigned int ft_completed
:1;
85 unsigned int pmk_r1_name_valid
:1;
86 #endif /* CONFIG_IEEE80211R */
88 u8 req_replay_counter
[WPA_REPLAY_COUNTER_LEN
];
89 int req_replay_counter_used
;
95 WPA_VERSION_NO_WPA
= 0 /* WPA not used */,
96 WPA_VERSION_WPA
= 1 /* WPA / IEEE 802.11i/D3.0 */,
97 WPA_VERSION_WPA2
= 2 /* WPA2 / IEEE 802.11i */
99 int pairwise
; /* Pairwise cipher suite, WPA_CIPHER_* */
100 int wpa_key_mgmt
; /* the selected WPA_KEY_MGMT_* */
101 struct rsn_pmksa_cache_entry
*pmksa
;
103 u32 dot11RSNAStatsTKIPLocalMICFailures
;
104 u32 dot11RSNAStatsTKIPRemoteMICFailures
;
106 #ifdef CONFIG_IEEE80211R
107 u8 xxkey
[PMK_LEN
]; /* PSK or the second 256 bits of MSK */
109 u8 pmk_r1_name
[WPA_PMK_NAME_LEN
]; /* PMKR1Name derived from FT Auth
111 u8 r0kh_id
[FT_R0KH_ID_MAX_LEN
]; /* R0KH-ID from FT Auth Request */
113 #endif /* CONFIG_IEEE80211R */
117 /* per group key state machine data */
119 struct wpa_group
*next
;
123 int GKeyDoneStations
;
127 Boolean GTKAuthenticator
;
128 u8 Counter
[WPA_NONCE_LEN
];
131 WPA_GROUP_GTK_INIT
= 0,
132 WPA_GROUP_SETKEYS
, WPA_GROUP_SETKEYSDONE
136 u8 GTK
[2][WPA_GTK_MAX_LEN
];
137 u8 GNonce
[WPA_NONCE_LEN
];
139 #ifdef CONFIG_IEEE80211W
140 u8 IGTK
[2][WPA_IGTK_LEN
];
141 int GN_igtk
, GM_igtk
;
142 #endif /* CONFIG_IEEE80211W */
146 struct wpa_ft_pmk_cache
;
148 /* per authenticator data */
149 struct wpa_authenticator
{
150 struct wpa_group
*group
;
152 unsigned int dot11RSNAStatsTKIPRemoteMICFailures
;
153 u32 dot11RSNAAuthenticationSuiteSelected
;
154 u32 dot11RSNAPairwiseCipherSelected
;
155 u32 dot11RSNAGroupCipherSelected
;
156 u8 dot11RSNAPMKIDUsed
[PMKID_LEN
];
157 u32 dot11RSNAAuthenticationSuiteRequested
; /* FIX: update */
158 u32 dot11RSNAPairwiseCipherRequested
; /* FIX: update */
159 u32 dot11RSNAGroupCipherRequested
; /* FIX: update */
160 unsigned int dot11RSNATKIPCounterMeasuresInvoked
;
161 unsigned int dot11RSNA4WayHandshakeFailures
;
163 struct wpa_stsl_negotiation
*stsl_negotiations
;
165 struct wpa_auth_config conf
;
166 struct wpa_auth_callbacks cb
;
173 struct rsn_pmksa_cache
*pmksa
;
174 struct wpa_ft_pmk_cache
*ft_pmk_cache
;
178 int wpa_write_rsn_ie(struct wpa_auth_config
*conf
, u8
*buf
, size_t len
,
180 void wpa_auth_logger(struct wpa_authenticator
*wpa_auth
, const u8
*addr
,
181 logger_level level
, const char *txt
);
182 void wpa_auth_vlogger(struct wpa_authenticator
*wpa_auth
, const u8
*addr
,
183 logger_level level
, const char *fmt
, ...);
184 void __wpa_send_eapol(struct wpa_authenticator
*wpa_auth
,
185 struct wpa_state_machine
*sm
, int key_info
,
186 const u8
*key_rsc
, const u8
*nonce
,
187 const u8
*kde
, size_t kde_len
,
188 int keyidx
, int encr
, int force_version
);
189 int wpa_auth_for_each_sta(struct wpa_authenticator
*wpa_auth
,
190 int (*cb
)(struct wpa_state_machine
*sm
, void *ctx
),
192 int wpa_auth_for_each_auth(struct wpa_authenticator
*wpa_auth
,
193 int (*cb
)(struct wpa_authenticator
*a
, void *ctx
),
196 #ifdef CONFIG_PEERKEY
197 int wpa_stsl_remove(struct wpa_authenticator
*wpa_auth
,
198 struct wpa_stsl_negotiation
*neg
);
199 void wpa_smk_error(struct wpa_authenticator
*wpa_auth
,
200 struct wpa_state_machine
*sm
, struct wpa_eapol_key
*key
);
201 void wpa_smk_m1(struct wpa_authenticator
*wpa_auth
,
202 struct wpa_state_machine
*sm
, struct wpa_eapol_key
*key
);
203 void wpa_smk_m3(struct wpa_authenticator
*wpa_auth
,
204 struct wpa_state_machine
*sm
, struct wpa_eapol_key
*key
);
205 #endif /* CONFIG_PEERKEY */
207 #ifdef CONFIG_IEEE80211R
208 int wpa_write_mdie(struct wpa_auth_config
*conf
, u8
*buf
, size_t len
);
209 int wpa_auth_derive_ptk_ft(struct wpa_state_machine
*sm
, const u8
*pmk
,
210 struct wpa_ptk
*ptk
);
211 struct wpa_ft_pmk_cache
* wpa_ft_pmk_cache_init(void);
212 void wpa_ft_pmk_cache_deinit(struct wpa_ft_pmk_cache
*cache
);
213 #endif /* CONFIG_IEEE80211R */
215 #endif /* WPA_AUTH_I_H */