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