From patchwork Tue Aug 27 03:55:34 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Winter X-Patchwork-Id: 1153663 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=lists.infradead.org (client-ip=2607:7c80:54:e::133; helo=bombadil.infradead.org; envelope-from=hostap-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=alliedtelesis.co.nz Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="WRA8EniL"; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=alliedtelesis.co.nz header.i=@alliedtelesis.co.nz header.b="2tiXwv5V"; dkim-atps=neutral Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:e::133]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 46Hjdm0bjGz9s00 for ; Tue, 27 Aug 2019 19:05:48 +1000 (AEST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=JiPKjHXzB0t0EVBRijtoud8yXjoXfehLhGO+7O2a6f8=; b=WRA8EniLSRjwVW 5FuW0XSY5j5s5ulvonLVfrqHsN+JJzFE4YLVtNTO3J9n7SOA3L27Q1XKXqWr+kuBZXFdJcf5NkOvh LgtOOht0ZvU4id/Ityn88J9EdPyTc6aAxMbPLr6oqJsmvH0iC01lU8rrt80eZRUxHsEDQjsCNb1Uh wgqBBxjddBTLpQMducpniquOI0/4SEB6ZJPTSPRxvl6sFWScr6N0hQqM0PIse4LikRdVf/Kz7vP+r pxDN1u2BYmJAsfmndLBH/uPK7ZNjYPpVUzdh+ObHRjwFKqUkDPoVP/kvGc2zse1tU3O64Jp04Vn2P IibjyDMZI22AFXA+6O4w==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.92 #3 (Red Hat Linux)) id 1i2XQ8-0002Kd-Rt; Tue, 27 Aug 2019 09:05:45 +0000 Received: from gate2.alliedtelesis.co.nz ([2001:df5:b000:5::4]) by bombadil.infradead.org with esmtps (Exim 4.92 #3 (Red Hat Linux)) id 1i2Say-0007g3-SM for hostap@lists.infradead.org; Tue, 27 Aug 2019 03:56:38 +0000 Received: from mmarshal3.atlnz.lc (mmarshal3.atlnz.lc [10.32.18.43]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by gate2.alliedtelesis.co.nz (Postfix) with ESMTPS id F23BE891AC for ; Tue, 27 Aug 2019 15:56:24 +1200 (NZST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=alliedtelesis.co.nz; s=mail181024; t=1566878184; bh=GAu2kxmTAeSsVIl/4f/HbM9xsaTqHI9cWGKDLu5pH2s=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=2tiXwv5VUuGx4T0lqp1z15cxhZQ/qpddfFKTARhxZD6awo/zYl3sLia8pm5gQpN9y JDLWkzYhfHl64YqflaBP8Az2t9ufcHQfoiWHudGNrqncuYak4fGMLv1KhilSczg30E VvwYs5jszEBkAuM3t0bJL6zb8CfcKTjr6rH8nK7PVUF6gePFejA3I+MP33hgHDdVjQ mYR9kS5BaLS7tqTb3P63iZG6TZxzftghCfam7aGAIzhnJs3JcJXYzpuuCyDT2nQOCt U1YhImTCuX2aspXOj6uV+mP2osWhN9OUoIw57QxRS829I+KsdDJknYTZA8qnX+V/gx 2uR930vZu4PBA== Received: from smtp (Not Verified[10.32.16.33]) by mmarshal3.atlnz.lc with Trustwave SEG (v7, 5, 8, 10121) id ; Tue, 27 Aug 2019 15:56:22 +1200 Received: from thomaswi-dl.ws.atlnz.lc (thomaswi-dl.ws.atlnz.lc [10.33.12.31]) by smtp (Postfix) with ESMTP id 5760D13EF9C; Tue, 27 Aug 2019 15:56:27 +1200 (NZST) Received: by thomaswi-dl.ws.atlnz.lc (Postfix, from userid 1719) id 57C68440366; Tue, 27 Aug 2019 15:56:24 +1200 (NZST) From: Thomas Winter To: hostap@lists.infradead.org Subject: [PATCH 1/5] mka: Change RECEIVE and RETIRE states to standard Date: Tue, 27 Aug 2019 15:55:34 +1200 Message-Id: <25b9238ff1e5ad3c48d393e85133876022f24b86.1566876816.git.Thomas.Winter@alliedtelesis.co.nz> X-Mailer: git-send-email 2.23.0 In-Reply-To: References: MIME-Version: 1.0 x-atlnz-ls: pat X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20190826_205637_121075_71416FA9 X-CRM114-Status: GOOD ( 10.47 ) X-Spam-Score: -0.2 (/) X-Spam-Report: SpamAssassin version 3.4.2 on bombadil.infradead.org summary: Content analysis details: (-0.2 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 SPF_PASS SPF: sender matches SPF record -0.0 SPF_HELO_PASS SPF: HELO matches SPF record -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain X-Mailman-Approved-At: Tue, 27 Aug 2019 02:05:38 -0700 X-BeenThere: hostap@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Thomas Winter Sender: "Hostap" Errors-To: hostap-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org The RECEIVE and RETIRE states are incorrect which can result in incorrect information being advertised in SAKuse MKPDUs. These have been changed to match IEEE 802.1X-2010 Figure 12-2 CP state machine. Hostap implemented an interpretation of the standard as described in a proposed amendment titled "MKA pending PN exhastion" which was deemed to be wrong. This amendment was included in IEEE 802.1Xck-2018. Signed-off-by: Thomas Winter --- src/pae/ieee802_1x_cp.c | 26 ++++++++++---------------- 1 file changed, 10 insertions(+), 16 deletions(-) diff --git a/src/pae/ieee802_1x_cp.c b/src/pae/ieee802_1x_cp.c index 1c4dc3e63..ab6abda24 100644 --- a/src/pae/ieee802_1x_cp.c +++ b/src/pae/ieee802_1x_cp.c @@ -212,18 +212,6 @@ SM_STATE(CP, SECURED) SM_STATE(CP, RECEIVE) { SM_ENTRY(CP, RECEIVE); - /* RECEIVE state machine not keep with Figure 12-2 in - * IEEE Std 802.1X-2010 */ - if (sm->oki) { - ieee802_1x_kay_delete_sas(sm->kay, sm->oki); - os_free(sm->oki); - } - sm->oki = sm->lki; - sm->oan = sm->lan; - sm->otx = sm->ltx; - sm->orx = sm->lrx; - ieee802_1x_kay_set_old_sa_attr(sm->kay, sm->oki, sm->oan, - sm->otx, sm->orx); sm->lki = os_malloc(sizeof(*sm->lki)); if (!sm->lki) { @@ -320,17 +308,23 @@ SM_STATE(CP, ABANDON) SM_STATE(CP, RETIRE) { SM_ENTRY(CP, RETIRE); - /* RETIRE state machine not keep with Figure 12-2 in - * IEEE Std 802.1X-2010 */ if (sm->oki) { ieee802_1x_kay_delete_sas(sm->kay, sm->oki); os_free(sm->oki); sm->oki = NULL; } - sm->orx = FALSE; - sm->otx = FALSE; + sm->oki = sm->lki; + sm->otx = sm->ltx; + sm->orx = sm->lrx; + sm->oan = sm->lan; ieee802_1x_kay_set_old_sa_attr(sm->kay, sm->oki, sm->oan, sm->otx, sm->orx); + sm->lrx = FALSE; + sm->ltx = FALSE; + sm->lan = 0; + sm->lki = NULL; + ieee802_1x_kay_set_latest_sa_attr(sm->kay, sm->lki, sm->lan, + sm->ltx, sm->lrx); } From patchwork Tue Aug 27 03:55:35 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Winter X-Patchwork-Id: 1153664 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=lists.infradead.org (client-ip=2607:7c80:54:e::133; helo=bombadil.infradead.org; envelope-from=hostap-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=alliedtelesis.co.nz Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="KVARG7FI"; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=alliedtelesis.co.nz header.i=@alliedtelesis.co.nz header.b="00mjYcp/"; dkim-atps=neutral Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:e::133]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 46Hjf16KKVz9s00 for ; Tue, 27 Aug 2019 19:06:01 +1000 (AEST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=S8fkd4DZCfcOMGlhnbvheHfGoksrQcLG5aOA7bIPm0w=; b=KVARG7FIwlx57d efAGKm9Z2VC1SCv6HqaATN0kwMJaOzwRPJRMLEqfzoTIDqA7PunwCBBKo00Tn1LyfffyRUlx82jnu L5ZAw0PUNxilE/Czi2nQFxcbN+BIOxlgrkZD/IC89Fd1c1/gfFkRFLlvBvvw60wl9JP092DbuTdWe 5KXcPjMTqetAhvASoo2WGGyDOgXZwE7piYBi8fSDP5Sq27Fl7IhvtdYVakeh2BnjwqESmmlsoxnlR +KdQ5xx8fsOnovjlOL4bWLflgn/iUDIfEWZ5sm53MZ9F6wriyoa84OFSEbFelCMiSr/KeWX0fed+q vOTtQkD7YcWU+OBZxhlg==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.92 #3 (Red Hat Linux)) id 1i2XQN-0002Xl-GY; Tue, 27 Aug 2019 09:05:59 +0000 Received: from gate2.alliedtelesis.co.nz ([2001:df5:b000:5::4]) by bombadil.infradead.org with esmtps (Exim 4.92 #3 (Red Hat Linux)) id 1i2Sb1-0007lH-8P for hostap@lists.infradead.org; Tue, 27 Aug 2019 03:56:40 +0000 Received: from mmarshal3.atlnz.lc (mmarshal3.atlnz.lc [10.32.18.43]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by gate2.alliedtelesis.co.nz (Postfix) with ESMTPS id D43E0891A9 for ; Tue, 27 Aug 2019 15:56:24 +1200 (NZST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=alliedtelesis.co.nz; s=mail181024; t=1566878184; bh=JkeZWGRc+YZdysVUdWzxJRC+5SkNaHgcXNxurKBJuzE=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=00mjYcp/TuzThYbktW8f9P0FTgxhGwXJMXOhTH/vdn6QKHaAb76tYaVxrrJFxNbKi z7aW8ONzr1L+R04v6A9S4ZbPEbileYcSYo2lrwzePX67Xwlu5Ml+W9pTGfbRF2ur5Q +gXzhvz9NcEjwSVKlYcm4fR/3r8WbSTmf/XBcglwPzLClHSdk3AHpPa7/gU2OuRMQW VcwxH/cz/sDs+38g+eXPefNtxEoZNYxjne9kyd/57bwDrVAe/WGaIycH3IEc6tzoCK 8I09YPG0YoqV/VT37/FMi8u1OqVsgP4HC4ZAYTBjZ2vIouxJ4H/261OXdFyKuML7hj dQrLzW9Wfywiw== Received: from smtp (Not Verified[10.32.16.33]) by mmarshal3.atlnz.lc with Trustwave SEG (v7, 5, 8, 10121) id ; Tue, 27 Aug 2019 15:56:22 +1200 Received: from thomaswi-dl.ws.atlnz.lc (thomaswi-dl.ws.atlnz.lc [10.33.12.31]) by smtp (Postfix) with ESMTP id 561AC13EF9B; Tue, 27 Aug 2019 15:56:27 +1200 (NZST) Received: by thomaswi-dl.ws.atlnz.lc (Postfix, from userid 1719) id 57292440046; Tue, 27 Aug 2019 15:56:24 +1200 (NZST) From: Thomas Winter To: hostap@lists.infradead.org Subject: [PATCH 2/5] mka: Don't set newSAK to FALSE on ABANDON Date: Tue, 27 Aug 2019 15:55:35 +1200 Message-Id: <4ab872861dcdfd4b67074661fff0ebe64710ff9e.1566876816.git.Thomas.Winter@alliedtelesis.co.nz> X-Mailer: git-send-email 2.23.0 In-Reply-To: References: MIME-Version: 1.0 x-atlnz-ls: pat X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20190826_205639_510091_790C4B83 X-CRM114-Status: GOOD ( 10.27 ) X-Spam-Score: -0.2 (/) X-Spam-Report: SpamAssassin version 3.4.2 on bombadil.infradead.org summary: Content analysis details: (-0.2 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 SPF_PASS SPF: sender matches SPF record -0.0 SPF_HELO_PASS SPF: HELO matches SPF record -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain X-Mailman-Approved-At: Tue, 27 Aug 2019 02:05:47 -0700 X-BeenThere: hostap@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Thomas Winter Sender: "Hostap" Errors-To: hostap-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org Previously the ABANDON->RECEIVE state change was impossible and did not match the CP state machine in IEEE 802.1X-2010 Figure 12-2. Signed-off-by: Thomas Winter --- src/pae/ieee802_1x_cp.c | 1 - 1 file changed, 1 deletion(-) diff --git a/src/pae/ieee802_1x_cp.c b/src/pae/ieee802_1x_cp.c index ab6abda24..a19f07518 100644 --- a/src/pae/ieee802_1x_cp.c +++ b/src/pae/ieee802_1x_cp.c @@ -301,7 +301,6 @@ SM_STATE(CP, ABANDON) sm->lki = NULL; ieee802_1x_kay_set_latest_sa_attr(sm->kay, sm->lki, sm->lan, sm->ltx, sm->lrx); - sm->new_sak = FALSE; } From patchwork Tue Aug 27 03:55:36 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Winter X-Patchwork-Id: 1153665 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=lists.infradead.org (client-ip=2607:7c80:54:e::133; helo=bombadil.infradead.org; envelope-from=hostap-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=alliedtelesis.co.nz Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="hzjp7ARQ"; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=alliedtelesis.co.nz header.i=@alliedtelesis.co.nz header.b="mJsvsxC5"; dkim-atps=neutral Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:e::133]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 46HjfV1rQSz9s7T for ; Tue, 27 Aug 2019 19:06:26 +1000 (AEST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=HYAWwV0j5rR2531VkQrVNIT20Np5xCHmau+olrJoGys=; b=hzjp7ARQX2M+kh VOHJTnaYWMl8biotrlGGcWNahwesR/LC7vR/Om6w8/zW2lBW7K6LadCuMv64FqK+uLEnA/v4DgqU2 Bq6bQuUwxiwfMZDW8FEOZZeu8qPS9Z4SHmmyR1Fmyeu6terddwo+Pv5mtUwGv7pm6Gjc/JRUkngCQ 9TUm1Wh8Tb3zpDKde7jSK3ixGXS/yxbqk31scSGj4t30VEyn2Lcwm2O64Gcf3A6yn4TqzRMJozyeP Bg4A83JqRYVL+rfMaJf2l/nYEPdgYnqVovB6StuiVs2oG5Ixc0z+a9PDoIxGcElnteH7JyHPyAc3T 9Tm1QMuXPJhKfw/szn0g==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.92 #3 (Red Hat Linux)) id 1i2XQl-0002sw-KD; Tue, 27 Aug 2019 09:06:23 +0000 Received: from gate2.alliedtelesis.co.nz ([2001:df5:b000:5::4]) by bombadil.infradead.org with esmtps (Exim 4.92 #3 (Red Hat Linux)) id 1i2Sav-0007Wx-Cs for hostap@lists.infradead.org; Tue, 27 Aug 2019 03:56:35 +0000 Received: from mmarshal3.atlnz.lc (mmarshal3.atlnz.lc [10.32.18.43]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by gate2.alliedtelesis.co.nz (Postfix) with ESMTPS id C7A9C886BF for ; Tue, 27 Aug 2019 15:56:24 +1200 (NZST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=alliedtelesis.co.nz; s=mail181024; t=1566878184; bh=mtrPmO0zjOh7Yn8cI4e7nziOStCJKGKfRYwnG9mrqJ4=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=mJsvsxC5cbA8pSYEF6xLoKw8G/DDsSRF4ZC42e0kr3yFv1wTbFxr5QURv1LufTPVt mInbex2o6Y9fKq0PlzRXNUhaoAwzbIyaER9X/S0kQEY6rXkJGezOpPes3ZoPWm6CNQ 1rrw2JQjqWu6Y2VAsvdSXmo1Er/PhUePSBX6rBoI7qAyLdprJ+6KIFjq4iuh4ZGsgS Q8sow4kkz5O6UmEqMUhSQgorqPssG5c5TrOOgWASgQuL4dzAV0vgaAAwM2+huhi8hw p7le3KBUKqM17XySvFk7qQoiJfS2Iq6wr6kFz2dIipxP6A1jJZM2W7MoSQsKfbybkJ WoMM5xpxdJLzw== Received: from smtp (Not Verified[10.32.16.33]) by mmarshal3.atlnz.lc with Trustwave SEG (v7, 5, 8, 10121) id ; Tue, 27 Aug 2019 15:56:22 +1200 Received: from thomaswi-dl.ws.atlnz.lc (thomaswi-dl.ws.atlnz.lc [10.33.12.31]) by smtp (Postfix) with ESMTP id 5435B13EF40; Tue, 27 Aug 2019 15:56:27 +1200 (NZST) Received: by thomaswi-dl.ws.atlnz.lc (Postfix, from userid 1719) id 58B57440328; Tue, 27 Aug 2019 15:56:24 +1200 (NZST) From: Thomas Winter To: hostap@lists.infradead.org Subject: [PATCH 3/5] mka: Clear out old/latest key values on CHANGE Date: Tue, 27 Aug 2019 15:55:36 +1200 Message-Id: X-Mailer: git-send-email 2.23.0 In-Reply-To: References: MIME-Version: 1.0 x-atlnz-ls: pat X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20190826_205633_817823_C33EB52F X-CRM114-Status: GOOD ( 10.60 ) X-Spam-Score: -0.2 (/) X-Spam-Report: SpamAssassin version 3.4.2 on bombadil.infradead.org summary: Content analysis details: (-0.2 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 SPF_PASS SPF: sender matches SPF record -0.0 SPF_HELO_PASS SPF: HELO matches SPF record -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain X-Mailman-Approved-At: Tue, 27 Aug 2019 02:06:02 -0700 X-BeenThere: hostap@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Thomas Winter Sender: "Hostap" Errors-To: hostap-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org The associated SAs have been deleted and the key server has changed so there's no point in keeping the key values. Note that this isn't specified in the standard. Signed-off-by: Thomas Winter --- src/pae/ieee802_1x_cp.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/src/pae/ieee802_1x_cp.c b/src/pae/ieee802_1x_cp.c index a19f07518..7b7cfde2c 100644 --- a/src/pae/ieee802_1x_cp.c +++ b/src/pae/ieee802_1x_cp.c @@ -141,6 +141,24 @@ SM_STATE(CP, CHANGE) ieee802_1x_kay_delete_sas(sm->kay, sm->lki); if (sm->oki) ieee802_1x_kay_delete_sas(sm->kay, sm->oki); + /* The standard doesn't say it but we should clear out the latest + * and old key values. Why would we keep advertising them if + * they've been deleted and the key server has been changed? + */ + os_free(sm->oki); + sm->oki = NULL; + sm->otx = FALSE; + sm->orx = FALSE; + sm->oan = 0; + ieee802_1x_kay_set_old_sa_attr(sm->kay, sm->oki, sm->oan, + sm->otx, sm->orx); + os_free(sm->lki); + sm->lki = NULL; + sm->lrx = FALSE; + sm->ltx = FALSE; + sm->lan = 0; + ieee802_1x_kay_set_latest_sa_attr(sm->kay, sm->lki, sm->lan, + sm->ltx, sm->lrx); } From patchwork Tue Aug 27 03:55:37 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Winter X-Patchwork-Id: 1153666 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=lists.infradead.org (client-ip=2607:7c80:54:e::133; helo=bombadil.infradead.org; envelope-from=hostap-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=alliedtelesis.co.nz Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="JpZuHyZt"; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=alliedtelesis.co.nz header.i=@alliedtelesis.co.nz header.b="mrrHkPe5"; dkim-atps=neutral Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:e::133]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 46Hjfl6MWGz9s7T for ; Tue, 27 Aug 2019 19:06:39 +1000 (AEST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=ADzEehv12t/NQ9b0OrwYPCI2k9tMHHWLnDNpmdq/dZ0=; b=JpZuHyZtdPObZo B9GUzS4Aqv7hqmyembyIW1s6yUbm1/sQgvh1mi4mv4VBIc5gr8OHuw/YqVOCSjc/iQwDKpeBAlWLw hwUKk2nvrdVm5DylGyblooXrUahnyfuH7yYlql5jw7opGPrsl4F9DT6TU742ppJqudWIeffdNld94 RrgTtkBIfODfR2W4zHc3oSJAGqCyuY+owyioTzmkdmRetYIC77x1cTml3gpgKiuoZdUYslcNVsR8H 3PpOO4h2meSQoTC6k0x1usRSLZ0bE0A7WsAjYxUD5VRxtPdhZysUpuLnyfk85aurPRF/sPkRAVKI4 IF6Vdv5UsC0JAvGuE1bA==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.92 #3 (Red Hat Linux)) id 1i2XQz-00034L-1o; Tue, 27 Aug 2019 09:06:37 +0000 Received: from gate2.alliedtelesis.co.nz ([202.36.163.20]) by bombadil.infradead.org with esmtps (Exim 4.92 #3 (Red Hat Linux)) id 1i2Sav-0007Wy-Cc for hostap@lists.infradead.org; Tue, 27 Aug 2019 03:56:35 +0000 Received: from mmarshal3.atlnz.lc (mmarshal3.atlnz.lc [10.32.18.43]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by gate2.alliedtelesis.co.nz (Postfix) with ESMTPS id E994B891AB for ; Tue, 27 Aug 2019 15:56:24 +1200 (NZST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=alliedtelesis.co.nz; s=mail181024; t=1566878184; bh=Q0+H3EjBu7Sh3ypqNKxqK1UpMU7oOV02CyjvHhHWl2g=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=mrrHkPe5TCUbyH5JEoIc0bIoEprUi7Y4fRhaXJrCVScDFVsRi2en2b38tJ1mciy06 ELqR1aVtudpX0Is2pLN+89mZ2/6vyMVwl41C9+SxlP0DfdC/5wslrWDz/OsGoafX5H FlkcsFhP4rGvL2XYs7rKpAK/Ysh5SIQFR9Xm+afer3gYGUl2O3cKJebsXSxGoX8DAF 8tspj+pPulBUdL5kighdERnjq9x+U4aRo9eUOpKQGEidhiF4mRuLuycQNNNQ3WjC/q YgpbgfsrFkdUPmFy0RzhKbOBMhlyxn2BhgxM4ELD7FsXH0AahnCeFzXC4A4LlQclEq Qr8r2j4l6b+Jw== Received: from smtp (Not Verified[10.32.16.33]) by mmarshal3.atlnz.lc with Trustwave SEG (v7, 5, 8, 10121) id ; Tue, 27 Aug 2019 15:56:22 +1200 Received: from thomaswi-dl.ws.atlnz.lc (thomaswi-dl.ws.atlnz.lc [10.33.12.31]) by smtp (Postfix) with ESMTP id 5516913EF59; Tue, 27 Aug 2019 15:56:27 +1200 (NZST) Received: by thomaswi-dl.ws.atlnz.lc (Postfix, from userid 1719) id 5A1EF44043C; Tue, 27 Aug 2019 15:56:24 +1200 (NZST) From: Thomas Winter To: hostap@lists.infradead.org Subject: [PATCH 4/5] mka: Check OLPN for exhaustion on SAKuse encode Date: Tue, 27 Aug 2019 15:55:37 +1200 Message-Id: <18ac3475583e9c949c0d757ddf0cbea5cb344b89.1566876816.git.Thomas.Winter@alliedtelesis.co.nz> X-Mailer: git-send-email 2.23.0 In-Reply-To: References: MIME-Version: 1.0 x-atlnz-ls: pat X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20190826_205633_818165_A42D6103 X-CRM114-Status: GOOD ( 14.48 ) X-Spam-Score: -0.2 (/) X-Spam-Report: SpamAssassin version 3.4.2 on bombadil.infradead.org summary: Content analysis details: (-0.2 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [202.36.163.20 listed in list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record -0.0 SPF_HELO_PASS SPF: HELO matches SPF record -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain X-Mailman-Approved-At: Tue, 27 Aug 2019 02:06:09 -0700 X-BeenThere: hostap@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Thomas Winter Sender: "Hostap" Errors-To: hostap-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org Most of the time is spent in the RETIRE state where LKI is not set and OKI is the currently used SAK so OLPN needs to be checked for PN exhaustion. Hostap implemented an interpretation of the standard as described in a proposed amendment titled "MKA pending PN exhastion" which was deemed to be wrong. This amendment was included in IEEE 802.1Xck-2018. Signed-off-by: Thomas Winter --- src/pae/ieee802_1x_kay.c | 34 +++++++++++++++++++++++----------- 1 file changed, 23 insertions(+), 11 deletions(-) diff --git a/src/pae/ieee802_1x_kay.c b/src/pae/ieee802_1x_kay.c index a330d0cf4..db292df24 100644 --- a/src/pae/ieee802_1x_kay.c +++ b/src/pae/ieee802_1x_kay.c @@ -1287,7 +1287,8 @@ ieee802_1x_mka_encode_sak_use_body( struct ieee802_1x_mka_sak_use_body *body; struct ieee802_1x_kay *kay = participant->kay; unsigned int length; - u32 pn = 1; + u32 olpn = 1; + u32 llpn = 1; length = ieee802_1x_mka_get_sak_use_length(participant); body = wpabuf_put(buf, length); @@ -1307,18 +1308,29 @@ ieee802_1x_mka_encode_sak_use_body( /* data delay protect */ body->delay_protect = kay->mka_hello_time <= MKA_BOUNDED_HELLO_TIME; - /* lowest accept packet number */ - pn = ieee802_1x_mka_get_lpn(participant, &participant->lki); - if (pn > kay->pn_exhaustion) { - wpa_printf(MSG_WARNING, "KaY: My LPN exhaustion"); - if (participant->is_key_server) - participant->new_sak = TRUE; + /* lowest accept packet numbers */ + olpn = ieee802_1x_mka_get_lpn(participant, &participant->oki); + body->olpn = host_to_be32(olpn); + llpn = ieee802_1x_mka_get_lpn(participant, &participant->lki); + body->llpn = host_to_be32(llpn); + if (participant->is_key_server) { + /* The CP will spend most of it's time in RETIRE where only + * the old key is populated. Therefore we should be checking + * the OLPN most of the time. + */ + if (participant->lrx) { + if (llpn > kay->pn_exhaustion) { + wpa_printf(MSG_WARNING, "KaY: My LLPN exhaustion"); + participant->new_sak = TRUE; + } + } else { + if (olpn > kay->pn_exhaustion) { + wpa_printf(MSG_WARNING, "KaY: My OLPN exhaustion"); + participant->new_sak = TRUE; + } + } } - body->llpn = host_to_be32(pn); - pn = ieee802_1x_mka_get_lpn(participant, &participant->oki); - body->olpn = host_to_be32(pn); - /* plain tx, plain rx */ body->ptx = !kay->macsec_protect; body->prx = kay->macsec_validate != Strict; From patchwork Tue Aug 27 03:55:38 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Winter X-Patchwork-Id: 1153667 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=lists.infradead.org (client-ip=2607:7c80:54:e::133; helo=bombadil.infradead.org; envelope-from=hostap-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=alliedtelesis.co.nz Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="BJxhL/U2"; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=alliedtelesis.co.nz header.i=@alliedtelesis.co.nz header.b="1blY/U9q"; dkim-atps=neutral Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:e::133]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 46Hjg346yDz9s00 for ; Tue, 27 Aug 2019 19:06:55 +1000 (AEST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=SSxi16c5f+aBW9L8gipzS5mY3uZImZ8eTq6S+hDq94U=; b=BJxhL/U2zReIje Hdj2UG6NkpnVxpKYV77PD5TiUtYdDRlR7OcqoJiAYctlVoT0RbcDk8uPd2L6D6//rRVadOtLZ38im 74SJfSWltGeJ/IIXo1xjadeTKY7DPpbNmlCMEyloh8J474b5TRccDcweRLVlIq0sd7zlxZgqylLnf Q+wbwgHlwY1LTH+R3bu6PmkpdwG3NYH2eOno2mBq1S5iuvZnkwBu14rSFJgKalLziqHqV+rZXMs1n 9l2e/qVD0/6n9mqDZaQfj1ziPO78VwkpwOXcqBmuS+lLZDYpab0O0bLjA5TNzX2AV95sB5It5eoNV Bc9sfJCqyk0KRXIa0XvA==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.92 #3 (Red Hat Linux)) id 1i2XRE-0003JL-Gj; Tue, 27 Aug 2019 09:06:52 +0000 Received: from gate2.alliedtelesis.co.nz ([2001:df5:b000:5::4]) by bombadil.infradead.org with esmtps (Exim 4.92 #3 (Red Hat Linux)) id 1i2Saz-0007jS-QH for hostap@lists.infradead.org; Tue, 27 Aug 2019 03:56:40 +0000 Received: from mmarshal3.atlnz.lc (mmarshal3.atlnz.lc [10.32.18.43]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by gate2.alliedtelesis.co.nz (Postfix) with ESMTPS id E70C6891AA for ; Tue, 27 Aug 2019 15:56:24 +1200 (NZST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=alliedtelesis.co.nz; s=mail181024; t=1566878184; bh=WFfUdluM80xZoWt3Im7yxSJCiAwKMzSXOKsSWFhXlvQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=1blY/U9q4cf5u1xzMH+c4/cU25qrfWYOXhTwSef+GiAmst7kXFINT98RIMksVSUkd wbTG21dk8WUQV5sR9F7pnOCudqaJvJ3YAPf57hIESt3ZkdBJPPC6xE+QPvNIvOqX8w f57H0PEteq9yQK/167c3S66hgRnHykQdqDnX+9ykHlHFhjHdwoVg6Pxm91PzrR9EKD iXh0HB78HZ3UtJ6tF2jn1Q0DlMHz4ARpW4AZXyFRhXNaTD0q+XOavMe/hVxDPUJHMo fiej3dTVfyQLS6mkSKlMe+lsLAEnYmQnFC1g7qoX1/h4b7s4wxxq+R69168w+j/Pje TTw9Upyysqifw== Received: from smtp (Not Verified[10.32.16.33]) by mmarshal3.atlnz.lc with Trustwave SEG (v7, 5, 8, 10121) id ; Tue, 27 Aug 2019 15:56:22 +1200 Received: from thomaswi-dl.ws.atlnz.lc (thomaswi-dl.ws.atlnz.lc [10.33.12.31]) by smtp (Postfix) with ESMTP id 58E7713EED5; Tue, 27 Aug 2019 15:56:27 +1200 (NZST) Received: by thomaswi-dl.ws.atlnz.lc (Postfix, from userid 1719) id 5CDB44404D3; Tue, 27 Aug 2019 15:56:24 +1200 (NZST) From: Thomas Winter To: hostap@lists.infradead.org Subject: [PATCH 5/5] mka: Check OLPN for exhaustion on SAKuse decode Date: Tue, 27 Aug 2019 15:55:38 +1200 Message-Id: <47a5194cdcfa3c0838e6b04b1506f2360926d5e4.1566876816.git.Thomas.Winter@alliedtelesis.co.nz> X-Mailer: git-send-email 2.23.0 In-Reply-To: References: MIME-Version: 1.0 x-atlnz-ls: pat X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20190826_205638_485437_25F20F71 X-CRM114-Status: GOOD ( 23.35 ) X-Spam-Score: -0.2 (/) X-Spam-Report: SpamAssassin version 3.4.2 on bombadil.infradead.org summary: Content analysis details: (-0.2 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 SPF_PASS SPF: sender matches SPF record -0.0 SPF_HELO_PASS SPF: HELO matches SPF record -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain X-Mailman-Approved-At: Tue, 27 Aug 2019 02:06:29 -0700 X-BeenThere: hostap@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Thomas Winter Sender: "Hostap" Errors-To: hostap-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org Most of the time is spent in the RETIRE state where LKI is not set and OKI is the currently used SAK so OLPN needs to be checked for PN exhaustion. Hostap implemented an interpretation of the standard as described in a proposed amendment titled "MKA pending PN exhastion" which was deemed to be wrong. This amendment was included in IEEE 802.1Xck-2018. Signed-off-by: Thomas Winter --- src/pae/ieee802_1x_kay.c | 193 +++++++++++++++++++++------------------ 1 file changed, 106 insertions(+), 87 deletions(-) diff --git a/src/pae/ieee802_1x_kay.c b/src/pae/ieee802_1x_kay.c index db292df24..e06ec337b 100644 --- a/src/pae/ieee802_1x_kay.c +++ b/src/pae/ieee802_1x_kay.c @@ -1381,7 +1381,7 @@ ieee802_1x_mka_decode_sak_use_body( struct ieee802_1x_mka_sak_use_body *body; struct ieee802_1x_kay_peer *peer; struct receive_sc *rxsc; - struct receive_sa *rxsa; + struct receive_sa *rxsa = NULL; struct data_key *sa_key = NULL; size_t body_len; struct ieee802_1x_mka_ki ki; @@ -1389,6 +1389,9 @@ ieee802_1x_mka_decode_sak_use_body( Boolean all_receiving; Boolean found; struct ieee802_1x_kay *kay = participant->kay; + struct ieee802_1x_kay_peer *peer_iter; + u32 olpn; + u32 llpn; if (!participant->principal) { wpa_printf(MSG_WARNING, "KaY: Participant is not principal"); @@ -1429,46 +1432,6 @@ ieee802_1x_mka_decode_sak_use_body( if (body->ptx) wpa_printf(MSG_WARNING, "KaY: peer's plain tx are TRUE"); - - /* check latest key is valid */ - if (body->ltx || body->lrx) { - found = FALSE; - os_memcpy(ki.mi, body->lsrv_mi, sizeof(ki.mi)); - ki.kn = be_to_host32(body->lkn); - dl_list_for_each(sa_key, &participant->sak_list, - struct data_key, list) { - if (is_ki_equal(&sa_key->key_identifier, &ki)) { - found = TRUE; - break; - } - } - if (!found) { - wpa_printf(MSG_INFO, "KaY: Latest key is invalid"); - return -1; - } - if (os_memcmp(participant->lki.mi, body->lsrv_mi, - sizeof(participant->lki.mi)) == 0 && - be_to_host32(body->lkn) == participant->lki.kn && - body->lan == participant->lan) { - peer->sak_used = TRUE; - } - if (body->ltx && peer->is_key_server) { - ieee802_1x_cp_set_servertransmitting(kay->cp, TRUE); - ieee802_1x_cp_sm_step(kay->cp); - } - } - - /* check old key is valid (but only if we remember our old key) */ - if (participant->oki.kn != 0 && (body->otx || body->orx)) { - if (os_memcmp(participant->oki.mi, body->osrv_mi, - sizeof(participant->oki.mi)) != 0 || - be_to_host32(body->okn) != participant->oki.kn || - body->oan != participant->oan) { - wpa_printf(MSG_WARNING, "KaY: Old key is invalid"); - return -1; - } - } - /* TODO: how to set the MACsec hardware when delay_protect is true */ if (body->delay_protect && (!be_to_host32(body->llpn) || !be_to_host32(body->olpn))) { @@ -1477,65 +1440,121 @@ ieee802_1x_mka_decode_sak_use_body( return -1; } - /* check all live peer have used the sak for receiving sa */ - all_receiving = TRUE; - dl_list_for_each(peer, &participant->live_peers, - struct ieee802_1x_kay_peer, list) { - if (!peer->sak_used) { - all_receiving = FALSE; - break; - } + olpn = be_to_host32(body->olpn); + llpn = be_to_host32(body->llpn); + + /* Our most recent distributed key should be the first in the list. + * If it doesn't exist then we can't really do anything. + * Be lenient and don't return error here as there are legitimate cases + * where this can happen such as when a new participant joins the CA and + * the first frame it receives can have a SAKuse but not distSAK. + */ + sa_key = dl_list_first (&participant->sak_list, struct data_key, list); + if (!sa_key) { + wpa_printf(MSG_INFO, "KaY: We don't have a latest distributed key - ignore SAK use"); + return 0; } - if (all_receiving) { - participant->to_dist_sak = FALSE; - ieee802_1x_cp_set_allreceiving(kay->cp, TRUE); - ieee802_1x_cp_sm_step(kay->cp); + + /* The peer's most recent key will be the "latest key" if it is present + * otherwise it will be the "old key" if in the RETIRE state. + */ + if (body->lrx) { + os_memcpy(ki.mi, body->lsrv_mi, sizeof(ki.mi)); + ki.kn = be_to_host32(body->lkn); + lpn = llpn; + } else { + os_memcpy(ki.mi, body->osrv_mi, sizeof(ki.mi)); + ki.kn = be_to_host32(body->okn); + lpn = olpn; } - /* if I'm key server, and detects peer member pn exhaustion, rekey. */ - lpn = be_to_host32(body->llpn); - if (lpn > kay->pn_exhaustion) { - if (participant->is_key_server) { - participant->new_sak = TRUE; - wpa_printf(MSG_WARNING, "KaY: Peer LPN exhaustion"); - } + /* If the most recent distributed keys don't agree then someone is out of sync. + * Perhaps non key server hasn't processed the most recent distSAK yet + * and the key server is processing an old packet after it has done + * distSAK. Be lenient and don't return error in this particular case + * otherwise the key server will reset it's MI and cause a traffic disruption + * which is really undesired for a simple timing issue. + */ + if (!is_ki_equal(&sa_key->key_identifier, &ki)) { + wpa_printf(MSG_INFO, "KaY: Distributed keys don't match - ignore SAK use"); + return 0; } + sa_key->next_pn = lpn; - if (sa_key) - sa_key->next_pn = lpn; - found = FALSE; - dl_list_for_each(rxsc, &participant->rxsc_list, struct receive_sc, - list) { - dl_list_for_each(rxsa, &rxsc->sa_list, struct receive_sa, - list) { - if (sa_key && rxsa->pkey == sa_key) { - found = TRUE; + /* The key server must check that all peers are using the most recent distributed key. + * Non key servers must check if the key server is transmitting. + */ + if (participant->is_key_server) { + /* Distributed keys are equal from above comparison. */ + peer->sak_used = TRUE; + + all_receiving = TRUE; + dl_list_for_each(peer_iter, &participant->live_peers, + struct ieee802_1x_kay_peer, list) { + if (!peer_iter->sak_used) { + all_receiving = FALSE; break; } } - if (found) - break; + if (all_receiving) { + participant->to_dist_sak = FALSE; + ieee802_1x_cp_set_allreceiving(kay->cp, TRUE); + ieee802_1x_cp_sm_step(kay->cp); + } + } else if (peer->is_key_server) { + if (body->ltx) { + ieee802_1x_cp_set_servertransmitting(kay->cp, TRUE); + ieee802_1x_cp_sm_step(kay->cp); + } } - if (!found) { - wpa_printf(MSG_WARNING, "KaY: Can't find rxsa"); - return -1; + + /* if I'm key server, and detects peer member pn exhaustion, rekey. + * We only need to check the PN of the most recent distributed key. This could + * be the peer's "latest" or "old" key depending on its current state. + * If both "old" and "latest" keys are present then the "old" key has + * already been exhausted. + */ + if (participant->is_key_server && lpn > kay->pn_exhaustion) { + participant->new_sak = TRUE; + wpa_printf(MSG_WARNING, "KaY: Peer LPN exhaustion"); } + /* Get the associated RX SAs of the keys for delay protection + * since both can be in use. + * Delay protect window (communicated via MKA) is + * tighter than SecY's current replay protect window, + * so tell SecY the new (and higher) lpn. + */ if (body->delay_protect) { - secy_get_receive_lowest_pn(participant->kay, rxsa); - if (lpn > rxsa->lowest_pn) { - /* Delay protect window (communicated via MKA) is - * tighter than SecY's current replay protect window, - * so tell SecY the new (and higher) lpn. */ - rxsa->lowest_pn = lpn; - secy_set_receive_lowest_pn(participant->kay, rxsa); - wpa_printf(MSG_DEBUG, "KaY: update lpn =0x%x", lpn); + found = FALSE; + dl_list_for_each(rxsc, &participant->rxsc_list, struct receive_sc, + list) { + dl_list_for_each(rxsa, &rxsc->sa_list, struct receive_sa, + list) { + if (sa_key && rxsa->pkey == sa_key) { + found = TRUE; + break; + } + } + if (found) + break; } - /* FIX: Delay protection for olpn not implemented. - * Note that Old Key is only active for MKA_SAK_RETIRE_TIME - * (3 seconds) and delay protection does allow PN's within - * a 2 seconds window, so olpn would be a lot of work for - * just 1 second's worth of protection. */ + if (rxsa) { + secy_get_receive_lowest_pn(participant->kay, rxsa); + if (lpn > rxsa->lowest_pn) { + rxsa->lowest_pn = lpn; + secy_set_receive_lowest_pn(participant->kay, rxsa); + wpa_printf(MSG_DEBUG, "KaY: update dist LPN=0x%x", lpn); + } + } + + /* FIX: Delay protection for the SA being replaced is not implemented. + * Note that this key will be active for at least MKA_SAK_RETIRE_TIME + * (3 seconds) but could be longer depending on how long it takes to + * get from RECEIVE to TRANSMITTING or if going via ABANDON. + * Delay protection does allow PN's within a 2 seconds window, so getting + * PN would be a lot of work for just 1 second's worth of protection. + */ } return 0;