Message ID | 20231013202827.2262708-3-shiftee@posteo.net |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:2908:b0:403:3b70:6f57 with SMTP id ib8csp2137226vqb; Fri, 13 Oct 2023 13:29:20 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFP+dVaFbGaXjqKnindutLZCjRcvjNZkgNord1nRsJ53Tk18KiX3oDbwvZPDBJqDwtTxnmj X-Received: by 2002:a05:6871:8a18:b0:1e9:bb3a:9a32 with SMTP id tl24-20020a0568718a1800b001e9bb3a9a32mr4843844oab.0.1697228960270; Fri, 13 Oct 2023 13:29:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697228960; cv=none; d=google.com; s=arc-20160816; b=kOh6VEulSIp+KRmbHyK2KJTIqIgLGAerTC9V/fgr5aBlxxcEbtONI/NzBCyIM6v2hk 9tMqpDWgAFgRGvRbUuUshCY1lwqydz7wlyKJeAmToNJuREwMkg0v94MQ1wjN+MLGQXgi skyB8ClJD30hkg9sInEy9i5sxiE9U4mgjYoCjgvxDMdYoO5mXCQg83IDNzLaTntBnffD P+aDB0QcWv4WGSFYQAeY6rMMZ7F+jgIQGb+OPgMzd9PEO7exUiPZtzu+zyIhtMJLiwLY QT+XHPbNK5BUJv4zwpkF/lek58Z3axl+0nL59tWt2PraSU3X5ywud9lssjNhSb362WDI GpIg== 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; bh=1GLFrwGH4uXeFR8RVOdSkxb/2TdBOc0jUn6jf8KiE5U=; fh=OK6NlIuxAObXnbB+YsmCJIFQ9spAlQ71xiCElZ04Vio=; b=ADvyDDZ0yC6uu+nWp/SSLBcMubTxTvPDOY28zmwD26WskjbCnMKfgaq12nBGlPL35P EmpPp3rkpTxz6h520tcvZq34U0CvGF7YHcpjsitudMLNbhNV+QSFP5SPUAjUcVs/MbSB HB2ygY9tRzOfuA1iKpvqMYoavPUsq5MNM8iRw7LtnHHbOcOLrZ5TFPusZVRkPdmr0xLX DMCFzaWvjMhg4PmaP3iyFr5xxtNmQub+x3D86JcI8ZirSSzzkqZ8rl7L/HYFgcaHAXIb pJZWiubYgCPpuSFAJcg7SH8mm9CypRPZIdF/xHENDqxgara0Qc8FpELft6jKZufVT9/G 8KrA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@posteo.net header.s=2017 header.b=p21QMCQZ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=posteo.net Received: from snail.vger.email (snail.vger.email. [23.128.96.37]) by mx.google.com with ESMTPS id l191-20020a6391c8000000b00585a02550e1si5594378pge.50.2023.10.13.13.29.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 13 Oct 2023 13:29:20 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) client-ip=23.128.96.37; Authentication-Results: mx.google.com; dkim=pass header.i=@posteo.net header.s=2017 header.b=p21QMCQZ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=posteo.net Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by snail.vger.email (Postfix) with ESMTP id 9F1358345280; Fri, 13 Oct 2023 13:29:19 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232256AbjJMU3N (ORCPT <rfc822;rua109.linux@gmail.com> + 19 others); Fri, 13 Oct 2023 16:29:13 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33082 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232197AbjJMU3L (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Fri, 13 Oct 2023 16:29:11 -0400 Received: from mout02.posteo.de (mout02.posteo.de [185.67.36.66]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 840AABE for <linux-kernel@vger.kernel.org>; Fri, 13 Oct 2023 13:29:09 -0700 (PDT) Received: from submission (posteo.de [185.67.36.169]) by mout02.posteo.de (Postfix) with ESMTPS id 0E3EE240103 for <linux-kernel@vger.kernel.org>; Fri, 13 Oct 2023 22:29:08 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=posteo.net; s=2017; t=1697228948; bh=PZesDCIO0qB1QiAn0VpqqXvIqc6VhWTAaPu3kq45sGo=; h=From:To:Cc:Subject:Date:Message-Id:MIME-Version: Content-Transfer-Encoding:From; b=p21QMCQZptEMN8nCgKKrSJyOyuSRMzuXEZInHKUlwjZmVMFuJHrKcz8TcT8Q5ijVU P43BfasODEUKbqFXO9F01rmPwq5DRdF+NXCZQsVnmK5/FSX3z+04vB1/hnyFk4k4Td q8WLruBeboMc5YIg/sVAfI1aeZq1gZRoXo816fyEM1valib3PmSo+RRqJLq3Cdcgaf GgEf4Q9OLc32FJE6fz6Lyes1HNk9LPRLIPAFmP5+049kCOcGSijQI7G6dFGi8RupOH rYLndMQal2wARJf1uLBEiw2hsixheq5cgvSysDglPh+fDIKoeX3iWSy9JZHDGq8XRF V0iUHB9Qub+5A== Received: from customer (localhost [127.0.0.1]) by submission (posteo.de) with ESMTPSA id 4S6dQB5FQ1z9rxF; Fri, 13 Oct 2023 22:29:06 +0200 (CEST) From: Mark O'Donovan <shiftee@posteo.net> To: linux-kernel@vger.kernel.org Cc: linux-nvme@lists.infradead.org, sagi@grimberg.me, hch@lst.de, axboe@kernel.dk, kbusch@kernel.org, hare@suse.de, Mark O'Donovan <shiftee@posteo.net>, Akash Appaiah <Akash.Appaiah@dell.com> Subject: [PATCH 2/2] nvme-auth: allow mixing of secret and hash lengths Date: Fri, 13 Oct 2023 20:28:27 +0000 Message-Id: <20231013202827.2262708-3-shiftee@posteo.net> In-Reply-To: <20231013202827.2262708-1-shiftee@posteo.net> References: <20231013202827.2262708-1-shiftee@posteo.net> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_BLOCKED, RCVD_IN_MSPIKE_H5,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (snail.vger.email [0.0.0.0]); Fri, 13 Oct 2023 13:29:19 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1779673554014833296 X-GMAIL-MSGID: 1779673554014833296 |
Series |
Remove secret-size restrictions for hashes
|
|
Commit Message
Mark O'Donovan
Oct. 13, 2023, 8:28 p.m. UTC
We can now use any of the secret transformation hashes with a secret, regardless of the secret size. e.g. a 32 byte key with the SHA-512(64 byte) hash. The example secret from the spec should now be permitted with any of the following: DHHC-1:00:ia6zGodOr4SEG0Zzaw398rpY0wqipUWj4jWjUh4HWUz6aQ2n: DHHC-1:01:ia6zGodOr4SEG0Zzaw398rpY0wqipUWj4jWjUh4HWUz6aQ2n: DHHC-1:02:ia6zGodOr4SEG0Zzaw398rpY0wqipUWj4jWjUh4HWUz6aQ2n: DHHC-1:03:ia6zGodOr4SEG0Zzaw398rpY0wqipUWj4jWjUh4HWUz6aQ2n: Note: Secrets are still restricted to 32,48 or 64 bits. Co-developed-by: Akash Appaiah <Akash.Appaiah@dell.com> Signed-off-by: Akash Appaiah <Akash.Appaiah@dell.com> Signed-off-by: Mark O'Donovan <shiftee@posteo.net> --- drivers/nvme/common/auth.c | 8 -------- 1 file changed, 8 deletions(-)
Comments
On 10/13/23 22:28, Mark O'Donovan wrote: > We can now use any of the secret transformation hashes with a > secret, regardless of the secret size. > e.g. a 32 byte key with the SHA-512(64 byte) hash. > > The example secret from the spec should now be permitted with > any of the following: > DHHC-1:00:ia6zGodOr4SEG0Zzaw398rpY0wqipUWj4jWjUh4HWUz6aQ2n: > DHHC-1:01:ia6zGodOr4SEG0Zzaw398rpY0wqipUWj4jWjUh4HWUz6aQ2n: > DHHC-1:02:ia6zGodOr4SEG0Zzaw398rpY0wqipUWj4jWjUh4HWUz6aQ2n: > DHHC-1:03:ia6zGodOr4SEG0Zzaw398rpY0wqipUWj4jWjUh4HWUz6aQ2n: > > Note: Secrets are still restricted to 32,48 or 64 bits. > > Co-developed-by: Akash Appaiah <Akash.Appaiah@dell.com> > Signed-off-by: Akash Appaiah <Akash.Appaiah@dell.com> > Signed-off-by: Mark O'Donovan <shiftee@posteo.net> > --- > drivers/nvme/common/auth.c | 8 -------- > 1 file changed, 8 deletions(-) > > diff --git a/drivers/nvme/common/auth.c b/drivers/nvme/common/auth.c > index d90e4f0c08b7..176855f86f0d 100644 > --- a/drivers/nvme/common/auth.c > +++ b/drivers/nvme/common/auth.c > @@ -187,14 +187,6 @@ struct nvme_dhchap_key *nvme_auth_extract_key(unsigned char *secret, > goto out_free_secret; > } > > - if (key_hash > 0 && > - (key_len - 4) != nvme_auth_hmac_hash_len(key_hash)) { > - pr_err("Mismatched key len %d for %s\n", key_len, > - nvme_auth_hmac_name(key_hash)); > - ret = -EINVAL; > - goto out_free_secret; > - } > - > /* The last four bytes is the CRC in little-endian format */ > key_len -= 4; > /* That, however, looks good. Reviewed-by: Hannes Reinecke <hare@suse.de> Cheers, Hannes
diff --git a/drivers/nvme/common/auth.c b/drivers/nvme/common/auth.c index d90e4f0c08b7..176855f86f0d 100644 --- a/drivers/nvme/common/auth.c +++ b/drivers/nvme/common/auth.c @@ -187,14 +187,6 @@ struct nvme_dhchap_key *nvme_auth_extract_key(unsigned char *secret, goto out_free_secret; } - if (key_hash > 0 && - (key_len - 4) != nvme_auth_hmac_hash_len(key_hash)) { - pr_err("Mismatched key len %d for %s\n", key_len, - nvme_auth_hmac_name(key_hash)); - ret = -EINVAL; - goto out_free_secret; - } - /* The last four bytes is the CRC in little-endian format */ key_len -= 4; /*