From patchwork Sun Aug 26 15:26:52 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: michael-dev X-Patchwork-Id: 180064 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 BA9852C00D8 for ; Mon, 27 Aug 2012 01:27:14 +1000 (EST) Received: from localhost (localhost [127.0.0.1]) by maxx.maxx.shmoo.com (Postfix) with ESMTP id 871669D2AC; Sun, 26 Aug 2012 11:27:12 -0400 (EDT) X-Virus-Scanned: amavisd-new at maxx.shmoo.com 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 Y4sChVsOVcBk; Sun, 26 Aug 2012 11:27:12 -0400 (EDT) Received: from maxx.shmoo.com (localhost [127.0.0.1]) by maxx.maxx.shmoo.com (Postfix) with ESMTP id E1DEA9D290; Sun, 26 Aug 2012 11:27:05 -0400 (EDT) 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 7539E9D290 for ; Sun, 26 Aug 2012 11:27:04 -0400 (EDT) X-Virus-Scanned: amavisd-new at maxx.shmoo.com 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 UM-m94UDeK5y for ; Sun, 26 Aug 2012 11:26:55 -0400 (EDT) Received: from a251.fem.tu-ilmenau.de (unknown [212.46.162.222]) by maxx.maxx.shmoo.com (Postfix) with ESMTP id 9319A9D28C for ; Sun, 26 Aug 2012 11:26:53 -0400 (EDT) Received: from localhost6.localdomain6 (localhost.localdomain [127.0.0.1]) by konsullaptop.a-keller (Postfix) with ESMTP id C4CA3223413; Sun, 26 Aug 2012 17:26:52 +0200 (CEST) Subject: [RFC PATCH 1/4] radius_msg_get_tunnel_password returns the n-th Tunnel-Password To: hostap@lists.shmoo.com From: Michael Braun Date: Sun, 26 Aug 2012 17:26:52 +0200 Message-ID: <20120826152609.9572.53911.stgit@localhost6.localdomain6> In-Reply-To: <20120826152517.9572.16585.stgit@localhost6.localdomain6> References: <20120826152517.9572.16585.stgit@localhost6.localdomain6> User-Agent: StGit/0.15 MIME-Version: 1.0 Cc: projekt-wlan@fem.tu-ilmenau.de 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: , Sender: hostap-bounces@lists.shmoo.com Errors-To: hostap-bounces@lists.shmoo.com This changes radius_msg_get_tunnel_password to return the n-th decoded Tunnel-Password. --- 0 files changed diff --git a/src/ap/ieee802_11_auth.c b/src/ap/ieee802_11_auth.c index 63ae345..12b65b5 100644 --- a/src/ap/ieee802_11_auth.c +++ b/src/ap/ieee802_11_auth.c @@ -482,7 +482,7 @@ hostapd_acl_recv_radius(struct radius_msg *msg, struct radius_msg *req, msg, &passphraselen, hapd->conf->radius->auth_server->shared_secret, hapd->conf->radius->auth_server->shared_secret_len, - req); + req, 0); cache->has_psk = passphrase != NULL; if (passphrase != NULL) { /* passphrase does not contain the NULL termination. diff --git a/src/radius/radius.c b/src/radius/radius.c index d5edfd8..de16a14 100644 --- a/src/radius/radius.c +++ b/src/radius/radius.c @@ -1406,11 +1406,12 @@ int radius_msg_get_vlanid(struct radius_msg *msg) * @secret: RADIUS shared secret * @secret_len: Length of secret * @sent_msg: Sent RADIUS message - * Returns: pointer to password (free with os_free) or %NULL + * @n: number of password attribute to return (starting with 0) + * Returns: pointer to n-th password (free with os_free) or %NULL */ char * radius_msg_get_tunnel_password(struct radius_msg *msg, int *keylen, const u8 *secret, size_t secret_len, - struct radius_msg *sent_msg) + struct radius_msg *sent_msg, size_t n) { u8 *buf = NULL; size_t buflen; @@ -1420,7 +1421,7 @@ char * radius_msg_get_tunnel_password(struct radius_msg *msg, int *keylen, size_t len[3]; u8 hash[16]; u8 *pos; - size_t i; + size_t i, j = 0; struct radius_attr_hdr *attr; const u8 *data; size_t dlen; @@ -1428,7 +1429,7 @@ char * radius_msg_get_tunnel_password(struct radius_msg *msg, int *keylen, size_t fdlen = -1; char *ret = NULL; - /* find attribute with lowest tag and check it */ + /* find n-th valid Tunnel-Password attribute */ for (i = 0; i < msg->attr_used; i++) { attr = radius_get_attr_hdr(msg, i); if (attr == NULL || @@ -1441,11 +1442,13 @@ char * radius_msg_get_tunnel_password(struct radius_msg *msg, int *keylen, dlen = attr->length - sizeof(*attr); if (dlen <= 3 || dlen % 16 != 3) continue; - if (fdata != NULL && fdata[0] <= data[0]) + j++; + if (j <= n) continue; fdata = data; fdlen = dlen; + break; } if (fdata == NULL) goto out; diff --git a/src/radius/radius.h b/src/radius/radius.h index 727640b..2031054 100644 --- a/src/radius/radius.h +++ b/src/radius/radius.h @@ -242,7 +242,7 @@ int radius_msg_get_attr(struct radius_msg *msg, u8 type, u8 *buf, size_t len); int radius_msg_get_vlanid(struct radius_msg *msg); char * radius_msg_get_tunnel_password(struct radius_msg *msg, int *keylen, const u8 *secret, size_t secret_len, - struct radius_msg *sent_msg); + struct radius_msg *sent_msg, size_t n); static inline int radius_msg_add_attr_int32(struct radius_msg *msg, u8 type, u32 value)