Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 1 | /* |
| 2 | * hostapd - IEEE 802.11i-2004 / WPA Authenticator |
Dmitry Shmidt | d2986c2 | 2017-10-23 14:22:09 -0700 | [diff] [blame^] | 3 | * Copyright (c) 2004-2017, Jouni Malinen <j@w1.fi> |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 4 | * |
Dmitry Shmidt | c5ec7f5 | 2012-03-06 16:33:24 -0800 | [diff] [blame] | 5 | * This software may be distributed under the terms of the BSD license. |
| 6 | * See README for more details. |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 7 | */ |
| 8 | |
| 9 | #ifndef WPA_AUTH_H |
| 10 | #define WPA_AUTH_H |
| 11 | |
| 12 | #include "common/defs.h" |
| 13 | #include "common/eapol_common.h" |
| 14 | #include "common/wpa_common.h" |
Dmitry Shmidt | 9d9e602 | 2015-04-23 10:34:55 -0700 | [diff] [blame] | 15 | #include "common/ieee802_11_defs.h" |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 16 | |
Dmitry Shmidt | d80a401 | 2015-11-05 16:35:40 -0800 | [diff] [blame] | 17 | #define MAX_OWN_IE_OVERRIDE 256 |
| 18 | |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 19 | #ifdef _MSC_VER |
| 20 | #pragma pack(push, 1) |
| 21 | #endif /* _MSC_VER */ |
| 22 | |
| 23 | /* IEEE Std 802.11r-2008, 11A.10.3 - Remote request/response frame definition |
| 24 | */ |
| 25 | struct ft_rrb_frame { |
| 26 | u8 frame_type; /* RSN_REMOTE_FRAME_TYPE_FT_RRB */ |
| 27 | u8 packet_type; /* FT_PACKET_REQUEST/FT_PACKET_RESPONSE */ |
| 28 | le16 action_length; /* little endian length of action_frame */ |
| 29 | u8 ap_address[ETH_ALEN]; |
| 30 | /* |
| 31 | * Followed by action_length bytes of FT Action frame (from Category |
| 32 | * field to the end of Action Frame body. |
| 33 | */ |
| 34 | } STRUCT_PACKED; |
| 35 | |
| 36 | #define RSN_REMOTE_FRAME_TYPE_FT_RRB 1 |
| 37 | |
| 38 | #define FT_PACKET_REQUEST 0 |
| 39 | #define FT_PACKET_RESPONSE 1 |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 40 | |
Dmitry Shmidt | d2986c2 | 2017-10-23 14:22:09 -0700 | [diff] [blame^] | 41 | /* Vendor-specific types for R0KH-R1KH protocol; not defined in 802.11r. These |
| 42 | * use OUI Extended EtherType as the encapsulating format. */ |
| 43 | #define FT_PACKET_R0KH_R1KH_PULL 0x01 |
| 44 | #define FT_PACKET_R0KH_R1KH_RESP 0x02 |
| 45 | #define FT_PACKET_R0KH_R1KH_PUSH 0x03 |
| 46 | #define FT_PACKET_R0KH_R1KH_SEQ_REQ 0x04 |
| 47 | #define FT_PACKET_R0KH_R1KH_SEQ_RESP 0x05 |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 48 | |
Dmitry Shmidt | d2986c2 | 2017-10-23 14:22:09 -0700 | [diff] [blame^] | 49 | /* packet layout |
| 50 | * IEEE 802 extended OUI ethertype frame header |
| 51 | * u16 authlen (little endian) |
| 52 | * multiple of struct ft_rrb_tlv (authenticated only, length = authlen) |
| 53 | * multiple of struct ft_rrb_tlv (AES-SIV encrypted, AES-SIV needs an extra |
| 54 | * blocksize length) |
| 55 | * |
| 56 | * AES-SIV AAD; |
| 57 | * source MAC address (6) |
| 58 | * authenticated-only TLVs (authlen) |
| 59 | * subtype (1; FT_PACKET_*) |
| 60 | */ |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 61 | |
Dmitry Shmidt | d2986c2 | 2017-10-23 14:22:09 -0700 | [diff] [blame^] | 62 | #define FT_RRB_NONCE_LEN 16 |
| 63 | |
| 64 | #define FT_RRB_LAST_EMPTY 0 /* placeholder or padding */ |
| 65 | |
| 66 | #define FT_RRB_SEQ 1 /* struct ft_rrb_seq */ |
| 67 | #define FT_RRB_NONCE 2 /* size FT_RRB_NONCE_LEN */ |
| 68 | #define FT_RRB_TIMESTAMP 3 /* le32 unix seconds */ |
| 69 | |
| 70 | #define FT_RRB_R0KH_ID 4 /* FT_R0KH_ID_MAX_LEN */ |
| 71 | #define FT_RRB_R1KH_ID 5 /* FT_R1KH_ID_LEN */ |
| 72 | #define FT_RRB_S1KH_ID 6 /* ETH_ALEN */ |
| 73 | |
| 74 | #define FT_RRB_PMK_R0_NAME 7 /* WPA_PMK_NAME_LEN */ |
| 75 | #define FT_RRB_PMK_R0 8 /* PMK_LEN */ |
| 76 | #define FT_RRB_PMK_R1_NAME 9 /* WPA_PMK_NAME_LEN */ |
| 77 | #define FT_RRB_PMK_R1 10 /* PMK_LEN */ |
| 78 | |
| 79 | #define FT_RRB_PAIRWISE 11 /* le16 */ |
| 80 | |
| 81 | struct ft_rrb_tlv { |
| 82 | le16 type; |
| 83 | le16 len; |
| 84 | /* followed by data of length len */ |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 85 | } STRUCT_PACKED; |
| 86 | |
Dmitry Shmidt | d2986c2 | 2017-10-23 14:22:09 -0700 | [diff] [blame^] | 87 | struct ft_rrb_seq { |
| 88 | le32 dom; |
| 89 | le32 seq; |
| 90 | le32 ts; |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 91 | } STRUCT_PACKED; |
| 92 | |
Dmitry Shmidt | d2986c2 | 2017-10-23 14:22:09 -0700 | [diff] [blame^] | 93 | /* session TLVs: |
| 94 | * required: PMK_R1, PMK_R1_NAME, PAIRWISE |
| 95 | * |
| 96 | * pull frame TLVs: |
| 97 | * auth: |
| 98 | * required: SEQ, NONCE, R0KH_ID, R1KH_ID |
| 99 | * encrypted: |
| 100 | * required: PMK_R0_NAME, S1KH_ID |
| 101 | * |
| 102 | * response frame TLVs: |
| 103 | * auth: |
| 104 | * required: SEQ, NONCE, R0KH_ID, R1KH_ID |
| 105 | * encrypted: |
| 106 | * required: S1KH_ID |
| 107 | * optional: session TLVs |
| 108 | * |
| 109 | * push frame TLVs: |
| 110 | * auth: |
| 111 | * required: SEQ, R0KH_ID, R1KH_ID |
| 112 | * encrypted: |
| 113 | * required: S1KH_ID, PMK_R0_NAME, session TLVs |
| 114 | * |
| 115 | * sequence number request frame TLVs: |
| 116 | * auth: |
| 117 | * required: R0KH_ID, R1KH_ID, NONCE |
| 118 | * |
| 119 | * sequence number response frame TLVs: |
| 120 | * auth: |
| 121 | * required: SEQ, NONCE, R0KH_ID, R1KH_ID |
| 122 | */ |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 123 | |
| 124 | #ifdef _MSC_VER |
| 125 | #pragma pack(pop) |
| 126 | #endif /* _MSC_VER */ |
| 127 | |
| 128 | |
| 129 | /* per STA state machine data */ |
| 130 | |
| 131 | struct wpa_authenticator; |
| 132 | struct wpa_state_machine; |
| 133 | struct rsn_pmksa_cache_entry; |
| 134 | struct eapol_state_machine; |
Dmitry Shmidt | d2986c2 | 2017-10-23 14:22:09 -0700 | [diff] [blame^] | 135 | struct ft_remote_seq; |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 136 | |
| 137 | |
| 138 | struct ft_remote_r0kh { |
| 139 | struct ft_remote_r0kh *next; |
| 140 | u8 addr[ETH_ALEN]; |
| 141 | u8 id[FT_R0KH_ID_MAX_LEN]; |
| 142 | size_t id_len; |
Dmitry Shmidt | d2986c2 | 2017-10-23 14:22:09 -0700 | [diff] [blame^] | 143 | u8 key[32]; |
| 144 | struct ft_remote_seq *seq; |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 145 | }; |
| 146 | |
| 147 | |
| 148 | struct ft_remote_r1kh { |
| 149 | struct ft_remote_r1kh *next; |
| 150 | u8 addr[ETH_ALEN]; |
| 151 | u8 id[FT_R1KH_ID_LEN]; |
Dmitry Shmidt | d2986c2 | 2017-10-23 14:22:09 -0700 | [diff] [blame^] | 152 | u8 key[32]; |
| 153 | struct ft_remote_seq *seq; |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 154 | }; |
| 155 | |
| 156 | |
| 157 | struct wpa_auth_config { |
| 158 | int wpa; |
| 159 | int wpa_key_mgmt; |
| 160 | int wpa_pairwise; |
| 161 | int wpa_group; |
| 162 | int wpa_group_rekey; |
| 163 | int wpa_strict_rekey; |
| 164 | int wpa_gmk_rekey; |
| 165 | int wpa_ptk_rekey; |
Dmitry Shmidt | ebd93af | 2017-02-21 13:40:44 -0800 | [diff] [blame] | 166 | u32 wpa_group_update_count; |
| 167 | u32 wpa_pairwise_update_count; |
Dmitry Shmidt | d2986c2 | 2017-10-23 14:22:09 -0700 | [diff] [blame^] | 168 | int wpa_disable_eapol_key_retries; |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 169 | int rsn_pairwise; |
| 170 | int rsn_preauth; |
| 171 | int eapol_version; |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 172 | int wmm_enabled; |
| 173 | int wmm_uapsd; |
Dmitry Shmidt | c55524a | 2011-07-07 11:18:38 -0700 | [diff] [blame] | 174 | int disable_pmksa_caching; |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 175 | int okc; |
| 176 | int tx_status; |
| 177 | #ifdef CONFIG_IEEE80211W |
| 178 | enum mfp_options ieee80211w; |
Dmitry Shmidt | b36ed7c | 2014-03-17 10:57:26 -0700 | [diff] [blame] | 179 | int group_mgmt_cipher; |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 180 | #endif /* CONFIG_IEEE80211W */ |
Dmitry Shmidt | 9839ecd | 2016-11-07 11:05:47 -0800 | [diff] [blame] | 181 | #ifdef CONFIG_IEEE80211R_AP |
Dmitry Shmidt | 9d9e602 | 2015-04-23 10:34:55 -0700 | [diff] [blame] | 182 | u8 ssid[SSID_MAX_LEN]; |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 183 | size_t ssid_len; |
| 184 | u8 mobility_domain[MOBILITY_DOMAIN_ID_LEN]; |
| 185 | u8 r0_key_holder[FT_R0KH_ID_MAX_LEN]; |
| 186 | size_t r0_key_holder_len; |
| 187 | u8 r1_key_holder[FT_R1KH_ID_LEN]; |
| 188 | u32 r0_key_lifetime; |
Dmitry Shmidt | d2986c2 | 2017-10-23 14:22:09 -0700 | [diff] [blame^] | 189 | int rkh_pos_timeout; |
| 190 | int rkh_neg_timeout; |
| 191 | int rkh_pull_timeout; /* ms */ |
| 192 | int rkh_pull_retries; |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 193 | u32 reassociation_deadline; |
Dmitry Shmidt | d2986c2 | 2017-10-23 14:22:09 -0700 | [diff] [blame^] | 194 | struct ft_remote_r0kh **r0kh_list; |
| 195 | struct ft_remote_r1kh **r1kh_list; |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 196 | int pmk_r1_push; |
| 197 | int ft_over_ds; |
Dmitry Shmidt | 9839ecd | 2016-11-07 11:05:47 -0800 | [diff] [blame] | 198 | int ft_psk_generate_local; |
| 199 | #endif /* CONFIG_IEEE80211R_AP */ |
Dmitry Shmidt | 61d9df3 | 2012-08-29 16:22:06 -0700 | [diff] [blame] | 200 | int disable_gtk; |
| 201 | int ap_mlme; |
Dmitry Shmidt | 51b6ea8 | 2013-05-08 10:42:09 -0700 | [diff] [blame] | 202 | #ifdef CONFIG_TESTING_OPTIONS |
| 203 | double corrupt_gtk_rekey_mic_probability; |
Dmitry Shmidt | d80a401 | 2015-11-05 16:35:40 -0800 | [diff] [blame] | 204 | u8 own_ie_override[MAX_OWN_IE_OVERRIDE]; |
| 205 | size_t own_ie_override_len; |
Dmitry Shmidt | 51b6ea8 | 2013-05-08 10:42:09 -0700 | [diff] [blame] | 206 | #endif /* CONFIG_TESTING_OPTIONS */ |
Dmitry Shmidt | cf32e60 | 2014-01-28 10:57:39 -0800 | [diff] [blame] | 207 | #ifdef CONFIG_P2P |
| 208 | u8 ip_addr_go[4]; |
| 209 | u8 ip_addr_mask[4]; |
| 210 | u8 ip_addr_start[4]; |
| 211 | u8 ip_addr_end[4]; |
| 212 | #endif /* CONFIG_P2P */ |
Dmitry Shmidt | d2986c2 | 2017-10-23 14:22:09 -0700 | [diff] [blame^] | 213 | #ifdef CONFIG_FILS |
| 214 | unsigned int fils_cache_id_set:1; |
| 215 | u8 fils_cache_id[FILS_CACHE_ID_LEN]; |
| 216 | #endif /* CONFIG_FILS */ |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 217 | }; |
| 218 | |
| 219 | typedef enum { |
| 220 | LOGGER_DEBUG, LOGGER_INFO, LOGGER_WARNING |
| 221 | } logger_level; |
| 222 | |
| 223 | typedef enum { |
| 224 | WPA_EAPOL_portEnabled, WPA_EAPOL_portValid, WPA_EAPOL_authorized, |
| 225 | WPA_EAPOL_portControl_Auto, WPA_EAPOL_keyRun, WPA_EAPOL_keyAvailable, |
| 226 | WPA_EAPOL_keyDone, WPA_EAPOL_inc_EapolFramesTx |
| 227 | } wpa_eapol_variable; |
| 228 | |
| 229 | struct wpa_auth_callbacks { |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 230 | void (*logger)(void *ctx, const u8 *addr, logger_level level, |
| 231 | const char *txt); |
| 232 | void (*disconnect)(void *ctx, const u8 *addr, u16 reason); |
Dmitry Shmidt | d5e4923 | 2012-12-03 15:08:10 -0800 | [diff] [blame] | 233 | int (*mic_failure_report)(void *ctx, const u8 *addr); |
Dmitry Shmidt | dda10c2 | 2015-03-24 16:05:01 -0700 | [diff] [blame] | 234 | void (*psk_failure_report)(void *ctx, const u8 *addr); |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 235 | void (*set_eapol)(void *ctx, const u8 *addr, wpa_eapol_variable var, |
| 236 | int value); |
| 237 | int (*get_eapol)(void *ctx, const u8 *addr, wpa_eapol_variable var); |
Dmitry Shmidt | 391c59f | 2013-09-03 12:16:28 -0700 | [diff] [blame] | 238 | const u8 * (*get_psk)(void *ctx, const u8 *addr, const u8 *p2p_dev_addr, |
Dmitry Shmidt | d2986c2 | 2017-10-23 14:22:09 -0700 | [diff] [blame^] | 239 | const u8 *prev_psk, size_t *psk_len); |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 240 | int (*get_msk)(void *ctx, const u8 *addr, u8 *msk, size_t *len); |
| 241 | int (*set_key)(void *ctx, int vlan_id, enum wpa_alg alg, |
| 242 | const u8 *addr, int idx, u8 *key, size_t key_len); |
| 243 | int (*get_seqnum)(void *ctx, const u8 *addr, int idx, u8 *seq); |
| 244 | int (*send_eapol)(void *ctx, const u8 *addr, const u8 *data, |
| 245 | size_t data_len, int encrypt); |
| 246 | int (*for_each_sta)(void *ctx, int (*cb)(struct wpa_state_machine *sm, |
| 247 | void *ctx), void *cb_ctx); |
| 248 | int (*for_each_auth)(void *ctx, int (*cb)(struct wpa_authenticator *a, |
| 249 | void *ctx), void *cb_ctx); |
| 250 | int (*send_ether)(void *ctx, const u8 *dst, u16 proto, const u8 *data, |
| 251 | size_t data_len); |
Dmitry Shmidt | d2986c2 | 2017-10-23 14:22:09 -0700 | [diff] [blame^] | 252 | int (*send_oui)(void *ctx, const u8 *dst, u8 oui_suffix, const u8 *data, |
| 253 | size_t data_len); |
Dmitry Shmidt | 9839ecd | 2016-11-07 11:05:47 -0800 | [diff] [blame] | 254 | #ifdef CONFIG_IEEE80211R_AP |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 255 | struct wpa_state_machine * (*add_sta)(void *ctx, const u8 *sta_addr); |
| 256 | int (*send_ft_action)(void *ctx, const u8 *dst, |
| 257 | const u8 *data, size_t data_len); |
Dmitry Shmidt | 61d9df3 | 2012-08-29 16:22:06 -0700 | [diff] [blame] | 258 | int (*add_tspec)(void *ctx, const u8 *sta_addr, u8 *tspec_ie, |
Dmitry Shmidt | fb79edc | 2014-01-10 10:45:54 -0800 | [diff] [blame] | 259 | size_t tspec_ielen); |
Dmitry Shmidt | 9839ecd | 2016-11-07 11:05:47 -0800 | [diff] [blame] | 260 | #endif /* CONFIG_IEEE80211R_AP */ |
Dmitry Shmidt | 6c0da2b | 2015-01-05 13:08:17 -0800 | [diff] [blame] | 261 | #ifdef CONFIG_MESH |
| 262 | int (*start_ampe)(void *ctx, const u8 *sta_addr); |
| 263 | #endif /* CONFIG_MESH */ |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 264 | }; |
| 265 | |
| 266 | struct wpa_authenticator * wpa_init(const u8 *addr, |
| 267 | struct wpa_auth_config *conf, |
Paul Stewart | 092955c | 2017-02-06 09:13:09 -0800 | [diff] [blame] | 268 | const struct wpa_auth_callbacks *cb, |
| 269 | void *cb_ctx); |
Dmitry Shmidt | 1f69aa5 | 2012-01-24 16:10:04 -0800 | [diff] [blame] | 270 | int wpa_init_keys(struct wpa_authenticator *wpa_auth); |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 271 | void wpa_deinit(struct wpa_authenticator *wpa_auth); |
| 272 | int wpa_reconfig(struct wpa_authenticator *wpa_auth, |
| 273 | struct wpa_auth_config *conf); |
| 274 | |
| 275 | enum { |
| 276 | WPA_IE_OK, WPA_INVALID_IE, WPA_INVALID_GROUP, WPA_INVALID_PAIRWISE, |
| 277 | WPA_INVALID_AKMP, WPA_NOT_ENABLED, WPA_ALLOC_FAIL, |
| 278 | WPA_MGMT_FRAME_PROTECTION_VIOLATION, WPA_INVALID_MGMT_GROUP_CIPHER, |
Dmitry Shmidt | d2986c2 | 2017-10-23 14:22:09 -0700 | [diff] [blame^] | 279 | WPA_INVALID_MDIE, WPA_INVALID_PROTO, WPA_INVALID_PMKID |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 280 | }; |
Dmitry Shmidt | ebd93af | 2017-02-21 13:40:44 -0800 | [diff] [blame] | 281 | |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 282 | int wpa_validate_wpa_ie(struct wpa_authenticator *wpa_auth, |
| 283 | struct wpa_state_machine *sm, |
| 284 | const u8 *wpa_ie, size_t wpa_ie_len, |
Dmitry Shmidt | d2986c2 | 2017-10-23 14:22:09 -0700 | [diff] [blame^] | 285 | const u8 *mdie, size_t mdie_len, |
| 286 | const u8 *owe_dh, size_t owe_dh_len); |
Dmitry Shmidt | f21452a | 2014-02-26 10:55:25 -0800 | [diff] [blame] | 287 | int wpa_validate_osen(struct wpa_authenticator *wpa_auth, |
| 288 | struct wpa_state_machine *sm, |
| 289 | const u8 *osen_ie, size_t osen_ie_len); |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 290 | int wpa_auth_uses_mfp(struct wpa_state_machine *sm); |
| 291 | struct wpa_state_machine * |
Dmitry Shmidt | 391c59f | 2013-09-03 12:16:28 -0700 | [diff] [blame] | 292 | wpa_auth_sta_init(struct wpa_authenticator *wpa_auth, const u8 *addr, |
| 293 | const u8 *p2p_dev_addr); |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 294 | int wpa_auth_sta_associated(struct wpa_authenticator *wpa_auth, |
| 295 | struct wpa_state_machine *sm); |
| 296 | void wpa_auth_sta_no_wpa(struct wpa_state_machine *sm); |
| 297 | void wpa_auth_sta_deinit(struct wpa_state_machine *sm); |
| 298 | void wpa_receive(struct wpa_authenticator *wpa_auth, |
| 299 | struct wpa_state_machine *sm, |
| 300 | u8 *data, size_t data_len); |
Dmitry Shmidt | d80a401 | 2015-11-05 16:35:40 -0800 | [diff] [blame] | 301 | enum wpa_event { |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 302 | WPA_AUTH, WPA_ASSOC, WPA_DISASSOC, WPA_DEAUTH, WPA_REAUTH, |
Dmitry Shmidt | d2986c2 | 2017-10-23 14:22:09 -0700 | [diff] [blame^] | 303 | WPA_REAUTH_EAPOL, WPA_ASSOC_FT, WPA_ASSOC_FILS, WPA_DRV_STA_REMOVED |
Dmitry Shmidt | d80a401 | 2015-11-05 16:35:40 -0800 | [diff] [blame] | 304 | }; |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 305 | void wpa_remove_ptk(struct wpa_state_machine *sm); |
Dmitry Shmidt | d80a401 | 2015-11-05 16:35:40 -0800 | [diff] [blame] | 306 | int wpa_auth_sm_event(struct wpa_state_machine *sm, enum wpa_event event); |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 307 | void wpa_auth_sm_notify(struct wpa_state_machine *sm); |
| 308 | void wpa_gtk_rekey(struct wpa_authenticator *wpa_auth); |
| 309 | int wpa_get_mib(struct wpa_authenticator *wpa_auth, char *buf, size_t buflen); |
| 310 | int wpa_get_mib_sta(struct wpa_state_machine *sm, char *buf, size_t buflen); |
| 311 | void wpa_auth_countermeasures_start(struct wpa_authenticator *wpa_auth); |
| 312 | int wpa_auth_pairwise_set(struct wpa_state_machine *sm); |
| 313 | int wpa_auth_get_pairwise(struct wpa_state_machine *sm); |
| 314 | int wpa_auth_sta_key_mgmt(struct wpa_state_machine *sm); |
| 315 | int wpa_auth_sta_wpa_version(struct wpa_state_machine *sm); |
Mathy Vanhoef | f6e1f66 | 2017-07-14 15:15:35 +0200 | [diff] [blame] | 316 | int wpa_auth_sta_ft_tk_already_set(struct wpa_state_machine *sm); |
Dmitry Shmidt | d2986c2 | 2017-10-23 14:22:09 -0700 | [diff] [blame^] | 317 | int wpa_auth_sta_fils_tk_already_set(struct wpa_state_machine *sm); |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 318 | int wpa_auth_sta_clear_pmksa(struct wpa_state_machine *sm, |
| 319 | struct rsn_pmksa_cache_entry *entry); |
| 320 | struct rsn_pmksa_cache_entry * |
| 321 | wpa_auth_sta_get_pmksa(struct wpa_state_machine *sm); |
| 322 | void wpa_auth_sta_local_mic_failure_report(struct wpa_state_machine *sm); |
| 323 | const u8 * wpa_auth_get_wpa_ie(struct wpa_authenticator *wpa_auth, |
| 324 | size_t *len); |
| 325 | int wpa_auth_pmksa_add(struct wpa_state_machine *sm, const u8 *pmk, |
Dmitry Shmidt | d80a401 | 2015-11-05 16:35:40 -0800 | [diff] [blame] | 326 | unsigned int pmk_len, |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 327 | int session_timeout, struct eapol_state_machine *eapol); |
| 328 | int wpa_auth_pmksa_add_preauth(struct wpa_authenticator *wpa_auth, |
| 329 | const u8 *pmk, size_t len, const u8 *sta_addr, |
| 330 | int session_timeout, |
| 331 | struct eapol_state_machine *eapol); |
Dmitry Shmidt | 6c0da2b | 2015-01-05 13:08:17 -0800 | [diff] [blame] | 332 | int wpa_auth_pmksa_add_sae(struct wpa_authenticator *wpa_auth, const u8 *addr, |
Dmitry Shmidt | 57c2d39 | 2016-02-23 13:40:19 -0800 | [diff] [blame] | 333 | const u8 *pmk, const u8 *pmkid); |
Dmitry Shmidt | d2986c2 | 2017-10-23 14:22:09 -0700 | [diff] [blame^] | 334 | int wpa_auth_pmksa_add2(struct wpa_authenticator *wpa_auth, const u8 *addr, |
| 335 | const u8 *pmk, size_t pmk_len, const u8 *pmkid, |
| 336 | int session_timeout, int akmp); |
Dmitry Shmidt | f7e0a99 | 2013-05-23 11:03:10 -0700 | [diff] [blame] | 337 | void wpa_auth_pmksa_remove(struct wpa_authenticator *wpa_auth, |
| 338 | const u8 *sta_addr); |
Dmitry Shmidt | e466304 | 2016-04-04 10:07:49 -0700 | [diff] [blame] | 339 | int wpa_auth_pmksa_list(struct wpa_authenticator *wpa_auth, char *buf, |
| 340 | size_t len); |
| 341 | void wpa_auth_pmksa_flush(struct wpa_authenticator *wpa_auth); |
Paul Stewart | 092955c | 2017-02-06 09:13:09 -0800 | [diff] [blame] | 342 | int wpa_auth_pmksa_list_mesh(struct wpa_authenticator *wpa_auth, const u8 *addr, |
| 343 | char *buf, size_t len); |
| 344 | struct rsn_pmksa_cache_entry * |
| 345 | wpa_auth_pmksa_create_entry(const u8 *aa, const u8 *spa, const u8 *pmk, |
| 346 | const u8 *pmkid, int expiration); |
| 347 | int wpa_auth_pmksa_add_entry(struct wpa_authenticator *wpa_auth, |
| 348 | struct rsn_pmksa_cache_entry *entry); |
Dmitry Shmidt | e466304 | 2016-04-04 10:07:49 -0700 | [diff] [blame] | 349 | struct rsn_pmksa_cache_entry * |
Dmitry Shmidt | 9839ecd | 2016-11-07 11:05:47 -0800 | [diff] [blame] | 350 | wpa_auth_pmksa_get(struct wpa_authenticator *wpa_auth, const u8 *sta_addr, |
| 351 | const u8 *pmkid); |
Dmitry Shmidt | d2986c2 | 2017-10-23 14:22:09 -0700 | [diff] [blame^] | 352 | struct rsn_pmksa_cache_entry * |
| 353 | wpa_auth_pmksa_get_fils_cache_id(struct wpa_authenticator *wpa_auth, |
| 354 | const u8 *sta_addr, const u8 *pmkid); |
Dmitry Shmidt | e466304 | 2016-04-04 10:07:49 -0700 | [diff] [blame] | 355 | void wpa_auth_pmksa_set_to_sm(struct rsn_pmksa_cache_entry *pmksa, |
| 356 | struct wpa_state_machine *sm, |
| 357 | struct wpa_authenticator *wpa_auth, |
| 358 | u8 *pmkid, u8 *pmk); |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 359 | int wpa_auth_sta_set_vlan(struct wpa_state_machine *sm, int vlan_id); |
| 360 | void wpa_auth_eapol_key_tx_status(struct wpa_authenticator *wpa_auth, |
| 361 | struct wpa_state_machine *sm, int ack); |
| 362 | |
Dmitry Shmidt | 9839ecd | 2016-11-07 11:05:47 -0800 | [diff] [blame] | 363 | #ifdef CONFIG_IEEE80211R_AP |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 364 | u8 * wpa_sm_write_assoc_resp_ies(struct wpa_state_machine *sm, u8 *pos, |
| 365 | size_t max_len, int auth_alg, |
| 366 | const u8 *req_ies, size_t req_ies_len); |
| 367 | void wpa_ft_process_auth(struct wpa_state_machine *sm, const u8 *bssid, |
| 368 | u16 auth_transaction, const u8 *ies, size_t ies_len, |
| 369 | void (*cb)(void *ctx, const u8 *dst, const u8 *bssid, |
| 370 | u16 auth_transaction, u16 resp, |
| 371 | const u8 *ies, size_t ies_len), |
| 372 | void *ctx); |
| 373 | u16 wpa_ft_validate_reassoc(struct wpa_state_machine *sm, const u8 *ies, |
| 374 | size_t ies_len); |
| 375 | int wpa_ft_action_rx(struct wpa_state_machine *sm, const u8 *data, size_t len); |
| 376 | int wpa_ft_rrb_rx(struct wpa_authenticator *wpa_auth, const u8 *src_addr, |
| 377 | const u8 *data, size_t data_len); |
Dmitry Shmidt | d2986c2 | 2017-10-23 14:22:09 -0700 | [diff] [blame^] | 378 | void wpa_ft_rrb_oui_rx(struct wpa_authenticator *wpa_auth, const u8 *src_addr, |
| 379 | const u8 *dst_addr, u8 oui_suffix, const u8 *data, |
| 380 | size_t data_len); |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 381 | void wpa_ft_push_pmk_r1(struct wpa_authenticator *wpa_auth, const u8 *addr); |
Dmitry Shmidt | d2986c2 | 2017-10-23 14:22:09 -0700 | [diff] [blame^] | 382 | void wpa_ft_deinit(struct wpa_authenticator *wpa_auth); |
| 383 | void wpa_ft_sta_deinit(struct wpa_state_machine *sm); |
Dmitry Shmidt | 9839ecd | 2016-11-07 11:05:47 -0800 | [diff] [blame] | 384 | #endif /* CONFIG_IEEE80211R_AP */ |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 385 | |
Dmitry Shmidt | 61d9df3 | 2012-08-29 16:22:06 -0700 | [diff] [blame] | 386 | void wpa_wnmsleep_rekey_gtk(struct wpa_state_machine *sm); |
| 387 | void wpa_set_wnmsleep(struct wpa_state_machine *sm, int flag); |
| 388 | int wpa_wnmsleep_gtk_subelem(struct wpa_state_machine *sm, u8 *pos); |
Dmitry Shmidt | 61d9df3 | 2012-08-29 16:22:06 -0700 | [diff] [blame] | 389 | int wpa_wnmsleep_igtk_subelem(struct wpa_state_machine *sm, u8 *pos); |
Dmitry Shmidt | 61d9df3 | 2012-08-29 16:22:06 -0700 | [diff] [blame] | 390 | |
Dmitry Shmidt | d5e4923 | 2012-12-03 15:08:10 -0800 | [diff] [blame] | 391 | int wpa_auth_uses_sae(struct wpa_state_machine *sm); |
Dmitry Shmidt | fb79edc | 2014-01-10 10:45:54 -0800 | [diff] [blame] | 392 | int wpa_auth_uses_ft_sae(struct wpa_state_machine *sm); |
Dmitry Shmidt | d5e4923 | 2012-12-03 15:08:10 -0800 | [diff] [blame] | 393 | |
Dmitry Shmidt | cf32e60 | 2014-01-28 10:57:39 -0800 | [diff] [blame] | 394 | int wpa_auth_get_ip_addr(struct wpa_state_machine *sm, u8 *addr); |
| 395 | |
Dmitry Shmidt | 2f74e36 | 2015-01-21 13:19:05 -0800 | [diff] [blame] | 396 | struct radius_das_attrs; |
| 397 | int wpa_auth_radius_das_disconnect_pmksa(struct wpa_authenticator *wpa_auth, |
| 398 | struct radius_das_attrs *attr); |
Dmitry Shmidt | 7f65602 | 2015-02-25 14:36:37 -0800 | [diff] [blame] | 399 | void wpa_auth_reconfig_group_keys(struct wpa_authenticator *wpa_auth); |
Dmitry Shmidt | 2f74e36 | 2015-01-21 13:19:05 -0800 | [diff] [blame] | 400 | |
Dmitry Shmidt | d80a401 | 2015-11-05 16:35:40 -0800 | [diff] [blame] | 401 | int wpa_auth_ensure_group(struct wpa_authenticator *wpa_auth, int vlan_id); |
| 402 | int wpa_auth_release_group(struct wpa_authenticator *wpa_auth, int vlan_id); |
Dmitry Shmidt | 9839ecd | 2016-11-07 11:05:47 -0800 | [diff] [blame] | 403 | int fils_auth_pmk_to_ptk(struct wpa_state_machine *sm, const u8 *pmk, |
Dmitry Shmidt | d2986c2 | 2017-10-23 14:22:09 -0700 | [diff] [blame^] | 404 | size_t pmk_len, const u8 *snonce, const u8 *anonce, |
| 405 | const u8 *dhss, size_t dhss_len, |
| 406 | struct wpabuf *g_sta, struct wpabuf *g_ap); |
Dmitry Shmidt | 9839ecd | 2016-11-07 11:05:47 -0800 | [diff] [blame] | 407 | int fils_decrypt_assoc(struct wpa_state_machine *sm, const u8 *fils_session, |
| 408 | const struct ieee80211_mgmt *mgmt, size_t frame_len, |
| 409 | u8 *pos, size_t left); |
| 410 | int fils_encrypt_assoc(struct wpa_state_machine *sm, u8 *buf, |
Dmitry Shmidt | ebd93af | 2017-02-21 13:40:44 -0800 | [diff] [blame] | 411 | size_t current_len, size_t max_len, |
| 412 | const struct wpabuf *hlp); |
Dmitry Shmidt | 9839ecd | 2016-11-07 11:05:47 -0800 | [diff] [blame] | 413 | int fils_set_tk(struct wpa_state_machine *sm); |
Dmitry Shmidt | d2986c2 | 2017-10-23 14:22:09 -0700 | [diff] [blame^] | 414 | u8 * hostapd_eid_assoc_fils_session(struct wpa_state_machine *sm, u8 *eid, |
| 415 | const u8 *fils_session, |
| 416 | struct wpabuf *fils_hlp_resp); |
| 417 | const u8 * wpa_fils_validate_fils_session(struct wpa_state_machine *sm, |
| 418 | const u8 *ies, size_t ies_len, |
| 419 | const u8 *fils_session); |
| 420 | int wpa_fils_validate_key_confirm(struct wpa_state_machine *sm, const u8 *ies, |
| 421 | size_t ies_len); |
| 422 | |
| 423 | int wpa_auth_write_fte(struct wpa_authenticator *wpa_auth, u8 *buf, size_t len); |
| 424 | void wpa_auth_get_fils_aead_params(struct wpa_state_machine *sm, |
| 425 | u8 *fils_anonce, u8 *fils_snonce, |
| 426 | u8 *fils_kek, size_t *fils_kek_len); |
| 427 | u8 * wpa_auth_write_assoc_resp_owe(struct wpa_state_machine *sm, |
| 428 | u8 *pos, size_t max_len, |
| 429 | const u8 *req_ies, size_t req_ies_len); |
| 430 | |
| 431 | int wpa_auth_resend_m1(struct wpa_state_machine *sm, int change_anonce, |
| 432 | void (*cb)(void *ctx1, void *ctx2), |
| 433 | void *ctx1, void *ctx2); |
| 434 | int wpa_auth_resend_m3(struct wpa_state_machine *sm, |
| 435 | void (*cb)(void *ctx1, void *ctx2), |
| 436 | void *ctx1, void *ctx2); |
| 437 | int wpa_auth_resend_group_m1(struct wpa_state_machine *sm, |
| 438 | void (*cb)(void *ctx1, void *ctx2), |
| 439 | void *ctx1, void *ctx2); |
Dmitry Shmidt | d80a401 | 2015-11-05 16:35:40 -0800 | [diff] [blame] | 440 | |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 441 | #endif /* WPA_AUTH_H */ |