wpa_supplicant / hostapd 2.0

wpa_auth.h

Go to the documentation of this file.
00001 
00010 #ifndef WPA_AUTH_H
00011 #define WPA_AUTH_H
00012 
00013 #include "common/defs.h"
00014 #include "common/eapol_common.h"
00015 #include "common/wpa_common.h"
00016 
00017 #ifdef _MSC_VER
00018 #pragma pack(push, 1)
00019 #endif /* _MSC_VER */
00020 
00021 /* IEEE Std 802.11r-2008, 11A.10.3 - Remote request/response frame definition
00022  */
00023 struct ft_rrb_frame {
00024         u8 frame_type; /* RSN_REMOTE_FRAME_TYPE_FT_RRB */
00025         u8 packet_type; /* FT_PACKET_REQUEST/FT_PACKET_RESPONSE */
00026         le16 action_length; /* little endian length of action_frame */
00027         u8 ap_address[ETH_ALEN];
00028         /*
00029          * Followed by action_length bytes of FT Action frame (from Category
00030          * field to the end of Action Frame body.
00031          */
00032 } STRUCT_PACKED;
00033 
00034 #define RSN_REMOTE_FRAME_TYPE_FT_RRB 1
00035 
00036 #define FT_PACKET_REQUEST 0
00037 #define FT_PACKET_RESPONSE 1
00038 /* Vendor-specific types for R0KH-R1KH protocol; not defined in 802.11r */
00039 #define FT_PACKET_R0KH_R1KH_PULL 200
00040 #define FT_PACKET_R0KH_R1KH_RESP 201
00041 #define FT_PACKET_R0KH_R1KH_PUSH 202
00042 
00043 #define FT_R0KH_R1KH_PULL_DATA_LEN 44
00044 #define FT_R0KH_R1KH_RESP_DATA_LEN 76
00045 #define FT_R0KH_R1KH_PUSH_DATA_LEN 88
00046 
00047 struct ft_r0kh_r1kh_pull_frame {
00048         u8 frame_type; /* RSN_REMOTE_FRAME_TYPE_FT_RRB */
00049         u8 packet_type; /* FT_PACKET_R0KH_R1KH_PULL */
00050         le16 data_length; /* little endian length of data (44) */
00051         u8 ap_address[ETH_ALEN];
00052 
00053         u8 nonce[16];
00054         u8 pmk_r0_name[WPA_PMK_NAME_LEN];
00055         u8 r1kh_id[FT_R1KH_ID_LEN];
00056         u8 s1kh_id[ETH_ALEN];
00057         u8 pad[4]; /* 8-octet boundary for AES key wrap */
00058         u8 key_wrap_extra[8];
00059 } STRUCT_PACKED;
00060 
00061 struct ft_r0kh_r1kh_resp_frame {
00062         u8 frame_type; /* RSN_REMOTE_FRAME_TYPE_FT_RRB */
00063         u8 packet_type; /* FT_PACKET_R0KH_R1KH_RESP */
00064         le16 data_length; /* little endian length of data (76) */
00065         u8 ap_address[ETH_ALEN];
00066 
00067         u8 nonce[16]; /* copied from pull */
00068         u8 r1kh_id[FT_R1KH_ID_LEN]; /* copied from pull */
00069         u8 s1kh_id[ETH_ALEN]; /* copied from pull */
00070         u8 pmk_r1[PMK_LEN];
00071         u8 pmk_r1_name[WPA_PMK_NAME_LEN];
00072         le16 pairwise;
00073         u8 pad[2]; /* 8-octet boundary for AES key wrap */
00074         u8 key_wrap_extra[8];
00075 } STRUCT_PACKED;
00076 
00077 struct ft_r0kh_r1kh_push_frame {
00078         u8 frame_type; /* RSN_REMOTE_FRAME_TYPE_FT_RRB */
00079         u8 packet_type; /* FT_PACKET_R0KH_R1KH_PUSH */
00080         le16 data_length; /* little endian length of data (88) */
00081         u8 ap_address[ETH_ALEN];
00082 
00083         /* Encrypted with AES key-wrap */
00084         u8 timestamp[4]; /* current time in seconds since unix epoch, little
00085                           * endian */
00086         u8 r1kh_id[FT_R1KH_ID_LEN];
00087         u8 s1kh_id[ETH_ALEN];
00088         u8 pmk_r0_name[WPA_PMK_NAME_LEN];
00089         u8 pmk_r1[PMK_LEN];
00090         u8 pmk_r1_name[WPA_PMK_NAME_LEN];
00091         le16 pairwise;
00092         u8 pad[6]; /* 8-octet boundary for AES key wrap */
00093         u8 key_wrap_extra[8];
00094 } STRUCT_PACKED;
00095 
00096 #ifdef _MSC_VER
00097 #pragma pack(pop)
00098 #endif /* _MSC_VER */
00099 
00100 
00101 /* per STA state machine data */
00102 
00103 struct wpa_authenticator;
00104 struct wpa_state_machine;
00105 struct rsn_pmksa_cache_entry;
00106 struct eapol_state_machine;
00107 
00108 
00109 struct ft_remote_r0kh {
00110         struct ft_remote_r0kh *next;
00111         u8 addr[ETH_ALEN];
00112         u8 id[FT_R0KH_ID_MAX_LEN];
00113         size_t id_len;
00114         u8 key[16];
00115 };
00116 
00117 
00118 struct ft_remote_r1kh {
00119         struct ft_remote_r1kh *next;
00120         u8 addr[ETH_ALEN];
00121         u8 id[FT_R1KH_ID_LEN];
00122         u8 key[16];
00123 };
00124 
00125 
00126 struct wpa_auth_config {
00127         int wpa;
00128         int wpa_key_mgmt;
00129         int wpa_pairwise;
00130         int wpa_group;
00131         int wpa_group_rekey;
00132         int wpa_strict_rekey;
00133         int wpa_gmk_rekey;
00134         int wpa_ptk_rekey;
00135         int rsn_pairwise;
00136         int rsn_preauth;
00137         int eapol_version;
00138         int peerkey;
00139         int wmm_enabled;
00140         int wmm_uapsd;
00141         int disable_pmksa_caching;
00142         int okc;
00143         int tx_status;
00144 #ifdef CONFIG_IEEE80211W
00145         enum mfp_options ieee80211w;
00146 #endif /* CONFIG_IEEE80211W */
00147 #ifdef CONFIG_IEEE80211R
00148 #define SSID_LEN 32
00149         u8 ssid[SSID_LEN];
00150         size_t ssid_len;
00151         u8 mobility_domain[MOBILITY_DOMAIN_ID_LEN];
00152         u8 r0_key_holder[FT_R0KH_ID_MAX_LEN];
00153         size_t r0_key_holder_len;
00154         u8 r1_key_holder[FT_R1KH_ID_LEN];
00155         u32 r0_key_lifetime;
00156         u32 reassociation_deadline;
00157         struct ft_remote_r0kh *r0kh_list;
00158         struct ft_remote_r1kh *r1kh_list;
00159         int pmk_r1_push;
00160         int ft_over_ds;
00161 #endif /* CONFIG_IEEE80211R */
00162 };
00163 
00164 typedef enum {
00165         LOGGER_DEBUG, LOGGER_INFO, LOGGER_WARNING
00166 } logger_level;
00167 
00168 typedef enum {
00169         WPA_EAPOL_portEnabled, WPA_EAPOL_portValid, WPA_EAPOL_authorized,
00170         WPA_EAPOL_portControl_Auto, WPA_EAPOL_keyRun, WPA_EAPOL_keyAvailable,
00171         WPA_EAPOL_keyDone, WPA_EAPOL_inc_EapolFramesTx
00172 } wpa_eapol_variable;
00173 
00174 struct wpa_auth_callbacks {
00175         void *ctx;
00176         void (*logger)(void *ctx, const u8 *addr, logger_level level,
00177                        const char *txt);
00178         void (*disconnect)(void *ctx, const u8 *addr, u16 reason);
00179         void (*mic_failure_report)(void *ctx, const u8 *addr);
00180         void (*set_eapol)(void *ctx, const u8 *addr, wpa_eapol_variable var,
00181                           int value);
00182         int (*get_eapol)(void *ctx, const u8 *addr, wpa_eapol_variable var);
00183         const u8 * (*get_psk)(void *ctx, const u8 *addr, const u8 *prev_psk);
00184         int (*get_msk)(void *ctx, const u8 *addr, u8 *msk, size_t *len);
00185         int (*set_key)(void *ctx, int vlan_id, enum wpa_alg alg,
00186                        const u8 *addr, int idx, u8 *key, size_t key_len);
00187         int (*get_seqnum)(void *ctx, const u8 *addr, int idx, u8 *seq);
00188         int (*send_eapol)(void *ctx, const u8 *addr, const u8 *data,
00189                           size_t data_len, int encrypt);
00190         int (*for_each_sta)(void *ctx, int (*cb)(struct wpa_state_machine *sm,
00191                                                  void *ctx), void *cb_ctx);
00192         int (*for_each_auth)(void *ctx, int (*cb)(struct wpa_authenticator *a,
00193                                                   void *ctx), void *cb_ctx);
00194         int (*send_ether)(void *ctx, const u8 *dst, u16 proto, const u8 *data,
00195                           size_t data_len);
00196 #ifdef CONFIG_IEEE80211R
00197         struct wpa_state_machine * (*add_sta)(void *ctx, const u8 *sta_addr);
00198         int (*send_ft_action)(void *ctx, const u8 *dst,
00199                               const u8 *data, size_t data_len);
00200 #endif /* CONFIG_IEEE80211R */
00201 };
00202 
00203 struct wpa_authenticator * wpa_init(const u8 *addr,
00204                                     struct wpa_auth_config *conf,
00205                                     struct wpa_auth_callbacks *cb);
00206 int wpa_init_keys(struct wpa_authenticator *wpa_auth);
00207 void wpa_deinit(struct wpa_authenticator *wpa_auth);
00208 int wpa_reconfig(struct wpa_authenticator *wpa_auth,
00209                  struct wpa_auth_config *conf);
00210 
00211 enum {
00212         WPA_IE_OK, WPA_INVALID_IE, WPA_INVALID_GROUP, WPA_INVALID_PAIRWISE,
00213         WPA_INVALID_AKMP, WPA_NOT_ENABLED, WPA_ALLOC_FAIL,
00214         WPA_MGMT_FRAME_PROTECTION_VIOLATION, WPA_INVALID_MGMT_GROUP_CIPHER,
00215         WPA_INVALID_MDIE, WPA_INVALID_PROTO
00216 };
00217         
00218 int wpa_validate_wpa_ie(struct wpa_authenticator *wpa_auth,
00219                         struct wpa_state_machine *sm,
00220                         const u8 *wpa_ie, size_t wpa_ie_len,
00221                         const u8 *mdie, size_t mdie_len);
00222 int wpa_auth_uses_mfp(struct wpa_state_machine *sm);
00223 struct wpa_state_machine *
00224 wpa_auth_sta_init(struct wpa_authenticator *wpa_auth, const u8 *addr);
00225 int wpa_auth_sta_associated(struct wpa_authenticator *wpa_auth,
00226                             struct wpa_state_machine *sm);
00227 void wpa_auth_sta_no_wpa(struct wpa_state_machine *sm);
00228 void wpa_auth_sta_deinit(struct wpa_state_machine *sm);
00229 void wpa_receive(struct wpa_authenticator *wpa_auth,
00230                  struct wpa_state_machine *sm,
00231                  u8 *data, size_t data_len);
00232 typedef enum {
00233         WPA_AUTH, WPA_ASSOC, WPA_DISASSOC, WPA_DEAUTH, WPA_REAUTH,
00234         WPA_REAUTH_EAPOL, WPA_ASSOC_FT
00235 } wpa_event;
00236 void wpa_remove_ptk(struct wpa_state_machine *sm);
00237 int wpa_auth_sm_event(struct wpa_state_machine *sm, wpa_event event);
00238 void wpa_auth_sm_notify(struct wpa_state_machine *sm);
00239 void wpa_gtk_rekey(struct wpa_authenticator *wpa_auth);
00240 int wpa_get_mib(struct wpa_authenticator *wpa_auth, char *buf, size_t buflen);
00241 int wpa_get_mib_sta(struct wpa_state_machine *sm, char *buf, size_t buflen);
00242 void wpa_auth_countermeasures_start(struct wpa_authenticator *wpa_auth);
00243 int wpa_auth_pairwise_set(struct wpa_state_machine *sm);
00244 int wpa_auth_get_pairwise(struct wpa_state_machine *sm);
00245 int wpa_auth_sta_key_mgmt(struct wpa_state_machine *sm);
00246 int wpa_auth_sta_wpa_version(struct wpa_state_machine *sm);
00247 int wpa_auth_sta_clear_pmksa(struct wpa_state_machine *sm,
00248                              struct rsn_pmksa_cache_entry *entry);
00249 struct rsn_pmksa_cache_entry *
00250 wpa_auth_sta_get_pmksa(struct wpa_state_machine *sm);
00251 void wpa_auth_sta_local_mic_failure_report(struct wpa_state_machine *sm);
00252 const u8 * wpa_auth_get_wpa_ie(struct wpa_authenticator *wpa_auth,
00253                                size_t *len);
00254 int wpa_auth_pmksa_add(struct wpa_state_machine *sm, const u8 *pmk,
00255                        int session_timeout, struct eapol_state_machine *eapol);
00256 int wpa_auth_pmksa_add_preauth(struct wpa_authenticator *wpa_auth,
00257                                const u8 *pmk, size_t len, const u8 *sta_addr,
00258                                int session_timeout,
00259                                struct eapol_state_machine *eapol);
00260 int wpa_auth_sta_set_vlan(struct wpa_state_machine *sm, int vlan_id);
00261 void wpa_auth_eapol_key_tx_status(struct wpa_authenticator *wpa_auth,
00262                                   struct wpa_state_machine *sm, int ack);
00263 
00264 #ifdef CONFIG_IEEE80211R
00265 u8 * wpa_sm_write_assoc_resp_ies(struct wpa_state_machine *sm, u8 *pos,
00266                                  size_t max_len, int auth_alg,
00267                                  const u8 *req_ies, size_t req_ies_len);
00268 void wpa_ft_process_auth(struct wpa_state_machine *sm, const u8 *bssid,
00269                          u16 auth_transaction, const u8 *ies, size_t ies_len,
00270                          void (*cb)(void *ctx, const u8 *dst, const u8 *bssid,
00271                                     u16 auth_transaction, u16 resp,
00272                                     const u8 *ies, size_t ies_len),
00273                          void *ctx);
00274 u16 wpa_ft_validate_reassoc(struct wpa_state_machine *sm, const u8 *ies,
00275                             size_t ies_len);
00276 int wpa_ft_action_rx(struct wpa_state_machine *sm, const u8 *data, size_t len);
00277 int wpa_ft_rrb_rx(struct wpa_authenticator *wpa_auth, const u8 *src_addr,
00278                   const u8 *data, size_t data_len);
00279 void wpa_ft_push_pmk_r1(struct wpa_authenticator *wpa_auth, const u8 *addr);
00280 #endif /* CONFIG_IEEE80211R */
00281 
00282 #endif /* WPA_AUTH_H */
00283 
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Defines