remove direct modification of identity, use value from service
authorDenis Vinogradov <denis.vinogradov@samsung.com>
Mon, 8 Jun 2020 03:11:35 +0000 (12:11 +0900)
committerYoojung Heo <yoojung.heo@samsung.com>
Tue, 25 Aug 2020 08:47:53 +0000 (17:47 +0900)
  For RFC822_ADDR MAC address could be used in IKE_SA identity,
  EAP indentity should exclude MAC. Remove modification to change
  indentity in code, use eap_identity field in add_conn.

Change-Id: I1f3197583dccf5208ca7e13c4210a6b45de18044
Signed-off-by: Denis Vinogradov <denis.vinogradov@samsung.com>
src/libcharon/sa/ikev2/authenticators/eap_authenticator.c

index e0654c9dab6799715d2054f8b1660992ea259143..23321873d18c8fe62c4eaa9268190952bcd44e76 100755 (executable)
@@ -129,38 +129,6 @@ static eap_method_t *load_method(private_eap_authenticator_t *this,
        {
                server = this->ike_sa->get_other_id(this->ike_sa);
                peer = this->ike_sa->get_my_id(this->ike_sa);
-#ifdef VOWIFI_CFG
-               if (peer->get_type(peer) == ID_RFC822_ADDR)
-               {
-                       chunk_t id = peer->get_encoding(peer);
-                       DBG1(DBG_IKE, "Current authentication ID: %s", id.ptr);
-                       if (strchr(id.ptr, '-') != NULL)
-                       {
-                               char output[id.len];
-                               unsigned char* delim;
-                               int ofs = 0;
-
-                               memset(output, 0, id.len);
-                               delim = strchr(id.ptr, '@');
-                               if (delim)
-                               {
-                                       int len = delim - id.ptr + 1;
-                                       memcpy(output, id.ptr, len);
-                                       ofs += len;
-                               }
-                               delim = strchr(id.ptr, ':');
-                               if (delim)
-                               {
-                                       int len = (id.ptr + id.len) - (++delim);
-                                       memcpy(output + ofs, delim, len);
-
-                                       DBG1(DBG_IKE, "New authentication ID: %s", output);
-
-                                       peer = identification_create_from_string(output);
-                               }
-                       }
-               }
-#endif
                auth = this->ike_sa->get_auth_cfg(this->ike_sa, TRUE);
        }
        if (this->eap_identity)
@@ -457,6 +425,14 @@ static eap_payload_t* client_process_eap(private_eap_authenticator_t *this,
                        return eap_payload_create_nak(in->get_identifier(in), conf_type,
                                                                                  conf_vendor, in->is_expanded(in));
                }
+#ifdef VOWIFI_CFG
+               id = auth->get(auth, AUTH_RULE_EAP_IDENTITY);
+               if ((id != NULL) && (id->get_type(id) != ID_ANY))
+               {
+                       DESTROY_IF(this->eap_identity);
+                       this->eap_identity = id->clone(id);
+               }
+#endif
                this->method = load_method(this, type, vendor, EAP_PEER);
                if (!this->method)
                {