Received: by 2002:a05:6a10:c604:0:0:0:0 with SMTP id y4csp3601057pxt; Tue, 10 Aug 2021 07:15:39 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzOizPBW5B58cUrnJxLzNQ+JxHi7JShChfckGPwX3nWRJhV6hHSdSiHIaqVUo6hLfovF2MT X-Received: by 2002:a05:6512:169d:: with SMTP id bu29mr22005712lfb.160.1628604938653; Tue, 10 Aug 2021 07:15:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1628604938; cv=none; d=google.com; s=arc-20160816; b=sAlRd4FFDAjsYzZ/GxZb/2jEmBbU6By0OgwMb9gPmy7DiyZNOHvWbGtg1MO6Z8Yjhq pRzbvijVBQlf9NVpzLEO7ayiTRIf9n8mRjR59VsxCkDAX2WtGoaj77R0KeF68NaSRyWL AlznR9bmruNJhJk7lW/CierflyH8D13YfW20jEn8c4y8dqDf9WK8+mY55tvXHbLHeiGL m492zoitMykcrlOv2zZnVLfKvSgHnzOlKN5CLV7xk8Gw2r5pY7Xy1xN68lInXqz/5v9O tkgWKxOqh95vsT/0jSiQZEsHwEbLL/9xvZCQ6EHIQ6EE34Vh+kTobfCKxumntB2QoDku K8Kg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature:dkim-signature; bh=MUoNB1RE7VhyoT1+GvVF1n3f2kAKysSACL4JZIm62EA=; b=lHFOI1BrQjeTtzD+0vCFAUkI5fq0VgJf65APhqFfHTQGKWPDbpSzJALr56ZZh+irYi fkO+GqNksiTe405MYaUXEb/72XC5DU7CXyP38TNR6szwDkWZEbbOh5wRowlJv78+xUQb atn29PeVYnuGWhZ3E+3sx+BxN5+FH1i+tfsiKwJJXuB7rAF1ay4D3OpE0OPa5zW+0Bbi sHmcO5VDrimlVXqT5SkuIRcxD16Ww7AGkZNlVu1OnKLemIyvw+HG+X+EfcqtwwsV6R94 zt1iaIRRgIqRyeyBW859hgcK7bKOI8ffAZnr8as1Yv08bvruKBfRMMhKeHTzNAmYWJC0 QFnw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@suse.de header.s=susede2_rsa header.b=EX2vEI9i; dkim=neutral (no key) header.i=@suse.de; spf=pass (google.com: domain of linux-crypto-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-crypto-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=suse.de Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id hx27si9770951ejc.177.2021.08.10.07.15.13; Tue, 10 Aug 2021 07:15:38 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-crypto-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@suse.de header.s=susede2_rsa header.b=EX2vEI9i; dkim=neutral (no key) header.i=@suse.de; spf=pass (google.com: domain of linux-crypto-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-crypto-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=suse.de Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240713AbhHJMnZ (ORCPT + 99 others); Tue, 10 Aug 2021 08:43:25 -0400 Received: from smtp-out2.suse.de ([195.135.220.29]:43718 "EHLO smtp-out2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240734AbhHJMnQ (ORCPT ); Tue, 10 Aug 2021 08:43:16 -0400 Received: from relay2.suse.de (relay2.suse.de [149.44.160.134]) by smtp-out2.suse.de (Postfix) with ESMTP id 3BCFE200B3; Tue, 10 Aug 2021 12:42:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1628599372; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=MUoNB1RE7VhyoT1+GvVF1n3f2kAKysSACL4JZIm62EA=; b=EX2vEI9iPdolviNRyMxdRU3CU11O4eOfGgO6VJpppShc8sUqjxev9d8M8aYZqSw13WphTh EoeWw5f+xYhnlDlZw3hGORRaLLLTc54ZtVzdxDiembtjbjJnVe7cZfHlfaKpB/iGuF19Ds USY31qdDkSHXqLG7pQCqGdzXbMJT5xQ= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1628599372; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=MUoNB1RE7VhyoT1+GvVF1n3f2kAKysSACL4JZIm62EA=; b=WFcQNkEFlZB//F5QFZeBEPxbYqgMdFIqhGS24JWxwebjGtKxSY9wgEMcjgmh5jYRMiu64y +/IoSmOIaqtRnfAQ== Received: from adalid.arch.suse.de (adalid.arch.suse.de [10.161.8.13]) by relay2.suse.de (Postfix) with ESMTP id 20CD7A3B96; Tue, 10 Aug 2021 12:42:52 +0000 (UTC) Received: by adalid.arch.suse.de (Postfix, from userid 16045) id 8D902518C55A; Tue, 10 Aug 2021 14:42:50 +0200 (CEST) From: Hannes Reinecke To: Christoph Hellwig Cc: Sagi Grimberg , Keith Busch , Herbert Xu , "David S . Miller" , linux-nvme@lists.infradead.org, linux-crypto@vger.kernel.org, Hannes Reinecke Subject: [PATCH 13/13] nvme: add non-standard ECDH and curve25517 algorithms Date: Tue, 10 Aug 2021 14:42:30 +0200 Message-Id: <20210810124230.12161-14-hare@suse.de> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20210810124230.12161-1-hare@suse.de> References: <20210810124230.12161-1-hare@suse.de> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-crypto@vger.kernel.org TLS 1.3 specifies ECDH and curve25517 in addition to the FFDHE groups, and these are already implemented in the kernel. So add support for these non-standard groups for NVMe in-band authentication to validate the augmented challenge implementation. Signed-off-by: Hannes Reinecke --- drivers/nvme/host/auth.c | 34 +++++++++++++++++++++++++++++++++- include/linux/nvme.h | 2 ++ 2 files changed, 35 insertions(+), 1 deletion(-) diff --git a/drivers/nvme/host/auth.c b/drivers/nvme/host/auth.c index e73b5be4a4b0..6de2910eec80 100644 --- a/drivers/nvme/host/auth.c +++ b/drivers/nvme/host/auth.c @@ -9,6 +9,8 @@ #include #include #include +#include +#include #include "nvme.h" #include "fabrics.h" #include "auth.h" @@ -69,6 +71,13 @@ static struct nvme_auth_dhgroup_map { { .id = NVME_AUTH_DHCHAP_DHGROUP_8192, .name = "ffdhe8192", .kpp = "dh", .privkey_size = 1024, .pubkey_size = 1024 }, + { .id = NVME_AUTH_DHCHAP_DHGROUP_ECDH, + .name = "ecdh", .kpp = "ecdh-nist-p256", + .privkey_size = 32, .pubkey_size = 64 }, + { .id = NVME_AUTH_DHCHAP_DHGROUP_25519, + .name = "curve25519", .kpp = "curve25519", + .privkey_size = CURVE25519_KEY_SIZE, + .pubkey_size = CURVE25519_KEY_SIZE }, }; const char *nvme_auth_dhgroup_name(int dhgroup_id) @@ -424,6 +433,27 @@ int nvme_auth_gen_privkey(struct crypto_kpp *dh_tfm, int dh_gid) kfree_sensitive(dh_secret); goto out; } + } else if (dh_gid == NVME_AUTH_DHCHAP_DHGROUP_ECDH) { + struct ecdh p = {0}; + + pkey_len = crypto_ecdh_key_len(&p); + pkey = kmalloc(pkey_len, GFP_KERNEL); + if (!pkey) + return -ENOMEM; + + get_random_bytes(pkey, pkey_len); + ret = crypto_ecdh_encode_key(pkey, pkey_len, &p); + if (ret) { + pr_debug("failed to encode private key, error %d\n", + ret); + goto out; + } + } else if (dh_gid == NVME_AUTH_DHCHAP_DHGROUP_25519) { + pkey_len = CURVE25519_KEY_SIZE; + pkey = kmalloc(pkey_len, GFP_KERNEL); + if (!pkey) + return -ENOMEM; + get_random_bytes(pkey, pkey_len); } else { pr_warn("invalid dh group %d\n", dh_gid); return -EINVAL; @@ -597,7 +627,7 @@ static int nvme_auth_set_dhchap_negotiate_data(struct nvme_ctrl *ctrl, data->napd = 1; data->auth_protocol[0].dhchap.authid = NVME_AUTH_DHCHAP_AUTH_ID; data->auth_protocol[0].dhchap.halen = 3; - data->auth_protocol[0].dhchap.dhlen = 6; + data->auth_protocol[0].dhchap.dhlen = 8; data->auth_protocol[0].dhchap.idlist[0] = NVME_AUTH_DHCHAP_SHA256; data->auth_protocol[0].dhchap.idlist[1] = NVME_AUTH_DHCHAP_SHA384; data->auth_protocol[0].dhchap.idlist[2] = NVME_AUTH_DHCHAP_SHA512; @@ -607,6 +637,8 @@ static int nvme_auth_set_dhchap_negotiate_data(struct nvme_ctrl *ctrl, data->auth_protocol[0].dhchap.idlist[6] = NVME_AUTH_DHCHAP_DHGROUP_4096; data->auth_protocol[0].dhchap.idlist[7] = NVME_AUTH_DHCHAP_DHGROUP_6144; data->auth_protocol[0].dhchap.idlist[8] = NVME_AUTH_DHCHAP_DHGROUP_8192; + data->auth_protocol[0].dhchap.idlist[9] = NVME_AUTH_DHCHAP_DHGROUP_ECDH; + data->auth_protocol[0].dhchap.idlist[10] = NVME_AUTH_DHCHAP_DHGROUP_25519; return size; } diff --git a/include/linux/nvme.h b/include/linux/nvme.h index e2142e3246eb..e1145bbfc92f 100644 --- a/include/linux/nvme.h +++ b/include/linux/nvme.h @@ -1477,6 +1477,8 @@ enum { NVME_AUTH_DHCHAP_DHGROUP_4096 = 0x03, NVME_AUTH_DHCHAP_DHGROUP_6144 = 0x04, NVME_AUTH_DHCHAP_DHGROUP_8192 = 0x05, + NVME_AUTH_DHCHAP_DHGROUP_ECDH = 0x0e, + NVME_AUTH_DHCHAP_DHGROUP_25519 = 0x0f, }; union nvmf_auth_protocol { -- 2.29.2