2008-11-23 12:34:26 -05:00
|
|
|
/*
|
|
|
|
* Wi-Fi Protected Setup - internal definitions
|
2012-06-27 15:15:55 -04:00
|
|
|
* Copyright (c) 2008-2012, Jouni Malinen <j@w1.fi>
|
2008-11-23 12:34:26 -05:00
|
|
|
*
|
2012-02-11 09:46:35 -05:00
|
|
|
* This software may be distributed under the terms of the BSD license.
|
|
|
|
* See README for more details.
|
2008-11-23 12:34:26 -05:00
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef WPS_I_H
|
|
|
|
#define WPS_I_H
|
|
|
|
|
|
|
|
#include "wps.h"
|
2012-06-27 13:18:47 -04:00
|
|
|
#include "wps_attr_parse.h"
|
2008-11-23 12:34:26 -05:00
|
|
|
|
2012-06-27 15:15:55 -04:00
|
|
|
struct wps_nfc_pw_token;
|
|
|
|
|
2008-11-28 13:50:08 -05:00
|
|
|
/**
|
|
|
|
* struct wps_data - WPS registration protocol data
|
|
|
|
*
|
|
|
|
* This data is stored at the EAP-WSC server/peer method and it is kept for a
|
|
|
|
* single registration protocol run.
|
|
|
|
*/
|
2008-11-23 12:34:26 -05:00
|
|
|
struct wps_data {
|
2009-01-03 12:50:49 -05:00
|
|
|
/**
|
|
|
|
* wps - Pointer to long term WPS context
|
|
|
|
*/
|
2008-11-23 12:34:26 -05:00
|
|
|
struct wps_context *wps;
|
2009-01-03 12:50:49 -05:00
|
|
|
|
|
|
|
/**
|
2009-01-03 13:09:35 -05:00
|
|
|
* registrar - Whether this end is a Registrar
|
2009-01-03 12:50:49 -05:00
|
|
|
*/
|
2009-01-03 13:09:35 -05:00
|
|
|
int registrar;
|
2009-01-03 12:50:49 -05:00
|
|
|
|
2009-11-15 11:54:37 -05:00
|
|
|
/**
|
|
|
|
* er - Whether the local end is an external registrar
|
|
|
|
*/
|
|
|
|
int er;
|
|
|
|
|
2008-11-23 12:34:26 -05:00
|
|
|
enum {
|
|
|
|
/* Enrollee states */
|
|
|
|
SEND_M1, RECV_M2, SEND_M3, RECV_M4, SEND_M5, RECV_M6, SEND_M7,
|
|
|
|
RECV_M8, RECEIVED_M2D, WPS_MSG_DONE, RECV_ACK, WPS_FINISHED,
|
|
|
|
SEND_WSC_NACK,
|
|
|
|
|
|
|
|
/* Registrar states */
|
|
|
|
RECV_M1, SEND_M2, RECV_M3, SEND_M4, RECV_M5, SEND_M6,
|
|
|
|
RECV_M7, SEND_M8, RECV_DONE, SEND_M2D, RECV_M2D_ACK
|
|
|
|
} state;
|
|
|
|
|
|
|
|
u8 uuid_e[WPS_UUID_LEN];
|
|
|
|
u8 uuid_r[WPS_UUID_LEN];
|
|
|
|
u8 mac_addr_e[ETH_ALEN];
|
|
|
|
u8 nonce_e[WPS_NONCE_LEN];
|
|
|
|
u8 nonce_r[WPS_NONCE_LEN];
|
|
|
|
u8 psk1[WPS_PSK_LEN];
|
|
|
|
u8 psk2[WPS_PSK_LEN];
|
|
|
|
u8 snonce[2 * WPS_SECRET_NONCE_LEN];
|
|
|
|
u8 peer_hash1[WPS_HASH_LEN];
|
|
|
|
u8 peer_hash2[WPS_HASH_LEN];
|
|
|
|
|
|
|
|
struct wpabuf *dh_privkey;
|
|
|
|
struct wpabuf *dh_pubkey_e;
|
|
|
|
struct wpabuf *dh_pubkey_r;
|
|
|
|
u8 authkey[WPS_AUTHKEY_LEN];
|
|
|
|
u8 keywrapkey[WPS_KEYWRAPKEY_LEN];
|
|
|
|
u8 emsk[WPS_EMSK_LEN];
|
|
|
|
|
|
|
|
struct wpabuf *last_msg;
|
|
|
|
|
|
|
|
u8 *dev_password;
|
|
|
|
size_t dev_password_len;
|
|
|
|
u16 dev_pw_id;
|
|
|
|
int pbc;
|
2013-02-14 13:41:14 -05:00
|
|
|
u8 *alt_dev_password;
|
|
|
|
size_t alt_dev_password_len;
|
|
|
|
u16 alt_dev_pw_id;
|
2008-11-23 12:34:26 -05:00
|
|
|
|
2009-01-03 12:50:49 -05:00
|
|
|
/**
|
|
|
|
* request_type - Request Type attribute from (Re)AssocReq
|
|
|
|
*/
|
|
|
|
u8 request_type;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* encr_type - Available encryption types
|
|
|
|
*/
|
|
|
|
u16 encr_type;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* auth_type - Available authentication types
|
|
|
|
*/
|
|
|
|
u16 auth_type;
|
2008-11-23 12:34:26 -05:00
|
|
|
|
|
|
|
u8 *new_psk;
|
|
|
|
size_t new_psk_len;
|
|
|
|
|
|
|
|
int wps_pin_revealed;
|
|
|
|
struct wps_credential cred;
|
|
|
|
|
|
|
|
struct wps_device_data peer_dev;
|
2008-12-16 15:37:55 -05:00
|
|
|
|
2009-01-03 12:50:49 -05:00
|
|
|
/**
|
|
|
|
* config_error - Configuration Error value to be used in NACK
|
|
|
|
*/
|
|
|
|
u16 config_error;
|
2011-01-13 10:50:59 -05:00
|
|
|
u16 error_indication;
|
2009-01-29 11:47:02 -05:00
|
|
|
|
|
|
|
int ext_reg;
|
2010-02-12 05:38:14 -05:00
|
|
|
int int_reg;
|
2009-09-06 06:58:15 -04:00
|
|
|
|
|
|
|
struct wps_credential *new_ap_settings;
|
2009-10-11 12:17:22 -04:00
|
|
|
|
|
|
|
void *dh_ctx;
|
2009-11-15 15:27:06 -05:00
|
|
|
|
|
|
|
void (*ap_settings_cb)(void *ctx, const struct wps_credential *cred);
|
|
|
|
void *ap_settings_cb_ctx;
|
2009-11-15 15:46:30 -05:00
|
|
|
|
|
|
|
struct wps_credential *use_cred;
|
2009-12-21 05:46:19 -05:00
|
|
|
|
|
|
|
int use_psk_key;
|
2011-02-07 11:28:36 -05:00
|
|
|
u8 p2p_dev_addr[ETH_ALEN]; /* P2P Device Address of the client or
|
|
|
|
* 00:00:00:00:00:00 if not a P2p client */
|
2011-05-17 12:53:02 -04:00
|
|
|
int pbc_in_m1;
|
2012-06-27 15:15:55 -04:00
|
|
|
|
|
|
|
struct wps_nfc_pw_token *nfc_pw_token;
|
2008-11-23 12:34:26 -05:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
/* wps_common.c */
|
2008-11-29 05:11:56 -05:00
|
|
|
void wps_kdf(const u8 *key, const u8 *label_prefix, size_t label_prefix_len,
|
|
|
|
const char *label, u8 *res, size_t res_len);
|
2008-11-23 12:34:26 -05:00
|
|
|
int wps_derive_keys(struct wps_data *wps);
|
|
|
|
void wps_derive_psk(struct wps_data *wps, const u8 *dev_passwd,
|
|
|
|
size_t dev_passwd_len);
|
|
|
|
struct wpabuf * wps_decrypt_encr_settings(struct wps_data *wps, const u8 *encr,
|
|
|
|
size_t encr_len);
|
2010-10-14 13:49:54 -04:00
|
|
|
void wps_fail_event(struct wps_context *wps, enum wps_msg_type msg,
|
2011-01-13 10:50:59 -05:00
|
|
|
u16 config_error, u16 error_indication);
|
2008-12-19 15:34:18 -05:00
|
|
|
void wps_success_event(struct wps_context *wps);
|
2009-01-23 14:57:43 -05:00
|
|
|
void wps_pwd_auth_fail_event(struct wps_context *wps, int enrollee, int part);
|
2009-11-01 14:26:13 -05:00
|
|
|
void wps_pbc_overlap_event(struct wps_context *wps);
|
|
|
|
void wps_pbc_timeout_event(struct wps_context *wps);
|
2008-11-29 06:16:26 -05:00
|
|
|
|
2010-11-04 12:16:14 -04:00
|
|
|
struct wpabuf * wps_build_wsc_ack(struct wps_data *wps);
|
|
|
|
struct wpabuf * wps_build_wsc_nack(struct wps_data *wps);
|
|
|
|
|
2008-11-29 06:16:26 -05:00
|
|
|
/* wps_attr_build.c */
|
|
|
|
int wps_build_public_key(struct wps_data *wps, struct wpabuf *msg);
|
|
|
|
int wps_build_req_type(struct wpabuf *msg, enum wps_request_type type);
|
2010-05-26 11:46:08 -04:00
|
|
|
int wps_build_resp_type(struct wpabuf *msg, enum wps_response_type type);
|
2008-11-29 06:16:26 -05:00
|
|
|
int wps_build_config_methods(struct wpabuf *msg, u16 methods);
|
|
|
|
int wps_build_uuid_e(struct wpabuf *msg, const u8 *uuid);
|
|
|
|
int wps_build_dev_password_id(struct wpabuf *msg, u16 id);
|
|
|
|
int wps_build_config_error(struct wpabuf *msg, u16 err);
|
|
|
|
int wps_build_authenticator(struct wps_data *wps, struct wpabuf *msg);
|
2008-11-23 12:34:26 -05:00
|
|
|
int wps_build_key_wrap_auth(struct wps_data *wps, struct wpabuf *msg);
|
|
|
|
int wps_build_encr_settings(struct wps_data *wps, struct wpabuf *msg,
|
|
|
|
struct wpabuf *plain);
|
|
|
|
int wps_build_version(struct wpabuf *msg);
|
2010-07-29 13:23:20 -04:00
|
|
|
int wps_build_wfa_ext(struct wpabuf *msg, int req_to_enroll,
|
|
|
|
const u8 *auth_macs, size_t auth_macs_count);
|
2008-11-23 12:34:26 -05:00
|
|
|
int wps_build_msg_type(struct wpabuf *msg, enum wps_msg_type msg_type);
|
|
|
|
int wps_build_enrollee_nonce(struct wps_data *wps, struct wpabuf *msg);
|
|
|
|
int wps_build_registrar_nonce(struct wps_data *wps, struct wpabuf *msg);
|
|
|
|
int wps_build_auth_type_flags(struct wps_data *wps, struct wpabuf *msg);
|
|
|
|
int wps_build_encr_type_flags(struct wps_data *wps, struct wpabuf *msg);
|
|
|
|
int wps_build_conn_type_flags(struct wps_data *wps, struct wpabuf *msg);
|
|
|
|
int wps_build_assoc_state(struct wps_data *wps, struct wpabuf *msg);
|
2012-06-27 11:25:16 -04:00
|
|
|
int wps_build_oob_dev_pw(struct wpabuf *msg, u16 dev_pw_id,
|
|
|
|
const struct wpabuf *pubkey, const u8 *dev_pw,
|
|
|
|
size_t dev_pw_len);
|
2010-05-26 12:11:55 -04:00
|
|
|
struct wpabuf * wps_ie_encapsulate(struct wpabuf *data);
|
2008-11-29 06:16:26 -05:00
|
|
|
|
|
|
|
/* wps_attr_process.c */
|
|
|
|
int wps_process_authenticator(struct wps_data *wps, const u8 *authenticator,
|
|
|
|
const struct wpabuf *msg);
|
|
|
|
int wps_process_key_wrap_auth(struct wps_data *wps, struct wpabuf *msg,
|
|
|
|
const u8 *key_wrap_auth);
|
2008-11-27 13:15:48 -05:00
|
|
|
int wps_process_cred(struct wps_parse_attr *attr,
|
|
|
|
struct wps_credential *cred);
|
|
|
|
int wps_process_ap_settings(struct wps_parse_attr *attr,
|
|
|
|
struct wps_credential *cred);
|
2008-11-23 12:34:26 -05:00
|
|
|
|
|
|
|
/* wps_enrollee.c */
|
2009-01-03 12:50:49 -05:00
|
|
|
struct wpabuf * wps_enrollee_get_msg(struct wps_data *wps,
|
|
|
|
enum wsc_op_code *op_code);
|
|
|
|
enum wps_process_res wps_enrollee_process_msg(struct wps_data *wps,
|
|
|
|
enum wsc_op_code op_code,
|
2008-11-23 12:34:26 -05:00
|
|
|
const struct wpabuf *msg);
|
|
|
|
|
|
|
|
/* wps_registrar.c */
|
2009-01-03 12:50:49 -05:00
|
|
|
struct wpabuf * wps_registrar_get_msg(struct wps_data *wps,
|
|
|
|
enum wsc_op_code *op_code);
|
2008-11-23 12:34:26 -05:00
|
|
|
enum wps_process_res wps_registrar_process_msg(struct wps_data *wps,
|
2009-01-03 12:50:49 -05:00
|
|
|
enum wsc_op_code op_code,
|
2008-11-23 12:34:26 -05:00
|
|
|
const struct wpabuf *msg);
|
2009-02-26 14:57:38 -05:00
|
|
|
int wps_build_cred(struct wps_data *wps, struct wpabuf *msg);
|
2009-09-07 15:09:13 -04:00
|
|
|
int wps_device_store(struct wps_registrar *reg,
|
|
|
|
struct wps_device_data *dev, const u8 *uuid);
|
2009-12-12 09:54:59 -05:00
|
|
|
void wps_registrar_selected_registrar_changed(struct wps_registrar *reg);
|
2010-07-29 13:23:20 -04:00
|
|
|
const u8 * wps_authorized_macs(struct wps_registrar *reg, size_t *count);
|
2010-07-21 22:19:53 -04:00
|
|
|
int wps_registrar_pbc_overlap(struct wps_registrar *reg,
|
|
|
|
const u8 *addr, const u8 *uuid_e);
|
2012-06-27 15:15:55 -04:00
|
|
|
void wps_registrar_remove_nfc_pw_token(struct wps_registrar *reg,
|
|
|
|
struct wps_nfc_pw_token *token);
|
2008-11-23 12:34:26 -05:00
|
|
|
|
|
|
|
#endif /* WPS_I_H */
|