1 /* 2 * Wi-Fi Protected Setup - attribute parsing 3 * Copyright (c) 2008-2012, Jouni Malinen <j@w1.fi> 4 * 5 * This software may be distributed under the terms of the BSD license. 6 * See README for more details. 7 */ 8 9 #ifndef WPS_ATTR_PARSE_H 10 #define WPS_ATTR_PARSE_H 11 12 #include "wps.h" 13 14 struct wps_parse_attr { 15 /* fixed length fields */ 16 const u8 *version; /* 1 octet */ 17 const u8 *version2; /* 1 octet */ 18 const u8 *msg_type; /* 1 octet */ 19 const u8 *enrollee_nonce; /* WPS_NONCE_LEN (16) octets */ 20 const u8 *registrar_nonce; /* WPS_NONCE_LEN (16) octets */ 21 const u8 *uuid_r; /* WPS_UUID_LEN (16) octets */ 22 const u8 *uuid_e; /* WPS_UUID_LEN (16) octets */ 23 const u8 *auth_type_flags; /* 2 octets */ 24 const u8 *encr_type_flags; /* 2 octets */ 25 const u8 *conn_type_flags; /* 1 octet */ 26 const u8 *config_methods; /* 2 octets */ 27 const u8 *sel_reg_config_methods; /* 2 octets */ 28 const u8 *primary_dev_type; /* 8 octets */ 29 const u8 *rf_bands; /* 1 octet */ 30 const u8 *assoc_state; /* 2 octets */ 31 const u8 *config_error; /* 2 octets */ 32 const u8 *dev_password_id; /* 2 octets */ 33 const u8 *os_version; /* 4 octets */ 34 const u8 *wps_state; /* 1 octet */ 35 const u8 *authenticator; /* WPS_AUTHENTICATOR_LEN (8) octets */ 36 const u8 *r_hash1; /* WPS_HASH_LEN (32) octets */ 37 const u8 *r_hash2; /* WPS_HASH_LEN (32) octets */ 38 const u8 *e_hash1; /* WPS_HASH_LEN (32) octets */ 39 const u8 *e_hash2; /* WPS_HASH_LEN (32) octets */ 40 const u8 *r_snonce1; /* WPS_SECRET_NONCE_LEN (16) octets */ 41 const u8 *r_snonce2; /* WPS_SECRET_NONCE_LEN (16) octets */ 42 const u8 *e_snonce1; /* WPS_SECRET_NONCE_LEN (16) octets */ 43 const u8 *e_snonce2; /* WPS_SECRET_NONCE_LEN (16) octets */ 44 const u8 *key_wrap_auth; /* WPS_KWA_LEN (8) octets */ 45 const u8 *auth_type; /* 2 octets */ 46 const u8 *encr_type; /* 2 octets */ 47 const u8 *network_idx; /* 1 octet */ 48 const u8 *network_key_idx; /* 1 octet */ 49 const u8 *mac_addr; /* ETH_ALEN (6) octets */ 50 const u8 *selected_registrar; /* 1 octet (Bool) */ 51 const u8 *request_type; /* 1 octet */ 52 const u8 *response_type; /* 1 octet */ 53 const u8 *ap_setup_locked; /* 1 octet */ 54 const u8 *settings_delay_time; /* 1 octet */ 55 const u8 *network_key_shareable; /* 1 octet (Bool) */ 56 const u8 *request_to_enroll; /* 1 octet (Bool) */ 57 const u8 *ap_channel; /* 2 octets */ 58 const u8 *registrar_configuration_methods; /* 2 octets */ 59 60 /* variable length fields */ 61 const u8 *manufacturer; 62 size_t manufacturer_len; 63 const u8 *model_name; 64 size_t model_name_len; 65 const u8 *model_number; 66 size_t model_number_len; 67 const u8 *serial_number; 68 size_t serial_number_len; 69 const u8 *dev_name; 70 size_t dev_name_len; 71 const u8 *public_key; 72 size_t public_key_len; 73 const u8 *encr_settings; 74 size_t encr_settings_len; 75 const u8 *ssid; /* <= 32 octets */ 76 size_t ssid_len; 77 const u8 *network_key; /* <= 64 octets */ 78 size_t network_key_len; 79 const u8 *authorized_macs; /* <= 30 octets */ 80 size_t authorized_macs_len; 81 const u8 *sec_dev_type_list; /* <= 128 octets */ 82 size_t sec_dev_type_list_len; 83 const u8 *oob_dev_password; /* 38..54 octets */ 84 size_t oob_dev_password_len; 85 86 /* attributes that can occur multiple times */ 87 #define MAX_CRED_COUNT 10 88 const u8 *cred[MAX_CRED_COUNT]; 89 size_t cred_len[MAX_CRED_COUNT]; 90 size_t num_cred; 91 92 #define MAX_REQ_DEV_TYPE_COUNT 10 93 const u8 *req_dev_type[MAX_REQ_DEV_TYPE_COUNT]; 94 size_t num_req_dev_type; 95 96 const u8 *vendor_ext[MAX_WPS_PARSE_VENDOR_EXT]; 97 size_t vendor_ext_len[MAX_WPS_PARSE_VENDOR_EXT]; 98 size_t num_vendor_ext; 99 }; 100 101 int wps_parse_msg(const struct wpabuf *msg, struct wps_parse_attr *attr); 102 103 #endif /* WPS_ATTR_PARSE_H */ 104