Lines Matching full:data

79 static void eap_sim_state(struct eap_sim_data *data, int state)  in eap_sim_state()  argument
82 eap_sim_state_txt(data->state), in eap_sim_state()
84 data->state = state; in eap_sim_state()
90 struct eap_sim_data *data; in eap_sim_init() local
93 data = os_zalloc(sizeof(*data)); in eap_sim_init()
94 if (data == NULL) in eap_sim_init()
97 if (random_get_bytes(data->nonce_mt, EAP_SIM_NONCE_MT_LEN)) { in eap_sim_init()
98 wpa_printf(MSG_WARNING, "EAP-SIM: Failed to get random data " in eap_sim_init()
100 os_free(data); in eap_sim_init()
106 data->imsi_privacy_key = crypto_rsa_key_read( in eap_sim_init()
108 if (!data->imsi_privacy_key) { in eap_sim_init()
112 os_free(data); in eap_sim_init()
118 os_free(data); in eap_sim_init()
124 data->error_code = NO_EAP_METHOD_ERROR; in eap_sim_init()
126 data->min_num_chal = 2; in eap_sim_init()
130 data->min_num_chal = atoi(pos + 17); in eap_sim_init()
131 if (data->min_num_chal < 2 || data->min_num_chal > 3) { in eap_sim_init()
135 (unsigned long) data->min_num_chal); in eap_sim_init()
137 crypto_rsa_key_free(data->imsi_privacy_key); in eap_sim_init()
139 os_free(data); in eap_sim_init()
144 (unsigned long) data->min_num_chal); in eap_sim_init()
147 data->result_ind = os_strstr(config->phase1, "result_ind=1") != in eap_sim_init()
151 data->use_pseudonym = !sm->init_phase2; in eap_sim_init()
152 if (config && config->anonymous_identity && data->use_pseudonym) { in eap_sim_init()
153 data->pseudonym = os_malloc(config->anonymous_identity_len); in eap_sim_init()
154 if (data->pseudonym) { in eap_sim_init()
155 os_memcpy(data->pseudonym, config->anonymous_identity, in eap_sim_init()
157 data->pseudonym_len = config->anonymous_identity_len; in eap_sim_init()
164 data->mk_identity = os_memdup(sm->identity, sm->identity_len); in eap_sim_init()
165 data->mk_identity_len = sm->identity_len; in eap_sim_init()
168 eap_sim_state(data, CONTINUE); in eap_sim_init()
170 return data; in eap_sim_init()
174 static void eap_sim_clear_keys(struct eap_sim_data *data, int reauth) in eap_sim_clear_keys() argument
177 os_memset(data->mk, 0, EAP_SIM_MK_LEN); in eap_sim_clear_keys()
178 os_memset(data->k_aut, 0, EAP_SIM_K_AUT_LEN); in eap_sim_clear_keys()
179 os_memset(data->k_encr, 0, EAP_SIM_K_ENCR_LEN); in eap_sim_clear_keys()
181 os_memset(data->kc, 0, 3 * EAP_SIM_KC_LEN); in eap_sim_clear_keys()
182 os_memset(data->sres, 0, 3 * EAP_SIM_SRES_LEN); in eap_sim_clear_keys()
183 os_memset(data->msk, 0, EAP_SIM_KEYING_DATA_LEN); in eap_sim_clear_keys()
184 os_memset(data->emsk, 0, EAP_EMSK_LEN); in eap_sim_clear_keys()
190 struct eap_sim_data *data = priv; in eap_sim_deinit() local
191 if (data) { in eap_sim_deinit()
192 os_free(data->ver_list); in eap_sim_deinit()
193 os_free(data->pseudonym); in eap_sim_deinit()
194 os_free(data->reauth_id); in eap_sim_deinit()
195 os_free(data->mk_identity); in eap_sim_deinit()
196 eap_sim_clear_keys(data, 0); in eap_sim_deinit()
198 crypto_rsa_key_free(data->imsi_privacy_key); in eap_sim_deinit()
200 os_free(data); in eap_sim_deinit()
205 static int eap_sim_ext_sim_req(struct eap_sm *sm, struct eap_sim_data *data) in eap_sim_ext_sim_req() argument
214 for (i = 0; i < data->num_chal; i++) { in eap_sim_ext_sim_req()
216 pos += wpa_snprintf_hex(pos, end - pos, data->rand[i], in eap_sim_ext_sim_req()
225 static int eap_sim_ext_sim_result(struct eap_sm *sm, struct eap_sim_data *data, in eap_sim_ext_sim_result() argument
244 for (i = 0; i < data->num_chal; i++) { in eap_sim_ext_sim_result()
246 data->rand[i], GSM_RAND_LEN); in eap_sim_ext_sim_result()
248 if (hexstr2bin(pos, data->kc[i], EAP_SIM_KC_LEN) < 0) in eap_sim_ext_sim_result()
251 data->kc[i], EAP_SIM_KC_LEN); in eap_sim_ext_sim_result()
257 if (hexstr2bin(pos, data->sres[i], EAP_SIM_SRES_LEN) < 0) in eap_sim_ext_sim_result()
260 data->sres[i], EAP_SIM_SRES_LEN); in eap_sim_ext_sim_result()
262 if (i + 1 < data->num_chal) { in eap_sim_ext_sim_result()
279 static int eap_sim_gsm_auth(struct eap_sm *sm, struct eap_sim_data *data) in eap_sim_gsm_auth() argument
291 return eap_sim_ext_sim_result(sm, data, conf); in eap_sim_gsm_auth()
293 return eap_sim_ext_sim_req(sm, data); in eap_sim_gsm_auth()
298 if (scard_gsm_auth(sm->scard_ctx, data->rand[0], in eap_sim_gsm_auth()
299 data->sres[0], data->kc[0]) || in eap_sim_gsm_auth()
300 scard_gsm_auth(sm->scard_ctx, data->rand[1], in eap_sim_gsm_auth()
301 data->sres[1], data->kc[1]) || in eap_sim_gsm_auth()
302 (data->num_chal > 2 && in eap_sim_gsm_auth()
303 scard_gsm_auth(sm->scard_ctx, data->rand[2], in eap_sim_gsm_auth()
304 data->sres[2], data->kc[2]))) { in eap_sim_gsm_auth()
336 for (i = 0; i < data->num_chal; i++) { in eap_sim_gsm_auth()
337 if (gsm_milenage(opc, k, data->rand[i], in eap_sim_gsm_auth()
338 data->sres[i], data->kc[i])) { in eap_sim_gsm_auth()
345 data->rand[i], GSM_RAND_LEN); in eap_sim_gsm_auth()
347 data->sres[i], EAP_SIM_SRES_LEN); in eap_sim_gsm_auth()
349 data->kc[i], EAP_SIM_KC_LEN); in eap_sim_gsm_auth()
366 for (i = 0; i < data->num_chal; i++) { in eap_sim_gsm_auth()
367 if (data->rand[i][0] == 0xaa) { in eap_sim_gsm_auth()
368 os_memcpy(data->kc[i], in eap_sim_gsm_auth()
371 os_memcpy(data->sres[i], "\xd1\xd2\xd3\xd4", in eap_sim_gsm_auth()
373 } else if (data->rand[i][0] == 0xbb) { in eap_sim_gsm_auth()
374 os_memcpy(data->kc[i], in eap_sim_gsm_auth()
377 os_memcpy(data->sres[i], "\xe1\xe2\xe3\xe4", in eap_sim_gsm_auth()
380 os_memcpy(data->kc[i], in eap_sim_gsm_auth()
383 os_memcpy(data->sres[i], "\xf1\xf2\xf3\xf4", in eap_sim_gsm_auth()
411 struct eap_sim_data *data, int id) in eap_sim_clear_identities() argument
413 if ((id & CLEAR_PSEUDONYM) && data->pseudonym) { in eap_sim_clear_identities()
415 os_free(data->pseudonym); in eap_sim_clear_identities()
416 data->pseudonym = NULL; in eap_sim_clear_identities()
417 data->pseudonym_len = 0; in eap_sim_clear_identities()
418 if (data->use_pseudonym) in eap_sim_clear_identities()
421 if ((id & CLEAR_REAUTH_ID) && data->reauth_id) { in eap_sim_clear_identities()
423 os_free(data->reauth_id); in eap_sim_clear_identities()
424 data->reauth_id = NULL; in eap_sim_clear_identities()
425 data->reauth_id_len = 0; in eap_sim_clear_identities()
430 static int eap_sim_learn_ids(struct eap_sm *sm, struct eap_sim_data *data, in eap_sim_learn_ids() argument
443 os_free(data->pseudonym); in eap_sim_learn_ids()
453 data->pseudonym = os_malloc(attr->next_pseudonym_len + in eap_sim_learn_ids()
455 if (data->pseudonym == NULL) { in eap_sim_learn_ids()
458 data->pseudonym_len = 0; in eap_sim_learn_ids()
461 os_memcpy(data->pseudonym, attr->next_pseudonym, in eap_sim_learn_ids()
464 os_memcpy(data->pseudonym + attr->next_pseudonym_len, in eap_sim_learn_ids()
467 data->pseudonym_len = attr->next_pseudonym_len + realm_len; in eap_sim_learn_ids()
468 if (data->use_pseudonym) in eap_sim_learn_ids()
469 eap_set_anon_id(sm, data->pseudonym, in eap_sim_learn_ids()
470 data->pseudonym_len); in eap_sim_learn_ids()
474 os_free(data->reauth_id); in eap_sim_learn_ids()
475 data->reauth_id = os_memdup(attr->next_reauth_id, in eap_sim_learn_ids()
477 if (data->reauth_id == NULL) { in eap_sim_learn_ids()
480 data->reauth_id_len = 0; in eap_sim_learn_ids()
483 data->reauth_id_len = attr->next_reauth_id_len; in eap_sim_learn_ids()
486 data->reauth_id, in eap_sim_learn_ids()
487 data->reauth_id_len); in eap_sim_learn_ids()
494 static struct wpabuf * eap_sim_client_error(struct eap_sim_data *data, u8 id, in eap_sim_client_error() argument
499 eap_sim_state(data, FAILURE); in eap_sim_client_error()
500 data->num_id_req = 0; in eap_sim_client_error()
501 data->num_notification = 0; in eap_sim_client_error()
562 struct eap_sim_data *data, u8 id, in eap_sim_response_start() argument
573 data->reauth = 0; in eap_sim_response_start()
574 if (id_req == ANY_ID && data->reauth_id) { in eap_sim_response_start()
575 identity = data->reauth_id; in eap_sim_response_start()
576 identity_len = data->reauth_id_len; in eap_sim_response_start()
577 data->reauth = 1; in eap_sim_response_start()
579 data->pseudonym && in eap_sim_response_start()
580 !eap_sim_anonymous_username(data->pseudonym, in eap_sim_response_start()
581 data->pseudonym_len)) { in eap_sim_response_start()
582 identity = data->pseudonym; in eap_sim_response_start()
583 identity_len = data->pseudonym_len; in eap_sim_response_start()
584 eap_sim_clear_identities(sm, data, CLEAR_REAUTH_ID); in eap_sim_response_start()
590 if (data->pseudonym && in eap_sim_response_start()
591 eap_sim_anonymous_username(data->pseudonym, in eap_sim_response_start()
592 data->pseudonym_len)) in eap_sim_response_start()
594 eap_sim_clear_identities(sm, data, ids); in eap_sim_response_start()
601 if (identity && data->imsi_privacy_key) { in eap_sim_response_start()
608 data->imsi_privacy_key, in eap_sim_response_start()
614 data, id, in eap_sim_response_start()
619 os_free(data->mk_identity); in eap_sim_response_start()
620 data->mk_identity = os_memdup(identity, identity_len); in eap_sim_response_start()
621 data->mk_identity_len = identity_len; in eap_sim_response_start()
640 os_free(data->mk_identity); in eap_sim_response_start()
641 data->mk_identity = os_memdup( in eap_sim_response_start()
644 data->mk_identity_len = config->imsi_identity_len; in eap_sim_response_start()
648 os_free(data->mk_identity); in eap_sim_response_start()
649 data->mk_identity = os_memdup(identity, identity_len); in eap_sim_response_start()
650 data->mk_identity_len = identity_len; in eap_sim_response_start()
654 if (!data->reauth) { in eap_sim_response_start()
656 data->nonce_mt, EAP_SIM_NONCE_MT_LEN); in eap_sim_response_start()
658 data->nonce_mt, EAP_SIM_NONCE_MT_LEN); in eap_sim_response_start()
660 data->selected_version); in eap_sim_response_start()
662 data->selected_version, NULL, 0); in eap_sim_response_start()
667 eap_sim_state(data, START_DONE); in eap_sim_response_start()
672 static struct wpabuf * eap_sim_response_challenge(struct eap_sim_data *data, in eap_sim_response_challenge() argument
680 if (data->use_result_ind) { in eap_sim_response_challenge()
686 return eap_sim_msg_finish(msg, EAP_TYPE_SIM, data->k_aut, in eap_sim_response_challenge()
687 (u8 *) data->sres, in eap_sim_response_challenge()
688 data->num_chal * EAP_SIM_SRES_LEN); in eap_sim_response_challenge()
692 static struct wpabuf * eap_sim_response_reauth(struct eap_sim_data *data, in eap_sim_response_reauth() argument
710 counter = data->counter_too_small; in eap_sim_response_reauth()
712 counter = data->counter; in eap_sim_response_reauth()
717 if (eap_sim_msg_add_encr_end(msg, data->k_encr, EAP_SIM_AT_PADDING)) { in eap_sim_response_reauth()
723 if (data->use_result_ind) { in eap_sim_response_reauth()
729 return eap_sim_msg_finish(msg, EAP_TYPE_SIM, data->k_aut, nonce_s, in eap_sim_response_reauth()
734 static struct wpabuf * eap_sim_response_notification(struct eap_sim_data *data, in eap_sim_response_notification() argument
738 u8 *k_aut = (notification & 0x4000) == 0 ? data->k_aut : NULL; in eap_sim_response_notification()
743 if (k_aut && data->reauth) { in eap_sim_response_notification()
748 wpa_printf(MSG_DEBUG, " *AT_COUNTER %d", data->counter); in eap_sim_response_notification()
749 eap_sim_msg_add(msg, EAP_SIM_AT_COUNTER, data->counter, in eap_sim_response_notification()
751 if (eap_sim_msg_add_encr_end(msg, data->k_encr, in eap_sim_response_notification()
768 struct eap_sim_data *data, u8 id, in eap_sim_process_start() argument
779 return eap_sim_client_error(data, id, in eap_sim_process_start()
783 os_free(data->ver_list); in eap_sim_process_start()
784 data->ver_list = os_memdup(attr->version_list, attr->version_list_len); in eap_sim_process_start()
785 if (data->ver_list == NULL) { in eap_sim_process_start()
788 return eap_sim_client_error(data, id, in eap_sim_process_start()
791 data->ver_list_len = attr->version_list_len; in eap_sim_process_start()
792 pos = data->ver_list; in eap_sim_process_start()
793 for (i = 0; i < data->ver_list_len / 2; i++) { in eap_sim_process_start()
804 return eap_sim_client_error(data, id, in eap_sim_process_start()
809 data->selected_version = selected_version; in eap_sim_process_start()
816 if (data->num_id_req > 0) in eap_sim_process_start()
818 data->num_id_req++; in eap_sim_process_start()
821 if (data->num_id_req > 1) in eap_sim_process_start()
823 data->num_id_req++; in eap_sim_process_start()
826 if (data->num_id_req > 2) in eap_sim_process_start()
828 data->num_id_req++; in eap_sim_process_start()
834 return eap_sim_client_error(data, id, in eap_sim_process_start()
838 return eap_sim_response_start(sm, data, id, attr->id_req); in eap_sim_process_start()
843 struct eap_sim_data *data, in eap_sim_process_challenge() argument
854 if (data->state != START_DONE) { in eap_sim_process_challenge()
857 eap_sim_state_txt(data->state)); in eap_sim_process_challenge()
858 return eap_sim_client_error(data, id, in eap_sim_process_challenge()
861 data->reauth = 0; in eap_sim_process_challenge()
867 return eap_sim_client_error(data, id, in eap_sim_process_challenge()
873 if (attr->num_chal < data->min_num_chal) { in eap_sim_process_challenge()
876 return eap_sim_client_error(data, id, in eap_sim_process_challenge()
882 return eap_sim_client_error(data, id, in eap_sim_process_challenge()
896 return eap_sim_client_error(data, id, in eap_sim_process_challenge()
900 os_memcpy(data->rand, attr->rand, attr->num_chal * GSM_RAND_LEN); in eap_sim_process_challenge()
901 data->num_chal = attr->num_chal; in eap_sim_process_challenge()
903 res = eap_sim_gsm_auth(sm, data); in eap_sim_process_challenge()
910 return eap_sim_client_error(data, id, in eap_sim_process_challenge()
914 identity = data->mk_identity; in eap_sim_process_challenge()
915 identity_len = data->mk_identity_len; in eap_sim_process_challenge()
918 eap_sim_derive_mk(identity, identity_len, data->nonce_mt, in eap_sim_process_challenge()
919 data->selected_version, data->ver_list, in eap_sim_process_challenge()
920 data->ver_list_len, data->num_chal, in eap_sim_process_challenge()
921 (const u8 *) data->kc, data->mk); in eap_sim_process_challenge()
922 eap_sim_derive_keys(data->mk, data->k_encr, data->k_aut, data->msk, in eap_sim_process_challenge()
923 data->emsk); in eap_sim_process_challenge()
924 if (eap_sim_verify_mac(data->k_aut, reqData, attr->mac, data->nonce_mt, in eap_sim_process_challenge()
932 return eap_sim_client_error(data, id, in eap_sim_process_challenge()
941 eap_sim_clear_identities(sm, data, CLEAR_REAUTH_ID); in eap_sim_process_challenge()
945 decrypted = eap_sim_parse_encr(data->k_encr, attr->encr_data, in eap_sim_process_challenge()
950 data, id, EAP_SIM_UNABLE_TO_PROCESS_PACKET); in eap_sim_process_challenge()
952 eap_sim_learn_ids(sm, data, &eattr); in eap_sim_process_challenge()
956 if (data->result_ind && attr->result_ind) in eap_sim_process_challenge()
957 data->use_result_ind = 1; in eap_sim_process_challenge()
959 if (data->state != FAILURE) { in eap_sim_process_challenge()
960 eap_sim_state(data, data->use_result_ind ? in eap_sim_process_challenge()
964 data->num_id_req = 0; in eap_sim_process_challenge()
965 data->num_notification = 0; in eap_sim_process_challenge()
969 data->counter = 0; in eap_sim_process_challenge()
970 return eap_sim_response_challenge(data, id); in eap_sim_process_challenge()
974 static int eap_sim_process_notification_reauth(struct eap_sim_data *data, in eap_sim_process_notification_reauth() argument
982 "reauth did not include encrypted data"); in eap_sim_process_notification_reauth()
986 decrypted = eap_sim_parse_encr(data->k_encr, attr->encr_data, in eap_sim_process_notification_reauth()
991 "data from notification message"); in eap_sim_process_notification_reauth()
995 if (eattr.counter < 0 || (size_t) eattr.counter != data->counter) { in eap_sim_process_notification_reauth()
1008 static int eap_sim_process_notification_auth(struct eap_sim_data *data, in eap_sim_process_notification_auth() argument
1018 if (eap_sim_verify_mac(data->k_aut, reqData, attr->mac, (u8 *) "", 0)) in eap_sim_process_notification_auth()
1025 if (data->reauth && in eap_sim_process_notification_auth()
1026 eap_sim_process_notification_reauth(data, attr)) { in eap_sim_process_notification_auth()
1037 struct eap_sm *sm, struct eap_sim_data *data, u8 id, in eap_sim_process_notification() argument
1041 if (data->num_notification > 0) { in eap_sim_process_notification()
1044 return eap_sim_client_error(data, id, in eap_sim_process_notification()
1047 data->num_notification++; in eap_sim_process_notification()
1051 return eap_sim_client_error(data, id, in eap_sim_process_notification()
1056 eap_sim_process_notification_auth(data, reqData, attr)) { in eap_sim_process_notification()
1057 return eap_sim_client_error(data, id, in eap_sim_process_notification()
1063 data->error_code = attr->notification; in eap_sim_process_notification()
1064 eap_sim_state(data, FAILURE); in eap_sim_process_notification()
1066 data->state == RESULT_SUCCESS) in eap_sim_process_notification()
1067 eap_sim_state(data, SUCCESS); in eap_sim_process_notification()
1068 return eap_sim_response_notification(data, id, attr->notification); in eap_sim_process_notification()
1073 struct eap_sm *sm, struct eap_sim_data *data, u8 id, in eap_sim_process_reauthentication() argument
1081 if (data->reauth_id == NULL) { in eap_sim_process_reauthentication()
1084 return eap_sim_client_error(data, id, in eap_sim_process_reauthentication()
1088 data->reauth = 1; in eap_sim_process_reauthentication()
1089 if (eap_sim_verify_mac(data->k_aut, reqData, attr->mac, (u8 *) "", 0)) in eap_sim_process_reauthentication()
1097 return eap_sim_client_error(data, id, in eap_sim_process_reauthentication()
1108 os_memcpy(data->reauth_mac, attr->mac, EAP_SIM_MAC_LEN); in eap_sim_process_reauthentication()
1110 os_memset(data->reauth_mac, 0x12, EAP_SIM_MAC_LEN); in eap_sim_process_reauthentication()
1112 os_memcpy(data->reauth_mac, attr->mac, EAP_SIM_MAC_LEN); in eap_sim_process_reauthentication()
1115 data->reauth_mac, EAP_SIM_MAC_LEN); in eap_sim_process_reauthentication()
1119 "message did not include encrypted data"); in eap_sim_process_reauthentication()
1120 return eap_sim_client_error(data, id, in eap_sim_process_reauthentication()
1124 decrypted = eap_sim_parse_encr(data->k_encr, attr->encr_data, in eap_sim_process_reauthentication()
1129 "data from reauthentication message"); in eap_sim_process_reauthentication()
1130 return eap_sim_client_error(data, id, in eap_sim_process_reauthentication()
1139 return eap_sim_client_error(data, id, in eap_sim_process_reauthentication()
1143 if (eattr.counter < 0 || (size_t) eattr.counter <= data->counter) { in eap_sim_process_reauthentication()
1146 "(%d <= %d)", eattr.counter, data->counter); in eap_sim_process_reauthentication()
1147 data->counter_too_small = eattr.counter; in eap_sim_process_reauthentication()
1152 eap_sim_clear_identities(sm, data, CLEAR_REAUTH_ID); in eap_sim_process_reauthentication()
1154 res = eap_sim_response_reauth(data, id, 1, eattr.nonce_s); in eap_sim_process_reauthentication()
1159 data->counter = eattr.counter; in eap_sim_process_reauthentication()
1161 os_memcpy(data->nonce_s, eattr.nonce_s, EAP_SIM_NONCE_S_LEN); in eap_sim_process_reauthentication()
1163 data->nonce_s, EAP_SIM_NONCE_S_LEN); in eap_sim_process_reauthentication()
1165 eap_sim_derive_keys_reauth(data->counter, in eap_sim_process_reauthentication()
1166 data->reauth_id, data->reauth_id_len, in eap_sim_process_reauthentication()
1167 data->nonce_s, data->mk, data->msk, in eap_sim_process_reauthentication()
1168 data->emsk); in eap_sim_process_reauthentication()
1169 eap_sim_clear_identities(sm, data, CLEAR_REAUTH_ID); in eap_sim_process_reauthentication()
1170 eap_sim_learn_ids(sm, data, &eattr); in eap_sim_process_reauthentication()
1172 if (data->result_ind && attr->result_ind) in eap_sim_process_reauthentication()
1173 data->use_result_ind = 1; in eap_sim_process_reauthentication()
1175 if (data->state != FAILURE) { in eap_sim_process_reauthentication()
1176 eap_sim_state(data, data->use_result_ind ? in eap_sim_process_reauthentication()
1180 data->num_id_req = 0; in eap_sim_process_reauthentication()
1181 data->num_notification = 0; in eap_sim_process_reauthentication()
1182 if (data->counter > EAP_SIM_MAX_FAST_REAUTHS) { in eap_sim_process_reauthentication()
1185 eap_sim_clear_identities(sm, data, CLEAR_REAUTH_ID); in eap_sim_process_reauthentication()
1188 return eap_sim_response_reauth(data, id, 0, data->nonce_s); in eap_sim_process_reauthentication()
1196 struct eap_sim_data *data = priv; in eap_sim_process() local
1204 wpa_hexdump_buf(MSG_DEBUG, "EAP-SIM: EAP data", reqData); in eap_sim_process()
1232 res = eap_sim_client_error(data, id, in eap_sim_process()
1239 res = eap_sim_process_start(sm, data, id, &attr); in eap_sim_process()
1242 res = eap_sim_process_challenge(sm, data, id, reqData, &attr); in eap_sim_process()
1245 res = eap_sim_process_notification(sm, data, id, reqData, in eap_sim_process()
1249 res = eap_sim_process_reauthentication(sm, data, id, reqData, in eap_sim_process()
1254 res = eap_sim_client_error(data, id, in eap_sim_process()
1259 res = eap_sim_client_error(data, id, in eap_sim_process()
1265 if (data->state == FAILURE) { in eap_sim_process()
1268 } else if (data->state == SUCCESS) { in eap_sim_process()
1269 ret->decision = data->use_result_ind ? in eap_sim_process()
1271 ret->methodState = data->use_result_ind ? in eap_sim_process()
1273 } else if (data->state == RESULT_SUCCESS) in eap_sim_process()
1286 struct eap_sim_data *data = priv; in eap_sim_has_reauth_data() local
1287 return data->pseudonym || data->reauth_id; in eap_sim_has_reauth_data()
1293 struct eap_sim_data *data = priv; in eap_sim_deinit_for_reauth() local
1295 os_free(data->mk_identity); in eap_sim_deinit_for_reauth()
1296 data->mk_identity = NULL; in eap_sim_deinit_for_reauth()
1297 data->mk_identity_len = 0; in eap_sim_deinit_for_reauth()
1298 data->use_result_ind = 0; in eap_sim_deinit_for_reauth()
1299 eap_sim_clear_keys(data, 1); in eap_sim_deinit_for_reauth()
1305 struct eap_sim_data *data = priv; in eap_sim_init_for_reauth() local
1306 if (random_get_bytes(data->nonce_mt, EAP_SIM_NONCE_MT_LEN)) { in eap_sim_init_for_reauth()
1307 wpa_printf(MSG_WARNING, "EAP-SIM: Failed to get random data " in eap_sim_init_for_reauth()
1309 eap_sim_deinit(sm, data); in eap_sim_init_for_reauth()
1316 os_free(data->mk_identity); in eap_sim_init_for_reauth()
1317 data->mk_identity = os_memdup(sm->identity, sm->identity_len); in eap_sim_init_for_reauth()
1318 data->mk_identity_len = sm->identity_len; in eap_sim_init_for_reauth()
1321 data->num_id_req = 0; in eap_sim_init_for_reauth()
1322 data->num_notification = 0; in eap_sim_init_for_reauth()
1323 eap_sim_state(data, CONTINUE); in eap_sim_init_for_reauth()
1331 struct eap_sim_data *data = priv; in eap_sim_get_identity() local
1333 if (data->reauth_id) { in eap_sim_get_identity()
1334 *len = data->reauth_id_len; in eap_sim_get_identity()
1335 return data->reauth_id; in eap_sim_get_identity()
1338 if (data->pseudonym) { in eap_sim_get_identity()
1339 *len = data->pseudonym_len; in eap_sim_get_identity()
1340 return data->pseudonym; in eap_sim_get_identity()
1349 struct eap_sim_data *data = priv; in eap_sim_isKeyAvailable() local
1350 return data->state == SUCCESS; in eap_sim_isKeyAvailable()
1356 struct eap_sim_data *data = priv; in eap_sim_getKey() local
1359 if (data->state != SUCCESS) in eap_sim_getKey()
1362 key = os_memdup(data->msk, EAP_SIM_KEYING_DATA_LEN); in eap_sim_getKey()
1374 struct eap_sim_data *data = priv; in eap_sim_get_session_id() local
1377 if (data->state != SUCCESS) in eap_sim_get_session_id()
1380 if (!data->reauth) in eap_sim_get_session_id()
1381 *len = 1 + data->num_chal * GSM_RAND_LEN + EAP_SIM_NONCE_MT_LEN; in eap_sim_get_session_id()
1389 if (!data->reauth) { in eap_sim_get_session_id()
1390 os_memcpy(id + 1, data->rand, data->num_chal * GSM_RAND_LEN); in eap_sim_get_session_id()
1391 os_memcpy(id + 1 + data->num_chal * GSM_RAND_LEN, in eap_sim_get_session_id()
1392 data->nonce_mt, EAP_SIM_NONCE_MT_LEN); in eap_sim_get_session_id()
1394 os_memcpy(id + 1, data->nonce_s, EAP_SIM_NONCE_S_LEN); in eap_sim_get_session_id()
1395 os_memcpy(id + 1 + EAP_SIM_NONCE_S_LEN, data->reauth_mac, in eap_sim_get_session_id()
1406 struct eap_sim_data *data = priv; in eap_sim_get_emsk() local
1409 if (data->state != SUCCESS) in eap_sim_get_emsk()
1412 key = os_memdup(data->emsk, EAP_EMSK_LEN); in eap_sim_get_emsk()
1424 struct eap_sim_data *data = priv; in eap_sim_get_error_code() local
1427 if (!data) in eap_sim_get_error_code()
1430 current_data_error = data->error_code; in eap_sim_get_error_code()
1433 data->error_code = NO_EAP_METHOD_ERROR; in eap_sim_get_error_code()