Lines Matching +full:wait +full:- +full:pin
2 * EAP-WSC peer for Wi-Fi Protected Setup
3 * Copyright (c) 2007-2009, 2012, Jouni Malinen <j@w1.fi>
51 wpa_printf(MSG_DEBUG, "EAP-WSC: %s -> %s", in eap_wsc_state()
52 eap_wsc_state_txt(data->state), in eap_wsc_state()
54 data->state = state; in eap_wsc_state()
74 len = end - pos; in eap_wsc_new_ap_settings()
75 if ((len & 1) || len > 2 * sizeof(cred->ssid) || in eap_wsc_new_ap_settings()
76 hexstr2bin(pos, cred->ssid, len / 2)) { in eap_wsc_new_ap_settings()
77 wpa_printf(MSG_DEBUG, "EAP-WSC: Invalid new_ssid"); in eap_wsc_new_ap_settings()
78 return -1; in eap_wsc_new_ap_settings()
80 cred->ssid_len = len / 2; in eap_wsc_new_ap_settings()
84 wpa_printf(MSG_DEBUG, "EAP-WSC: Missing new_auth"); in eap_wsc_new_ap_settings()
85 return -1; in eap_wsc_new_ap_settings()
88 cred->auth_type = WPS_AUTH_OPEN; in eap_wsc_new_ap_settings()
90 cred->auth_type = WPS_AUTH_WPAPSK; in eap_wsc_new_ap_settings()
92 cred->auth_type = WPS_AUTH_WPA2PSK; in eap_wsc_new_ap_settings()
94 wpa_printf(MSG_DEBUG, "EAP-WSC: Unknown new_auth"); in eap_wsc_new_ap_settings()
95 return -1; in eap_wsc_new_ap_settings()
100 wpa_printf(MSG_DEBUG, "EAP-WSC: Missing new_encr"); in eap_wsc_new_ap_settings()
101 return -1; in eap_wsc_new_ap_settings()
104 cred->encr_type = WPS_ENCR_NONE; in eap_wsc_new_ap_settings()
107 cred->encr_type = WPS_ENCR_WEP; in eap_wsc_new_ap_settings()
110 cred->encr_type = WPS_ENCR_TKIP; in eap_wsc_new_ap_settings()
112 cred->encr_type = WPS_ENCR_AES; in eap_wsc_new_ap_settings()
114 wpa_printf(MSG_DEBUG, "EAP-WSC: Unknown new_encr"); in eap_wsc_new_ap_settings()
115 return -1; in eap_wsc_new_ap_settings()
126 len = end - pos; in eap_wsc_new_ap_settings()
127 if ((len & 1) || len > 2 * sizeof(cred->key) || in eap_wsc_new_ap_settings()
128 hexstr2bin(pos, cred->key, len / 2)) { in eap_wsc_new_ap_settings()
129 wpa_printf(MSG_DEBUG, "EAP-WSC: Invalid new_key"); in eap_wsc_new_ap_settings()
130 return -1; in eap_wsc_new_ap_settings()
132 cred->key_len = len / 2; in eap_wsc_new_ap_settings()
153 wps = sm->wps; in eap_wsc_init()
155 wpa_printf(MSG_ERROR, "EAP-WSC: WPS context not available"); in eap_wsc_init()
168 wpa_hexdump_ascii(MSG_INFO, "EAP-WSC: Unexpected identity", in eap_wsc_init()
176 data->state = registrar ? MESG : WAIT_START; in eap_wsc_init()
177 data->registrar = registrar; in eap_wsc_init()
178 data->wps_ctx = wps; in eap_wsc_init()
186 wpa_printf(MSG_INFO, "EAP-WSC: phase1 configuration data not " in eap_wsc_init()
192 pos = os_strstr(phase1, "pin="); in eap_wsc_init()
195 cfg.pin = (const u8 *) pos; in eap_wsc_init()
198 cfg.pin_len = pos - (const char *) cfg.pin; in eap_wsc_init()
200 os_strncmp((const char *) cfg.pin, "nfc-pw", 6) == 0) { in eap_wsc_init()
201 cfg.pin = NULL; in eap_wsc_init()
216 if (cfg.pin || id == DEV_PW_NFC_CONNECTION_HANDOVER) in eap_wsc_init()
220 if (cfg.pin == NULL && !cfg.pbc && !nfc) { in eap_wsc_init()
221 wpa_printf(MSG_INFO, "EAP-WSC: PIN or PBC not set in phase1 " in eap_wsc_init()
233 len = end - pos; in eap_wsc_init()
238 wpa_printf(MSG_INFO, "EAP-WSC: Invalid pkhash"); in eap_wsc_init()
248 wpa_printf(MSG_DEBUG, "EAP-WSC: Failed to parse new AP " in eap_wsc_init()
253 wpa_printf(MSG_DEBUG, "EAP-WSC: Provide new AP settings for " in eap_wsc_init()
267 "EAP-WSC: Invalid multi_ap setting"); in eap_wsc_init()
271 data->wps = wps_init(&cfg); in eap_wsc_init()
272 if (data->wps == NULL) { in eap_wsc_init()
274 wpa_printf(MSG_DEBUG, "EAP-WSC: wps_init failed"); in eap_wsc_init()
279 data->fragment_size = res; in eap_wsc_init()
281 data->fragment_size = WSC_FRAGMENT_SIZE; in eap_wsc_init()
282 wpa_printf(MSG_DEBUG, "EAP-WSC: Fragment size limit %u", in eap_wsc_init()
283 (unsigned int) data->fragment_size); in eap_wsc_init()
285 if (registrar && cfg.pin) { in eap_wsc_init()
286 wps_registrar_add_pin(data->wps_ctx->registrar, NULL, NULL, in eap_wsc_init()
287 cfg.pin, cfg.pin_len, 0); in eap_wsc_init()
290 /* Use reduced client timeout for WPS to avoid long wait */ in eap_wsc_init()
291 if (sm->ClientTimeout > 30) in eap_wsc_init()
292 sm->ClientTimeout = 30; in eap_wsc_init()
301 wpabuf_free(data->in_buf); in eap_wsc_deinit()
302 wpabuf_free(data->out_buf); in eap_wsc_deinit()
303 wps_deinit(data->wps); in eap_wsc_deinit()
304 os_free(data->wps_ctx->network_key); in eap_wsc_deinit()
305 data->wps_ctx->network_key = NULL; in eap_wsc_deinit()
317 ret->ignore = false; in eap_wsc_build_msg()
318 wpa_printf(MSG_DEBUG, "EAP-WSC: Generating Response"); in eap_wsc_build_msg()
319 ret->allowNotifications = true; in eap_wsc_build_msg()
322 send_len = wpabuf_len(data->out_buf) - data->out_used; in eap_wsc_build_msg()
323 if (2 + send_len > data->fragment_size) { in eap_wsc_build_msg()
324 send_len = data->fragment_size - 2; in eap_wsc_build_msg()
326 if (data->out_used == 0) { in eap_wsc_build_msg()
328 send_len -= 2; in eap_wsc_build_msg()
339 wpabuf_put_u8(resp, data->out_op_code); /* Op-Code */ in eap_wsc_build_msg()
342 wpabuf_put_be16(resp, wpabuf_len(data->out_buf)); in eap_wsc_build_msg()
344 wpabuf_put_data(resp, wpabuf_head_u8(data->out_buf) + data->out_used, in eap_wsc_build_msg()
346 data->out_used += send_len; in eap_wsc_build_msg()
348 ret->methodState = METHOD_MAY_CONT; in eap_wsc_build_msg()
349 ret->decision = DECISION_FAIL; in eap_wsc_build_msg()
351 if (data->out_used == wpabuf_len(data->out_buf)) { in eap_wsc_build_msg()
352 wpa_printf(MSG_DEBUG, "EAP-WSC: Sending out %lu bytes " in eap_wsc_build_msg()
355 wpabuf_free(data->out_buf); in eap_wsc_build_msg()
356 data->out_buf = NULL; in eap_wsc_build_msg()
357 data->out_used = 0; in eap_wsc_build_msg()
358 if ((data->state == FAIL && data->out_op_code == WSC_ACK) || in eap_wsc_build_msg()
359 data->out_op_code == WSC_NACK || in eap_wsc_build_msg()
360 data->out_op_code == WSC_Done) { in eap_wsc_build_msg()
362 ret->methodState = METHOD_DONE; in eap_wsc_build_msg()
366 wpa_printf(MSG_DEBUG, "EAP-WSC: Sending out %lu bytes " in eap_wsc_build_msg()
368 (unsigned long) wpabuf_len(data->out_buf) - in eap_wsc_build_msg()
369 data->out_used); in eap_wsc_build_msg()
381 if (op_code != data->in_op_code) { in eap_wsc_process_cont()
382 wpa_printf(MSG_DEBUG, "EAP-WSC: Unexpected Op-Code %d in " in eap_wsc_process_cont()
384 op_code, data->in_op_code); in eap_wsc_process_cont()
385 return -1; in eap_wsc_process_cont()
388 if (len > wpabuf_tailroom(data->in_buf)) { in eap_wsc_process_cont()
389 wpa_printf(MSG_DEBUG, "EAP-WSC: Fragment overflow"); in eap_wsc_process_cont()
391 return -1; in eap_wsc_process_cont()
394 wpabuf_put_data(data->in_buf, buf, len); in eap_wsc_process_cont()
395 wpa_printf(MSG_DEBUG, "EAP-WSC: Received %lu bytes, waiting " in eap_wsc_process_cont()
397 (unsigned long) wpabuf_tailroom(data->in_buf)); in eap_wsc_process_cont()
410 if (data->in_buf == NULL && !(flags & WSC_FLAGS_LF)) { in eap_wsc_process_fragment()
411 wpa_printf(MSG_DEBUG, "EAP-WSC: No Message Length field in a " in eap_wsc_process_fragment()
413 ret->ignore = true; in eap_wsc_process_fragment()
417 if (data->in_buf == NULL) { in eap_wsc_process_fragment()
419 data->in_buf = wpabuf_alloc(message_length); in eap_wsc_process_fragment()
420 if (data->in_buf == NULL) { in eap_wsc_process_fragment()
421 wpa_printf(MSG_DEBUG, "EAP-WSC: No memory for " in eap_wsc_process_fragment()
423 ret->ignore = true; in eap_wsc_process_fragment()
426 data->in_op_code = op_code; in eap_wsc_process_fragment()
427 wpabuf_put_data(data->in_buf, buf, len); in eap_wsc_process_fragment()
428 wpa_printf(MSG_DEBUG, "EAP-WSC: Received %lu bytes in first " in eap_wsc_process_fragment()
431 (unsigned long) wpabuf_tailroom(data->in_buf)); in eap_wsc_process_fragment()
454 ret->ignore = true; in eap_wsc_process()
466 if (end - pos < 2) { in eap_wsc_process()
467 wpa_printf(MSG_DEBUG, "EAP-WSC: Message underflow"); in eap_wsc_process()
468 ret->ignore = true; in eap_wsc_process()
474 if (message_length < end - pos || message_length > 50000) { in eap_wsc_process()
475 wpa_printf(MSG_DEBUG, "EAP-WSC: Invalid Message " in eap_wsc_process()
477 ret->ignore = true; in eap_wsc_process()
482 wpa_printf(MSG_DEBUG, "EAP-WSC: Received packet: Op-Code %d " in eap_wsc_process()
486 if (data->state == WAIT_FRAG_ACK) { in eap_wsc_process()
488 wpa_printf(MSG_DEBUG, "EAP-WSC: Unexpected Op-Code %d " in eap_wsc_process()
490 ret->ignore = true; in eap_wsc_process()
493 wpa_printf(MSG_DEBUG, "EAP-WSC: Fragment acknowledged"); in eap_wsc_process()
500 wpa_printf(MSG_DEBUG, "EAP-WSC: Unexpected Op-Code %d", in eap_wsc_process()
502 ret->ignore = true; in eap_wsc_process()
506 if (data->state == WAIT_START) { in eap_wsc_process()
508 wpa_printf(MSG_DEBUG, "EAP-WSC: Unexpected Op-Code %d " in eap_wsc_process()
510 ret->ignore = true; in eap_wsc_process()
513 wpa_printf(MSG_DEBUG, "EAP-WSC: Received start"); in eap_wsc_process()
518 wpa_printf(MSG_DEBUG, "EAP-WSC: Unexpected Op-Code %d", in eap_wsc_process()
520 ret->ignore = true; in eap_wsc_process()
524 if (data->in_buf && in eap_wsc_process()
525 eap_wsc_process_cont(data, pos, end - pos, op_code) < 0) { in eap_wsc_process()
526 ret->ignore = true; in eap_wsc_process()
533 end - pos); in eap_wsc_process()
536 if (data->in_buf == NULL) { in eap_wsc_process()
538 wpabuf_set(&tmpbuf, pos, end - pos); in eap_wsc_process()
539 data->in_buf = &tmpbuf; in eap_wsc_process()
542 res = wps_process_msg(data->wps, op_code, data->in_buf); in eap_wsc_process()
545 wpa_printf(MSG_DEBUG, "EAP-WSC: WPS processing completed " in eap_wsc_process()
546 "successfully - wait for EAP failure"); in eap_wsc_process()
554 wpa_printf(MSG_DEBUG, "EAP-WSC: WPS processing failed"); in eap_wsc_process()
559 if (data->in_buf != &tmpbuf) in eap_wsc_process()
560 wpabuf_free(data->in_buf); in eap_wsc_process()
561 data->in_buf = NULL; in eap_wsc_process()
564 if (data->out_buf == NULL) { in eap_wsc_process()
565 data->out_buf = wps_get_msg(data->wps, &data->out_op_code); in eap_wsc_process()
566 if (data->out_buf == NULL) { in eap_wsc_process()
567 wpa_printf(MSG_DEBUG, "EAP-WSC: Failed to receive " in eap_wsc_process()
570 ret->methodState = METHOD_DONE; in eap_wsc_process()
571 ret->decision = DECISION_FAIL; in eap_wsc_process()
574 data->out_used = 0; in eap_wsc_process()
579 if (data->state == FAIL && ret->methodState == METHOD_DONE) { in eap_wsc_process()
580 /* Use reduced client timeout for WPS to avoid long wait */ in eap_wsc_process()
581 if (sm->ClientTimeout > 2) in eap_wsc_process()
582 sm->ClientTimeout = 2; in eap_wsc_process()
596 return -1; in eap_peer_wsc_register()
598 eap->init = eap_wsc_init; in eap_peer_wsc_register()
599 eap->deinit = eap_wsc_deinit; in eap_peer_wsc_register()
600 eap->process = eap_wsc_process; in eap_peer_wsc_register()