From patchwork Fri Nov 2 18:02:14 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrey Kartashev X-Patchwork-Id: 992479 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=gmail.com Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="Ww3PPmGA"; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="SzfL+Tkw"; dkim-atps=neutral Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:e::133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 42mqh64vThzB4XK for ; Sat, 3 Nov 2018 05:03:50 +1100 (AEDT) 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:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id: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=uhwB8KFXwsjMfP8al+E4zYWbJvBbZNqHASW+nA4ZIV8=; b=Ww3PPmGAEh0QhxpMm8JfMlahzs Jo7ag4/6sB0SwT67BwBkaC/u4Lp2uNWPzL2EQ1G5S6Y8cpeGFkIm1nT4giVXIMhFKM5vgjBKScjC2 +q+37S8gH10ng3xuO/KdUmT2eWK8P+Tx3cMGFfqY/4wDjPRTazHd0QFkxvOF9Ylte9Sm9bJEiVgIK wjrjb35SzJEOcpGAFbeiD1CAssz3axeN9rlDx7frG66CkGtAjdI/plqSx0R1HkXIm3gU0YWmsvOeA DTE5OJ1NnyT3seM7Co5araki8K48u6MKvpLTARixl1P5eBBQ1jDZPloKay8bVIQki0lHyHMyj6wMg UAe57k2Q==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1gIdnA-0002nt-Gr; Fri, 02 Nov 2018 18:03:32 +0000 Received: from mail-lf1-x141.google.com ([2a00:1450:4864:20::141]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1gIdms-0002Wo-N4 for hostap@lists.infradead.org; Fri, 02 Nov 2018 18:03:16 +0000 Received: by mail-lf1-x141.google.com with SMTP id p86so1928018lfg.5 for ; Fri, 02 Nov 2018 11:03:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=M6IB7Wq85ovWKo0Uz9kn4Z1E9eoUNSgMz4rtJOwzNds=; b=SzfL+TkwjPJU7EbXSy9ZGejpaY83HhdEsm4Xce/oij7PUbhhVvAJEuR7rS7tlRXB60 aYhhjiKwuIj3V9hm60c4IKUL2+US/aTrzfj2lzM/mghJSe2ou/kzILkprTlM+zxnbg/d UK3QPm5Ys0JypSsR1lTkf3FJjltfEn8+mqyLo9o8xhcVDKiAB3bA8zR8r/Wro+fX6x4t zvP53gg00dy/KAsdDHTgP2oMdXC5FTPvYZ8G7BlwUAxQ7ls74+rFheIelV0UVjoy2lMh S6T4RhiVEfJBQVUsmGfwiJQsrSA5rFf9LGkZ5MNe9wPYRtqd/BnmL2lJ0lpX5rwEbxBJ uPKA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=M6IB7Wq85ovWKo0Uz9kn4Z1E9eoUNSgMz4rtJOwzNds=; b=NVth+ZGW7MPfnhjSEqhF2Xqf5OwMaon4/4aMwl9efyCyBTZmAav7RTSR2KBMIAcXKd pcCPBZYVC0zM6BGE3ju15XYtu/HdaWtRCzbkoI8urrL+pnzfoAq69S6sCsJCuttqTAAF tsYF+3Kh8n9CWvHpz+dfpmou4WNY87EN74hYt9VGw+foknp4k9mvZpheSbRkohOZBjXB Qs2+kMcB7n9tl9dWAa35h0FfmOiOZrbHHlRY+JLK25GygyeJiaftqn0sKx5yco6DS+IF RQ73gTyh7r2fR0fZaO72VNgXz37yt3ZWl319vR4HjcpeB8iwv4IKK1c/Fmqhoi6NVCQU Z83g== X-Gm-Message-State: AGRZ1gLRm13ppCPbQtUHo9CRT0s/qFBY3Xf9Gmvq4Qr97cM2p/AbGH/Y 1oMfzEVGeCsLrVf6D6Sm74aqhJLh X-Google-Smtp-Source: AJdET5fywx3pDxVgAJClwEzgqDWPXA92gwiKo4QlcwhjqxA30WcNFl7qvAhNctIragWtkyv9Js8wSA== X-Received: by 2002:a19:4d8d:: with SMTP id a135mr7949254lfb.80.1541181782319; Fri, 02 Nov 2018 11:03:02 -0700 (PDT) Received: from localhost.localdomain ([194.103.244.100]) by smtp.gmail.com with ESMTPSA id a9sm1002595lfa.19.2018.11.02.11.03.01 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 02 Nov 2018 11:03:01 -0700 (PDT) From: Andrey Kartashev To: hostap@lists.infradead.org Subject: [PATCH 2/8] mka: Allow to setup MACsec replay protection Date: Fri, 2 Nov 2018 19:02:14 +0100 Message-Id: <20181102180220.20948-2-a.s.kartashev@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20181102180220.20948-1-a.s.kartashev@gmail.com> References: <20181102180220.20948-1-a.s.kartashev@gmail.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20181102_110314_753045_2A0F5B7F X-CRM114-Status: GOOD ( 19.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 RCVD_IN_DNSWL_NONE RBL: Sender listed at http://www.dnswl.org/, no trust [2a00:1450:4864:20:0:0:0:141 listed in] [list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail provider (a.s.kartashev[at]gmail.com) -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 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature X-BeenThere: hostap@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Andrey Kartashev MIME-Version: 1.0 Sender: "Hostap" Errors-To: hostap-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org From: Andrey Kartashev This patch adds new configuration parameters to allow user to setup MACsec replay protection feature. Note that according to IEEE 802.1X-2010 replay protection and delay protection are different features: replay protection is related only too SecY and does not appear on MKA level while delay protection is something that KaY can use to manage SecY state. Signed-off-by: Andrey Kartashev --- src/pae/ieee802_1x_kay.c | 10 ++++++---- src/pae/ieee802_1x_kay.h | 1 + wpa_supplicant/config.c | 2 ++ wpa_supplicant/config_file.c | 2 ++ wpa_supplicant/config_ssid.h | 26 ++++++++++++++++++++++++++ wpa_supplicant/wpa_cli.c | 2 ++ wpa_supplicant/wpa_supplicant.conf | 16 ++++++++++++++++ wpa_supplicant/wpas_kay.c | 5 +++-- 8 files changed, 58 insertions(+), 6 deletions(-) diff --git a/src/pae/ieee802_1x_kay.c b/src/pae/ieee802_1x_kay.c index cda23fcab..20dd10c07 100644 --- a/src/pae/ieee802_1x_kay.c +++ b/src/pae/ieee802_1x_kay.c @@ -1214,8 +1214,9 @@ ieee802_1x_mka_encode_sak_use_body( return 0; } - /* data protect, lowest accept packet number */ - body->delay_protect = kay->macsec_replay_protect; + /* data delay protect (it is not same as replay protect!) */ + body->delay_protect = FALSE; + /* 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"); @@ -3137,6 +3138,7 @@ static void kay_l2_receive(void *ctx, const u8 *src_addr, const u8 *buf, */ struct ieee802_1x_kay * ieee802_1x_kay_init(struct ieee802_1x_kay_ctx *ctx, enum macsec_policy policy, + Boolean macsec_replay_protect, u32 macsec_replay_window, u16 port, u8 priority, const char *ifname, const u8 *addr) { struct ieee802_1x_kay *kay; @@ -3196,8 +3198,8 @@ ieee802_1x_kay_init(struct ieee802_1x_kay_ctx *ctx, enum macsec_policy policy, kay->macsec_protect = TRUE; kay->macsec_encrypt = policy == SHOULD_ENCRYPT; kay->macsec_validate = Strict; - kay->macsec_replay_protect = FALSE; - kay->macsec_replay_window = 0; + kay->macsec_replay_protect = macsec_replay_protect; + kay->macsec_replay_window = macsec_replay_window; if (kay->macsec_capable >= MACSEC_CAP_INTEG_AND_CONF) kay->macsec_confidentiality = CONFIDENTIALITY_OFFSET_0; else diff --git a/src/pae/ieee802_1x_kay.h b/src/pae/ieee802_1x_kay.h index b2650596c..57f1260b8 100644 --- a/src/pae/ieee802_1x_kay.h +++ b/src/pae/ieee802_1x_kay.h @@ -236,6 +236,7 @@ u64 mka_sci_u64(struct ieee802_1x_mka_sci *sci); struct ieee802_1x_kay * ieee802_1x_kay_init(struct ieee802_1x_kay_ctx *ctx, enum macsec_policy policy, + Boolean macsec_replay_protect, u32 macsec_replay_window, u16 port, u8 priority, const char *ifname, const u8 *addr); void ieee802_1x_kay_deinit(struct ieee802_1x_kay *kay); diff --git a/wpa_supplicant/config.c b/wpa_supplicant/config.c index c43960697..8cf418a47 100644 --- a/wpa_supplicant/config.c +++ b/wpa_supplicant/config.c @@ -2299,6 +2299,8 @@ static const struct parse_data ssid_fields[] = { #ifdef CONFIG_MACSEC { INT_RANGE(macsec_policy, 0, 1) }, { INT_RANGE(macsec_integ_only, 0, 1) }, + { INT_RANGE(macsec_replay_protect, 0, 1) }, + { INT(macsec_replay_window) }, { INT_RANGE(macsec_port, 1, 65534) }, { INT_RANGE(mka_priority, 0, 255) }, { FUNC_KEY(mka_cak) }, diff --git a/wpa_supplicant/config_file.c b/wpa_supplicant/config_file.c index 09115e19d..3a0e13e65 100644 --- a/wpa_supplicant/config_file.c +++ b/wpa_supplicant/config_file.c @@ -853,6 +853,8 @@ static void wpa_config_write_network(FILE *f, struct wpa_ssid *ssid) write_mka_cak(f, ssid); write_mka_ckn(f, ssid); INT(macsec_integ_only); + INT(macsec_replay_protect); + INT(macsec_replay_window); INT(macsec_port); INT_DEF(mka_priority, DEFAULT_PRIO_NOT_KEY_SERVER); #endif /* CONFIG_MACSEC */ diff --git a/wpa_supplicant/config_ssid.h b/wpa_supplicant/config_ssid.h index d2a52d760..a31ee1a2e 100644 --- a/wpa_supplicant/config_ssid.h +++ b/wpa_supplicant/config_ssid.h @@ -773,6 +773,32 @@ struct wpa_ssid { */ int macsec_integ_only; + /** + * macsec_replay_protect - Enable MACsec replay protection + * + * This setting applies only when MACsec is in use, i.e., + * - macsec_policy is enabled + * - the key server has decided to enable MACsec + * + * 0: Replay protection disabled (default) + * 1: Replay protection enabled + */ + int macsec_replay_protect; + + /** + * macsec_replay_window - Set MACsec replay protection window (a window in + * which replay is tolerated, to allow receipt of frames that have been + * misordered by the network) + * + * This setting applies only when MACsec replay protection active, i.e., + * - macsec_replay_protect is enabled + * - the key server has decided to enable MACsec + * + * 0: No replay window, strict check (default) + * 1 ... 2^32-1: number of packets that could be misordered + */ + u32 macsec_replay_window; + /** * macsec_port - MACsec port (in SCI) * diff --git a/wpa_supplicant/wpa_cli.c b/wpa_supplicant/wpa_cli.c index 05e3ebf2f..9d39dcdd6 100644 --- a/wpa_supplicant/wpa_cli.c +++ b/wpa_supplicant/wpa_cli.c @@ -1426,6 +1426,8 @@ static const char *network_fields[] = { #ifdef CONFIG_MACSEC "macsec_policy", "macsec_integ_only", + "macsec_replay_protect", + "macsec_replay_window", "macsec_port", "mka_priority", #endif /* CONFIG_MACSEC */ diff --git a/wpa_supplicant/wpa_supplicant.conf b/wpa_supplicant/wpa_supplicant.conf index 4f5916025..f46a25d6f 100644 --- a/wpa_supplicant/wpa_supplicant.conf +++ b/wpa_supplicant/wpa_supplicant.conf @@ -987,6 +987,22 @@ fast_reauth=1 # 0: Encrypt traffic (default) # 1: Integrity only # +# macsec_replay_protect: IEEE 802.1X/MACsec replay protection +# This setting applies only when MACsec is in use, i.e., +# - macsec_policy is enabled +# - the key server has decided to enable MACsec +# 0: Replay protection disabled (default) +# 1: Replay protection enabled +# +# macsec_replay_window: IEEE 802.1X/MACsec replay protection window +# This determines a window in which replay is tolerated, to allow receipt +# of frames that have been misordered by the network) +# This setting applies only when MACsec replay protection active, i.e., +# - macsec_replay_protect is enabled +# - the key server has decided to enable MACsec +# 0: No replay window, strict check (default) +# 1 ... 2^32-1: number of packets that could be misordered +# # macsec_port: IEEE 802.1X/MACsec port # Port component of the SCI # Range: 1-65534 (default: 1) diff --git a/wpa_supplicant/wpas_kay.c b/wpa_supplicant/wpas_kay.c index d3d06b8ae..e10ce72da 100644 --- a/wpa_supplicant/wpas_kay.c +++ b/wpa_supplicant/wpas_kay.c @@ -232,8 +232,9 @@ int ieee802_1x_alloc_kay_sm(struct wpa_supplicant *wpa_s, struct wpa_ssid *ssid) kay_ctx->enable_transmit_sa = wpas_enable_transmit_sa; kay_ctx->disable_transmit_sa = wpas_disable_transmit_sa; - res = ieee802_1x_kay_init(kay_ctx, policy, ssid->macsec_port, - ssid->mka_priority, wpa_s->ifname, + res = ieee802_1x_kay_init(kay_ctx, policy, + ssid->macsec_replay_protect, ssid->macsec_replay_window, + ssid->macsec_port, ssid->mka_priority, wpa_s->ifname, wpa_s->own_addr); /* ieee802_1x_kay_init() frees kay_ctx on failure */ if (res == NULL)