Updated through tag hostap_2_5 from git://w1.fi/hostap.git
[mech_eap.git] / libeap / src / eap_peer / eap_sim.c
index 3d8afb2..99a2816 100644 (file)
@@ -1,15 +1,9 @@
 /*
  * EAP peer method: EAP-SIM (RFC 4186)
- * Copyright (c) 2004-2008, Jouni Malinen <j@w1.fi>
+ * Copyright (c) 2004-2012, Jouni Malinen <j@w1.fi>
  *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 as
- * published by the Free Software Foundation.
- *
- * Alternatively, this software may be distributed under the terms of BSD
- * license.
- *
- * See README and COPYING for more details.
+ * This software may be distributed under the terms of the BSD license.
+ * See README for more details.
  */
 
 #include "includes.h"
@@ -17,6 +11,7 @@
 #include "common.h"
 #include "pcsc_funcs.h"
 #include "crypto/milenage.h"
+#include "crypto/random.h"
 #include "eap_peer/eap_i.h"
 #include "eap_config.h"
 #include "eap_common/eap_sim_common.h"
@@ -48,7 +43,7 @@ struct eap_sim_data {
        u8 *last_eap_identity;
        size_t last_eap_identity_len;
        enum {
-               CONTINUE, RESULT_SUCCESS, RESULT_FAILURE, SUCCESS, FAILURE
+               CONTINUE, RESULT_SUCCESS, SUCCESS, FAILURE
        } state;
        int result_ind, use_result_ind;
 };
@@ -62,8 +57,6 @@ static const char * eap_sim_state_txt(int state)
                return "CONTINUE";
        case RESULT_SUCCESS:
                return "RESULT_SUCCESS";
-       case RESULT_FAILURE:
-               return "RESULT_FAILURE";
        case SUCCESS:
                return "SUCCESS";
        case FAILURE:
@@ -93,7 +86,7 @@ static void * eap_sim_init(struct eap_sm *sm)
        if (data == NULL)
                return NULL;
 
-       if (os_get_random(data->nonce_mt, EAP_SIM_NONCE_MT_LEN)) {
+       if (random_get_bytes(data->nonce_mt, EAP_SIM_NONCE_MT_LEN)) {
                wpa_printf(MSG_WARNING, "EAP-SIM: Failed to get random data "
                           "for NONCE_MT");
                os_free(data);
@@ -122,12 +115,35 @@ static void * eap_sim_init(struct eap_sm *sm)
                        NULL;
        }
 
+       if (config && config->anonymous_identity) {
+               data->pseudonym = os_malloc(config->anonymous_identity_len);
+               if (data->pseudonym) {
+                       os_memcpy(data->pseudonym, config->anonymous_identity,
+                                 config->anonymous_identity_len);
+                       data->pseudonym_len = config->anonymous_identity_len;
+               }
+       }
+
        eap_sim_state(data, CONTINUE);
 
        return data;
 }
 
 
+static void eap_sim_clear_keys(struct eap_sim_data *data, int reauth)
+{
+       if (!reauth) {
+               os_memset(data->mk, 0, EAP_SIM_MK_LEN);
+               os_memset(data->k_aut, 0, EAP_SIM_K_AUT_LEN);
+               os_memset(data->k_encr, 0, EAP_SIM_K_ENCR_LEN);
+       }
+       os_memset(data->kc, 0, 3 * EAP_SIM_KC_LEN);
+       os_memset(data->sres, 0, 3 * EAP_SIM_SRES_LEN);
+       os_memset(data->msk, 0, EAP_SIM_KEYING_DATA_LEN);
+       os_memset(data->emsk, 0, EAP_EMSK_LEN);
+}
+
+
 static void eap_sim_deinit(struct eap_sm *sm, void *priv)
 {
        struct eap_sim_data *data = priv;
@@ -136,11 +152,86 @@ static void eap_sim_deinit(struct eap_sm *sm, void *priv)
                os_free(data->pseudonym);
                os_free(data->reauth_id);
                os_free(data->last_eap_identity);
+               eap_sim_clear_keys(data, 0);
                os_free(data);
        }
 }
 
 
+static int eap_sim_ext_sim_req(struct eap_sm *sm, struct eap_sim_data *data)
+{
+       char req[200], *pos, *end;
+       size_t i;
+
+       wpa_printf(MSG_DEBUG, "EAP-SIM: Use external SIM processing");
+       pos = req;
+       end = pos + sizeof(req);
+       pos += os_snprintf(pos, end - pos, "GSM-AUTH");
+       for (i = 0; i < data->num_chal; i++) {
+               pos += os_snprintf(pos, end - pos, ":");
+               pos += wpa_snprintf_hex(pos, end - pos, data->rand[i],
+                                       GSM_RAND_LEN);
+       }
+
+       eap_sm_request_sim(sm, req);
+       return 1;
+}
+
+
+static int eap_sim_ext_sim_result(struct eap_sm *sm, struct eap_sim_data *data,
+                                 struct eap_peer_config *conf)
+{
+       char *resp, *pos;
+       size_t i;
+
+       wpa_printf(MSG_DEBUG,
+                  "EAP-SIM: Use result from external SIM processing");
+
+       resp = conf->external_sim_resp;
+       conf->external_sim_resp = NULL;
+
+       if (os_strncmp(resp, "GSM-AUTH:", 9) != 0) {
+               wpa_printf(MSG_DEBUG, "EAP-SIM: Unrecognized external SIM processing response");
+               os_free(resp);
+               return -1;
+       }
+
+       pos = resp + 9;
+       for (i = 0; i < data->num_chal; i++) {
+               wpa_hexdump(MSG_DEBUG, "EAP-SIM: RAND",
+                           data->rand[i], GSM_RAND_LEN);
+
+               if (hexstr2bin(pos, data->kc[i], EAP_SIM_KC_LEN) < 0)
+                       goto invalid;
+               wpa_hexdump_key(MSG_DEBUG, "EAP-SIM: Kc",
+                               data->kc[i], EAP_SIM_KC_LEN);
+               pos += EAP_SIM_KC_LEN * 2;
+               if (*pos != ':')
+                       goto invalid;
+               pos++;
+
+               if (hexstr2bin(pos, data->sres[i], EAP_SIM_SRES_LEN) < 0)
+                       goto invalid;
+               wpa_hexdump_key(MSG_DEBUG, "EAP-SIM: SRES",
+                               data->sres[i], EAP_SIM_SRES_LEN);
+               pos += EAP_SIM_SRES_LEN * 2;
+               if (i + 1 < data->num_chal) {
+                       if (*pos != ':')
+                               goto invalid;
+                       pos++;
+               }
+       }
+
+       os_free(resp);
+       return 0;
+
+invalid:
+       wpa_printf(MSG_DEBUG, "EAP-SIM: Invalid external SIM processing GSM-AUTH response");
+       os_free(resp);
+       return -1;
+}
+
+
 static int eap_sim_gsm_auth(struct eap_sm *sm, struct eap_sim_data *data)
 {
        struct eap_peer_config *conf;
@@ -150,6 +241,14 @@ static int eap_sim_gsm_auth(struct eap_sm *sm, struct eap_sim_data *data)
        conf = eap_get_config(sm);
        if (conf == NULL)
                return -1;
+
+       if (sm->external_sim) {
+               if (conf->external_sim_resp)
+                       return eap_sim_ext_sim_result(sm, data, conf);
+               else
+                       return eap_sim_ext_sim_req(sm, data);
+       }
+
        if (conf->pcsc) {
                if (scard_gsm_auth(sm->scard_ctx, data->rand[0],
                                   data->sres[0], data->kc[0]) ||
@@ -263,23 +362,24 @@ static int eap_sim_supported_ver(int version)
 #define CLEAR_REAUTH_ID        0x02
 #define CLEAR_EAP_ID   0x04
 
-static void eap_sim_clear_identities(struct eap_sim_data *data, int id)
+static void eap_sim_clear_identities(struct eap_sm *sm,
+                                    struct eap_sim_data *data, int id)
 {
-       wpa_printf(MSG_DEBUG, "EAP-SIM: forgetting old%s%s%s",
-                  id & CLEAR_PSEUDONYM ? " pseudonym" : "",
-                  id & CLEAR_REAUTH_ID ? " reauth_id" : "",
-                  id & CLEAR_EAP_ID ? " eap_id" : "");
-       if (id & CLEAR_PSEUDONYM) {
+       if ((id & CLEAR_PSEUDONYM) && data->pseudonym) {
+               wpa_printf(MSG_DEBUG, "EAP-SIM: forgetting old pseudonym");
                os_free(data->pseudonym);
                data->pseudonym = NULL;
                data->pseudonym_len = 0;
+               eap_set_anon_id(sm, NULL, 0);
        }
-       if (id & CLEAR_REAUTH_ID) {
+       if ((id & CLEAR_REAUTH_ID) && data->reauth_id) {
+               wpa_printf(MSG_DEBUG, "EAP-SIM: forgetting old reauth_id");
                os_free(data->reauth_id);
                data->reauth_id = NULL;
                data->reauth_id_len = 0;
        }
-       if (id & CLEAR_EAP_ID) {
+       if ((id & CLEAR_EAP_ID) && data->last_eap_identity) {
+               wpa_printf(MSG_DEBUG, "EAP-SIM: forgetting old eap_id");
                os_free(data->last_eap_identity);
                data->last_eap_identity = NULL;
                data->last_eap_identity_len = 0;
@@ -287,24 +387,45 @@ static void eap_sim_clear_identities(struct eap_sim_data *data, int id)
 }
 
 
-static int eap_sim_learn_ids(struct eap_sim_data *data,
+static int eap_sim_learn_ids(struct eap_sm *sm, struct eap_sim_data *data,
                             struct eap_sim_attrs *attr)
 {
        if (attr->next_pseudonym) {
+               const u8 *identity = NULL;
+               size_t identity_len = 0;
+               const u8 *realm = NULL;
+               size_t realm_len = 0;
+
+               wpa_hexdump_ascii(MSG_DEBUG,
+                                 "EAP-SIM: (encr) AT_NEXT_PSEUDONYM",
+                                 attr->next_pseudonym,
+                                 attr->next_pseudonym_len);
                os_free(data->pseudonym);
-               data->pseudonym = os_malloc(attr->next_pseudonym_len);
+               /* Look for the realm of the permanent identity */
+               identity = eap_get_config_identity(sm, &identity_len);
+               if (identity) {
+                       for (realm = identity, realm_len = identity_len;
+                            realm_len > 0; realm_len--, realm++) {
+                               if (*realm == '@')
+                                       break;
+                       }
+               }
+               data->pseudonym = os_malloc(attr->next_pseudonym_len +
+                                           realm_len);
                if (data->pseudonym == NULL) {
                        wpa_printf(MSG_INFO, "EAP-SIM: (encr) No memory for "
                                   "next pseudonym");
+                       data->pseudonym_len = 0;
                        return -1;
                }
                os_memcpy(data->pseudonym, attr->next_pseudonym,
                          attr->next_pseudonym_len);
-               data->pseudonym_len = attr->next_pseudonym_len;
-               wpa_hexdump_ascii(MSG_DEBUG,
-                                 "EAP-SIM: (encr) AT_NEXT_PSEUDONYM",
-                                 data->pseudonym,
-                                 data->pseudonym_len);
+               if (realm_len) {
+                       os_memcpy(data->pseudonym + attr->next_pseudonym_len,
+                                 realm, realm_len);
+               }
+               data->pseudonym_len = attr->next_pseudonym_len + realm_len;
+               eap_set_anon_id(sm, data->pseudonym, data->pseudonym_len);
        }
 
        if (attr->next_reauth_id) {
@@ -313,6 +434,7 @@ static int eap_sim_learn_ids(struct eap_sim_data *data,
                if (data->reauth_id == NULL) {
                        wpa_printf(MSG_INFO, "EAP-SIM: (encr) No memory for "
                                   "next reauth_id");
+                       data->reauth_id_len = 0;
                        return -1;
                }
                os_memcpy(data->reauth_id, attr->next_reauth_id,
@@ -337,10 +459,12 @@ static struct wpabuf * eap_sim_client_error(struct eap_sim_data *data, u8 id,
        data->num_id_req = 0;
        data->num_notification = 0;
 
+       wpa_printf(MSG_DEBUG, "EAP-SIM: Send Client-Error (error code %d)",
+                  err);
        msg = eap_sim_msg_init(EAP_CODE_RESPONSE, id, EAP_TYPE_SIM,
                               EAP_SIM_SUBTYPE_CLIENT_ERROR);
        eap_sim_msg_add(msg, EAP_SIM_AT_CLIENT_ERROR_CODE, err, NULL, 0);
-       return eap_sim_msg_finish(msg, NULL, NULL, 0);
+       return eap_sim_msg_finish(msg, EAP_TYPE_SIM, NULL, NULL, 0);
 }
 
 
@@ -361,16 +485,16 @@ static struct wpabuf * eap_sim_response_start(struct eap_sm *sm,
                   data->pseudonym) {
                identity = data->pseudonym;
                identity_len = data->pseudonym_len;
-               eap_sim_clear_identities(data, CLEAR_REAUTH_ID);
+               eap_sim_clear_identities(sm, data, CLEAR_REAUTH_ID);
        } else if (id_req != NO_ID_REQ) {
                identity = eap_get_config_identity(sm, &identity_len);
                if (identity) {
-                       eap_sim_clear_identities(data, CLEAR_PSEUDONYM |
+                       eap_sim_clear_identities(sm, data, CLEAR_PSEUDONYM |
                                                 CLEAR_REAUTH_ID);
                }
        }
        if (id_req != NO_ID_REQ)
-               eap_sim_clear_identities(data, CLEAR_EAP_ID);
+               eap_sim_clear_identities(sm, data, CLEAR_EAP_ID);
 
        wpa_printf(MSG_DEBUG, "Generating EAP-SIM Start (id=%d)", id);
        msg = eap_sim_msg_init(EAP_CODE_RESPONSE, id,
@@ -393,7 +517,7 @@ static struct wpabuf * eap_sim_response_start(struct eap_sm *sm,
                                identity, identity_len);
        }
 
-       return eap_sim_msg_finish(msg, NULL, NULL, 0);
+       return eap_sim_msg_finish(msg, EAP_TYPE_SIM, NULL, NULL, 0);
 }
 
 
@@ -411,13 +535,15 @@ static struct wpabuf * eap_sim_response_challenge(struct eap_sim_data *data,
        }
        wpa_printf(MSG_DEBUG, "   AT_MAC");
        eap_sim_msg_add_mac(msg, EAP_SIM_AT_MAC);
-       return eap_sim_msg_finish(msg, data->k_aut, (u8 *) data->sres,
+       return eap_sim_msg_finish(msg, EAP_TYPE_SIM, data->k_aut,
+                                 (u8 *) data->sres,
                                  data->num_chal * EAP_SIM_SRES_LEN);
 }
 
 
 static struct wpabuf * eap_sim_response_reauth(struct eap_sim_data *data,
-                                              u8 id, int counter_too_small)
+                                              u8 id, int counter_too_small,
+                                              const u8 *nonce_s)
 {
        struct eap_sim_msg *msg;
        unsigned int counter;
@@ -452,7 +578,7 @@ static struct wpabuf * eap_sim_response_reauth(struct eap_sim_data *data,
        }
        wpa_printf(MSG_DEBUG, "   AT_MAC");
        eap_sim_msg_add_mac(msg, EAP_SIM_AT_MAC);
-       return eap_sim_msg_finish(msg, data->k_aut, data->nonce_s,
+       return eap_sim_msg_finish(msg, EAP_TYPE_SIM, data->k_aut, nonce_s,
                                  EAP_SIM_NONCE_S_LEN);
 }
 
@@ -486,7 +612,7 @@ static struct wpabuf * eap_sim_response_notification(struct eap_sim_data *data,
                wpa_printf(MSG_DEBUG, "   AT_MAC");
                eap_sim_msg_add_mac(msg, EAP_SIM_AT_MAC);
        }
-       return eap_sim_msg_finish(msg, k_aut, (u8 *) "", 0);
+       return eap_sim_msg_finish(msg, EAP_TYPE_SIM, k_aut, (u8 *) "", 0);
 }
 
 
@@ -575,6 +701,7 @@ static struct wpabuf * eap_sim_process_challenge(struct eap_sm *sm,
        const u8 *identity;
        size_t identity_len;
        struct eap_sim_attrs eattr;
+       int res;
 
        wpa_printf(MSG_DEBUG, "EAP-SIM: subtype Challenge");
        data->reauth = 0;
@@ -618,8 +745,13 @@ static struct wpabuf * eap_sim_process_challenge(struct eap_sm *sm,
 
        os_memcpy(data->rand, attr->rand, attr->num_chal * GSM_RAND_LEN);
        data->num_chal = attr->num_chal;
-               
-       if (eap_sim_gsm_auth(sm, data)) {
+
+       res = eap_sim_gsm_auth(sm, data);
+       if (res > 0) {
+               wpa_printf(MSG_DEBUG, "EAP-SIM: Wait for external SIM processing");
+               return NULL;
+       }
+       if (res) {
                wpa_printf(MSG_WARNING, "EAP-SIM: GSM authentication failed");
                return eap_sim_client_error(data, id,
                                            EAP_SIM_UNABLE_TO_PROCESS_PACKET);
@@ -648,11 +780,11 @@ static struct wpabuf * eap_sim_process_challenge(struct eap_sm *sm,
                                            EAP_SIM_UNABLE_TO_PROCESS_PACKET);
        }
 
-       /* Old reauthentication and pseudonym identities must not be used
-        * anymore. In other words, if no new identities are received, full
-        * authentication will be used on next reauthentication. */
-       eap_sim_clear_identities(data, CLEAR_PSEUDONYM | CLEAR_REAUTH_ID |
-                                CLEAR_EAP_ID);
+       /* Old reauthentication identity must not be used anymore. In
+        * other words, if no new reauth identity is received, full
+        * authentication will be used on next reauthentication (using
+        * pseudonym identity or permanent identity). */
+       eap_sim_clear_identities(sm, data, CLEAR_REAUTH_ID | CLEAR_EAP_ID);
 
        if (attr->encr_data) {
                u8 *decrypted;
@@ -663,14 +795,14 @@ static struct wpabuf * eap_sim_process_challenge(struct eap_sm *sm,
                        return eap_sim_client_error(
                                data, id, EAP_SIM_UNABLE_TO_PROCESS_PACKET);
                }
-               eap_sim_learn_ids(data, &eattr);
+               eap_sim_learn_ids(sm, data, &eattr);
                os_free(decrypted);
        }
 
        if (data->result_ind && attr->result_ind)
                data->use_result_ind = 1;
 
-       if (data->state != FAILURE && data->state != RESULT_FAILURE) {
+       if (data->state != FAILURE) {
                eap_sim_state(data, data->use_result_ind ?
                              RESULT_SUCCESS : SUCCESS);
        }
@@ -834,9 +966,11 @@ static struct wpabuf * eap_sim_process_reauthentication(
        }
 
        if (eattr.counter < 0 || (size_t) eattr.counter <= data->counter) {
+               struct wpabuf *res;
                wpa_printf(MSG_INFO, "EAP-SIM: (encr) Invalid counter "
                           "(%d <= %d)", eattr.counter, data->counter);
                data->counter_too_small = eattr.counter;
+
                /* Reply using Re-auth w/ AT_COUNTER_TOO_SMALL. The current
                 * reauth_id must not be used to start a new reauthentication.
                 * However, since it was used in the last EAP-Response-Identity
@@ -847,8 +981,11 @@ static struct wpabuf * eap_sim_process_reauthentication(
                data->last_eap_identity_len = data->reauth_id_len;
                data->reauth_id = NULL;
                data->reauth_id_len = 0;
+
+               res = eap_sim_response_reauth(data, id, 1, eattr.nonce_s);
                os_free(decrypted);
-               return eap_sim_response_reauth(data, id, 1);
+
+               return res;
        }
        data->counter = eattr.counter;
 
@@ -860,13 +997,13 @@ static struct wpabuf * eap_sim_process_reauthentication(
                                   data->reauth_id, data->reauth_id_len,
                                   data->nonce_s, data->mk, data->msk,
                                   data->emsk);
-       eap_sim_clear_identities(data, CLEAR_REAUTH_ID | CLEAR_EAP_ID);
-       eap_sim_learn_ids(data, &eattr);
+       eap_sim_clear_identities(sm, data, CLEAR_REAUTH_ID | CLEAR_EAP_ID);
+       eap_sim_learn_ids(sm, data, &eattr);
 
        if (data->result_ind && attr->result_ind)
                data->use_result_ind = 1;
 
-       if (data->state != FAILURE && data->state != RESULT_FAILURE) {
+       if (data->state != FAILURE) {
                eap_sim_state(data, data->use_result_ind ?
                              RESULT_SUCCESS : SUCCESS);
        }
@@ -876,10 +1013,11 @@ static struct wpabuf * eap_sim_process_reauthentication(
        if (data->counter > EAP_SIM_MAX_FAST_REAUTHS) {
                wpa_printf(MSG_DEBUG, "EAP-SIM: Maximum number of "
                           "fast reauths performed - force fullauth");
-               eap_sim_clear_identities(data, CLEAR_REAUTH_ID | CLEAR_EAP_ID);
+               eap_sim_clear_identities(sm, data,
+                                        CLEAR_REAUTH_ID | CLEAR_EAP_ID);
        }
        os_free(decrypted);
-       return eap_sim_response_reauth(data, id, 0);
+       return eap_sim_response_reauth(data, id, 0, data->nonce_s);
 }
 
 
@@ -904,7 +1042,7 @@ static struct wpabuf * eap_sim_process(struct eap_sm *sm, void *priv,
        }
 
        pos = eap_hdr_validate(EAP_VENDOR_IETF, EAP_TYPE_SIM, reqData, &len);
-       if (pos == NULL || len < 1) {
+       if (pos == NULL || len < 3) {
                ret->ignore = TRUE;
                return NULL;
        }
@@ -964,9 +1102,7 @@ done:
                        DECISION_UNCOND_SUCC : DECISION_COND_SUCC;
                ret->methodState = data->use_result_ind ?
                        METHOD_DONE : METHOD_MAY_CONT;
-       } else if (data->state == RESULT_FAILURE)
-               ret->methodState = METHOD_CONT;
-       else if (data->state == RESULT_SUCCESS)
+       } else if (data->state == RESULT_SUCCESS)
                ret->methodState = METHOD_CONT;
 
        if (ret->methodState == METHOD_DONE) {
@@ -987,15 +1123,16 @@ static Boolean eap_sim_has_reauth_data(struct eap_sm *sm, void *priv)
 static void eap_sim_deinit_for_reauth(struct eap_sm *sm, void *priv)
 {
        struct eap_sim_data *data = priv;
-       eap_sim_clear_identities(data, CLEAR_EAP_ID);
+       eap_sim_clear_identities(sm, data, CLEAR_EAP_ID);
        data->use_result_ind = 0;
+       eap_sim_clear_keys(data, 1);
 }
 
 
 static void * eap_sim_init_for_reauth(struct eap_sm *sm, void *priv)
 {
        struct eap_sim_data *data = priv;
-       if (os_get_random(data->nonce_mt, EAP_SIM_NONCE_MT_LEN)) {
+       if (random_get_bytes(data->nonce_mt, EAP_SIM_NONCE_MT_LEN)) {
                wpa_printf(MSG_WARNING, "EAP-SIM: Failed to get random data "
                           "for NONCE_MT");
                os_free(data);
@@ -1053,6 +1190,29 @@ static u8 * eap_sim_getKey(struct eap_sm *sm, void *priv, size_t *len)
 }
 
 
+static u8 * eap_sim_get_session_id(struct eap_sm *sm, void *priv, size_t *len)
+{
+       struct eap_sim_data *data = priv;
+       u8 *id;
+
+       if (data->state != SUCCESS)
+               return NULL;
+
+       *len = 1 + data->num_chal * GSM_RAND_LEN + EAP_SIM_NONCE_MT_LEN;
+       id = os_malloc(*len);
+       if (id == NULL)
+               return NULL;
+
+       id[0] = EAP_TYPE_SIM;
+       os_memcpy(id + 1, data->rand, data->num_chal * GSM_RAND_LEN);
+       os_memcpy(id + 1 + data->num_chal * GSM_RAND_LEN, data->nonce_mt,
+                 EAP_SIM_NONCE_MT_LEN);
+       wpa_hexdump(MSG_DEBUG, "EAP-SIM: Derived Session-Id", id, *len);
+
+       return id;
+}
+
+
 static u8 * eap_sim_get_emsk(struct eap_sm *sm, void *priv, size_t *len)
 {
        struct eap_sim_data *data = priv;
@@ -1087,6 +1247,7 @@ int eap_peer_sim_register(void)
        eap->process = eap_sim_process;
        eap->isKeyAvailable = eap_sim_isKeyAvailable;
        eap->getKey = eap_sim_getKey;
+       eap->getSessionId = eap_sim_get_session_id;
        eap->has_reauth_data = eap_sim_has_reauth_data;
        eap->deinit_for_reauth = eap_sim_deinit_for_reauth;
        eap->init_for_reauth = eap_sim_init_for_reauth;