Home | History | Annotate | Download | only in eap_peer

Lines Matching refs:sm

38 static Boolean eap_sm_allowMethod(struct eap_sm *sm, int vendor,
40 static struct wpabuf * eap_sm_buildNak(struct eap_sm *sm, int id);
41 static void eap_sm_processIdentity(struct eap_sm *sm,
43 static void eap_sm_processNotify(struct eap_sm *sm, const struct wpabuf *req);
45 static void eap_sm_parseEapReq(struct eap_sm *sm, const struct wpabuf *req);
53 static Boolean eapol_get_bool(struct eap_sm *sm, enum eapol_bool_var var)
55 return sm->eapol_cb->get_bool(sm->eapol_ctx, var);
59 static void eapol_set_bool(struct eap_sm *sm, enum eapol_bool_var var,
62 sm->eapol_cb->set_bool(sm->eapol_ctx, var, value);
66 static unsigned int eapol_get_int(struct eap_sm *sm, enum eapol_int_var var)
68 return sm->eapol_cb->get_int(sm->eapol_ctx, var);
72 static void eapol_set_int(struct eap_sm *sm, enum eapol_int_var var,
75 sm->eapol_cb->set_int(sm->eapol_ctx, var, value);
79 static struct wpabuf * eapol_get_eapReqData(struct eap_sm *sm)
81 return sm->eapol_cb->get_eapReqData(sm->eapol_ctx);
85 static void eap_notify_status(struct eap_sm *sm, const char *status,
90 if (sm->eapol_cb->notify_status)
91 sm->eapol_cb->notify_status(sm->eapol_ctx, status, parameter);
95 static void eap_deinit_prev_method(struct eap_sm *sm, const char *txt)
97 ext_password_free(sm->ext_pw_buf);
98 sm->ext_pw_buf = NULL;
100 if (sm->m == NULL || sm->eap_method_priv == NULL)
104 "(%d, %s) at %s", sm->selectedMethod, sm->m->name, txt);
105 sm->m->deinit(sm, sm->eap_method_priv);
106 sm->eap_method_priv = NULL;
107 sm->m = NULL;
113 * @sm: Pointer to EAP state machine allocated with eap_peer_sm_init()
118 int eap_allowed_method(struct eap_sm *sm, int vendor, u32 method)
120 struct eap_peer_config *config = eap_get_config(sm);
145 if (sm->fast_reauth && sm->m && sm->m->has_reauth_data &&
146 sm->m->has_reauth_data(sm, sm->eap_method_priv) &&
147 !sm->prev_failure) {
150 sm->m->deinit_for_reauth(sm, sm->eap_method_priv);
152 eap_deinit_prev_method(sm, "INITIALIZE");
154 sm->selectedMethod = EAP_TYPE_NONE;
155 sm->methodState = METHOD_NONE;
156 sm->allowNotifications = TRUE;
157 sm->decision = DECISION_FAIL;
158 sm->ClientTimeout = EAP_CLIENT_TIMEOUT_DEFAULT;
159 eapol_set_int(sm, EAPOL_idleWhile, sm->ClientTimeout);
160 eapol_set_bool(sm, EAPOL_eapSuccess, FALSE);
161 eapol_set_bool(sm, EAPOL_eapFail, FALSE);
162 os_free(sm->eapKeyData);
163 sm->eapKeyData = NULL;
164 sm->eapKeyAvailable = FALSE;
165 eapol_set_bool(sm, EAPOL_eapRestart, FALSE);
166 sm->lastId = -1; /* new session - make sure this does not match with
176 eapol_set_bool(sm, EAPOL_eapResp, FALSE);
177 eapol_set_bool(sm, EAPOL_eapNoResp, FALSE);
178 sm->num_rounds = 0;
179 sm->prev_failure = 0;
191 sm->num_rounds = 0;
197 eapol_set_int(sm, EAPOL_idleWhile, 0);
221 eapReqData = eapol_get_eapReqData(sm);
223 eap_sm_parseEapReq(sm, eapReqData);
224 sm->num_rounds++;
240 if (sm->reqMethod == EAP_TYPE_EXPANDED)
241 method = sm->reqVendorMethod;
243 method = sm->reqMethod;
245 eap_method = eap_peer_get_eap_method(sm->reqVendor, method);
247 if (!eap_sm_allowMethod(sm, sm->reqVendor, method)) {
249 sm->reqVendor, method);
250 wpa_msg(sm->msg_ctx, MSG_INFO, WPA_EVENT_EAP_PROPOSED_METHOD
252 sm->reqVendor, method);
253 eap_notify_status(sm, "refuse proposed method",
258 wpa_msg(sm->msg_ctx, MSG_INFO, WPA_EVENT_EAP_PROPOSED_METHOD
259 "vendor=%u method=%u", sm->reqVendor, method);
261 eap_notify_status(sm, "accept proposed method",
271 if (sm->fast_reauth &&
272 sm->m && sm->m->vendor == sm->reqVendor &&
273 sm->m->method == method &&
274 sm->m->has_reauth_data &&
275 sm->m->has_reauth_data(sm, sm->eap_method_priv)) {
280 eap_deinit_prev_method(sm, "GET_METHOD");
284 sm->selectedMethod = sm->reqMethod;
285 if (sm->m == NULL)
286 sm->m = eap_method;
287 if (!sm->m) {
290 sm->reqVendor, method);
294 sm->ClientTimeout = EAP_CLIENT_TIMEOUT_DEFAULT;
298 sm->reqVendor, method, sm->m->name);
300 sm->eap_method_priv = sm->m->init_for_reauth(
301 sm, sm->eap_method_priv);
303 sm->eap_method_priv = sm->m->init(sm);
305 if (sm->eap_method_priv == NULL) {
306 struct eap_peer_config *config = eap_get_config(sm);
307 wpa_msg(sm->msg_ctx, MSG_INFO,
310 sm->reqVendor, method, sm->m->name);
311 sm->m = NULL;
312 sm->methodState = METHOD_NONE;
313 sm->selectedMethod = EAP_TYPE_NONE;
314 if (sm->reqMethod == EAP_TYPE_TLS && config &&
330 sm->methodState = METHOD_INIT;
331 wpa_msg(sm->msg_ctx, MSG_INFO, WPA_EVENT_EAP_METHOD
333 sm->reqVendor, method, sm->m->name);
337 wpabuf_free(sm->eapRespData);
338 sm->eapRespData = NULL;
339 sm->eapRespData = eap_sm_buildNak(sm, sm->reqId);
353 if (sm->m == NULL) {
358 eapReqData = eapol_get_eapReqData(sm);
377 ret.ignore = sm->ignore;
378 ret.methodState = sm->methodState;
379 ret.decision = sm->decision;
380 ret.allowNotifications = sm->allowNotifications;
381 wpabuf_free(sm->eapRespData);
382 sm->eapRespData = NULL;
383 sm->eapRespData = sm->m->process(sm, sm->eap_method_priv, &ret,
391 sm->ignore = ret.ignore;
392 if (sm->ignore)
394 sm->methodState = ret.methodState;
395 sm->decision = ret.decision;
396 sm->allowNotifications = ret.allowNotifications;
398 if (sm->m->isKeyAvailable && sm->m->getKey &&
399 sm->m->isKeyAvailable(sm, sm->eap_method_priv)) {
400 os_free(sm->eapKeyData);
401 sm->eapKeyData = sm->m->getKey(sm, sm->eap_method_priv,
402 &sm->eapKeyDataLen);
414 wpabuf_free(sm->lastRespData);
415 if (sm->eapRespData) {
416 if (sm->workaround)
417 os_memcpy(sm->last_md5, sm->req_md5, 16);
418 sm->lastId = sm->reqId;
419 sm->lastRespData = wpabuf_dup(sm->eapRespData);
420 eapol_set_bool(sm, EAPOL_eapResp, TRUE);
422 sm->lastRespData = NULL;
423 eapol_set_bool(sm, EAPOL_eapReq, FALSE);
424 eapol_set_int(sm, EAPOL_idleWhile, sm->ClientTimeout);
435 eapol_set_bool(sm, EAPOL_eapReq, FALSE);
436 eapol_set_bool(sm, EAPOL_eapNoResp, TRUE);
448 eapReqData = eapol_get_eapReqData(sm);
451 eap_sm_processIdentity(sm, eapReqData);
452 wpabuf_free(sm->eapRespData);
453 sm->eapRespData = NULL;
454 sm->eapRespData = eap_sm_buildIdentity(sm, sm->reqId, 0);
466 eapReqData = eapol_get_eapReqData(sm);
469 eap_sm_processNotify(sm, eapReqData);
470 wpabuf_free(sm->eapRespData);
471 sm->eapRespData = NULL;
472 sm->eapRespData = eap_sm_buildNotify(sm->reqId);
482 wpabuf_free(sm->eapRespData);
483 if (sm->lastRespData)
484 sm->eapRespData = wpabuf_dup(sm->lastRespData);
486 sm->eapRespData = NULL;
498 if (sm->eapKeyData != NULL)
499 sm->eapKeyAvailable = TRUE;
500 eapol_set_bool(sm, EAPOL_eapSuccess, TRUE);
507 eapol_set_bool(sm, EAPOL_eapReq, FALSE);
515 eapol_set_bool(sm, EAPOL_eapNoResp, TRUE);
517 wpa_msg(sm->msg_ctx, MSG_INFO, WPA_EVENT_EAP_SUCCESS
529 eapol_set_bool(sm, EAPOL_eapFail, TRUE);
536 eapol_set_bool(sm, EAPOL_eapReq, FALSE);
543 eapol_set_bool(sm, EAPOL_eapNoResp, TRUE);
545 wpa_msg(sm->msg_ctx, MSG_INFO, WPA_EVENT_EAP_FAILURE
548 sm->prev_failure = 1;
552 static int eap_success_workaround(struct eap_sm *sm, int reqId, int lastId)
564 if (sm->workaround && (reqId == ((lastId + 1) & 0xff) ||
582 static void eap_peer_sm_step_idle(struct eap_sm *sm)
589 if (eapol_get_bool(sm, EAPOL_eapReq))
591 else if ((eapol_get_bool(sm, EAPOL_altAccept) &&
592 sm->decision != DECISION_FAIL) ||
593 (eapol_get_int(sm, EAPOL_idleWhile) == 0 &&
594 sm->decision == DECISION_UNCOND_SUCC))
596 else if (eapol_get_bool(sm, EAPOL_altReject) ||
597 (eapol_get_int(sm, EAPOL_idleWhile) == 0 &&
598 sm->decision != DECISION_UNCOND_SUCC) ||
599 (eapol_get_bool(sm, EAPOL_altAccept) &&
600 sm->methodState != METHOD_CONT &&
601 sm->decision == DECISION_FAIL))
603 else if (sm->selectedMethod == EAP_TYPE_LEAP &&
604 sm->leap_done && sm->decision != DECISION_FAIL &&
605 sm->methodState == METHOD_DONE)
607 else if (sm->selectedMethod == EAP_TYPE_PEAP &&
608 sm->peap_done && sm->decision != DECISION_FAIL &&
609 sm->methodState == METHOD_DONE)
614 static int eap_peer_req_is_duplicate(struct eap_sm *sm)
618 duplicate = (sm->reqId == sm->lastId) && sm->rxReq;
619 if (sm->workaround && duplicate &&
620 os_memcmp(sm->req_md5, sm->last_md5, 16) != 0) {
640 static void eap_peer_sm_step_received(struct eap_sm *sm)
642 int duplicate = eap_peer_req_is_duplicate(sm);
649 if (sm->rxSuccess && sm->decision != DECISION_FAIL &&
650 (sm->reqId == sm->lastId ||
651 eap_success_workaround(sm, sm->reqId, sm->lastId)))
653 else if (sm->methodState != METHOD_CONT &&
654 ((sm->rxFailure &&
655 sm->decision != DECISION_UNCOND_SUCC) ||
656 (sm->rxSuccess && sm->decision == DECISION_FAIL &&
657 (sm->selectedMethod != EAP_TYPE_LEAP ||
658 sm->methodState != METHOD_MAY_CONT))) &&
659 (sm->reqId == sm->lastId ||
660 eap_success_workaround(sm, sm->reqId, sm->lastId)))
662 else if (sm->rxReq && duplicate)
664 else if (sm->rxReq && !duplicate &&
665 sm->reqMethod == EAP_TYPE_NOTIFICATION &&
666 sm->allowNotifications)
668 else if (sm->rxReq && !duplicate &&
669 sm->selectedMethod == EAP_TYPE_NONE &&
670 sm->reqMethod == EAP_TYPE_IDENTITY)
672 else if (sm->rxReq && !duplicate &&
673 sm->selectedMethod == EAP_TYPE_NONE &&
674 sm->reqMethod != EAP_TYPE_IDENTITY &&
675 sm->reqMethod != EAP_TYPE_NOTIFICATION)
677 else if (sm->rxReq && !duplicate &&
678 sm->reqMethod == sm->selectedMethod &&
679 sm->methodState != METHOD_DONE)
681 else if (sm->selectedMethod == EAP_TYPE_LEAP &&
682 (sm->rxSuccess || sm->rxResp))
689 static void eap_peer_sm_step_local(struct eap_sm *sm)
691 switch (sm->EAP_state) {
696 if (eapol_get_bool(sm, EAPOL_portEnabled) &&
697 !sm->force_disabled)
701 eap_peer_sm_step_idle(sm);
704 eap_peer_sm_step_received(sm);
707 if (sm->selectedMethod == sm->reqMethod)
713 if (sm->ignore)
744 if (eapol_get_bool(sm, EAPOL_eapRestart) &&
745 eapol_get_bool(sm, EAPOL_portEnabled))
747 else if (!eapol_get_bool(sm, EAPOL_portEnabled) || sm->force_disabled)
749 else if (sm->num_rounds > EAP_MAX_AUTH_ROUNDS) {
758 if (sm->num_rounds == EAP_MAX_AUTH_ROUNDS + 1) {
759 wpa_msg(sm->msg_ctx, MSG_INFO, "EAP: more than %d "
762 sm->num_rounds++;
767 eap_peer_sm_step_local(sm);
772 static Boolean eap_sm_allowMethod(struct eap_sm *sm, int vendor,
775 if (!eap_allowed_method(sm, vendor, method)) {
789 struct eap_sm *sm, int id, const struct eap_method *methods,
808 if (sm->reqVendor == m->vendor &&
809 sm->reqVendorMethod == m->method)
811 if (eap_allowed_method(sm, m->vendor, m->method)) {
835 static struct wpabuf * eap_sm_buildNak(struct eap_sm *sm, int id)
844 "vendor=%u method=%u not allowed)", sm->reqMethod,
845 sm->reqVendor, sm->reqVendorMethod);
849 if (sm->reqMethod == EAP_TYPE_EXPANDED)
850 return eap_sm_build_expanded_nak(sm, id, methods, count);
861 if (m->vendor == EAP_VENDOR_IETF && m->method == sm->reqMethod)
863 if (eap_allowed_method(sm, m->vendor, m->method)) {
884 static void eap_sm_processIdentity(struct eap_sm *sm, const struct wpabuf *req)
889 wpa_msg(sm->msg_ctx, MSG_INFO, WPA_EVENT_EAP_STARTED
933 static int eap_sm_append_3gpp_realm(struct eap_sm *sm, char *imsi,
945 mnc_len = scard_get_mnc_len(sm->scard_ctx);
975 static int eap_sm_imsi_identity(struct eap_sm *sm,
985 if (scard_get_imsi(sm->scard_ctx, imsi, &imsi_len)) {
997 if (eap_sm_append_3gpp_realm(sm, imsi, sizeof(imsi), &imsi_len) < 0) {
1046 static int eap_sm_set_scard_pin(struct eap_sm *sm,
1050 if (scard_set_pin(sm->scard_ctx, conf->pin)) {
1059 eap_sm_request_pin(sm);
1068 static int eap_sm_get_scard_identity(struct eap_sm *sm,
1072 if (eap_sm_set_scard_pin(sm, conf))
1075 return eap_sm_imsi_identity(sm, conf);
1084 * @sm: Pointer to EAP state machine allocated with eap_peer_sm_init()
1093 struct wpabuf * eap_sm_buildIdentity(struct eap_sm *sm, int id, int encrypted)
1095 struct eap_peer_config *config = eap_get_config(sm);
1106 if (sm->m && sm->m->get_identity &&
1107 (identity = sm->m->get_identity(sm, sm->eap_method_priv,
1127 if (eap_sm_get_scard_identity(sm, config) < 0)
1134 eap_sm_request_identity(sm);
1138 if (eap_sm_set_scard_pin(sm, config) < 0)
1153 static void eap_sm_processNotify(struct eap_sm *sm, const struct wpabuf *req)
1172 wpa_msg(sm->msg_ctx, MSG_INFO, "%s%s",
1192 static void eap_sm_parseEapReq(struct eap_sm *sm, const struct wpabuf *req)
1198 sm->rxReq = sm->rxResp = sm->rxSuccess = sm->rxFailure = FALSE;
1199 sm->reqId = 0;
1200 sm->reqMethod = EAP_TYPE_NONE;
1201 sm->reqVendor = EAP_VENDOR_IETF;
1202 sm->reqVendorMethod = EAP_TYPE_NONE;
1217 sm->reqId = hdr->identifier;
1219 if (sm->workaround) {
1222 md5_vector(1, addr, &plen, sm->req_md5);
1232 sm->rxReq = TRUE;
1234 sm->reqMethod = *pos++;
1235 if (sm->reqMethod == EAP_TYPE_EXPANDED) {
1242 sm->reqVendor = WPA_GET_BE24(pos);
1244 sm->reqVendorMethod = WPA_GET_BE32(pos);
1248 sm->reqId, sm->reqMethod, sm->reqVendor,
1249 sm->reqVendorMethod);
1252 if (sm->selectedMethod == EAP_TYPE_LEAP) {
1263 sm->rxResp = TRUE;
1265 sm->reqMethod = *pos;
1268 sm->reqMethod, sm->reqId);
1275 eap_notify_status(sm, "completion", "success");
1276 sm->rxSuccess = TRUE;
1280 eap_notify_status(sm, "completion", "failure");
1281 sm->rxFailure = TRUE;
1294 struct eap_sm *sm = ctx;
1299 eap_notify_status(sm, "remote certificate verification",
1303 wpa_msg(sm->msg_ctx, MSG_INFO, WPA_EVENT_EAP_TLS_CERT_ERROR
1309 eap_notify_status(sm, "remote certificate verification",
1313 if (!sm->eapol_cb->notify_cert)
1326 sm->eapol_cb->notify_cert(sm->eapol_ctx,
1333 eap_notify_status(sm, "local TLS alert",
1336 eap_notify_status(sm, "remote TLS alert",
1363 struct eap_sm *sm;
1366 sm = os_zalloc(sizeof(*sm));
1367 if (sm == NULL)
1369 sm->eapol_ctx = eapol_ctx;
1370 sm->eapol_cb = eapol_cb;
1371 sm->msg_ctx = msg_ctx;
1372 sm->ClientTimeout = EAP_CLIENT_TIMEOUT_DEFAULT;
1373 sm->wps = conf->wps;
1383 tlsconf.cb_ctx = sm;
1385 sm->ssl_ctx = tls_init(&tlsconf);
1386 if (sm->ssl_ctx == NULL) {
1389 os_free(sm);
1393 sm->ssl_ctx2 = tls_init(&tlsconf);
1394 if (sm->ssl_ctx2 == NULL) {
1400 return sm;
1406 * @sm: Pointer to EAP state machine allocated with eap_peer_sm_init()
1411 void eap_peer_sm_deinit(struct eap_sm *sm)
1413 if (sm == NULL)
1415 eap_deinit_prev_method(sm, "EAP deinit");
1416 eap_sm_abort(sm);
1417 if (sm->ssl_ctx2)
1418 tls_deinit(sm->ssl_ctx2);
1419 tls_deinit(sm->ssl_ctx);
1420 os_free(sm);
1426 * @sm: Pointer to EAP state machine allocated with eap_peer_sm_init()
1433 int eap_peer_sm_step(struct eap_sm *sm)
1437 sm->changed = FALSE;
1439 if (sm->changed)
1441 } while (sm->changed);
1448 * @sm: Pointer to EAP state machine allocated with eap_peer_sm_init()
1453 void eap_sm_abort(struct eap_sm *sm)
1455 wpabuf_free(sm->lastRespData);
1456 sm->lastRespData = NULL;
1457 wpabuf_free(sm->eapRespData);
1458 sm->eapRespData = NULL;
1459 os_free(sm->eapKeyData);
1460 sm->eapKeyData = NULL;
1465 eapol_set_bool(sm, EAPOL_eapSuccess, FALSE);
1546 * @sm: Pointer to EAP state machine allocated with eap_peer_sm_init()
1557 int eap_sm_get_status(struct eap_sm *sm, char *buf, size_t buflen, int verbose)
1561 if (sm == NULL)
1566 eap_sm_state_txt(sm->EAP_state));
1570 if (sm->selectedMethod != EAP_TYPE_NONE) {
1572 if (sm->m) {
1573 name = sm->m->name;
1577 sm->selectedMethod);
1585 sm->selectedMethod, name);
1590 if (sm->m && sm->m->get_status) {
1591 len += sm->m->get_status(sm, sm->eap_method_priv,
1603 sm->reqMethod,
1604 eap_sm_method_state_txt(sm->methodState),
1605 eap_sm_decision_txt(sm->decision),
1606 sm->ClientTimeout);
1618 static void eap_sm_request(struct eap_sm *sm, enum wpa_ctrl_req_type field,
1624 if (sm == NULL)
1626 config = eap_get_config(sm);
1669 if (sm->eapol_cb->eap_param_needed)
1670 sm->eapol_cb->eap_param_needed(sm->eapol_ctx, field, txt);
1673 #define eap_sm_request(sm, type, msg, msglen) do { } while (0)
1676 const char * eap_sm_get_method_name(struct eap_sm *sm)
1678 if (sm->m == NULL)
1680 return sm->m->name;
1686 * @sm: Pointer to EAP state machine allocated with eap_peer_sm_init()
1693 void eap_sm_request_identity(struct eap_sm *sm)
1695 eap_sm_request(sm, WPA_CTRL_REQ_EAP_IDENTITY, NULL, 0);
1701 * @sm: Pointer to EAP state machine allocated with eap_peer_sm_init()
1708 void eap_sm_request_password(struct eap_sm *sm)
1710 eap_sm_request(sm, WPA_CTRL_REQ_EAP_PASSWORD, NULL, 0);
1716 * @sm: Pointer to EAP state machine allocated with eap_peer_sm_init()
1723 void eap_sm_request_new_password(struct eap_sm *sm)
1725 eap_sm_request(sm, WPA_CTRL_REQ_EAP_NEW_PASSWORD, NULL, 0);
1731 * @sm: Pointer to EAP state machine allocated with eap_peer_sm_init()
1738 void eap_sm_request_pin(struct eap_sm *sm)
1740 eap_sm_request(sm, WPA_CTRL_REQ_EAP_PIN, NULL, 0);
1746 * @sm: Pointer to EAP state machine allocated with eap_peer_sm_init()
1754 void eap_sm_request_otp(struct eap_sm *sm, const char *msg, size_t msg_len)
1756 eap_sm_request(sm, WPA_CTRL_REQ_EAP_OTP, msg, msg_len);
1762 * @sm: Pointer to EAP state machine allocated with eap_peer_sm_init()
1769 void eap_sm_request_passphrase(struct eap_sm *sm)
1771 eap_sm_request(sm, WPA_CTRL_REQ_EAP_PASSPHRASE, NULL, 0);
1777 * @sm: Pointer to EAP state machine allocated with eap_peer_sm_init()
1782 void eap_sm_notify_ctrl_attached(struct eap_sm *sm)
1784 struct eap_peer_config *config = eap_get_config(sm);
1794 eap_sm_request_identity(sm);
1796 eap_sm_request_password(sm);
1798 eap_sm_request_new_password(sm);
1800 eap_sm_request_otp(sm, NULL, 0);
1802 eap_sm_request_pin(sm);
1804 eap_sm_request_passphrase(sm);
1886 * @sm: Pointer to EAP state machine allocated with eap_peer_sm_init()
1889 void eap_set_fast_reauth(struct eap_sm *sm, int enabled)
1891 sm->fast_reauth = enabled;
1897 * @sm: Pointer to EAP state machine allocated with eap_peer_sm_init()
1900 void eap_set_workaround(struct eap_sm *sm, unsigned int workaround)
1902 sm->workaround = workaround;
1908 * @sm: Pointer to EAP state machine allocated with eap_peer_sm_init()
1916 struct eap_peer_config * eap_get_config(struct eap_sm *sm)
1918 return sm->eapol_cb->get_config(sm->eapol_ctx);
1924 * @sm: Pointer to EAP state machine allocated with eap_peer_sm_init()
1928 const u8 * eap_get_config_identity(struct eap_sm *sm, size_t *len)
1930 struct eap_peer_config *config = eap_get_config(sm);
1938 static int eap_get_ext_password(struct eap_sm *sm,
1951 ext_password_free(sm->ext_pw_buf);
1952 sm->ext_pw_buf = ext_password_get(sm->ext_pw, name);
1955 return sm->ext_pw_buf == NULL ? -1 : 0;
1961 * @sm: Pointer to EAP state machine allocated with eap_peer_sm_init()
1965 const u8 * eap_get_config_password(struct eap_sm *sm, size_t *len)
1967 struct eap_peer_config *config = eap_get_config(sm);
1972 if (eap_get_ext_password(sm, config) < 0)
1974 *len = wpabuf_len(sm->ext_pw_buf);
1975 return wpabuf_head(sm->ext_pw_buf);
1985 * @sm: Pointer to EAP state machine allocated with eap_peer_sm_init()
1992 const u8 * eap_get_config_password2(struct eap_sm *sm, size_t *len, int *hash)
1994 struct eap_peer_config *config = eap_get_config(sm);
1999 if (eap_get_ext_password(sm, config) < 0)
2001 *len = wpabuf_len(sm->ext_pw_buf);
2002 return wpabuf_head(sm->ext_pw_buf);
2014 * @sm: Pointer to EAP state machine allocated with eap_peer_sm_init()
2018 const u8 * eap_get_config_new_password(struct eap_sm *sm, size_t *len)
2020 struct eap_peer_config *config = eap_get_config(sm);
2030 * @sm: Pointer to EAP state machine allocated with eap_peer_sm_init()
2034 const u8 * eap_get_config_otp(struct eap_sm *sm, size_t *len)
2036 struct eap_peer_config *config = eap_get_config(sm);
2046 * @sm: Pointer to EAP state machine allocated with eap_peer_sm_init()
2052 void eap_clear_config_otp(struct eap_sm *sm)
2054 struct eap_peer_config *config = eap_get_config(sm);
2066 * @sm: Pointer to EAP state machine allocated with eap_peer_sm_init()
2069 const char * eap_get_config_phase1(struct eap_sm *sm)
2071 struct eap_peer_config *config = eap_get_config(sm);
2080 * @sm: Pointer to EAP state machine allocated with eap_peer_sm_init()
2083 const char * eap_get_config_phase2(struct eap_sm *sm)
2085 struct eap_peer_config *config = eap_get_config(sm);
2092 int eap_get_config_fragment_size(struct eap_sm *sm)
2094 struct eap_peer_config *config = eap_get_config(sm);
2103 * @sm: Pointer to EAP state machine allocated with eap_peer_sm_init()
2106 int eap_key_available(struct eap_sm *sm)
2108 return sm ? sm->eapKeyAvailable : 0;
2114 * @sm: Pointer to EAP state machine allocated with eap_peer_sm_init()
2121 void eap_notify_success(struct eap_sm *sm)
2123 if (sm) {
2124 sm->decision = DECISION_COND_SUCC;
2125 sm->EAP_state = EAP_SUCCESS;
2132 * @sm: Pointer to EAP state machine allocated with eap_peer_sm_init()
2137 void eap_notify_lower_layer_success(struct eap_sm *sm)
2139 if (sm == NULL)
2142 if (eapol_get_bool(sm, EAPOL_eapSuccess) ||
2143 sm->decision == DECISION_FAIL ||
2144 (sm->methodState != METHOD_MAY_CONT &&
2145 sm->methodState != METHOD_DONE))
2148 if (sm->eapKeyData != NULL)
2149 sm->eapKeyAvailable = TRUE;
2150 eapol_set_bool(sm, EAPOL_eapSuccess, TRUE);
2151 wpa_msg(sm->msg_ctx, MSG_INFO, WPA_EVENT_EAP_SUCCESS
2159 * @sm: Pointer to EAP state machine allocated with eap_peer_sm_init()
2168 const u8 * eap_get_eapKeyData(struct eap_sm *sm, size_t *len)
2170 if (sm == NULL || sm->eapKeyData == NULL) {
2175 *len = sm->eapKeyDataLen;
2176 return sm->eapKeyData;
2182 * @sm: Pointer to EAP state machine allocated with eap_peer_sm_init()
2190 struct wpabuf * eap_get_eapRespData(struct eap_sm *sm)
2194 if (sm == NULL || sm->eapRespData == NULL)
2197 resp = sm->eapRespData;
2198 sm->eapRespData = NULL;
2206 * @sm: Pointer to EAP state machine allocated with eap_peer_sm_init()
2212 void eap_register_scard_ctx(struct eap_sm *sm, void *ctx)
2214 if (sm)
2215 sm->scard_ctx = ctx;
2221 * @sm: Pointer to EAP state machine allocated with eap_peer_sm_init()
2227 void eap_set_config_blob(struct eap_sm *sm, struct wpa_config_blob *blob)
2230 sm->eapol_cb->set_config_blob(sm->eapol_ctx, blob);
2237 * @sm: Pointer to EAP state machine allocated with eap_peer_sm_init()
2241 const struct wpa_config_blob * eap_get_config_blob(struct eap_sm *sm,
2245 return sm->eapol_cb->get_config_blob(sm->eapol_ctx, name);
2254 * @sm: Pointer to EAP state machine allocated with eap_peer_sm_init()
2260 void eap_set_force_disabled(struct eap_sm *sm, int disabled)
2262 sm->force_disabled = disabled;
2268 * @sm: Pointer to EAP state machine allocated with eap_peer_sm_init()
2275 void eap_notify_pending(struct eap_sm *sm)
2277 sm->eapol_cb->notify_pending(sm->eapol_ctx);
2283 * @sm: Pointer to EAP state machine allocated with eap_peer_sm_init()
2285 void eap_invalidate_cached_session(struct eap_sm *sm)
2287 if (sm)
2288 eap_deinit_prev_method(sm, "invalidate");
2318 void eap_sm_set_ext_pw_ctx(struct eap_sm *sm, struct ext_password_data *ext)
2320 ext_password_free(sm->ext_pw_buf);
2321 sm->ext_pw_buf = NULL;
2322 sm->ext_pw = ext;
2328 * @sm: Pointer to EAP state machine allocated with eap_peer_sm_init()
2332 void eap_set_anon_id(struct eap_sm *sm, const u8 *id, size_t len)
2334 if (sm->eapol_cb->set_anon_id)
2335 sm->eapol_cb->set_anon_id(sm->eapol_ctx, id, len);