wps_i.h

Go to the documentation of this file.
00001 
00016 #ifndef WPS_I_H
00017 #define WPS_I_H
00018 
00019 #include "wps.h"
00020 
00028 struct wps_data {
00033         struct wps_context *wps;
00034 
00039         int registrar;
00040 
00045         int er;
00046 
00047         enum {
00048                 /* Enrollee states */
00049                 SEND_M1, RECV_M2, SEND_M3, RECV_M4, SEND_M5, RECV_M6, SEND_M7,
00050                 RECV_M8, RECEIVED_M2D, WPS_MSG_DONE, RECV_ACK, WPS_FINISHED,
00051                 SEND_WSC_NACK,
00052 
00053                 /* Registrar states */
00054                 RECV_M1, SEND_M2, RECV_M3, SEND_M4, RECV_M5, SEND_M6,
00055                 RECV_M7, SEND_M8, RECV_DONE, SEND_M2D, RECV_M2D_ACK
00056         } state;
00057 
00058         u8 uuid_e[WPS_UUID_LEN];
00059         u8 uuid_r[WPS_UUID_LEN];
00060         u8 mac_addr_e[ETH_ALEN];
00061         u8 nonce_e[WPS_NONCE_LEN];
00062         u8 nonce_r[WPS_NONCE_LEN];
00063         u8 psk1[WPS_PSK_LEN];
00064         u8 psk2[WPS_PSK_LEN];
00065         u8 snonce[2 * WPS_SECRET_NONCE_LEN];
00066         u8 peer_hash1[WPS_HASH_LEN];
00067         u8 peer_hash2[WPS_HASH_LEN];
00068 
00069         struct wpabuf *dh_privkey;
00070         struct wpabuf *dh_pubkey_e;
00071         struct wpabuf *dh_pubkey_r;
00072         u8 authkey[WPS_AUTHKEY_LEN];
00073         u8 keywrapkey[WPS_KEYWRAPKEY_LEN];
00074         u8 emsk[WPS_EMSK_LEN];
00075 
00076         struct wpabuf *last_msg;
00077 
00078         u8 *dev_password;
00079         size_t dev_password_len;
00080         u16 dev_pw_id;
00081         int pbc;
00082 
00087         u8 request_type;
00088 
00093         u16 encr_type;
00094 
00099         u16 auth_type;
00100 
00101         u8 *new_psk;
00102         size_t new_psk_len;
00103 
00104         int wps_pin_revealed;
00105         struct wps_credential cred;
00106 
00107         struct wps_device_data peer_dev;
00108 
00113         u16 config_error;
00114 
00115         int ext_reg;
00116 
00117         struct wps_credential *new_ap_settings;
00118 
00119         void *dh_ctx;
00120 
00121         void (*ap_settings_cb)(void *ctx, const struct wps_credential *cred);
00122         void *ap_settings_cb_ctx;
00123 
00124         struct wps_credential *use_cred;
00125 };
00126 
00127 
00128 struct wps_parse_attr {
00129         /* fixed length fields */
00130         const u8 *version; /* 1 octet */
00131         const u8 *msg_type; /* 1 octet */
00132         const u8 *enrollee_nonce; /* WPS_NONCE_LEN (16) octets */
00133         const u8 *registrar_nonce; /* WPS_NONCE_LEN (16) octets */
00134         const u8 *uuid_r; /* WPS_UUID_LEN (16) octets */
00135         const u8 *uuid_e; /* WPS_UUID_LEN (16) octets */
00136         const u8 *auth_type_flags; /* 2 octets */
00137         const u8 *encr_type_flags; /* 2 octets */
00138         const u8 *conn_type_flags; /* 1 octet */
00139         const u8 *config_methods; /* 2 octets */
00140         const u8 *sel_reg_config_methods; /* 2 octets */
00141         const u8 *primary_dev_type; /* 8 octets */
00142         const u8 *rf_bands; /* 1 octet */
00143         const u8 *assoc_state; /* 2 octets */
00144         const u8 *config_error; /* 2 octets */
00145         const u8 *dev_password_id; /* 2 octets */
00146         const u8 *oob_dev_password; /* WPS_OOB_DEVICE_PASSWORD_ATTR_LEN (54)
00147                                      * octets */
00148         const u8 *os_version; /* 4 octets */
00149         const u8 *wps_state; /* 1 octet */
00150         const u8 *authenticator; /* WPS_AUTHENTICATOR_LEN (8) octets */
00151         const u8 *r_hash1; /* WPS_HASH_LEN (32) octets */
00152         const u8 *r_hash2; /* WPS_HASH_LEN (32) octets */
00153         const u8 *e_hash1; /* WPS_HASH_LEN (32) octets */
00154         const u8 *e_hash2; /* WPS_HASH_LEN (32) octets */
00155         const u8 *r_snonce1; /* WPS_SECRET_NONCE_LEN (16) octets */
00156         const u8 *r_snonce2; /* WPS_SECRET_NONCE_LEN (16) octets */
00157         const u8 *e_snonce1; /* WPS_SECRET_NONCE_LEN (16) octets */
00158         const u8 *e_snonce2; /* WPS_SECRET_NONCE_LEN (16) octets */
00159         const u8 *key_wrap_auth; /* WPS_KWA_LEN (8) octets */
00160         const u8 *auth_type; /* 2 octets */
00161         const u8 *encr_type; /* 2 octets */
00162         const u8 *network_idx; /* 1 octet */
00163         const u8 *network_key_idx; /* 1 octet */
00164         const u8 *mac_addr; /* ETH_ALEN (6) octets */
00165         const u8 *key_prov_auto; /* 1 octet (Bool) */
00166         const u8 *dot1x_enabled; /* 1 octet (Bool) */
00167         const u8 *selected_registrar; /* 1 octet (Bool) */
00168         const u8 *request_type; /* 1 octet */
00169         const u8 *response_type; /* 1 octet */
00170         const u8 *ap_setup_locked; /* 1 octet */
00171 
00172         /* variable length fields */
00173         const u8 *manufacturer;
00174         size_t manufacturer_len;
00175         const u8 *model_name;
00176         size_t model_name_len;
00177         const u8 *model_number;
00178         size_t model_number_len;
00179         const u8 *serial_number;
00180         size_t serial_number_len;
00181         const u8 *dev_name;
00182         size_t dev_name_len;
00183         const u8 *public_key;
00184         size_t public_key_len;
00185         const u8 *encr_settings;
00186         size_t encr_settings_len;
00187         const u8 *ssid; /* <= 32 octets */
00188         size_t ssid_len;
00189         const u8 *network_key; /* <= 64 octets */
00190         size_t network_key_len;
00191         const u8 *eap_type; /* <= 8 octets */
00192         size_t eap_type_len;
00193         const u8 *eap_identity; /* <= 64 octets */
00194         size_t eap_identity_len;
00195 
00196         /* attributes that can occur multiple times */
00197 #define MAX_CRED_COUNT 10
00198         const u8 *cred[MAX_CRED_COUNT];
00199         size_t cred_len[MAX_CRED_COUNT];
00200         size_t num_cred;
00201 };
00202 
00203 /* wps_common.c */
00204 void wps_kdf(const u8 *key, const u8 *label_prefix, size_t label_prefix_len,
00205              const char *label, u8 *res, size_t res_len);
00206 int wps_derive_keys(struct wps_data *wps);
00207 void wps_derive_psk(struct wps_data *wps, const u8 *dev_passwd,
00208                     size_t dev_passwd_len);
00209 struct wpabuf * wps_decrypt_encr_settings(struct wps_data *wps, const u8 *encr,
00210                                           size_t encr_len);
00211 void wps_fail_event(struct wps_context *wps, enum wps_msg_type msg);
00212 void wps_success_event(struct wps_context *wps);
00213 void wps_pwd_auth_fail_event(struct wps_context *wps, int enrollee, int part);
00214 void wps_pbc_overlap_event(struct wps_context *wps);
00215 void wps_pbc_timeout_event(struct wps_context *wps);
00216 
00217 extern struct oob_device_data oob_ufd_device_data;
00218 extern struct oob_device_data oob_nfc_device_data;
00219 extern struct oob_nfc_device_data oob_nfc_pn531_device_data;
00220 
00221 /* wps_attr_parse.c */
00222 int wps_parse_msg(const struct wpabuf *msg, struct wps_parse_attr *attr);
00223 
00224 /* wps_attr_build.c */
00225 int wps_build_public_key(struct wps_data *wps, struct wpabuf *msg);
00226 int wps_build_req_type(struct wpabuf *msg, enum wps_request_type type);
00227 int wps_build_config_methods(struct wpabuf *msg, u16 methods);
00228 int wps_build_uuid_e(struct wpabuf *msg, const u8 *uuid);
00229 int wps_build_dev_password_id(struct wpabuf *msg, u16 id);
00230 int wps_build_config_error(struct wpabuf *msg, u16 err);
00231 int wps_build_authenticator(struct wps_data *wps, struct wpabuf *msg);
00232 int wps_build_key_wrap_auth(struct wps_data *wps, struct wpabuf *msg);
00233 int wps_build_encr_settings(struct wps_data *wps, struct wpabuf *msg,
00234                             struct wpabuf *plain);
00235 int wps_build_version(struct wpabuf *msg);
00236 int wps_build_msg_type(struct wpabuf *msg, enum wps_msg_type msg_type);
00237 int wps_build_enrollee_nonce(struct wps_data *wps, struct wpabuf *msg);
00238 int wps_build_registrar_nonce(struct wps_data *wps, struct wpabuf *msg);
00239 int wps_build_auth_type_flags(struct wps_data *wps, struct wpabuf *msg);
00240 int wps_build_encr_type_flags(struct wps_data *wps, struct wpabuf *msg);
00241 int wps_build_conn_type_flags(struct wps_data *wps, struct wpabuf *msg);
00242 int wps_build_assoc_state(struct wps_data *wps, struct wpabuf *msg);
00243 int wps_build_oob_dev_password(struct wpabuf *msg, struct wps_context *wps);
00244 
00245 /* wps_attr_process.c */
00246 int wps_process_authenticator(struct wps_data *wps, const u8 *authenticator,
00247                               const struct wpabuf *msg);
00248 int wps_process_key_wrap_auth(struct wps_data *wps, struct wpabuf *msg,
00249                               const u8 *key_wrap_auth);
00250 int wps_process_cred(struct wps_parse_attr *attr,
00251                      struct wps_credential *cred);
00252 int wps_process_ap_settings(struct wps_parse_attr *attr,
00253                             struct wps_credential *cred);
00254 
00255 /* wps_enrollee.c */
00256 struct wpabuf * wps_enrollee_get_msg(struct wps_data *wps,
00257                                      enum wsc_op_code *op_code);
00258 enum wps_process_res wps_enrollee_process_msg(struct wps_data *wps,
00259                                               enum wsc_op_code op_code,
00260                                               const struct wpabuf *msg);
00261 
00262 /* wps_registrar.c */
00263 struct wpabuf * wps_registrar_get_msg(struct wps_data *wps,
00264                                       enum wsc_op_code *op_code);
00265 enum wps_process_res wps_registrar_process_msg(struct wps_data *wps,
00266                                                enum wsc_op_code op_code,
00267                                                const struct wpabuf *msg);
00268 int wps_build_cred(struct wps_data *wps, struct wpabuf *msg);
00269 int wps_device_store(struct wps_registrar *reg,
00270                      struct wps_device_data *dev, const u8 *uuid);
00271 
00272 /* ndef.c */
00273 struct wpabuf * ndef_parse_wifi(struct wpabuf *buf);
00274 struct wpabuf * ndef_build_wifi(struct wpabuf *buf);
00275 
00276 static inline int wps_version_supported(const u8 *version)
00277 {
00278         /* Require major version match, but allow minor version differences */
00279         return version && (*version & 0xf0) == (WPS_VERSION & 0xf0);
00280 }
00281 
00282 #endif /* WPS_I_H */
00283 
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Defines

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