00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015 #ifndef WPA_AUTH_I_H
00016 #define WPA_AUTH_I_H
00017
00018
00019 #define RSNA_MAX_EAPOL_RETRIES 4
00020
00021 struct wpa_group;
00022
00023 struct wpa_stsl_negotiation {
00024 struct wpa_stsl_negotiation *next;
00025 u8 initiator[ETH_ALEN];
00026 u8 peer[ETH_ALEN];
00027 };
00028
00029
00030 struct wpa_state_machine {
00031 struct wpa_authenticator *wpa_auth;
00032 struct wpa_group *group;
00033
00034 u8 addr[ETH_ALEN];
00035
00036 enum {
00037 WPA_PTK_INITIALIZE, WPA_PTK_DISCONNECT, WPA_PTK_DISCONNECTED,
00038 WPA_PTK_AUTHENTICATION, WPA_PTK_AUTHENTICATION2,
00039 WPA_PTK_INITPMK, WPA_PTK_INITPSK, WPA_PTK_PTKSTART,
00040 WPA_PTK_PTKCALCNEGOTIATING, WPA_PTK_PTKCALCNEGOTIATING2,
00041 WPA_PTK_PTKINITNEGOTIATING, WPA_PTK_PTKINITDONE
00042 } wpa_ptk_state;
00043
00044 enum {
00045 WPA_PTK_GROUP_IDLE = 0,
00046 WPA_PTK_GROUP_REKEYNEGOTIATING,
00047 WPA_PTK_GROUP_REKEYESTABLISHED,
00048 WPA_PTK_GROUP_KEYERROR
00049 } wpa_ptk_group_state;
00050
00051 Boolean Init;
00052 Boolean DeauthenticationRequest;
00053 Boolean AuthenticationRequest;
00054 Boolean ReAuthenticationRequest;
00055 Boolean Disconnect;
00056 int TimeoutCtr;
00057 int GTimeoutCtr;
00058 Boolean TimeoutEvt;
00059 Boolean EAPOLKeyReceived;
00060 Boolean EAPOLKeyPairwise;
00061 Boolean EAPOLKeyRequest;
00062 Boolean MICVerified;
00063 Boolean GUpdateStationKeys;
00064 u8 ANonce[WPA_NONCE_LEN];
00065 u8 SNonce[WPA_NONCE_LEN];
00066 u8 PMK[PMK_LEN];
00067 struct wpa_ptk PTK;
00068 Boolean PTK_valid;
00069 Boolean pairwise_set;
00070 int keycount;
00071 Boolean Pair;
00072 struct {
00073 u8 counter[WPA_REPLAY_COUNTER_LEN];
00074 Boolean valid;
00075 } key_replay[RSNA_MAX_EAPOL_RETRIES];
00076 Boolean PInitAKeys;
00077 Boolean PTKRequest;
00078 Boolean has_GTK;
00079 Boolean PtkGroupInit;
00080
00081 u8 *last_rx_eapol_key;
00082 size_t last_rx_eapol_key_len;
00083
00084 unsigned int changed:1;
00085 unsigned int in_step_loop:1;
00086 unsigned int pending_deinit:1;
00087 unsigned int started:1;
00088 unsigned int mgmt_frame_prot:1;
00089 #ifdef CONFIG_IEEE80211R
00090 unsigned int ft_completed:1;
00091 unsigned int pmk_r1_name_valid:1;
00092 #endif
00093
00094 u8 req_replay_counter[WPA_REPLAY_COUNTER_LEN];
00095 int req_replay_counter_used;
00096
00097 u8 *wpa_ie;
00098 size_t wpa_ie_len;
00099
00100 enum {
00101 WPA_VERSION_NO_WPA = 0 ,
00102 WPA_VERSION_WPA = 1 ,
00103 WPA_VERSION_WPA2 = 2
00104 } wpa;
00105 int pairwise;
00106 int wpa_key_mgmt;
00107 struct rsn_pmksa_cache_entry *pmksa;
00108
00109 u32 dot11RSNAStatsTKIPLocalMICFailures;
00110 u32 dot11RSNAStatsTKIPRemoteMICFailures;
00111
00112 #ifdef CONFIG_IEEE80211R
00113 u8 xxkey[PMK_LEN];
00114 size_t xxkey_len;
00115 u8 pmk_r1_name[WPA_PMK_NAME_LEN];
00116
00117 u8 r0kh_id[FT_R0KH_ID_MAX_LEN];
00118 size_t r0kh_id_len;
00119 u8 sup_pmk_r1_name[WPA_PMK_NAME_LEN];
00120
00121 u8 *assoc_resp_ftie;
00122 #endif
00123 };
00124
00125
00126
00127 struct wpa_group {
00128 struct wpa_group *next;
00129 int vlan_id;
00130
00131 Boolean GInit;
00132 int GKeyDoneStations;
00133 Boolean GTKReKey;
00134 int GTK_len;
00135 int GN, GM;
00136 Boolean GTKAuthenticator;
00137 u8 Counter[WPA_NONCE_LEN];
00138
00139 enum {
00140 WPA_GROUP_GTK_INIT = 0,
00141 WPA_GROUP_SETKEYS, WPA_GROUP_SETKEYSDONE
00142 } wpa_group_state;
00143
00144 u8 GMK[WPA_GMK_LEN];
00145 u8 GTK[2][WPA_GTK_MAX_LEN];
00146 u8 GNonce[WPA_NONCE_LEN];
00147 Boolean changed;
00148 #ifdef CONFIG_IEEE80211W
00149 u8 IGTK[2][WPA_IGTK_LEN];
00150 int GN_igtk, GM_igtk;
00151 #endif
00152 };
00153
00154
00155 struct wpa_ft_pmk_cache;
00156
00157
00158 struct wpa_authenticator {
00159 struct wpa_group *group;
00160
00161 unsigned int dot11RSNAStatsTKIPRemoteMICFailures;
00162 u32 dot11RSNAAuthenticationSuiteSelected;
00163 u32 dot11RSNAPairwiseCipherSelected;
00164 u32 dot11RSNAGroupCipherSelected;
00165 u8 dot11RSNAPMKIDUsed[PMKID_LEN];
00166 u32 dot11RSNAAuthenticationSuiteRequested;
00167 u32 dot11RSNAPairwiseCipherRequested;
00168 u32 dot11RSNAGroupCipherRequested;
00169 unsigned int dot11RSNATKIPCounterMeasuresInvoked;
00170 unsigned int dot11RSNA4WayHandshakeFailures;
00171
00172 struct wpa_stsl_negotiation *stsl_negotiations;
00173
00174 struct wpa_auth_config conf;
00175 struct wpa_auth_callbacks cb;
00176
00177 u8 *wpa_ie;
00178 size_t wpa_ie_len;
00179
00180 u8 addr[ETH_ALEN];
00181
00182 struct rsn_pmksa_cache *pmksa;
00183 struct wpa_ft_pmk_cache *ft_pmk_cache;
00184 };
00185
00186
00187 int wpa_write_rsn_ie(struct wpa_auth_config *conf, u8 *buf, size_t len,
00188 const u8 *pmkid);
00189 void wpa_auth_logger(struct wpa_authenticator *wpa_auth, const u8 *addr,
00190 logger_level level, const char *txt);
00191 void wpa_auth_vlogger(struct wpa_authenticator *wpa_auth, const u8 *addr,
00192 logger_level level, const char *fmt, ...);
00193 void __wpa_send_eapol(struct wpa_authenticator *wpa_auth,
00194 struct wpa_state_machine *sm, int key_info,
00195 const u8 *key_rsc, const u8 *nonce,
00196 const u8 *kde, size_t kde_len,
00197 int keyidx, int encr, int force_version);
00198 int wpa_auth_for_each_sta(struct wpa_authenticator *wpa_auth,
00199 int (*cb)(struct wpa_state_machine *sm, void *ctx),
00200 void *cb_ctx);
00201 int wpa_auth_for_each_auth(struct wpa_authenticator *wpa_auth,
00202 int (*cb)(struct wpa_authenticator *a, void *ctx),
00203 void *cb_ctx);
00204
00205 #ifdef CONFIG_PEERKEY
00206 int wpa_stsl_remove(struct wpa_authenticator *wpa_auth,
00207 struct wpa_stsl_negotiation *neg);
00208 void wpa_smk_error(struct wpa_authenticator *wpa_auth,
00209 struct wpa_state_machine *sm, struct wpa_eapol_key *key);
00210 void wpa_smk_m1(struct wpa_authenticator *wpa_auth,
00211 struct wpa_state_machine *sm, struct wpa_eapol_key *key);
00212 void wpa_smk_m3(struct wpa_authenticator *wpa_auth,
00213 struct wpa_state_machine *sm, struct wpa_eapol_key *key);
00214 #endif
00215
00216 #ifdef CONFIG_IEEE80211R
00217 int wpa_write_mdie(struct wpa_auth_config *conf, u8 *buf, size_t len);
00218 int wpa_write_ftie(struct wpa_auth_config *conf, const u8 *r0kh_id,
00219 size_t r0kh_id_len,
00220 const u8 *anonce, const u8 *snonce,
00221 u8 *buf, size_t len, const u8 *subelem,
00222 size_t subelem_len);
00223 int wpa_auth_derive_ptk_ft(struct wpa_state_machine *sm, const u8 *pmk,
00224 struct wpa_ptk *ptk, size_t ptk_len);
00225 struct wpa_ft_pmk_cache * wpa_ft_pmk_cache_init(void);
00226 void wpa_ft_pmk_cache_deinit(struct wpa_ft_pmk_cache *cache);
00227 void wpa_ft_install_ptk(struct wpa_state_machine *sm);
00228 #endif
00229
00230 #endif