From patchwork Sun Jan 15 20:32:48 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Baatz X-Patchwork-Id: 136208 Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from maxx.maxx.shmoo.com (maxx.shmoo.com [205.134.188.171]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client CN "maxx.shmoo.com", Issuer "CA Cert Signing Authority" (not verified)) by ozlabs.org (Postfix) with ESMTPS id 43F11B6EF7 for ; Mon, 16 Jan 2012 07:33:39 +1100 (EST) Received: from localhost (localhost [127.0.0.1]) by maxx.maxx.shmoo.com (Postfix) with ESMTP id C3E2B9CE2D; Sun, 15 Jan 2012 15:33:32 -0500 (EST) X-Quarantine-ID: X-Virus-Scanned: amavisd-new at maxx.shmoo.com X-Amavis-Alert: BAD HEADER, Duplicate header field: "In-Reply-To" Received: from maxx.maxx.shmoo.com ([127.0.0.1]) by localhost (maxx.shmoo.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id NYULR9kjktPs; Sun, 15 Jan 2012 15:33:32 -0500 (EST) Received: from maxx.shmoo.com (localhost [127.0.0.1]) by maxx.maxx.shmoo.com (Postfix) with ESMTP id DD27B17C070; Sun, 15 Jan 2012 15:33:05 -0500 (EST) X-Original-To: mailman-post+hostap@maxx.shmoo.com Delivered-To: mailman-post+hostap@maxx.shmoo.com Received: from localhost (localhost [127.0.0.1]) by maxx.maxx.shmoo.com (Postfix) with ESMTP id DC4899C38D for ; Sun, 15 Jan 2012 15:33:03 -0500 (EST) X-Quarantine-ID: X-Virus-Scanned: amavisd-new at maxx.shmoo.com X-Amavis-Alert: BAD HEADER, Duplicate header field: "In-Reply-To" Received: from maxx.maxx.shmoo.com ([127.0.0.1]) by localhost (maxx.shmoo.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id n1Qunzg2CEub for ; Sun, 15 Jan 2012 15:32:59 -0500 (EST) Received: from mail-ey0-f172.google.com (mail-ey0-f172.google.com [209.85.215.172]) (using TLSv1 with cipher RC4-SHA (128/128 bits)) (Client CN "smtp.gmail.com", Issuer "Google Internet Authority" (not verified)) by maxx.maxx.shmoo.com (Postfix) with ESMTPS id F17EA9C1BD for ; Sun, 15 Jan 2012 15:32:55 -0500 (EST) Received: by eaai13 with SMTP id i13so185793eaa.17 for ; Sun, 15 Jan 2012 12:32:55 -0800 (PST) Received: by 10.213.13.10 with SMTP id z10mr2058540ebz.63.1326659573949; Sun, 15 Jan 2012 12:32:53 -0800 (PST) Received: from gandalf.schnuecks.de (p5DE8F246.dip.t-dialin.net. [93.232.242.70]) by mx.google.com with ESMTPS id b49sm62958882eec.9.2012.01.15.12.32.51 (version=TLSv1/SSLv3 cipher=OTHER); Sun, 15 Jan 2012 12:32:52 -0800 (PST) Received: by gandalf.schnuecks.de (Postfix, from userid 500) id 903554048A; Sun, 15 Jan 2012 21:32:49 +0100 (CET) From: Simon Baatz To: hostap@lists.shmoo.com Subject: [PATCH 4/4] EAP-SIM/EAP-AKA peer: Support realms according to 3GPP TS 23.003 Date: Sun, 15 Jan 2012 21:32:48 +0100 Message-Id: <8229f081493e769d577f7fbaeea0352cd89a72e4.1326658542.git.gmbnomis@gmail.com> X-Mailer: git-send-email 1.7.5.4 In-Reply-To: References: <20120109044329.GA16253@w1.fi> In-Reply-To: References: X-BeenThere: hostap@lists.shmoo.com X-Mailman-Version: 2.1.9 Precedence: list List-Id: HostAP Project List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: hostap-bounces@lists.shmoo.com Errors-To: hostap-bounces@lists.shmoo.com If the identity is derived from the SIM, use a realm according to 3GPP TS 23.003. Signed-hostap: Simon Baatz --- src/eap_peer/eap.c | 47 ++++++++++++++++++++++++++++++++++++++++++++++- 1 files changed, 46 insertions(+), 1 deletions(-) diff --git a/src/eap_peer/eap.c b/src/eap_peer/eap.c index 91fa4a9..02070d7 100644 --- a/src/eap_peer/eap.c +++ b/src/eap_peer/eap.c @@ -878,6 +878,51 @@ static void eap_sm_processIdentity(struct eap_sm *sm, const struct wpabuf *req) #ifdef PCSC_FUNCS +static int eap_sm_append_3gpp_realm(struct eap_sm *sm, + struct eap_peer_config *conf) +{ + char *realm_3gpp = "@wlan.mnc000.mcc000.3gppnetwork.org"; + u8 *full_id = NULL; + size_t full_id_len = 0; + int mnc_len; + + full_id = os_malloc(conf->identity_len + strlen(realm_3gpp)); + if (full_id == NULL) { + wpa_printf(MSG_WARNING, "Failed to allocate buffer for " + "3GPP realm"); + return -1; + } + os_memcpy(full_id, conf->identity, conf->identity_len); + os_memcpy(full_id + conf->identity_len, + realm_3gpp, strlen(realm_3gpp)); + full_id_len = conf->identity_len + strlen(realm_3gpp); + + full_id[conf->identity_len + 16] = full_id[1]; + full_id[conf->identity_len + 17] = full_id[2]; + full_id[conf->identity_len + 18] = full_id[3]; + + mnc_len = scard_get_mnc_len(sm->scard_ctx); + if (mnc_len < 0) { + wpa_printf(MSG_WARNING, "Failed to get MNC length from (U)SIM" + " assuming 3"); + mnc_len = 3; + } + if (mnc_len == 2) { + full_id[conf->identity_len + 10] = full_id[4]; + full_id[conf->identity_len + 11] = full_id[5]; + } else if (mnc_len == 3) { + full_id[conf->identity_len + 9] = full_id[4]; + full_id[conf->identity_len + 10] = full_id[5]; + full_id[conf->identity_len + 11] = full_id[6]; + } + + os_free(conf->identity); + conf->identity = full_id; + conf->identity_len = full_id_len; + + return 0; +} + static int eap_sm_imsi_identity(struct eap_sm *sm, struct eap_peer_config *conf) { @@ -916,7 +961,7 @@ static int eap_sm_imsi_identity(struct eap_sm *sm, os_memcpy(conf->identity + 1, imsi, imsi_len); conf->identity_len = 1 + imsi_len; - return 0; + return eap_sm_append_3gpp_realm(sm, conf); } #endif /* PCSC_FUNCS */