From patchwork Tue Oct 17 10:52:51 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mark O'Donovan X-Patchwork-Id: 154065 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:2908:b0:403:3b70:6f57 with SMTP id ib8csp4045960vqb; Tue, 17 Oct 2023 03:53:44 -0700 (PDT) X-Google-Smtp-Source: AGHT+IE+o/HuIP23eCejIkm0DAZwdFJnRKv7lh17dzuLUwBiUSz5n24QJsjVTHa2us9jBhxcZR7T X-Received: by 2002:a17:90b:3510:b0:27d:6268:b75c with SMTP id ls16-20020a17090b351000b0027d6268b75cmr1899815pjb.4.1697540024462; Tue, 17 Oct 2023 03:53:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697540024; cv=none; d=google.com; s=arc-20160816; b=D2z3H8KtMqr1YFqVWf50sO4H9dfKz6r+khkUeVGXBzlwEjUGLdCyelC3kD6jjhspu0 1J2NWsLEo64F/oMZqbNQ0mK7Xrh37iCcvJ3IZfauzm5l1BejqCIQRFVfJ1fDpcGkuxHu OX/WZnf7Li1sFg2mqoOSSjBN+FrcEdSQ5z4umNCtoDX2YlxGeOjhIMG92qR5q8ops0H9 06EpcR7Yc+GoqII7BuntDzGOe1nQEUe2ljMEA22/nZtY4LvPNydntrP889/XbPAAQEHD zLYDdcRdvDzH7OXMI2u82DaO3luDyvK+sq9UELOGptoqeqrYEg/ZxykfK8qViaatFd3Z UwNw== 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=MgYSQUsaCKTBOjvnSrqGBHDLXVdDU+83yjZTXDijhpU=; fh=OK6NlIuxAObXnbB+YsmCJIFQ9spAlQ71xiCElZ04Vio=; b=1BL27kN1Exv6Nb9fz9EL4ledeyKMMwWySbCq8i2cQhXZPWvgbKnyhLryC/0T2drAPP FTICUf1UAB6+DT+0cfdx1NoOgH+Tl0Eg3AyXv2dYbfQkISQtt62BatwFXi/NoxfuGgOl 03+1mN3NGQ+IVRF82mfPyBvOxV+TP92KwQhW5mzfq9GeYYlnEV7stNBXFMgrGJDiVb2F Aqz6qGv9+0UTjebv5Lpx0NC2CsCxiIEqZFY32Cmw5c5FGUZj63JHCGwJqzu3JaWx9aCQ JnV246fyy1CMDlmAMZ80TW1ivtJymiK3CImQaJi+lcrf/UEneiDnLFSXSkPFF92nAgad 4u7A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@posteo.net header.s=2017 header.b=pEcE4rLH; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 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 lipwig.vger.email (lipwig.vger.email. [2620:137:e000::3:3]) by mx.google.com with ESMTPS id v23-20020a17090ae99700b0027740192bc9si1460406pjy.152.2023.10.17.03.53.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 17 Oct 2023 03:53:44 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 as permitted sender) client-ip=2620:137:e000::3:3; Authentication-Results: mx.google.com; dkim=pass header.i=@posteo.net header.s=2017 header.b=pEcE4rLH; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 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 lipwig.vger.email (Postfix) with ESMTP id 9A602802F548; Tue, 17 Oct 2023 03:53:42 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at lipwig.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1343747AbjJQKxT (ORCPT + 19 others); Tue, 17 Oct 2023 06:53:19 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49044 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1343680AbjJQKxN (ORCPT ); Tue, 17 Oct 2023 06:53:13 -0400 Received: from mout01.posteo.de (mout01.posteo.de [185.67.36.65]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 237FCA2 for ; Tue, 17 Oct 2023 03:53:12 -0700 (PDT) Received: from submission (posteo.de [185.67.36.169]) by mout01.posteo.de (Postfix) with ESMTPS id BD1AB24002B for ; Tue, 17 Oct 2023 12:53:10 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=posteo.net; s=2017; t=1697539990; bh=QzwVfBdifB51edMzB/+yD4kt6tOaLkGIgcIPJIModxs=; h=From:To:Cc:Subject:Date:Message-Id:MIME-Version: Content-Transfer-Encoding:From; b=pEcE4rLHEDQ1ldQlDn9UAH6zsBnG37g3Ze2AQBI6PpnTYdFEeardtvkqkUL9v3pJi cM80Zgch2X8y0Hd/PB/p7+JBH82s+UAXfLJeH1SWXt8JlprhonIoz+Osjy5IuDE37k 3mIz2sIZJgXuHDJ5ajybp0zgEjznvQqt+jiufTsH/kLdP7N1dmNhQMEKwN05h9p2+9 Z1TybwjxgdK+RS8R3tepSpjvcE/seF9JMvYg0Wp7faQxgWAqLOqGmv0eegutk6lwH/ C2oFqxK6ZD94lpdwOdvbPq/O4xNgfo4hpgPkIUJj0S+17WKP04HeSuE9GDqR2QfhxY vS78FKCqaVBdA== Received: from customer (localhost [127.0.0.1]) by submission (posteo.de) with ESMTPSA id 4S8rRn34mlz6tvp; Tue, 17 Oct 2023 12:53:09 +0200 (CEST) From: Mark O'Donovan 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 , Akash Appaiah Subject: [PATCH v4 3/3] nvme-auth: allow mixing of secret and hash lengths Date: Tue, 17 Oct 2023 10:52:51 +0000 Message-Id: <20231017105251.3274652-4-shiftee@posteo.net> In-Reply-To: <20231017105251.3274652-1-shiftee@posteo.net> References: <20231017105251.3274652-1-shiftee@posteo.net> MIME-Version: 1.0 X-Spam-Status: No, score=-0.8 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lipwig.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (lipwig.vger.email [0.0.0.0]); Tue, 17 Oct 2023 03:53:42 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1779999728918965557 X-GMAIL-MSGID: 1779999728918965557 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 Signed-off-by: Akash Appaiah Signed-off-by: Mark O'Donovan Reviewed-by: Hannes Reinecke --- 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 f9e7ed8e729d..ddfcc3889fec 100644 --- a/drivers/nvme/common/auth.c +++ b/drivers/nvme/common/auth.c @@ -190,14 +190,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; /*