1 /*
2 * Wi-Fi Protected Setup - attribute building
3 * Copyright (c) 2008-2016, 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 #include "includes.h"
10
11 #include "common.h"
12 #include "crypto/aes_wrap.h"
13 #include "crypto/crypto.h"
14 #include "crypto/dh_group5.h"
15 #include "crypto/sha256.h"
16 #include "crypto/random.h"
17 #include "common/ieee802_11_defs.h"
18 #include "wps_i.h"
19
20
wps_build_public_key(struct wps_data * wps,struct wpabuf * msg)21 int wps_build_public_key(struct wps_data *wps, struct wpabuf *msg)
22 {
23 struct wpabuf *pubkey = NULL;
24
25 wpa_printf(MSG_DEBUG, "WPS: * Public Key");
26 wpabuf_clear_free(wps->dh_privkey);
27 wps->dh_privkey = NULL;
28 if (wps->dev_pw_id != DEV_PW_DEFAULT && wps->wps->dh_privkey &&
29 wps->wps->dh_ctx) {
30 wpa_printf(MSG_DEBUG, "WPS: Using pre-configured DH keys");
31 if (wps->wps->dh_pubkey == NULL) {
32 wpa_printf(MSG_DEBUG,
33 "WPS: wps->wps->dh_pubkey == NULL");
34 return -1;
35 }
36 wps->dh_privkey = wpabuf_dup(wps->wps->dh_privkey);
37 wps->dh_ctx = wps->wps->dh_ctx;
38 wps->wps->dh_ctx = NULL;
39 pubkey = wpabuf_dup(wps->wps->dh_pubkey);
40 #ifdef CONFIG_WPS_NFC
41 } else if ((wps->dev_pw_id >= 0x10 ||
42 wps->dev_pw_id == DEV_PW_NFC_CONNECTION_HANDOVER) &&
43 (wps->wps->ap ||
44 (wps->wps->ap_nfc_dh_pubkey &&
45 wps->wps->ap_nfc_dev_pw_id ==
46 DEV_PW_NFC_CONNECTION_HANDOVER &&
47 wps->dev_pw_id == DEV_PW_NFC_CONNECTION_HANDOVER)) &&
48 (wps->dev_pw_id == wps->wps->ap_nfc_dev_pw_id ||
49 wps->wps->ap_nfc_dh_pubkey)) {
50 wpa_printf(MSG_DEBUG, "WPS: Using NFC password token DH keys");
51 if (wps->wps->ap_nfc_dh_privkey == NULL) {
52 wpa_printf(MSG_DEBUG,
53 "WPS: wps->wps->ap_nfc_dh_privkey == NULL");
54 return -1;
55 }
56 if (wps->wps->ap_nfc_dh_pubkey == NULL) {
57 wpa_printf(MSG_DEBUG,
58 "WPS: wps->wps->ap_nfc_dh_pubkey == NULL");
59 return -1;
60 }
61 wps->dh_privkey = wpabuf_dup(wps->wps->ap_nfc_dh_privkey);
62 pubkey = wpabuf_dup(wps->wps->ap_nfc_dh_pubkey);
63 if (wps->dh_privkey && pubkey)
64 wps->dh_ctx = dh5_init_fixed(wps->dh_privkey, pubkey);
65 #endif /* CONFIG_WPS_NFC */
66 } else {
67 wpa_printf(MSG_DEBUG, "WPS: Generate new DH keys");
68 dh5_free(wps->dh_ctx);
69 wps->dh_ctx = dh5_init(&wps->dh_privkey, &pubkey);
70 pubkey = wpabuf_zeropad(pubkey, 192);
71 }
72 if (wps->dh_ctx == NULL || wps->dh_privkey == NULL || pubkey == NULL) {
73 wpa_printf(MSG_DEBUG, "WPS: Failed to initialize "
74 "Diffie-Hellman handshake");
75 wpabuf_free(pubkey);
76 return -1;
77 }
78 wpa_hexdump_buf_key(MSG_DEBUG, "WPS: DH Private Key", wps->dh_privkey);
79 wpa_hexdump_buf(MSG_DEBUG, "WPS: DH own Public Key", pubkey);
80
81 #ifdef ESP_SUPPLICANT
82 if (msg) {
83 #endif
84 wpabuf_put_be16(msg, ATTR_PUBLIC_KEY);
85 wpabuf_put_be16(msg, wpabuf_len(pubkey));
86 wpabuf_put_buf(msg, pubkey);
87 #ifdef ESP_SUPPLICANT
88 }
89 #endif
90
91 if (wps->registrar) {
92 wpabuf_free(wps->dh_pubkey_r);
93 wps->dh_pubkey_r = pubkey;
94 } else {
95 wpabuf_free(wps->dh_pubkey_e);
96 wps->dh_pubkey_e = pubkey;
97 }
98
99 return 0;
100 }
101
102
wps_build_req_type(struct wpabuf * msg,enum wps_request_type type)103 int wps_build_req_type(struct wpabuf *msg, enum wps_request_type type)
104 {
105 wpa_printf(MSG_DEBUG, "WPS: * Request Type");
106 wpabuf_put_be16(msg, ATTR_REQUEST_TYPE);
107 wpabuf_put_be16(msg, 1);
108 wpabuf_put_u8(msg, type);
109 return 0;
110 }
111
112
wps_build_resp_type(struct wpabuf * msg,enum wps_response_type type)113 int wps_build_resp_type(struct wpabuf *msg, enum wps_response_type type)
114 {
115 wpa_printf(MSG_DEBUG, "WPS: * Response Type (%d)", type);
116 wpabuf_put_be16(msg, ATTR_RESPONSE_TYPE);
117 wpabuf_put_be16(msg, 1);
118 wpabuf_put_u8(msg, type);
119 return 0;
120 }
121
122
wps_build_config_methods(struct wpabuf * msg,u16 methods)123 int wps_build_config_methods(struct wpabuf *msg, u16 methods)
124 {
125 wpa_printf(MSG_DEBUG, "WPS: * Config Methods (%x)", methods);
126 wpabuf_put_be16(msg, ATTR_CONFIG_METHODS);
127 wpabuf_put_be16(msg, 2);
128 wpabuf_put_be16(msg, methods);
129 return 0;
130 }
131
132
wps_build_uuid_e(struct wpabuf * msg,const u8 * uuid)133 int wps_build_uuid_e(struct wpabuf *msg, const u8 *uuid)
134 {
135 if (wpabuf_tailroom(msg) < 4 + WPS_UUID_LEN)
136 return -1;
137 wpa_printf(MSG_DEBUG, "WPS: * UUID-E");
138 wpabuf_put_be16(msg, ATTR_UUID_E);
139 wpabuf_put_be16(msg, WPS_UUID_LEN);
140 wpabuf_put_data(msg, uuid, WPS_UUID_LEN);
141 return 0;
142 }
143
144
wps_build_dev_password_id(struct wpabuf * msg,u16 id)145 int wps_build_dev_password_id(struct wpabuf *msg, u16 id)
146 {
147 wpa_printf(MSG_DEBUG, "WPS: * Device Password ID (%d)", id);
148 wpabuf_put_be16(msg, ATTR_DEV_PASSWORD_ID);
149 wpabuf_put_be16(msg, 2);
150 wpabuf_put_be16(msg, id);
151 return 0;
152 }
153
154
wps_build_config_error(struct wpabuf * msg,u16 err)155 int wps_build_config_error(struct wpabuf *msg, u16 err)
156 {
157 wpa_printf(MSG_DEBUG, "WPS: * Configuration Error (%d)", err);
158 wpabuf_put_be16(msg, ATTR_CONFIG_ERROR);
159 wpabuf_put_be16(msg, 2);
160 wpabuf_put_be16(msg, err);
161 return 0;
162 }
163
164
wps_build_authenticator(struct wps_data * wps,struct wpabuf * msg)165 int wps_build_authenticator(struct wps_data *wps, struct wpabuf *msg)
166 {
167 u8 hash[SHA256_MAC_LEN];
168 const u8 *addr[2];
169 size_t len[2];
170
171 if (wps->last_msg == NULL) {
172 wpa_printf(MSG_DEBUG, "WPS: Last message not available for "
173 "building authenticator");
174 return -1;
175 }
176
177 /* Authenticator = HMAC-SHA256_AuthKey(M_prev || M_curr*)
178 * (M_curr* is M_curr without the Authenticator attribute)
179 */
180 addr[0] = wpabuf_head(wps->last_msg);
181 len[0] = wpabuf_len(wps->last_msg);
182 addr[1] = wpabuf_head(msg);
183 len[1] = wpabuf_len(msg);
184 if (hmac_sha256_vector(wps->authkey, WPS_AUTHKEY_LEN, 2, addr, len,
185 hash) < 0)
186 return -1;
187
188 wpa_printf(MSG_DEBUG, "WPS: * Authenticator");
189 wpabuf_put_be16(msg, ATTR_AUTHENTICATOR);
190 wpabuf_put_be16(msg, WPS_AUTHENTICATOR_LEN);
191 wpabuf_put_data(msg, hash, WPS_AUTHENTICATOR_LEN);
192
193 return 0;
194 }
195
196
wps_build_version(struct wpabuf * msg)197 int wps_build_version(struct wpabuf *msg)
198 {
199 /*
200 * Note: This attribute is deprecated and set to hardcoded 0x10 for
201 * backwards compatibility reasons. The real version negotiation is
202 * done with Version2.
203 */
204 if (wpabuf_tailroom(msg) < 5)
205 return -1;
206 wpa_printf(MSG_DEBUG, "WPS: * Version (hardcoded 0x10)");
207 wpabuf_put_be16(msg, ATTR_VERSION);
208 wpabuf_put_be16(msg, 1);
209 wpabuf_put_u8(msg, 0x10);
210 return 0;
211 }
212
213
wps_build_wfa_ext(struct wpabuf * msg,int req_to_enroll,const u8 * auth_macs,size_t auth_macs_count,u8 multi_ap_subelem)214 int wps_build_wfa_ext(struct wpabuf *msg, int req_to_enroll,
215 const u8 *auth_macs, size_t auth_macs_count,
216 u8 multi_ap_subelem)
217 {
218 u8 *len;
219
220 #ifdef CONFIG_WPS_TESTING
221 if (WPS_VERSION == 0x10)
222 return 0;
223 #endif /* CONFIG_WPS_TESTING */
224
225 if (wpabuf_tailroom(msg) <
226 7 + 3 + (req_to_enroll ? 3 : 0) +
227 (auth_macs ? 2 + auth_macs_count * ETH_ALEN : 0))
228 return -1;
229 wpabuf_put_be16(msg, ATTR_VENDOR_EXT);
230 len = wpabuf_put(msg, 2); /* to be filled */
231 wpabuf_put_be24(msg, WPS_VENDOR_ID_WFA);
232
233 wpa_printf(MSG_DEBUG, "WPS: * Version2 (0x%x)", WPS_VERSION);
234 wpabuf_put_u8(msg, WFA_ELEM_VERSION2);
235 wpabuf_put_u8(msg, 1);
236 wpabuf_put_u8(msg, WPS_VERSION);
237
238 if (req_to_enroll) {
239 wpa_printf(MSG_DEBUG, "WPS: * Request to Enroll (1)");
240 wpabuf_put_u8(msg, WFA_ELEM_REQUEST_TO_ENROLL);
241 wpabuf_put_u8(msg, 1);
242 wpabuf_put_u8(msg, 1);
243 }
244
245 if (auth_macs && auth_macs_count) {
246 size_t i;
247 wpa_printf(MSG_DEBUG, "WPS: * AuthorizedMACs (count=%d)",
248 (int) auth_macs_count);
249 wpabuf_put_u8(msg, WFA_ELEM_AUTHORIZEDMACS);
250 wpabuf_put_u8(msg, auth_macs_count * ETH_ALEN);
251 wpabuf_put_data(msg, auth_macs, auth_macs_count * ETH_ALEN);
252 for (i = 0; i < auth_macs_count; i++)
253 wpa_printf(MSG_DEBUG, "WPS: AuthorizedMAC: " MACSTR,
254 MAC2STR(&auth_macs[i * ETH_ALEN]));
255 }
256
257 if (multi_ap_subelem) {
258 wpa_printf(MSG_DEBUG, "WPS: * Multi-AP (0x%x)",
259 multi_ap_subelem);
260 wpabuf_put_u8(msg, WFA_ELEM_MULTI_AP);
261 wpabuf_put_u8(msg, 1); /* length */
262 wpabuf_put_u8(msg, multi_ap_subelem);
263 }
264
265 WPA_PUT_BE16(len, (u8 *) wpabuf_put(msg, 0) - len - 2);
266
267 #ifdef CONFIG_WPS_TESTING
268 if (WPS_VERSION > 0x20) {
269 if (wpabuf_tailroom(msg) < 5)
270 return -1;
271 wpa_printf(MSG_DEBUG, "WPS: * Extensibility Testing - extra "
272 "attribute");
273 wpabuf_put_be16(msg, ATTR_EXTENSIBILITY_TEST);
274 wpabuf_put_be16(msg, 1);
275 wpabuf_put_u8(msg, 42);
276 }
277 #endif /* CONFIG_WPS_TESTING */
278 return 0;
279 }
280
281
wps_build_msg_type(struct wpabuf * msg,enum wps_msg_type msg_type)282 int wps_build_msg_type(struct wpabuf *msg, enum wps_msg_type msg_type)
283 {
284 wpa_printf(MSG_DEBUG, "WPS: * Message Type (%d)", msg_type);
285 wpabuf_put_be16(msg, ATTR_MSG_TYPE);
286 wpabuf_put_be16(msg, 1);
287 wpabuf_put_u8(msg, msg_type);
288 return 0;
289 }
290
291
wps_build_enrollee_nonce(struct wps_data * wps,struct wpabuf * msg)292 int wps_build_enrollee_nonce(struct wps_data *wps, struct wpabuf *msg)
293 {
294 wpa_printf(MSG_DEBUG, "WPS: * Enrollee Nonce");
295 wpabuf_put_be16(msg, ATTR_ENROLLEE_NONCE);
296 wpabuf_put_be16(msg, WPS_NONCE_LEN);
297 wpabuf_put_data(msg, wps->nonce_e, WPS_NONCE_LEN);
298 return 0;
299 }
300
301
wps_build_registrar_nonce(struct wps_data * wps,struct wpabuf * msg)302 int wps_build_registrar_nonce(struct wps_data *wps, struct wpabuf *msg)
303 {
304 wpa_printf(MSG_DEBUG, "WPS: * Registrar Nonce");
305 wpabuf_put_be16(msg, ATTR_REGISTRAR_NONCE);
306 wpabuf_put_be16(msg, WPS_NONCE_LEN);
307 wpabuf_put_data(msg, wps->nonce_r, WPS_NONCE_LEN);
308 return 0;
309 }
310
311
wps_build_auth_type_flags(struct wps_data * wps,struct wpabuf * msg)312 int wps_build_auth_type_flags(struct wps_data *wps, struct wpabuf *msg)
313 {
314 u16 auth_types = WPS_AUTH_TYPES;
315 /* WPA/WPA2-Enterprise enrollment not supported through WPS */
316 auth_types &= ~WPS_AUTH_WPA;
317 auth_types &= ~WPS_AUTH_WPA2;
318 auth_types &= ~WPS_AUTH_SHARED;
319 #ifdef CONFIG_NO_TKIP
320 auth_types &= ~WPS_AUTH_WPAPSK;
321 #endif /* CONFIG_NO_TKIP */
322 #ifdef CONFIG_WPS_TESTING
323 if (wps_force_auth_types_in_use) {
324 wpa_printf(MSG_DEBUG,
325 "WPS: Testing - replace auth type 0x%x with 0x%x",
326 auth_types, wps_force_auth_types);
327 auth_types = wps_force_auth_types;
328 }
329 #endif /* CONFIG_WPS_TESTING */
330 wpa_printf(MSG_DEBUG, "WPS: * Authentication Type Flags (0x%x)",
331 auth_types);
332 wpabuf_put_be16(msg, ATTR_AUTH_TYPE_FLAGS);
333 wpabuf_put_be16(msg, 2);
334 wpabuf_put_be16(msg, auth_types);
335 return 0;
336 }
337
338
wps_build_encr_type_flags(struct wps_data * wps,struct wpabuf * msg)339 int wps_build_encr_type_flags(struct wps_data *wps, struct wpabuf *msg)
340 {
341 u16 encr_types = WPS_ENCR_TYPES;
342 encr_types &= ~WPS_ENCR_WEP;
343 #ifdef CONFIG_NO_TKIP
344 encr_types &= ~WPS_ENCR_TKIP;
345 #endif /* CONFIG_NO_TKIP */
346 #ifdef CONFIG_WPS_TESTING
347 if (wps_force_encr_types_in_use) {
348 wpa_printf(MSG_DEBUG,
349 "WPS: Testing - replace encr type 0x%x with 0x%x",
350 encr_types, wps_force_encr_types);
351 encr_types = wps_force_encr_types;
352 }
353 #endif /* CONFIG_WPS_TESTING */
354 wpa_printf(MSG_DEBUG, "WPS: * Encryption Type Flags (0x%x)",
355 encr_types);
356 wpabuf_put_be16(msg, ATTR_ENCR_TYPE_FLAGS);
357 wpabuf_put_be16(msg, 2);
358 wpabuf_put_be16(msg, encr_types);
359 return 0;
360 }
361
362
wps_build_conn_type_flags(struct wps_data * wps,struct wpabuf * msg)363 int wps_build_conn_type_flags(struct wps_data *wps, struct wpabuf *msg)
364 {
365 wpa_printf(MSG_DEBUG, "WPS: * Connection Type Flags");
366 wpabuf_put_be16(msg, ATTR_CONN_TYPE_FLAGS);
367 wpabuf_put_be16(msg, 1);
368 wpabuf_put_u8(msg, WPS_CONN_ESS);
369 return 0;
370 }
371
372
wps_build_assoc_state(struct wps_data * wps,struct wpabuf * msg)373 int wps_build_assoc_state(struct wps_data *wps, struct wpabuf *msg)
374 {
375 wpa_printf(MSG_DEBUG, "WPS: * Association State");
376 wpabuf_put_be16(msg, ATTR_ASSOC_STATE);
377 wpabuf_put_be16(msg, 2);
378 wpabuf_put_be16(msg, WPS_ASSOC_NOT_ASSOC);
379 return 0;
380 }
381
382
wps_build_key_wrap_auth(struct wps_data * wps,struct wpabuf * msg)383 int wps_build_key_wrap_auth(struct wps_data *wps, struct wpabuf *msg)
384 {
385 u8 hash[SHA256_MAC_LEN];
386
387 wpa_printf(MSG_DEBUG, "WPS: * Key Wrap Authenticator");
388 if (hmac_sha256(wps->authkey, WPS_AUTHKEY_LEN, wpabuf_head(msg),
389 wpabuf_len(msg), hash) < 0)
390 return -1;
391
392 wpabuf_put_be16(msg, ATTR_KEY_WRAP_AUTH);
393 wpabuf_put_be16(msg, WPS_KWA_LEN);
394 wpabuf_put_data(msg, hash, WPS_KWA_LEN);
395 return 0;
396 }
397
398
wps_build_encr_settings(struct wps_data * wps,struct wpabuf * msg,struct wpabuf * plain)399 int wps_build_encr_settings(struct wps_data *wps, struct wpabuf *msg,
400 struct wpabuf *plain)
401 {
402 size_t pad_len;
403 const size_t block_size = 16;
404 u8 *iv, *data;
405
406 wpa_printf(MSG_DEBUG, "WPS: * Encrypted Settings");
407
408 /* PKCS#5 v2.0 pad */
409 pad_len = block_size - wpabuf_len(plain) % block_size;
410 os_memset(wpabuf_put(plain, pad_len), pad_len, pad_len);
411
412 wpabuf_put_be16(msg, ATTR_ENCR_SETTINGS);
413 wpabuf_put_be16(msg, block_size + wpabuf_len(plain));
414
415 iv = wpabuf_put(msg, block_size);
416 if (random_get_bytes(iv, block_size) < 0)
417 return -1;
418
419 data = wpabuf_put(msg, 0);
420 wpabuf_put_buf(msg, plain);
421 if (aes_128_cbc_encrypt(wps->keywrapkey, iv, data, wpabuf_len(plain)))
422 return -1;
423
424 return 0;
425 }
426
427
428 #ifdef CONFIG_WPS_OOB
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)429 int wps_build_oob_dev_pw(struct wpabuf *msg, u16 dev_pw_id,
430 const struct wpabuf *pubkey, const u8 *dev_pw,
431 size_t dev_pw_len)
432 {
433 size_t hash_len;
434 const u8 *addr[1];
435 u8 pubkey_hash[WPS_HASH_LEN];
436
437 wpa_printf(MSG_DEBUG, "WPS: * OOB Device Password (dev_pw_id=%u)",
438 dev_pw_id);
439 addr[0] = wpabuf_head(pubkey);
440 hash_len = wpabuf_len(pubkey);
441 if (sha256_vector(1, addr, &hash_len, pubkey_hash) < 0)
442 return -1;
443 #ifdef CONFIG_WPS_TESTING
444 if (wps_corrupt_pkhash) {
445 wpa_hexdump(MSG_DEBUG, "WPS: Real Public Key Hash",
446 pubkey_hash, WPS_OOB_PUBKEY_HASH_LEN);
447 wpa_printf(MSG_INFO, "WPS: Testing - corrupt public key hash");
448 pubkey_hash[WPS_OOB_PUBKEY_HASH_LEN - 2]++;
449 }
450 #endif /* CONFIG_WPS_TESTING */
451
452 wpabuf_put_be16(msg, ATTR_OOB_DEVICE_PASSWORD);
453 wpabuf_put_be16(msg, WPS_OOB_PUBKEY_HASH_LEN + 2 + dev_pw_len);
454 wpa_hexdump(MSG_DEBUG, "WPS: Public Key Hash",
455 pubkey_hash, WPS_OOB_PUBKEY_HASH_LEN);
456 wpabuf_put_data(msg, pubkey_hash, WPS_OOB_PUBKEY_HASH_LEN);
457 wpabuf_put_be16(msg, dev_pw_id);
458 if (dev_pw) {
459 wpa_hexdump_key(MSG_DEBUG, "WPS: OOB Device Password",
460 dev_pw, dev_pw_len);
461 wpabuf_put_data(msg, dev_pw, dev_pw_len);
462 }
463
464 return 0;
465 }
466 #endif /* CONFIG_WPS_OOB */
467
468
469 /* Encapsulate WPS IE data with one (or more, if needed) IE headers */
wps_ie_encapsulate(struct wpabuf * data)470 struct wpabuf * wps_ie_encapsulate(struct wpabuf *data)
471 {
472 struct wpabuf *ie;
473 const u8 *pos, *end;
474
475 ie = wpabuf_alloc(wpabuf_len(data) + 100);
476 if (ie == NULL) {
477 wpabuf_free(data);
478 return NULL;
479 }
480
481 pos = wpabuf_head(data);
482 end = pos + wpabuf_len(data);
483
484 while (end > pos) {
485 size_t frag_len = end - pos;
486 if (frag_len > 251)
487 frag_len = 251;
488 wpabuf_put_u8(ie, WLAN_EID_VENDOR_SPECIFIC);
489 wpabuf_put_u8(ie, 4 + frag_len);
490 wpabuf_put_be32(ie, WPS_DEV_OUI_WFA);
491 wpabuf_put_data(ie, pos, frag_len);
492 pos += frag_len;
493 }
494
495 wpabuf_free(data);
496
497 return ie;
498 }
499
500
wps_build_mac_addr(struct wpabuf * msg,const u8 * addr)501 int wps_build_mac_addr(struct wpabuf *msg, const u8 *addr)
502 {
503 wpa_printf(MSG_DEBUG, "WPS: * MAC Address (" MACSTR ")",
504 MAC2STR(addr));
505 wpabuf_put_be16(msg, ATTR_MAC_ADDR);
506 wpabuf_put_be16(msg, ETH_ALEN);
507 wpabuf_put_data(msg, addr, ETH_ALEN);
508 return 0;
509 }
510
511
wps_build_rf_bands_attr(struct wpabuf * msg,u8 rf_bands)512 int wps_build_rf_bands_attr(struct wpabuf *msg, u8 rf_bands)
513 {
514 wpa_printf(MSG_DEBUG, "WPS: * RF Bands (%x)", rf_bands);
515 wpabuf_put_be16(msg, ATTR_RF_BANDS);
516 wpabuf_put_be16(msg, 1);
517 wpabuf_put_u8(msg, rf_bands);
518 return 0;
519 }
520
521
wps_build_ap_channel(struct wpabuf * msg,u16 ap_channel)522 int wps_build_ap_channel(struct wpabuf *msg, u16 ap_channel)
523 {
524 wpa_printf(MSG_DEBUG, "WPS: * AP Channel (%u)", ap_channel);
525 wpabuf_put_be16(msg, ATTR_AP_CHANNEL);
526 wpabuf_put_be16(msg, 2);
527 wpabuf_put_be16(msg, ap_channel);
528 return 0;
529 }
530