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

Generated on Sat Nov 21 23:16:49 2009 for hostapd by  doxygen 1.6.1