From patchwork Mon Jan 2 23:29:14 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Baatz X-Patchwork-Id: 133929 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 C208FB6F99 for ; Tue, 3 Jan 2012 10:30:22 +1100 (EST) Received: from localhost (localhost [127.0.0.1]) by maxx.maxx.shmoo.com (Postfix) with ESMTP id C8F589D299; Mon, 2 Jan 2012 18:30:10 -0500 (EST) X-Quarantine-ID: <3dzFHzRinG+o> 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 3dzFHzRinG+o; Mon, 2 Jan 2012 18:30:10 -0500 (EST) Received: from maxx.shmoo.com (localhost [127.0.0.1]) by maxx.maxx.shmoo.com (Postfix) with ESMTP id C53B19CE2D; Mon, 2 Jan 2012 18:29:33 -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 DEBAA9D21F for ; Mon, 2 Jan 2012 18:29:31 -0500 (EST) X-Quarantine-ID: <5Y-fhUdSpFzG> 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 5Y-fhUdSpFzG for ; Mon, 2 Jan 2012 18:29:27 -0500 (EST) Received: from mail-ee0-f44.google.com (mail-ee0-f44.google.com [74.125.83.44]) (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 5D48A9CDCC for ; Mon, 2 Jan 2012 18:29:19 -0500 (EST) Received: by mail-ee0-f44.google.com with SMTP id c14so16726019eek.17 for ; Mon, 02 Jan 2012 15:29:19 -0800 (PST) Received: by 10.14.98.196 with SMTP id v44mr20178175eef.53.1325546959174; Mon, 02 Jan 2012 15:29:19 -0800 (PST) Received: from gandalf.schnuecks.de (p5DE8D9A7.dip.t-dialin.net. [93.232.217.167]) by mx.google.com with ESMTPS id y12sm196761671eeb.11.2012.01.02.15.29.18 (version=TLSv1/SSLv3 cipher=OTHER); Mon, 02 Jan 2012 15:29:18 -0800 (PST) Received: by gandalf.schnuecks.de (Postfix, from userid 500) id CD7A140B42; Tue, 3 Jan 2012 00:29:14 +0100 (CET) From: Simon Baatz To: hostap@lists.shmoo.com Subject: [RFC][PATCH 5/5] EAP-SIM/EAP-AKA peer: Support realms according to 3GPP TS 23.003 Date: Tue, 3 Jan 2012 00:29:14 +0100 Message-Id: <8c70eeed5eec7f9b7df7daacbbfad99959b59751.1325546256.git.gmbnomis@gmail.com> X-Mailer: git-send-email 1.7.5.4 In-Reply-To: References: 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, allow to use a realm according to 3GPP TS 23.003. --- src/eap_peer/eap.c | 48 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 48 insertions(+), 0 deletions(-) diff --git a/src/eap_peer/eap.c b/src/eap_peer/eap.c index 91fa4a9..e2f5713 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,6 +961,9 @@ static int eap_sm_imsi_identity(struct eap_sm *sm, os_memcpy(conf->identity + 1, imsi, imsi_len); conf->identity_len = 1 + imsi_len; + if (conf->realm_3gpp) { + return eap_sm_append_3gpp_realm(sm, conf); + } return 0; } #endif /* PCSC_FUNCS */