2008-02-27 20:34:43 -05:00
|
|
|
/*
|
|
|
|
* hostapd - IEEE 802.11i-2004 / WPA Authenticator
|
|
|
|
* Copyright (c) 2004-2007, Jouni Malinen <j@w1.fi>
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License version 2 as
|
|
|
|
* published by the Free Software Foundation.
|
|
|
|
*
|
|
|
|
* Alternatively, this software may be distributed under the terms of BSD
|
|
|
|
* license.
|
|
|
|
*
|
|
|
|
* See README and COPYING for more details.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef WPA_AUTH_H
|
|
|
|
#define WPA_AUTH_H
|
|
|
|
|
2009-11-29 10:51:55 -05:00
|
|
|
#include "common/defs.h"
|
|
|
|
#include "common/eapol_common.h"
|
|
|
|
#include "common/wpa_common.h"
|
2008-02-27 20:34:43 -05:00
|
|
|
|
|
|
|
#ifdef _MSC_VER
|
|
|
|
#pragma pack(push, 1)
|
|
|
|
#endif /* _MSC_VER */
|
|
|
|
|
2008-08-15 04:25:24 -04:00
|
|
|
/* IEEE Std 802.11r-2008, 11A.10.3 - Remote request/response frame definition
|
|
|
|
*/
|
2008-02-27 20:34:43 -05:00
|
|
|
struct ft_rrb_frame {
|
|
|
|
u8 frame_type; /* RSN_REMOTE_FRAME_TYPE_FT_RRB */
|
|
|
|
u8 packet_type; /* FT_PACKET_REQUEST/FT_PACKET_RESPONSE */
|
2009-01-03 14:00:38 -05:00
|
|
|
le16 action_length; /* little endian length of action_frame */
|
2008-02-27 20:34:43 -05:00
|
|
|
u8 ap_address[ETH_ALEN];
|
|
|
|
/*
|
|
|
|
* Followed by action_length bytes of FT Action frame (from Category
|
|
|
|
* field to the end of Action Frame body.
|
|
|
|
*/
|
|
|
|
} STRUCT_PACKED;
|
|
|
|
|
|
|
|
#define RSN_REMOTE_FRAME_TYPE_FT_RRB 1
|
|
|
|
|
|
|
|
#define FT_PACKET_REQUEST 0
|
|
|
|
#define FT_PACKET_RESPONSE 1
|
|
|
|
/* Vendor-specific types for R0KH-R1KH protocol; not defined in 802.11r */
|
|
|
|
#define FT_PACKET_R0KH_R1KH_PULL 200
|
|
|
|
#define FT_PACKET_R0KH_R1KH_RESP 201
|
|
|
|
#define FT_PACKET_R0KH_R1KH_PUSH 202
|
|
|
|
|
|
|
|
#define FT_R0KH_R1KH_PULL_DATA_LEN 44
|
|
|
|
#define FT_R0KH_R1KH_RESP_DATA_LEN 76
|
2010-03-07 15:18:33 -05:00
|
|
|
#define FT_R0KH_R1KH_PUSH_DATA_LEN 88
|
2008-02-27 20:34:43 -05:00
|
|
|
|
|
|
|
struct ft_r0kh_r1kh_pull_frame {
|
|
|
|
u8 frame_type; /* RSN_REMOTE_FRAME_TYPE_FT_RRB */
|
|
|
|
u8 packet_type; /* FT_PACKET_R0KH_R1KH_PULL */
|
2009-01-03 14:00:38 -05:00
|
|
|
le16 data_length; /* little endian length of data (44) */
|
2008-02-27 20:34:43 -05:00
|
|
|
u8 ap_address[ETH_ALEN];
|
|
|
|
|
|
|
|
u8 nonce[16];
|
|
|
|
u8 pmk_r0_name[WPA_PMK_NAME_LEN];
|
|
|
|
u8 r1kh_id[FT_R1KH_ID_LEN];
|
|
|
|
u8 s1kh_id[ETH_ALEN];
|
|
|
|
u8 pad[4]; /* 8-octet boundary for AES key wrap */
|
|
|
|
u8 key_wrap_extra[8];
|
|
|
|
} STRUCT_PACKED;
|
|
|
|
|
|
|
|
struct ft_r0kh_r1kh_resp_frame {
|
|
|
|
u8 frame_type; /* RSN_REMOTE_FRAME_TYPE_FT_RRB */
|
|
|
|
u8 packet_type; /* FT_PACKET_R0KH_R1KH_RESP */
|
2009-01-03 14:00:38 -05:00
|
|
|
le16 data_length; /* little endian length of data (76) */
|
2008-02-27 20:34:43 -05:00
|
|
|
u8 ap_address[ETH_ALEN];
|
|
|
|
|
|
|
|
u8 nonce[16]; /* copied from pull */
|
|
|
|
u8 r1kh_id[FT_R1KH_ID_LEN]; /* copied from pull */
|
|
|
|
u8 s1kh_id[ETH_ALEN]; /* copied from pull */
|
|
|
|
u8 pmk_r1[PMK_LEN];
|
|
|
|
u8 pmk_r1_name[WPA_PMK_NAME_LEN];
|
2010-03-07 15:18:33 -05:00
|
|
|
le16 pairwise;
|
|
|
|
u8 pad[2]; /* 8-octet boundary for AES key wrap */
|
2008-02-27 20:34:43 -05:00
|
|
|
u8 key_wrap_extra[8];
|
|
|
|
} STRUCT_PACKED;
|
|
|
|
|
|
|
|
struct ft_r0kh_r1kh_push_frame {
|
|
|
|
u8 frame_type; /* RSN_REMOTE_FRAME_TYPE_FT_RRB */
|
|
|
|
u8 packet_type; /* FT_PACKET_R0KH_R1KH_PUSH */
|
2010-03-07 15:18:33 -05:00
|
|
|
le16 data_length; /* little endian length of data (88) */
|
2008-02-27 20:34:43 -05:00
|
|
|
u8 ap_address[ETH_ALEN];
|
|
|
|
|
|
|
|
/* Encrypted with AES key-wrap */
|
|
|
|
u8 timestamp[4]; /* current time in seconds since unix epoch, little
|
|
|
|
* endian */
|
|
|
|
u8 r1kh_id[FT_R1KH_ID_LEN];
|
|
|
|
u8 s1kh_id[ETH_ALEN];
|
|
|
|
u8 pmk_r0_name[WPA_PMK_NAME_LEN];
|
|
|
|
u8 pmk_r1[PMK_LEN];
|
|
|
|
u8 pmk_r1_name[WPA_PMK_NAME_LEN];
|
2010-03-07 15:18:33 -05:00
|
|
|
le16 pairwise;
|
|
|
|
u8 pad[6]; /* 8-octet boundary for AES key wrap */
|
2008-02-27 20:34:43 -05:00
|
|
|
u8 key_wrap_extra[8];
|
|
|
|
} STRUCT_PACKED;
|
|
|
|
|
|
|
|
#ifdef _MSC_VER
|
|
|
|
#pragma pack(pop)
|
|
|
|
#endif /* _MSC_VER */
|
|
|
|
|
|
|
|
|
|
|
|
/* per STA state machine data */
|
|
|
|
|
|
|
|
struct wpa_authenticator;
|
|
|
|
struct wpa_state_machine;
|
|
|
|
struct rsn_pmksa_cache_entry;
|
|
|
|
struct eapol_state_machine;
|
|
|
|
|
|
|
|
|
|
|
|
struct ft_remote_r0kh {
|
|
|
|
struct ft_remote_r0kh *next;
|
|
|
|
u8 addr[ETH_ALEN];
|
|
|
|
u8 id[FT_R0KH_ID_MAX_LEN];
|
|
|
|
size_t id_len;
|
|
|
|
u8 key[16];
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
struct ft_remote_r1kh {
|
|
|
|
struct ft_remote_r1kh *next;
|
|
|
|
u8 addr[ETH_ALEN];
|
|
|
|
u8 id[FT_R1KH_ID_LEN];
|
|
|
|
u8 key[16];
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
struct wpa_auth_config {
|
|
|
|
int wpa;
|
|
|
|
int wpa_key_mgmt;
|
|
|
|
int wpa_pairwise;
|
|
|
|
int wpa_group;
|
|
|
|
int wpa_group_rekey;
|
|
|
|
int wpa_strict_rekey;
|
|
|
|
int wpa_gmk_rekey;
|
2008-11-06 12:57:21 -05:00
|
|
|
int wpa_ptk_rekey;
|
2008-02-27 20:34:43 -05:00
|
|
|
int rsn_pairwise;
|
|
|
|
int rsn_preauth;
|
|
|
|
int eapol_version;
|
|
|
|
int peerkey;
|
2009-03-04 05:33:24 -05:00
|
|
|
int wmm_enabled;
|
2010-04-11 04:32:15 -04:00
|
|
|
int wmm_uapsd;
|
2008-08-03 13:17:58 -04:00
|
|
|
int okc;
|
2008-02-27 20:34:43 -05:00
|
|
|
#ifdef CONFIG_IEEE80211W
|
2010-01-03 14:02:51 -05:00
|
|
|
enum mfp_options ieee80211w;
|
2008-02-27 20:34:43 -05:00
|
|
|
#endif /* CONFIG_IEEE80211W */
|
|
|
|
#ifdef CONFIG_IEEE80211R
|
|
|
|
#define SSID_LEN 32
|
|
|
|
u8 ssid[SSID_LEN];
|
|
|
|
size_t ssid_len;
|
|
|
|
u8 mobility_domain[MOBILITY_DOMAIN_ID_LEN];
|
|
|
|
u8 r0_key_holder[FT_R0KH_ID_MAX_LEN];
|
|
|
|
size_t r0_key_holder_len;
|
|
|
|
u8 r1_key_holder[FT_R1KH_ID_LEN];
|
|
|
|
u32 r0_key_lifetime;
|
|
|
|
u32 reassociation_deadline;
|
|
|
|
struct ft_remote_r0kh *r0kh_list;
|
|
|
|
struct ft_remote_r1kh *r1kh_list;
|
|
|
|
int pmk_r1_push;
|
|
|
|
#endif /* CONFIG_IEEE80211R */
|
|
|
|
};
|
|
|
|
|
|
|
|
typedef enum {
|
|
|
|
LOGGER_DEBUG, LOGGER_INFO, LOGGER_WARNING
|
|
|
|
} logger_level;
|
|
|
|
|
|
|
|
typedef enum {
|
|
|
|
WPA_EAPOL_portEnabled, WPA_EAPOL_portValid, WPA_EAPOL_authorized,
|
|
|
|
WPA_EAPOL_portControl_Auto, WPA_EAPOL_keyRun, WPA_EAPOL_keyAvailable,
|
|
|
|
WPA_EAPOL_keyDone, WPA_EAPOL_inc_EapolFramesTx
|
|
|
|
} wpa_eapol_variable;
|
|
|
|
|
|
|
|
struct wpa_auth_callbacks {
|
|
|
|
void *ctx;
|
|
|
|
void (*logger)(void *ctx, const u8 *addr, logger_level level,
|
|
|
|
const char *txt);
|
|
|
|
void (*disconnect)(void *ctx, const u8 *addr, u16 reason);
|
|
|
|
void (*mic_failure_report)(void *ctx, const u8 *addr);
|
|
|
|
void (*set_eapol)(void *ctx, const u8 *addr, wpa_eapol_variable var,
|
|
|
|
int value);
|
|
|
|
int (*get_eapol)(void *ctx, const u8 *addr, wpa_eapol_variable var);
|
|
|
|
const u8 * (*get_psk)(void *ctx, const u8 *addr, const u8 *prev_psk);
|
|
|
|
int (*get_msk)(void *ctx, const u8 *addr, u8 *msk, size_t *len);
|
2009-12-26 03:35:08 -05:00
|
|
|
int (*set_key)(void *ctx, int vlan_id, enum wpa_alg alg,
|
|
|
|
const u8 *addr, int idx, u8 *key, size_t key_len);
|
2008-02-27 20:34:43 -05:00
|
|
|
int (*get_seqnum)(void *ctx, const u8 *addr, int idx, u8 *seq);
|
|
|
|
int (*send_eapol)(void *ctx, const u8 *addr, const u8 *data,
|
|
|
|
size_t data_len, int encrypt);
|
|
|
|
int (*for_each_sta)(void *ctx, int (*cb)(struct wpa_state_machine *sm,
|
|
|
|
void *ctx), void *cb_ctx);
|
2008-08-03 13:17:58 -04:00
|
|
|
int (*for_each_auth)(void *ctx, int (*cb)(struct wpa_authenticator *a,
|
|
|
|
void *ctx), void *cb_ctx);
|
2008-02-27 20:34:43 -05:00
|
|
|
int (*send_ether)(void *ctx, const u8 *dst, u16 proto, const u8 *data,
|
|
|
|
size_t data_len);
|
|
|
|
#ifdef CONFIG_IEEE80211R
|
|
|
|
struct wpa_state_machine * (*add_sta)(void *ctx, const u8 *sta_addr);
|
|
|
|
int (*send_ft_action)(void *ctx, const u8 *dst,
|
|
|
|
const u8 *data, size_t data_len);
|
|
|
|
#endif /* CONFIG_IEEE80211R */
|
|
|
|
};
|
|
|
|
|
|
|
|
struct wpa_authenticator * wpa_init(const u8 *addr,
|
|
|
|
struct wpa_auth_config *conf,
|
|
|
|
struct wpa_auth_callbacks *cb);
|
|
|
|
void wpa_deinit(struct wpa_authenticator *wpa_auth);
|
|
|
|
int wpa_reconfig(struct wpa_authenticator *wpa_auth,
|
|
|
|
struct wpa_auth_config *conf);
|
|
|
|
|
|
|
|
enum {
|
|
|
|
WPA_IE_OK, WPA_INVALID_IE, WPA_INVALID_GROUP, WPA_INVALID_PAIRWISE,
|
|
|
|
WPA_INVALID_AKMP, WPA_NOT_ENABLED, WPA_ALLOC_FAIL,
|
|
|
|
WPA_MGMT_FRAME_PROTECTION_VIOLATION, WPA_INVALID_MGMT_GROUP_CIPHER,
|
2008-10-14 23:34:39 -04:00
|
|
|
WPA_INVALID_MDIE, WPA_INVALID_PROTO
|
2008-02-27 20:34:43 -05:00
|
|
|
};
|
|
|
|
|
|
|
|
int wpa_validate_wpa_ie(struct wpa_authenticator *wpa_auth,
|
|
|
|
struct wpa_state_machine *sm,
|
|
|
|
const u8 *wpa_ie, size_t wpa_ie_len,
|
|
|
|
const u8 *mdie, size_t mdie_len);
|
2008-06-17 04:21:11 -04:00
|
|
|
int wpa_auth_uses_mfp(struct wpa_state_machine *sm);
|
2008-02-27 20:34:43 -05:00
|
|
|
struct wpa_state_machine *
|
|
|
|
wpa_auth_sta_init(struct wpa_authenticator *wpa_auth, const u8 *addr);
|
2010-01-10 14:45:44 -05:00
|
|
|
int wpa_auth_sta_associated(struct wpa_authenticator *wpa_auth,
|
|
|
|
struct wpa_state_machine *sm);
|
2008-11-30 10:22:51 -05:00
|
|
|
void wpa_auth_sta_no_wpa(struct wpa_state_machine *sm);
|
2008-02-27 20:34:43 -05:00
|
|
|
void wpa_auth_sta_deinit(struct wpa_state_machine *sm);
|
|
|
|
void wpa_receive(struct wpa_authenticator *wpa_auth,
|
|
|
|
struct wpa_state_machine *sm,
|
|
|
|
u8 *data, size_t data_len);
|
|
|
|
typedef enum {
|
|
|
|
WPA_AUTH, WPA_ASSOC, WPA_DISASSOC, WPA_DEAUTH, WPA_REAUTH,
|
|
|
|
WPA_REAUTH_EAPOL, WPA_ASSOC_FT
|
|
|
|
} wpa_event;
|
|
|
|
void wpa_remove_ptk(struct wpa_state_machine *sm);
|
2010-01-10 14:45:44 -05:00
|
|
|
int wpa_auth_sm_event(struct wpa_state_machine *sm, wpa_event event);
|
2008-02-27 20:34:43 -05:00
|
|
|
void wpa_auth_sm_notify(struct wpa_state_machine *sm);
|
|
|
|
void wpa_gtk_rekey(struct wpa_authenticator *wpa_auth);
|
|
|
|
int wpa_get_mib(struct wpa_authenticator *wpa_auth, char *buf, size_t buflen);
|
|
|
|
int wpa_get_mib_sta(struct wpa_state_machine *sm, char *buf, size_t buflen);
|
|
|
|
void wpa_auth_countermeasures_start(struct wpa_authenticator *wpa_auth);
|
|
|
|
int wpa_auth_pairwise_set(struct wpa_state_machine *sm);
|
2008-12-22 07:05:53 -05:00
|
|
|
int wpa_auth_get_pairwise(struct wpa_state_machine *sm);
|
2008-02-27 20:34:43 -05:00
|
|
|
int wpa_auth_sta_key_mgmt(struct wpa_state_machine *sm);
|
|
|
|
int wpa_auth_sta_wpa_version(struct wpa_state_machine *sm);
|
|
|
|
int wpa_auth_sta_clear_pmksa(struct wpa_state_machine *sm,
|
|
|
|
struct rsn_pmksa_cache_entry *entry);
|
|
|
|
struct rsn_pmksa_cache_entry *
|
|
|
|
wpa_auth_sta_get_pmksa(struct wpa_state_machine *sm);
|
|
|
|
void wpa_auth_sta_local_mic_failure_report(struct wpa_state_machine *sm);
|
|
|
|
const u8 * wpa_auth_get_wpa_ie(struct wpa_authenticator *wpa_auth,
|
|
|
|
size_t *len);
|
|
|
|
int wpa_auth_pmksa_add(struct wpa_state_machine *sm, const u8 *pmk,
|
|
|
|
int session_timeout, struct eapol_state_machine *eapol);
|
|
|
|
int wpa_auth_pmksa_add_preauth(struct wpa_authenticator *wpa_auth,
|
|
|
|
const u8 *pmk, size_t len, const u8 *sta_addr,
|
|
|
|
int session_timeout,
|
|
|
|
struct eapol_state_machine *eapol);
|
|
|
|
int wpa_auth_sta_set_vlan(struct wpa_state_machine *sm, int vlan_id);
|
|
|
|
|
|
|
|
#ifdef CONFIG_IEEE80211R
|
|
|
|
u8 * wpa_sm_write_assoc_resp_ies(struct wpa_state_machine *sm, u8 *pos,
|
2009-03-09 16:25:58 -04:00
|
|
|
size_t max_len, int auth_alg,
|
|
|
|
const u8 *req_ies, size_t req_ies_len);
|
2008-02-27 20:34:43 -05:00
|
|
|
void wpa_ft_process_auth(struct wpa_state_machine *sm, const u8 *bssid,
|
|
|
|
u16 auth_transaction, const u8 *ies, size_t ies_len,
|
|
|
|
void (*cb)(void *ctx, const u8 *dst, const u8 *bssid,
|
|
|
|
u16 auth_transaction, u16 resp,
|
|
|
|
const u8 *ies, size_t ies_len),
|
|
|
|
void *ctx);
|
|
|
|
u16 wpa_ft_validate_reassoc(struct wpa_state_machine *sm, const u8 *ies,
|
|
|
|
size_t ies_len);
|
|
|
|
int wpa_ft_action_rx(struct wpa_state_machine *sm, const u8 *data, size_t len);
|
|
|
|
int wpa_ft_rrb_rx(struct wpa_authenticator *wpa_auth, const u8 *src_addr,
|
|
|
|
const u8 *data, size_t data_len);
|
|
|
|
void wpa_ft_push_pmk_r1(struct wpa_authenticator *wpa_auth, const u8 *addr);
|
|
|
|
#endif /* CONFIG_IEEE80211R */
|
|
|
|
|
|
|
|
#endif /* WPA_AUTH_H */
|