wpa.h

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

Generated on Sat Nov 28 23:07:46 2009 for wpa_supplicant/hostapd by  doxygen 1.6.1