eiwd

no dbus iwd with iwctl functionality
git clone https://git.daat.foo/repos/eiwd.git
Log | Files | Refs | Submodules | README | LICENSE

wscutil.h (21548B)


      1 /*
      2  *
      3  *  Wireless daemon for Linux
      4  *
      5  *  Copyright (C) 2015-2019  Intel Corporation. All rights reserved.
      6  *
      7  *  This library is free software; you can redistribute it and/or
      8  *  modify it under the terms of the GNU Lesser General Public
      9  *  License as published by the Free Software Foundation; either
     10  *  version 2.1 of the License, or (at your option) any later version.
     11  *
     12  *  This library is distributed in the hope that it will be useful,
     13  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
     14  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
     15  *  Lesser General Public License for more details.
     16  *
     17  *  You should have received a copy of the GNU Lesser General Public
     18  *  License along with this library; if not, write to the Free Software
     19  *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
     20  *
     21  */
     22 
     23 #include "src/defs.h"
     24 
     25 struct iovec;
     26 
     27 /* Wi-Fi Simple Configuration Technical Specification v2.0.5, Section 12 */
     28 enum wsc_attr {
     29 	WSC_ATTR_8021X_ENABLED					= 0x1062,
     30 	WSC_ATTR_AP_CHANNEL					= 0x1001,
     31 	WSC_ATTR_AP_SETUP_LOCKED				= 0x1057,
     32 	WSC_ATTR_APPLICATION_EXTENTION				= 0x1058,
     33 	WSC_ATTR_APP_SESSION_KEY				= 0x1063,
     34 	WSC_ATTR_ASSOCIATION_STATE				= 0x1002,
     35 	WSC_ATTR_AUTHENTICATION_TYPE				= 0x1003,
     36 	WSC_ATTR_AUTHENTICATION_TYPE_FLAGS			= 0x1004,
     37 	WSC_ATTR_AUTHENTICATOR					= 0x1005,
     38 	WSC_ATTR_CONFIGURATION_ERROR				= 0x1009,
     39 	WSC_ATTR_CONFIGURATION_METHODS				= 0x1008,
     40 	WSC_ATTR_CONFIRMATION_URL4				= 0x100A,
     41 	WSC_ATTR_CONFIRMATION_URL6				= 0x100B,
     42 	WSC_ATTR_CONNECTION_TYPE				= 0x100C,
     43 	WSC_ATTR_CONNECTION_TYPE_FLAGS				= 0x100D,
     44 	WSC_ATTR_CREDENTIAL					= 0x100E,
     45 	WSC_ATTR_DEVICE_NAME					= 0x1011,
     46 	WSC_ATTR_DEVICE_PASSWORD_ID				= 0x1012,
     47 	WSC_ATTR_EAP_IDENTITY					= 0x104D,
     48 	WSC_ATTR_EAP_TYPE					= 0x1059,
     49 	WSC_ATTR_E_HASH1					= 0x1014,
     50 	WSC_ATTR_E_HASH2					= 0x1015,
     51 	WSC_ATTR_ENCRYPTED_SETTINGS				= 0x1018,
     52 	WSC_ATTR_ENCRYPTION_TYPE				= 0x100F,
     53 	WSC_ATTR_ENCRYPTION_TYPE_FLAGS				= 0x1010,
     54 	WSC_ATTR_ENROLLEE_NONCE					= 0x101A,
     55 	WSC_ATTR_E_SNONCE1					= 0x1016,
     56 	WSC_ATTR_E_SNONCE2					= 0x1017,
     57 	WSC_ATTR_FEATURE_ID					= 0x101B,
     58 	WSC_ATTR_IDENTITY					= 0x101C,
     59 	WSC_ATTR_IDENTITY_PROOF					= 0x101D,
     60 	WSC_ATTR_INITIALIZATION_VECTOR				= 0x1060,
     61 	WSC_ATTR_KEY_IDENTIFIER					= 0x101F,
     62 	WSC_ATTR_KEY_LIFETIME					= 0x1051,
     63 	WSC_ATTR_KEY_PROVIDED_AUTOMATICALLY			= 0x1061,
     64 	WSC_ATTR_KEY_WRAP_AUTHENTICATOR				= 0x101E,
     65 	WSC_ATTR_MAC_ADDRESS					= 0x1020,
     66 	WSC_ATTR_MANUFACTURER					= 0x1021,
     67 	WSC_ATTR_MESSAGE_COUNTER				= 0x104E,
     68 	WSC_ATTR_MESSAGE_TYPE					= 0x1022,
     69 	WSC_ATTR_MODEL_NAME					= 0x1023,
     70 	WSC_ATTR_MODEL_NUMBER					= 0x1024,
     71 	WSC_ATTR_NETWORK_INDEX					= 0x1026,
     72 	WSC_ATTR_NETWORK_KEY					= 0x1027,
     73 	WSC_ATTR_NETWORK_KEY_INDEX				= 0x1028,
     74 	WSC_ATTR_NEW_DEVICE_NAME				= 0x1029,
     75 	WSC_ATTR_NEW_PASSWORD					= 0x102A,
     76 	WSC_ATTR_OOB_DEVICE_PASSWORD				= 0x102C,
     77 	WSC_ATTR_OS_VERSION					= 0x102D,
     78 	WSC_ATTR_PERMITTED_CONFIGURATION_METHODS		= 0x1052,
     79 	WSC_ATTR_PORTABLE_DEVICE				= 0x1056,
     80 	WSC_ATTR_POWER_LEVEL					= 0x102F,
     81 	WSC_ATTR_PRIMARY_DEVICE_TYPE				= 0x1054,
     82 	WSC_ATTR_PSK_CURRENT					= 0x1030,
     83 	WSC_ATTR_PSK_MAX					= 0x1031,
     84 	WSC_ATTR_PUBLIC_KEY					= 0x1032,
     85 	WSC_ATTR_PUBLIC_KEY_HASH				= 0x104F,
     86 	WSC_ATTR_RADIO_ENABLED					= 0x1033,
     87 	WSC_ATTR_REBOOT						= 0x1034,
     88 	WSC_ATTR_REGISTRAR_CURRENT				= 0x1035,
     89 	WSC_ATTR_REGISTRAR_ESTABLISHED				= 0x1036,
     90 	WSC_ATTR_REGISTRAR_LIST					= 0x1037,
     91 	WSC_ATTR_REGISTRAR_MAX					= 0x1038,
     92 	WSC_ATTR_REGISTRAR_NONCE				= 0x1039,
     93 	WSC_ATTR_REKEY_KEY					= 0x1050,
     94 	WSC_ATTR_REQUEST_TYPE					= 0x103A,
     95 	WSC_ATTR_REQUESTED_DEVICE_TYPE				= 0x106A,
     96 	WSC_ATTR_RESPONSE_TYPE					= 0x103B,
     97 	WSC_ATTR_RF_BANDS					= 0x103C,
     98 	WSC_ATTR_R_HASH1					= 0x103D,
     99 	WSC_ATTR_R_HASH2					= 0x103E,
    100 	WSC_ATTR_R_SNONCE1					= 0x103F,
    101 	WSC_ATTR_R_SNONCE2					= 0x1040,
    102 	WSC_ATTR_SECONDARY_DEVICE_TYPE_LIST			= 0x1055,
    103 	WSC_ATTR_SELECTED_REGISTRAR				= 0x1041,
    104 	WSC_ATTR_SELECTED_REGISTRAR_CONFIGURATION_METHODS	= 0x1053,
    105 	WSC_ATTR_SERIAL_NUMBER					= 0x1042,
    106 	WSC_ATTR_SSID						= 0x1045,
    107 	WSC_ATTR_TOTAL_NETWORKS					= 0x1046,
    108 	WSC_ATTR_UUID_E						= 0x1047,
    109 	WSC_ATTR_UUID_R						= 0x1048,
    110 	WSC_ATTR_VENDOR_EXTENSION				= 0x1049,
    111 	WSC_ATTR_VERSION					= 0x104A,
    112 	WSC_ATTR_WEP_TRANSMIT_KEY				= 0x1064,
    113 	WSC_ATTR_WSC_STATE					= 0x1044,
    114 	WSC_ATTR_X509_CERTIFICATE_REQUEST			= 0x104B,
    115 	WSC_ATTR_X509_CERTIFICATE				= 0x104C,
    116 	WSC_ATTR_INVALID					= 0x0000,
    117 };
    118 
    119 /* Table 29 */
    120 enum wsc_wfa_extension {
    121 	WSC_WFA_EXTENSION_VERSION2				= 0x00,
    122 	WSC_WFA_EXTENSION_AUTHORIZED_MACS			= 0x01,
    123 	WSC_WFA_EXTENSION_NETWORK_KEY_SHAREABLE			= 0x02,
    124 	WSC_WFA_EXTENSION_REQUEST_TO_ENROLL			= 0x03,
    125 	WSC_WFA_EXTENSION_SETTINGS_DELAY_TIME			= 0x04,
    126 	WSC_WFA_EXTENSION_REGISTRAR_CONFIGRATION_METHODS	= 0x05,
    127 };
    128 
    129 /* Table 31 */
    130 enum wsc_association_state {
    131 	WSC_ASSOCIATION_STATE_NOT_ASSOCIATED			= 0,
    132 	WSC_ASSOCIATION_STATE_CONNECTION_SUCCESS		= 1,
    133 	WSC_ASSOCIATION_STATE_CONFIGURATION_FAILURE		= 2,
    134 	WSC_ASSOCIATION_STATE_ASSOCIATION_FAILURE		= 3,
    135 	WSC_ASSOCIATION_STATE_IP_FAILURE			= 4,
    136 };
    137 
    138 /* Table 32 */
    139 enum wsc_authentication_type {
    140 	WSC_AUTHENTICATION_TYPE_OPEN			= 0x0001,
    141 	WSC_AUTHENTICATION_TYPE_WPA_PERSONAL		= 0x0002,
    142 	WSC_AUTHENTICATION_TYPE_SHARED			= 0x0004,
    143 	WSC_AUTHENTICATION_TYPE_WPA_ENTERPRISE		= 0x0008,
    144 	WSC_AUTHENTICATION_TYPE_WPA2_ENTERPRISE		= 0x0010,
    145 	WSC_AUTHENTICATION_TYPE_WPA2_PERSONAL		= 0x0020,
    146 };
    147 
    148 /* Table 33 */
    149 enum wsc_configration_method {
    150 	WSC_CONFIGURATION_METHOD_USBA			= 0x0001,
    151 	WSC_CONFIGURATION_METHOD_ETHERNET		= 0x0002,
    152 	WSC_CONFIGURATION_METHOD_LABEL			= 0x0004,
    153 	WSC_CONFIGURATION_METHOD_DISPLAY		= 0x0008,
    154 	WSC_CONFIGURATION_METHOD_EXTERNAL_NFC_TOKEN	= 0x0010,
    155 	WSC_CONFIGURATION_METHOD_INTEGRATED_NFC_TOKEN	= 0x0020,
    156 	WSC_CONFIGURATION_METHOD_NFC_INTERFACE		= 0x0040,
    157 	WSC_CONFIGURATION_METHOD_PUSH_BUTTON		= 0x0080,
    158 	WSC_CONFIGURATION_METHOD_KEYPAD			= 0x0100,
    159 	WSC_CONFIGURATION_METHOD_VIRTUAL_PUSH_BUTTON	= 0x0280,
    160 	WSC_CONFIGURATION_METHOD_PHYSICAL_PUSH_BUTTON	= 0x0480,
    161 	WSC_CONFIGURATION_METHOD_P2P			= 0x1000,
    162 	WSC_CONFIGURATION_METHOD_VIRTUAL_DISPLAY_PIN	= 0x2008,
    163 	WSC_CONFIGURATION_METHOD_PHYSICAL_DISPLAY_PIN	= 0x4008,
    164 };
    165 
    166 /* Table 34 */
    167 enum wsc_configuration_error {
    168 	WSC_CONFIGURATION_ERROR_NO_ERROR				= 0,
    169 	WSC_CONFIGURATION_ERROR_OOB_INTERFACE_READ_ERROR		= 1,
    170 	WSC_CONFIGURATION_ERROR_DECRYPTION_CRC_FAILURE			= 2,
    171 	WSC_CONFIGURATION_ERROR_2_4_CHANNEL_NOT_SUPPORTED		= 3,
    172 	WSC_CONFIGURATION_ERROR_5_0_CHANNEL_NOT_SUPPORTED		= 4,
    173 	WSC_CONFIGURATION_ERROR_SIGNAL_TOO_WEAK				= 5,
    174 	WSC_CONFIGURATION_ERROR_NETWORK_AUTH_FAILURE			= 6,
    175 	WSC_CONFIGURATION_ERROR_NETWORK_ASSOCIATION_FAILURE		= 7,
    176 	WSC_CONFIGURATION_ERROR_NO_DHCP_RESPONSE			= 8,
    177 	WSC_CONFIGURATION_ERROR_FAILED_DHCP_CONFIG			= 9,
    178 	WSC_CONFIGURATION_ERROR_IP_ADDRESS_CONFILICT			= 10,
    179 	WSC_CONFIGURATION_ERROR_COULD_NOT_CONNECT_TO_REGISTRAR		= 11,
    180 	WSC_CONFIGURATION_ERROR_MULTIPLE_PBC_SESSIONS_DETECTED		= 12,
    181 	WSC_CONFIGURATION_ERROR_ROGUE_ACTIVITY_SUSPECTED		= 13,
    182 	WSC_CONFIGURATION_ERROR_DEVICE_BUSY				= 14,
    183 	WSC_CONFIGURATION_ERROR_SETUP_LOCKED				= 15,
    184 	WSC_CONFIGURATION_ERROR_MESSAGE_TIMEOUT				= 16,
    185 	WSC_CONFIGURATION_ERROR_REGISTRATION_SESSION_TIMEOUT		= 17,
    186 	WSC_CONFIGURATION_ERROR_DEVICE_PASSWORD_AUTH_FAILURE		= 18,
    187 	WSC_CONFIGURATION_ERROR_60_GHZ_CHANNEL_NOT_SUPPORTED		= 19,
    188 	WSC_CONFIGURATION_ERROR_PUBLIC_KEY_HASH_MISMATCH		= 20,
    189 };
    190 
    191 /* Table 35 */
    192 enum wsc_connection_type {
    193 	WSC_CONNECTION_TYPE_ESS		= 0x1,
    194 	WSC_CONNECTION_TYPE_IBSS	= 0x2,
    195 };
    196 
    197 /* Table 37 */
    198 enum wsc_device_password_id {
    199 	WSC_DEVICE_PASSWORD_ID_DEFAULT			= 0x0000,
    200 	WSC_DEVICE_PASSWORD_ID_USER_SPECIFIED		= 0x0001,
    201 	WSC_DEVICE_PASSWORD_ID_MACHINE_SPECIFIED	= 0x0002,
    202 	WSC_DEVICE_PASSWORD_ID_REKEY			= 0x0003,
    203 	WSC_DEVICE_PASSWORD_ID_PUSH_BUTTON		= 0x0004,
    204 	WSC_DEVICE_PASSWORD_ID_REGISTRAR_SPECIFIED	= 0x0005,
    205 	WSC_DEVICE_PASSWORD_ID_NFC_CONNECTION_HANDOVER	= 0x0007,
    206 };
    207 
    208 /* Table 38 */
    209 enum wsc_encryption_type {
    210 	WSC_ENCRYPTION_TYPE_NONE		= 0x0001,
    211 	WSC_ENCRYPTION_TYPE_WEP			= 0x0002,
    212 	WSC_ENCRYPTION_TYPE_TKIP		= 0x0004,
    213 	WSC_ENCRYPTION_TYPE_AES			= 0x0008,
    214 	WSC_ENCRYPTION_TYPE_AES_TKIP		= 0x000C,
    215 };
    216 
    217 /* Table 39 */
    218 enum wsc_message_type {
    219 	WSC_MESSAGE_TYPE_BEACON			= 0x01,
    220 	WSC_MESSAGE_TYPE_PROBE_REQUEST		= 0x02,
    221 	WSC_MESSAGE_TYPE_PROBE_RESPONSE		= 0x03,
    222 	WSC_MESSAGE_TYPE_M1			= 0x04,
    223 	WSC_MESSAGE_TYPE_M2			= 0x05,
    224 	WSC_MESSAGE_TYPE_M2D			= 0x06,
    225 	WSC_MESSAGE_TYPE_M3			= 0x07,
    226 	WSC_MESSAGE_TYPE_M4			= 0x08,
    227 	WSC_MESSAGE_TYPE_M5			= 0x09,
    228 	WSC_MESSAGE_TYPE_M6			= 0x0A,
    229 	WSC_MESSAGE_TYPE_M7			= 0x0B,
    230 	WSC_MESSAGE_TYPE_M8			= 0x0C,
    231 	WSC_MESSAGE_TYPE_WSC_ACK		= 0x0D,
    232 	WSC_MESSAGE_TYPE_WSC_NACK		= 0x0E,
    233 	WSC_MESSAGE_TYPE_WSC_DONE		= 0x0F,
    234 };
    235 
    236 /* Table 42 */
    237 enum wsc_request_type {
    238 	WSC_REQUEST_TYPE_ENROLLEE_INFO		= 0x00,
    239 	WSC_REQUEST_TYPE_ENROLLEE_OPEN_8021X	= 0x01,
    240 	WSC_REQUEST_TYPE_REGISTRAR		= 0x02,
    241 	WSC_REQUEST_TYPE_WLAN_MANAGER_REGISTRAR	= 0x03,
    242 };
    243 
    244 /* Table 43 */
    245 enum wsc_response_type {
    246 	WSC_RESPONSE_TYPE_ENROLLEE_INFO		= 0x00,
    247 	WSC_RESPONSE_TYPE_ENROLLEE_OPEN_8021X	= 0x01,
    248 	WSC_RESPONSE_TYPE_REGISTRAR		= 0x02,
    249 	WSC_RESPONSE_TYPE_AP			= 0x03,
    250 };
    251 
    252 /* Table 44 */
    253 enum wsc_rf_band {
    254 	WSC_RF_BAND_2_4_GHZ			= 0x01,
    255 	WSC_RF_BAND_5_0_GHZ			= 0x02,
    256 	WSC_RF_BAND_60_GHZ			= 0x04,
    257 };
    258 
    259 /* Table 45 */
    260 enum wsc_state {
    261 	WSC_STATE_NOT_CONFIGURED	= 0x01,
    262 	WSC_STATE_CONFIGURED		= 0x02,
    263 };
    264 
    265 extern const unsigned char wsc_wfa_oui[3];
    266 
    267 struct wsc_wfa_ext_iter {
    268 	unsigned short max;
    269 	unsigned short pos;
    270 	const unsigned char *pdu;
    271 	unsigned char type;
    272 	unsigned char len;
    273 	const unsigned char *data;
    274 };
    275 
    276 void wsc_wfa_ext_iter_init(struct wsc_wfa_ext_iter *iter,
    277 				const unsigned char *pdu, unsigned short len);
    278 bool wsc_wfa_ext_iter_next(struct wsc_wfa_ext_iter *iter);
    279 
    280 static inline unsigned char wsc_wfa_ext_iter_get_type(
    281 						struct wsc_wfa_ext_iter *iter)
    282 {
    283 	return iter->type;
    284 }
    285 
    286 static inline unsigned char wsc_wfa_ext_iter_get_length(
    287 						struct wsc_wfa_ext_iter *iter)
    288 {
    289 	return iter->len;
    290 }
    291 
    292 static inline const unsigned char *wsc_wfa_ext_iter_get_data(
    293 						struct wsc_wfa_ext_iter *iter)
    294 {
    295 	return iter->data;
    296 }
    297 
    298 struct wsc_attr_iter {
    299 	unsigned int max;
    300 	unsigned int pos;
    301 	const unsigned char *pdu;
    302 	unsigned short type;
    303 	unsigned short len;
    304 	const unsigned char *data;
    305 };
    306 
    307 void wsc_attr_iter_init(struct wsc_attr_iter *iter, const unsigned char *pdu,
    308 			unsigned int len);
    309 bool wsc_attr_iter_next(struct wsc_attr_iter *iter);
    310 bool wsc_attr_iter_recurse_wfa_ext(struct wsc_attr_iter *iter,
    311 					struct wsc_wfa_ext_iter *wfa_iter);
    312 
    313 static inline unsigned int wsc_attr_iter_get_type(struct wsc_attr_iter *iter)
    314 {
    315 	return iter->type;
    316 }
    317 
    318 static inline unsigned int wsc_attr_iter_get_length(struct wsc_attr_iter *iter)
    319 {
    320 	return iter->len;
    321 }
    322 
    323 static inline const unsigned char *wsc_attr_iter_get_data(
    324 						struct wsc_attr_iter *iter)
    325 {
    326 	return iter->data;
    327 }
    328 
    329 static inline unsigned int wsc_attr_iter_get_pos(struct wsc_attr_iter *iter)
    330 {
    331 	return iter->pos;
    332 }
    333 
    334 struct wsc_credential {
    335 	uint8_t ssid[SSID_MAX_SIZE];
    336 	uint8_t ssid_len;
    337 	uint16_t auth_type;
    338 	uint16_t encryption_type;
    339 	uint8_t network_key[65];	/* max 64 + space for null terminator */
    340 	uint8_t network_key_len;
    341 	uint8_t addr[6];
    342 };
    343 
    344 struct wsc_primary_device_type {
    345 	uint16_t category;
    346 	uint8_t oui[3];
    347 	uint8_t oui_type;
    348 	uint16_t subcategory;
    349 };
    350 
    351 struct wsc_beacon {
    352 	bool version2;
    353 	enum wsc_state state;
    354 	bool ap_setup_locked;
    355 	bool selected_registrar;
    356 	enum wsc_device_password_id device_password_id;
    357 	uint16_t selected_reg_config_methods;
    358 	uint8_t uuid_e[16];
    359 	uint8_t rf_bands;
    360 	uint8_t authorized_macs[30];
    361 	uint16_t reg_config_methods;
    362 };
    363 
    364 struct wsc_probe_response {
    365 	bool version2;
    366 	enum wsc_state state;
    367 	bool ap_setup_locked;
    368 	bool selected_registrar;
    369 	enum wsc_device_password_id device_password_id;
    370 	uint16_t selected_reg_config_methods;
    371 	enum wsc_response_type response_type;
    372 	uint8_t uuid_e[16];
    373 	char manufacturer[65];
    374 	char model_name[33];
    375 	char model_number[33];
    376 	char serial_number[33];
    377 	struct wsc_primary_device_type primary_device_type;
    378 	char device_name[33];
    379 	uint16_t config_methods;
    380 	uint8_t rf_bands;
    381 	uint8_t authorized_macs[30];
    382 	uint16_t reg_config_methods;
    383 };
    384 
    385 struct wsc_probe_request {
    386 	bool version2;
    387 	enum wsc_request_type request_type;
    388 	uint16_t config_methods;
    389 	uint8_t uuid_e[16];
    390 	struct wsc_primary_device_type primary_device_type;
    391 	uint8_t rf_bands;
    392 	enum wsc_association_state association_state;
    393 	enum wsc_configuration_error configuration_error;
    394 	enum wsc_device_password_id device_password_id;
    395 	char manufacturer[65];
    396 	char model_name[33];
    397 	char model_number[33];
    398 	char serial_number[33];
    399 	char device_name[33];
    400 	bool request_to_enroll;
    401 	struct wsc_primary_device_type requested_device_type;
    402 };
    403 
    404 struct wsc_association_request {
    405 	bool version2;
    406 	enum wsc_request_type request_type;
    407 };
    408 
    409 struct wsc_association_response {
    410 	bool version2;
    411 	enum wsc_response_type response_type;
    412 };
    413 
    414 struct wsc_m1 {
    415 	bool version2;
    416 	uint8_t uuid_e[16];
    417 	uint8_t addr[6];
    418 	uint8_t enrollee_nonce[16];
    419 	uint8_t public_key[192];
    420 	uint16_t auth_type_flags;
    421 	uint16_t encryption_type_flags;
    422 	uint8_t connection_type_flags;
    423 	uint16_t config_methods;
    424 	enum wsc_state state;
    425 	char manufacturer[65];
    426 	char model_name[33];
    427 	char model_number[33];
    428 	char serial_number[33];
    429 	struct wsc_primary_device_type primary_device_type;
    430 	char device_name[33];
    431 	uint8_t rf_bands;
    432 	enum wsc_association_state association_state;
    433 	enum wsc_device_password_id device_password_id;
    434 	enum wsc_configuration_error configuration_error;
    435 	uint32_t os_version;
    436 	bool request_to_enroll;
    437 };
    438 
    439 struct wsc_m2 {
    440 	bool version2;
    441 	uint8_t enrollee_nonce[16];
    442 	uint8_t registrar_nonce[16];
    443 	uint8_t uuid_r[16];
    444 	uint8_t public_key[192];
    445 	uint16_t auth_type_flags;
    446 	uint16_t encryption_type_flags;
    447 	uint8_t connection_type_flags;
    448 	uint16_t config_methods;
    449 	char manufacturer[65];
    450 	char model_name[33];
    451 	char model_number[33];
    452 	char serial_number[33];
    453 	struct wsc_primary_device_type primary_device_type;
    454 	char device_name[33];
    455 	uint8_t rf_bands;
    456 	enum wsc_association_state association_state;
    457 	enum wsc_configuration_error configuration_error;
    458 	enum wsc_device_password_id device_password_id;
    459 	uint32_t os_version;
    460 	uint8_t authenticator[8];
    461 };
    462 
    463 struct wsc_m3 {
    464 	bool version2;
    465 	uint8_t registrar_nonce[16];
    466 	uint8_t e_hash1[32];
    467 	uint8_t e_hash2[32];
    468 	uint8_t authenticator[8];
    469 };
    470 
    471 struct wsc_m4 {
    472 	bool version2;
    473 	uint8_t enrollee_nonce[16];
    474 	uint8_t r_hash1[32];
    475 	uint8_t r_hash2[32];
    476 	uint8_t authenticator[8];
    477 };
    478 
    479 struct wsc_m4_encrypted_settings {
    480 	uint8_t r_snonce1[16];
    481 	uint8_t authenticator[8];
    482 };
    483 
    484 struct wsc_m5 {
    485 	bool version2;
    486 	uint8_t registrar_nonce[16];
    487 	uint8_t authenticator[8];
    488 };
    489 
    490 struct wsc_m5_encrypted_settings {
    491 	uint8_t e_snonce1[16];
    492 	uint8_t authenticator[8];
    493 };
    494 
    495 struct wsc_m6 {
    496 	bool version2;
    497 	uint8_t enrollee_nonce[16];
    498 	uint8_t authenticator[8];
    499 };
    500 
    501 struct wsc_m6_encrypted_settings {
    502 	uint8_t r_snonce2[16];
    503 	uint8_t authenticator[8];
    504 };
    505 
    506 struct wsc_m7 {
    507 	bool version2;
    508 	uint8_t registrar_nonce[16];
    509 	uint8_t authenticator[8];
    510 };
    511 
    512 struct wsc_m7_encrypted_settings {
    513 	uint8_t e_snonce2[16];
    514 	uint8_t authenticator[8];
    515 };
    516 
    517 struct wsc_m8 {
    518 	bool version2;
    519 	uint8_t enrollee_nonce[16];
    520 	uint8_t authenticator[8];
    521 };
    522 
    523 struct wsc_m8_encrypted_settings {
    524 	uint8_t new_password[64];
    525 	uint8_t new_password_len;
    526 	enum wsc_device_password_id device_password_id;
    527 	uint8_t authenticator[8];
    528 };
    529 
    530 struct wsc_ack {
    531 	bool version2;
    532 	uint8_t enrollee_nonce[16];
    533 	uint8_t registrar_nonce[16];
    534 };
    535 
    536 struct wsc_nack {
    537 	bool version2;
    538 	uint8_t enrollee_nonce[16];
    539 	uint8_t registrar_nonce[16];
    540 	enum wsc_configuration_error configuration_error;
    541 };
    542 
    543 struct wsc_done {
    544 	bool version2;
    545 	uint8_t enrollee_nonce[16];
    546 	uint8_t registrar_nonce[16];
    547 };
    548 
    549 int wsc_parse_primary_device_type(const uint8_t *pdu, size_t len,
    550 					struct wsc_primary_device_type *out);
    551 
    552 enum wsc_attr_flag {
    553 	WSC_ATTR_FLAG_REQUIRED  = 0x1,  /* Always required */
    554 	WSC_ATTR_FLAG_VERSION2  = 0x2,  /* Included if Version2 is present */
    555 	WSC_ATTR_FLAG_REGISTRAR = 0x4,  /* Included if Selected Registrar is true */
    556 };
    557 
    558 int wsc_parse_attrs(const unsigned char *pdu, unsigned int len,
    559 			bool *out_version2, struct wsc_wfa_ext_iter *ext_iter,
    560 			enum wsc_attr authenticator_type,
    561 			uint8_t *authenticator, int type, ...);
    562 
    563 int wsc_parse_credential(const uint8_t *pdu, uint32_t len,
    564 						struct wsc_credential *out);
    565 
    566 int wsc_parse_beacon(const unsigned char *pdu, unsigned int len,
    567 				struct wsc_beacon *out);
    568 int wsc_parse_probe_response(const unsigned char *pdu, unsigned int len,
    569 				struct wsc_probe_response *out);
    570 int wsc_parse_probe_request(const unsigned char *pdu, unsigned int len,
    571 				struct wsc_probe_request *out);
    572 int wsc_parse_association_request(const uint8_t *pdu, uint32_t len,
    573 					struct wsc_association_request *out);
    574 int wsc_parse_association_response(const uint8_t *pdu, uint32_t len,
    575 					struct wsc_association_response *out);
    576 
    577 int wsc_parse_m1(const uint8_t *pdu, uint32_t len, struct wsc_m1 *out);
    578 int wsc_parse_m2(const uint8_t *pdu, uint32_t len, struct wsc_m2 *out);
    579 int wsc_parse_m3(const uint8_t *pdu, uint32_t len, struct wsc_m3 *out);
    580 int wsc_parse_m4(const uint8_t *pdu, uint32_t len, struct wsc_m4 *out,
    581 						struct iovec *out_encrypted);
    582 int wsc_parse_m4_encrypted_settings(const uint8_t *pdu, uint32_t len,
    583 					struct wsc_m4_encrypted_settings *out);
    584 int wsc_parse_m5(const uint8_t *pdu, uint32_t len, struct wsc_m5 *out,
    585 						struct iovec *out_encrypted);
    586 int wsc_parse_m5_encrypted_settings(const uint8_t *pdu, uint32_t len,
    587 					struct wsc_m5_encrypted_settings *out);
    588 int wsc_parse_m6(const uint8_t *pdu, uint32_t len, struct wsc_m6 *out,
    589 						struct iovec *out_encrypted);
    590 int wsc_parse_m6_encrypted_settings(const uint8_t *pdu, uint32_t len,
    591 					struct wsc_m6_encrypted_settings *out);
    592 int wsc_parse_m7(const uint8_t *pdu, uint32_t len, struct wsc_m7 *out,
    593 						struct iovec *out_encrypted);
    594 int wsc_parse_m7_encrypted_settings(const uint8_t *pdu, uint32_t len,
    595 					struct wsc_m7_encrypted_settings *out);
    596 int wsc_parse_m8(const uint8_t *pdu, uint32_t len, struct wsc_m8 *out,
    597 						struct iovec *out_encrypted);
    598 int wsc_parse_m8_encrypted_settings(const uint8_t *pdu, uint32_t len,
    599 					struct wsc_m8_encrypted_settings *out,
    600 					struct iovec *iov, size_t *iovcnt);
    601 
    602 int wsc_parse_wsc_ack(const uint8_t *pdu, uint32_t len, struct wsc_ack *out);
    603 int wsc_parse_wsc_nack(const uint8_t *pdu, uint32_t len, struct wsc_nack *out);
    604 
    605 int wsc_parse_wsc_done(const uint8_t *pdu, uint32_t len, struct wsc_done *out);
    606 
    607 uint8_t *wsc_build_credential(const struct wsc_credential *in, size_t *out_len);
    608 
    609 uint8_t *wsc_build_beacon(const struct wsc_beacon *beacon, size_t *out_len);
    610 uint8_t *wsc_build_probe_request(const struct wsc_probe_request *probe_request,
    611 				size_t *out_len);
    612 uint8_t *wsc_build_probe_response(
    613 		const struct wsc_probe_response *probe_response,
    614 		size_t *out_len);
    615 uint8_t *wsc_build_association_request(
    616 		const struct wsc_association_request *association_request,
    617 		size_t *out_len);
    618 uint8_t *wsc_build_association_response(
    619 		const struct wsc_association_response *association_response,
    620 		size_t *out_len);
    621 
    622 uint8_t *wsc_build_m1(const struct wsc_m1 *m1, size_t *out_len);
    623 uint8_t *wsc_build_m2(const struct wsc_m2 *m2, size_t *out_len);
    624 uint8_t *wsc_build_m3(const struct wsc_m3 *m3, size_t *out_len);
    625 uint8_t *wsc_build_m4(const struct wsc_m4 *m4, const uint8_t *encrypted,
    626 			size_t encrypted_len, size_t *out_len);
    627 uint8_t *wsc_build_m4_encrypted_settings(
    628 				const struct wsc_m4_encrypted_settings *in,
    629 				size_t *out_len);
    630 uint8_t *wsc_build_m5(const struct wsc_m5 *m5, const uint8_t *encrypted,
    631 			size_t encrypted_len, size_t *out_len);
    632 uint8_t *wsc_build_m5_encrypted_settings(
    633 				const struct wsc_m5_encrypted_settings *in,
    634 				size_t *out_len);
    635 uint8_t *wsc_build_m6(const struct wsc_m6 *m6, const uint8_t *encrypted,
    636 			size_t encrypted_len, size_t *out_len);
    637 uint8_t *wsc_build_m6_encrypted_settings(
    638 				const struct wsc_m6_encrypted_settings *in,
    639 				size_t *out_len);
    640 uint8_t *wsc_build_m7(const struct wsc_m7 *m7, const uint8_t *encrypted,
    641 			size_t encrypted_len, size_t *out_len);
    642 uint8_t *wsc_build_m7_encrypted_settings(
    643 				const struct wsc_m7_encrypted_settings *in,
    644 				size_t *out_len);
    645 uint8_t *wsc_build_m8(const struct wsc_m8 *m8, const uint8_t *encrypted,
    646 			size_t encrypted_len, size_t *out_len);
    647 uint8_t *wsc_build_m8_encrypted_settings(
    648 				const struct wsc_m8_encrypted_settings *in,
    649 				const struct wsc_credential *creds,
    650 				unsigned int creds_cnt, size_t *out_len);
    651 
    652 uint8_t *wsc_build_wsc_ack(const struct wsc_ack *ack, size_t *out_len);
    653 uint8_t *wsc_build_wsc_nack(const struct wsc_nack *nack, size_t *out_len);
    654 
    655 uint8_t *wsc_build_wsc_done(const struct wsc_done *done, size_t *out_len);
    656 
    657 struct wsc_p2p_attrs {
    658 	bool version;
    659 	bool version2;
    660 	enum wsc_device_password_id device_password_id;
    661 	uint16_t config_methods;
    662 };
    663 
    664 uint8_t *wsc_build_p2p_attrs(const struct wsc_p2p_attrs *attrs,
    665 				size_t *out_len);
    666 
    667 bool wsc_uuid_from_addr(const uint8_t addr[], uint8_t *out_uuid);
    668 
    669 struct wsc_session_key {
    670 	uint8_t auth_key[32];
    671 	uint8_t keywrap_key[16];
    672 	uint8_t emsk[32];
    673 } __attribute__ ((packed));
    674 
    675 bool wsc_kdf(const void *kdk, void *output, size_t size);
    676 
    677 bool wsc_pin_is_valid(const char *pin);
    678 bool wsc_pin_is_checksum_valid(const char *pin);
    679 bool wsc_pin_generate(char *pin);
    680 
    681 bool wsc_device_type_to_dbus_str(const struct wsc_primary_device_type *val,
    682 					const char **category_str,
    683 					const char **subcategory_str);
    684 bool wsc_device_type_from_subcategory_str(struct wsc_primary_device_type *out,
    685 						const char *subcategory_str);
    686 bool wsc_device_type_from_setting_str(const char *value,
    687 					struct wsc_primary_device_type *out);