From patchwork Fri Nov 2 18:02:18 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrey Kartashev X-Patchwork-Id: 992483 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="fXuf1LyF"; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="V07SiYZ3"; 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 42mqhc3xq3zB4XD for ; Sat, 3 Nov 2018 05:04:16 +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=37OFx67I6u2ghnOqHK7KCwy4SU0y3rKuNKzUGioy640=; b=fXuf1LyFWh/5bgUSl1k3Cnaizq XU0IirO3ct81YJr6+82sSdXX4owgbzYVxHVlXZr8ZqbPnCTm5fk0r6MB9U2IgzFTkJir37KzOEZ6T CVejWT3uEBpxfkQp+iWAJctvwCfNDFKoXPq6WT2hX2Hsf0zdrxcpr92fxiyLPI3O5Rh52LjcGuv6d ur77zaQm6J3W7hggkwlU/XWVSu1ticwVlERRO8ezrI73xH14Hwg0SKvyy+9XfQ/tZPL/hBcaURgnG CAEnuHHWo3E3tn8yH1X+/tw4eLdNgXVBRzpTIFmC/6z+vOVq65dyrL8a1vqXj0d/xzNEOFhc30FAk nVn0CGXw==; 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 1gIdnb-0003S5-Nj; Fri, 02 Nov 2018 18:03:59 +0000 Received: from mail-lf1-x129.google.com ([2a00:1450:4864:20::129]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1gIdmy-0002Wz-6N for hostap@lists.infradead.org; Fri, 02 Nov 2018 18:03:21 +0000 Received: by mail-lf1-x129.google.com with SMTP id n3-v6so1913793lfe.7 for ; Fri, 02 Nov 2018 11:03:09 -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=Eci1awOwN3XZyCKUSoGyFtvMkkypSbXPuK5jpxCRA2E=; b=V07SiYZ3MW98bHapSco0AHlQzkswedFkEd/BOLe8GR2ELm0btRyDoDJbyED2bqnBuU 3IjKxrTQHPTL6ct81GCSHmupGkAed76dDlkY9JPMpHGnWN9dlnSJpbh/GXV0ivlvFk5i +JNDIG/zLbjEHm/MVW32RulU6GxMgcoFvRZysOi04477XWkH6ZH3YakcroetEtAoriHh l4ZKqVgvizwNTQtZvLa+VRmB8c0tE3UFnp7Bbb1yU7nXx0U7k61mmxjvUjvWyaZrthvj OhI+UU0kG4uvgqeAxLURF+wnDrysUyQ5NfH1LxEkNvpdjiinf4WzNGoCOdnzIJFXhsIX 11Sg== 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=Eci1awOwN3XZyCKUSoGyFtvMkkypSbXPuK5jpxCRA2E=; b=dSfres7P5CC28OHk79aFsgm6/9wXtpOwUNHryDCh6+JTwq6HjoBzD0pH862PkJwkKI mbRCkRoTkQLvruDXQv2ukUGVDDfg4ndzd83KJMmVk2HKAW0HkS4/UocLZtNBTwjznO2t RKBS+zGiRk+3KA7HBca1oVm0NpvQHC4F3h1F2qjh/qicK2yeIFGX3EnSckfEavlxnId+ xEepIVaQgCZuW9wT+2J7+5Bzn0qcGkoP1RT5K2zwQvBPfv81SGVSpriEKqOyUWJqz1VM ezDXEB8XroT3FaRZY+BryJTtCI3Helb6WYeTwz1pyweQ+vq8deiYiIyRepx/0fyhQhL6 FyXA== X-Gm-Message-State: AGRZ1gKCJiUhTrpjbXqeLXR7OlGH81BXf/kSmTwxhlbKtq+cUAVdJieG Q+Pu/BXEqw7r8bRALQMXtCuLGyzg X-Google-Smtp-Source: AJdET5eNZeoh6bVOOgFCRQkstl8kfcuQZqEYDvog98GWNGAwW13JodCO01hFtBMBoWAl4hBhpR2T4w== X-Received: by 2002:a19:54d7:: with SMTP id b84mr7034783lfl.131.1541181787871; Fri, 02 Nov 2018 11:03:07 -0700 (PDT) Received: from localhost.localdomain ([194.103.244.100]) by smtp.gmail.com with ESMTPSA id a9sm1002595lfa.19.2018.11.02.11.03.06 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 02 Nov 2018 11:03:07 -0700 (PDT) From: Andrey Kartashev To: hostap@lists.infradead.org Subject: [PATCH 6/8] mka: Support for AES-256 key generation Date: Fri, 2 Nov 2018 19:02:18 +0100 Message-Id: <20181102180220.20948-6-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_110320_232336_FF197565 X-CRM114-Status: GOOD ( 15.38 ) 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:129 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 There is already partial support of GCM-AES-256. It is possible to enable this mode by setting 'kay->macsec_csindex = 1;' in ieee802_1x_kay_init() function, but generated key contain only 128 bits of data while other 128 bits are in 0. This patch enables KaY to generate full 256bit key from same 128bit CAK. Signed-off-by: Andrey Kartashev --- src/pae/ieee802_1x_kay.c | 12 ++++++------ src/pae/ieee802_1x_key.c | 6 ++++-- src/pae/ieee802_1x_key.h | 2 +- 3 files changed, 11 insertions(+), 9 deletions(-) diff --git a/src/pae/ieee802_1x_kay.c b/src/pae/ieee802_1x_kay.c index a4771b792..3a31bdf93 100644 --- a/src/pae/ieee802_1x_kay.c +++ b/src/pae/ieee802_1x_kay.c @@ -2039,12 +2039,12 @@ ieee802_1x_kay_generate_new_sak(struct ieee802_1x_mka_participant *participant) ctx_offset += sizeof(participant->mi); os_memcpy(context + ctx_offset, &kay->dist_kn, sizeof(kay->dist_kn)); - if (key_len == 16) { - ieee802_1x_sak_128bits_aes_cmac(participant->cak.key, - context, ctx_len, key); - } else if (key_len == 32) { - ieee802_1x_sak_128bits_aes_cmac(participant->cak.key, - context, ctx_len, key); + if ((key_len == 16)||(key_len == 32)) { + if (ieee802_1x_sak_128bits_aes_cmac(participant->cak.key, + context, ctx_len, key, key_len)) { + wpa_printf(MSG_ERROR, "KaY: Failed to generate SAK"); + goto fail; + } } else { wpa_printf(MSG_ERROR, "KaY: SAK Length not support"); goto fail; diff --git a/src/pae/ieee802_1x_key.c b/src/pae/ieee802_1x_key.c index 9a8d923d1..3ed9d1645 100644 --- a/src/pae/ieee802_1x_key.c +++ b/src/pae/ieee802_1x_key.c @@ -183,7 +183,9 @@ int ieee802_1x_icv_128bits_aes_cmac(const u8 *ick, const u8 *msg, * SAK = KDF(Key, Label, KS-nonce | MI-value list | KN, SAKLength) */ int ieee802_1x_sak_128bits_aes_cmac(const u8 *cak, const u8 *ctx, - size_t ctx_bytes, u8 *sak) + size_t ctx_bytes, u8 *sak, size_t sak_bytes) { - return aes_kdf_128(cak, "IEEE8021 SAK", ctx, ctx_bytes * 8, 128, sak); + return aes_kdf_128(cak, "IEEE8021 SAK", ctx, ctx_bytes * 8, + sak_bytes * 8, sak); } + diff --git a/src/pae/ieee802_1x_key.h b/src/pae/ieee802_1x_key.h index ea318ea4d..1be5df07e 100644 --- a/src/pae/ieee802_1x_key.h +++ b/src/pae/ieee802_1x_key.h @@ -21,6 +21,6 @@ int ieee802_1x_ick_128bits_aes_cmac(const u8 *cak, const u8 *ckn, int ieee802_1x_icv_128bits_aes_cmac(const u8 *ick, const u8 *msg, size_t msg_bytes, u8 *icv); int ieee802_1x_sak_128bits_aes_cmac(const u8 *cak, const u8 *ctx, - size_t ctx_bytes, u8 *sak); + size_t ctx_bytes, u8 *sak, size_t sak_bytes); #endif /* IEEE802_1X_KEY_H */