|
wpa_supplicant / hostapd 2.0
|
00001 00010 #ifndef WPS_I_H 00011 #define WPS_I_H 00012 00013 #include "wps.h" 00014 00022 struct wps_data { 00027 struct wps_context *wps; 00028 00033 int registrar; 00034 00039 int er; 00040 00041 enum { 00042 /* Enrollee states */ 00043 SEND_M1, RECV_M2, SEND_M3, RECV_M4, SEND_M5, RECV_M6, SEND_M7, 00044 RECV_M8, RECEIVED_M2D, WPS_MSG_DONE, RECV_ACK, WPS_FINISHED, 00045 SEND_WSC_NACK, 00046 00047 /* Registrar states */ 00048 RECV_M1, SEND_M2, RECV_M3, SEND_M4, RECV_M5, SEND_M6, 00049 RECV_M7, SEND_M8, RECV_DONE, SEND_M2D, RECV_M2D_ACK 00050 } state; 00051 00052 u8 uuid_e[WPS_UUID_LEN]; 00053 u8 uuid_r[WPS_UUID_LEN]; 00054 u8 mac_addr_e[ETH_ALEN]; 00055 u8 nonce_e[WPS_NONCE_LEN]; 00056 u8 nonce_r[WPS_NONCE_LEN]; 00057 u8 psk1[WPS_PSK_LEN]; 00058 u8 psk2[WPS_PSK_LEN]; 00059 u8 snonce[2 * WPS_SECRET_NONCE_LEN]; 00060 u8 peer_hash1[WPS_HASH_LEN]; 00061 u8 peer_hash2[WPS_HASH_LEN]; 00062 00063 struct wpabuf *dh_privkey; 00064 struct wpabuf *dh_pubkey_e; 00065 struct wpabuf *dh_pubkey_r; 00066 u8 authkey[WPS_AUTHKEY_LEN]; 00067 u8 keywrapkey[WPS_KEYWRAPKEY_LEN]; 00068 u8 emsk[WPS_EMSK_LEN]; 00069 00070 struct wpabuf *last_msg; 00071 00072 u8 *dev_password; 00073 size_t dev_password_len; 00074 u16 dev_pw_id; 00075 int pbc; 00076 00081 u8 request_type; 00082 00087 u16 encr_type; 00088 00093 u16 auth_type; 00094 00095 u8 *new_psk; 00096 size_t new_psk_len; 00097 00098 int wps_pin_revealed; 00099 struct wps_credential cred; 00100 00101 struct wps_device_data peer_dev; 00102 00107 u16 config_error; 00108 u16 error_indication; 00109 00110 int ext_reg; 00111 int int_reg; 00112 00113 struct wps_credential *new_ap_settings; 00114 00115 void *dh_ctx; 00116 00117 void (*ap_settings_cb)(void *ctx, const struct wps_credential *cred); 00118 void *ap_settings_cb_ctx; 00119 00120 struct wps_credential *use_cred; 00121 00122 int use_psk_key; 00123 u8 p2p_dev_addr[ETH_ALEN]; /* P2P Device Address of the client or 00124 * 00:00:00:00:00:00 if not a P2p client */ 00125 int pbc_in_m1; 00126 }; 00127 00128 00129 struct wps_parse_attr { 00130 /* fixed length fields */ 00131 const u8 *version; /* 1 octet */ 00132 const u8 *version2; /* 1 octet */ 00133 const u8 *msg_type; /* 1 octet */ 00134 const u8 *enrollee_nonce; /* WPS_NONCE_LEN (16) octets */ 00135 const u8 *registrar_nonce; /* WPS_NONCE_LEN (16) octets */ 00136 const u8 *uuid_r; /* WPS_UUID_LEN (16) octets */ 00137 const u8 *uuid_e; /* WPS_UUID_LEN (16) octets */ 00138 const u8 *auth_type_flags; /* 2 octets */ 00139 const u8 *encr_type_flags; /* 2 octets */ 00140 const u8 *conn_type_flags; /* 1 octet */ 00141 const u8 *config_methods; /* 2 octets */ 00142 const u8 *sel_reg_config_methods; /* 2 octets */ 00143 const u8 *primary_dev_type; /* 8 octets */ 00144 const u8 *rf_bands; /* 1 octet */ 00145 const u8 *assoc_state; /* 2 octets */ 00146 const u8 *config_error; /* 2 octets */ 00147 const u8 *dev_password_id; /* 2 octets */ 00148 const u8 *oob_dev_password; /* WPS_OOB_DEVICE_PASSWORD_ATTR_LEN (54) 00149 * octets */ 00150 const u8 *os_version; /* 4 octets */ 00151 const u8 *wps_state; /* 1 octet */ 00152 const u8 *authenticator; /* WPS_AUTHENTICATOR_LEN (8) octets */ 00153 const u8 *r_hash1; /* WPS_HASH_LEN (32) octets */ 00154 const u8 *r_hash2; /* WPS_HASH_LEN (32) octets */ 00155 const u8 *e_hash1; /* WPS_HASH_LEN (32) octets */ 00156 const u8 *e_hash2; /* WPS_HASH_LEN (32) octets */ 00157 const u8 *r_snonce1; /* WPS_SECRET_NONCE_LEN (16) octets */ 00158 const u8 *r_snonce2; /* WPS_SECRET_NONCE_LEN (16) octets */ 00159 const u8 *e_snonce1; /* WPS_SECRET_NONCE_LEN (16) octets */ 00160 const u8 *e_snonce2; /* WPS_SECRET_NONCE_LEN (16) octets */ 00161 const u8 *key_wrap_auth; /* WPS_KWA_LEN (8) octets */ 00162 const u8 *auth_type; /* 2 octets */ 00163 const u8 *encr_type; /* 2 octets */ 00164 const u8 *network_idx; /* 1 octet */ 00165 const u8 *network_key_idx; /* 1 octet */ 00166 const u8 *mac_addr; /* ETH_ALEN (6) octets */ 00167 const u8 *key_prov_auto; /* 1 octet (Bool) */ 00168 const u8 *dot1x_enabled; /* 1 octet (Bool) */ 00169 const u8 *selected_registrar; /* 1 octet (Bool) */ 00170 const u8 *request_type; /* 1 octet */ 00171 const u8 *response_type; /* 1 octet */ 00172 const u8 *ap_setup_locked; /* 1 octet */ 00173 const u8 *settings_delay_time; /* 1 octet */ 00174 const u8 *network_key_shareable; /* 1 octet (Bool) */ 00175 const u8 *request_to_enroll; /* 1 octet (Bool) */ 00176 00177 /* variable length fields */ 00178 const u8 *manufacturer; 00179 size_t manufacturer_len; 00180 const u8 *model_name; 00181 size_t model_name_len; 00182 const u8 *model_number; 00183 size_t model_number_len; 00184 const u8 *serial_number; 00185 size_t serial_number_len; 00186 const u8 *dev_name; 00187 size_t dev_name_len; 00188 const u8 *public_key; 00189 size_t public_key_len; 00190 const u8 *encr_settings; 00191 size_t encr_settings_len; 00192 const u8 *ssid; /* <= 32 octets */ 00193 size_t ssid_len; 00194 const u8 *network_key; /* <= 64 octets */ 00195 size_t network_key_len; 00196 const u8 *eap_type; /* <= 8 octets */ 00197 size_t eap_type_len; 00198 const u8 *eap_identity; /* <= 64 octets */ 00199 size_t eap_identity_len; 00200 const u8 *authorized_macs; /* <= 30 octets */ 00201 size_t authorized_macs_len; 00202 const u8 *sec_dev_type_list; /* <= 128 octets */ 00203 size_t sec_dev_type_list_len; 00204 00205 /* attributes that can occur multiple times */ 00206 #define MAX_CRED_COUNT 10 00207 const u8 *cred[MAX_CRED_COUNT]; 00208 size_t cred_len[MAX_CRED_COUNT]; 00209 size_t num_cred; 00210 00211 #define MAX_REQ_DEV_TYPE_COUNT 10 00212 const u8 *req_dev_type[MAX_REQ_DEV_TYPE_COUNT]; 00213 size_t num_req_dev_type; 00214 00215 const u8 *vendor_ext[MAX_WPS_PARSE_VENDOR_EXT]; 00216 size_t vendor_ext_len[MAX_WPS_PARSE_VENDOR_EXT]; 00217 size_t num_vendor_ext; 00218 }; 00219 00220 /* wps_common.c */ 00221 void wps_kdf(const u8 *key, const u8 *label_prefix, size_t label_prefix_len, 00222 const char *label, u8 *res, size_t res_len); 00223 int wps_derive_keys(struct wps_data *wps); 00224 void wps_derive_psk(struct wps_data *wps, const u8 *dev_passwd, 00225 size_t dev_passwd_len); 00226 struct wpabuf * wps_decrypt_encr_settings(struct wps_data *wps, const u8 *encr, 00227 size_t encr_len); 00228 void wps_fail_event(struct wps_context *wps, enum wps_msg_type msg, 00229 u16 config_error, u16 error_indication); 00230 void wps_success_event(struct wps_context *wps); 00231 void wps_pwd_auth_fail_event(struct wps_context *wps, int enrollee, int part); 00232 void wps_pbc_overlap_event(struct wps_context *wps); 00233 void wps_pbc_timeout_event(struct wps_context *wps); 00234 00235 extern struct oob_device_data oob_ufd_device_data; 00236 extern struct oob_device_data oob_nfc_device_data; 00237 extern struct oob_nfc_device_data oob_nfc_pn531_device_data; 00238 00239 struct wpabuf * wps_build_wsc_ack(struct wps_data *wps); 00240 struct wpabuf * wps_build_wsc_nack(struct wps_data *wps); 00241 00242 /* wps_attr_parse.c */ 00243 int wps_parse_msg(const struct wpabuf *msg, struct wps_parse_attr *attr); 00244 00245 /* wps_attr_build.c */ 00246 int wps_build_public_key(struct wps_data *wps, struct wpabuf *msg); 00247 int wps_build_req_type(struct wpabuf *msg, enum wps_request_type type); 00248 int wps_build_resp_type(struct wpabuf *msg, enum wps_response_type type); 00249 int wps_build_config_methods(struct wpabuf *msg, u16 methods); 00250 int wps_build_uuid_e(struct wpabuf *msg, const u8 *uuid); 00251 int wps_build_dev_password_id(struct wpabuf *msg, u16 id); 00252 int wps_build_config_error(struct wpabuf *msg, u16 err); 00253 int wps_build_authenticator(struct wps_data *wps, struct wpabuf *msg); 00254 int wps_build_key_wrap_auth(struct wps_data *wps, struct wpabuf *msg); 00255 int wps_build_encr_settings(struct wps_data *wps, struct wpabuf *msg, 00256 struct wpabuf *plain); 00257 int wps_build_version(struct wpabuf *msg); 00258 int wps_build_wfa_ext(struct wpabuf *msg, int req_to_enroll, 00259 const u8 *auth_macs, size_t auth_macs_count); 00260 int wps_build_msg_type(struct wpabuf *msg, enum wps_msg_type msg_type); 00261 int wps_build_enrollee_nonce(struct wps_data *wps, struct wpabuf *msg); 00262 int wps_build_registrar_nonce(struct wps_data *wps, struct wpabuf *msg); 00263 int wps_build_auth_type_flags(struct wps_data *wps, struct wpabuf *msg); 00264 int wps_build_encr_type_flags(struct wps_data *wps, struct wpabuf *msg); 00265 int wps_build_conn_type_flags(struct wps_data *wps, struct wpabuf *msg); 00266 int wps_build_assoc_state(struct wps_data *wps, struct wpabuf *msg); 00267 int wps_build_oob_dev_password(struct wpabuf *msg, struct wps_context *wps); 00268 struct wpabuf * wps_ie_encapsulate(struct wpabuf *data); 00269 00270 /* wps_attr_process.c */ 00271 int wps_process_authenticator(struct wps_data *wps, const u8 *authenticator, 00272 const struct wpabuf *msg); 00273 int wps_process_key_wrap_auth(struct wps_data *wps, struct wpabuf *msg, 00274 const u8 *key_wrap_auth); 00275 int wps_process_cred(struct wps_parse_attr *attr, 00276 struct wps_credential *cred); 00277 int wps_process_ap_settings(struct wps_parse_attr *attr, 00278 struct wps_credential *cred); 00279 00280 /* wps_enrollee.c */ 00281 struct wpabuf * wps_enrollee_get_msg(struct wps_data *wps, 00282 enum wsc_op_code *op_code); 00283 enum wps_process_res wps_enrollee_process_msg(struct wps_data *wps, 00284 enum wsc_op_code op_code, 00285 const struct wpabuf *msg); 00286 00287 /* wps_registrar.c */ 00288 struct wpabuf * wps_registrar_get_msg(struct wps_data *wps, 00289 enum wsc_op_code *op_code); 00290 enum wps_process_res wps_registrar_process_msg(struct wps_data *wps, 00291 enum wsc_op_code op_code, 00292 const struct wpabuf *msg); 00293 int wps_build_cred(struct wps_data *wps, struct wpabuf *msg); 00294 int wps_device_store(struct wps_registrar *reg, 00295 struct wps_device_data *dev, const u8 *uuid); 00296 void wps_registrar_selected_registrar_changed(struct wps_registrar *reg); 00297 const u8 * wps_authorized_macs(struct wps_registrar *reg, size_t *count); 00298 int wps_registrar_pbc_overlap(struct wps_registrar *reg, 00299 const u8 *addr, const u8 *uuid_e); 00300 00301 /* ndef.c */ 00302 struct wpabuf * ndef_parse_wifi(struct wpabuf *buf); 00303 struct wpabuf * ndef_build_wifi(struct wpabuf *buf); 00304 00305 #endif /* WPS_I_H */ 00306
1.7.3