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


wpa_supplicant_node
Author(s): Package maintained by Blaise Gassend
autogenerated on Thu Apr 24 2014 15:33:22