From patchwork Tue Oct 17 10:52:48 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: 15481 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:2908:b0:403:3b70:6f57 with SMTP id ib8csp4045919vqb; Tue, 17 Oct 2023 03:53:36 -0700 (PDT) X-Google-Smtp-Source: AGHT+IG05N/fJDXiugmlyAnVvWnlEUxoaORQ88eB9RAAU+0+X7qaacOxTbdDu8krHRpkAduxuhSh X-Received: by 2002:a05:6a20:7fa9:b0:171:737:dfaf with SMTP id d41-20020a056a207fa900b001710737dfafmr2066875pzj.5.1697540016427; Tue, 17 Oct 2023 03:53:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697540016; cv=none; d=google.com; s=arc-20160816; b=KGUvojttPQ+bW40m8b3S0aZbQt6lGKx44CA33Kh8tK6T9lI5Vi4aS/nNf8B4KAh2xA JU4Y7gSjBh+wNNJPVa4MofDlJUZQk9Iwp+ph/XUUxa3sTwOD63UTPxLUi+uYafFqVlZU afjSQbGPsPMe5b4IUY5DFMaW5wZWsb6jI/tDs51KyUzAPZUYUfX7iPqjKFRGqL4sHRgK CU4ZN3C4KFtah+HuOrrQ4Yxj+YdKUSO6CAt40AlWEuhhtANOH2tYK9cq+W5UXuH7FBBL aXiur+GqVtiJEihCNVePJ48pPfScl6lPC2oJP70RIKYslhiDmSACNGtk1j5Dveea6Ztr g36Q== 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 :message-id:date:subject:cc:to:from:dkim-signature; bh=oHPRNRXaBXnP0hKN6x717ORPsdbjv/XJtSjT888Zphg=; fh=nK/B2gIzvYPsKU0sJgdKEVdz5eoE00hHt727sEimwsQ=; b=QRsnWCaH12DXbKPUVSXa6MVzHU/5diKguwv5nOGNOntuEk7prZwC/9H+j2rwYISoq4 nfq1l5nnN1XtBdCPvf74Aj2EhF0/t+WNp/hIAR3PQHaC1PKmClt3odr/mQlPAddz/8fa rXyh196JIEa9gyJT+Cb/v3F/ObxrxKROOx8cHZnu5Ipp6kCM1CeYDXpKVSXjK4pWfict QueyBqvlvlAI4mBZj5UuGTp6FiGuq72XbMZpTXU9y/4yVkLJDKxQvSN0iU9awftpBy95 DBVMkskr+0/3uj0x4lyQCqmz9VzqtIZiGQA/vNnQDCn4JAThCQnagZN5ZQDGXbk4YZ2N ReBQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@posteo.net header.s=2017 header.b=eV44l1Vx; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:8 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 fry.vger.email (fry.vger.email. [2620:137:e000::3:8]) by mx.google.com with ESMTPS id h11-20020a65480b000000b00578bb5917d7si1466742pgs.153.2023.10.17.03.53.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 17 Oct 2023 03:53:36 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:8 as permitted sender) client-ip=2620:137:e000::3:8; Authentication-Results: mx.google.com; dkim=pass header.i=@posteo.net header.s=2017 header.b=eV44l1Vx; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:8 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 fry.vger.email (Postfix) with ESMTP id CE3ED8021ECD; Tue, 17 Oct 2023 03:53:33 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at fry.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1343509AbjJQKxM (ORCPT + 19 others); Tue, 17 Oct 2023 06:53:12 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49020 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234627AbjJQKxL (ORCPT ); Tue, 17 Oct 2023 06:53:11 -0400 Received: from mout01.posteo.de (mout01.posteo.de [185.67.36.65]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 53312A2 for ; Tue, 17 Oct 2023 03:53:09 -0700 (PDT) Received: from submission (posteo.de [185.67.36.169]) by mout01.posteo.de (Postfix) with ESMTPS id 90771240029 for ; Tue, 17 Oct 2023 12:53:07 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=posteo.net; s=2017; t=1697539987; bh=MLzZUl/+BHQHydxEN9HgZzS0VH6NylU05183B2OuUXA=; h=From:To:Cc:Subject:Date:Message-Id:MIME-Version: Content-Transfer-Encoding:From; b=eV44l1Vxi5z6Z7TNlLCHy0v74F8mtYkWDKBQm0hXL8vbaH6kQHGsB2ILpTU4GHIRu OsAAHLuzKAnJcW/YsjnuxmwLrJqBeZn0HruXVTKYXrNq4S15Mpza6bxkH+sSIANjmW PeKpDCWemL53SUCWZQWmZpwDF2kDy+/uo9IQ3tJheqdR1nuDWfCpVtz7SK7a74U+/U YGyL5NURq8y3xxzRqjgGBqtY4dbni/vLzF+7+nqlFu1S0fA6tJoY1OL8BA7w3Stp1K SUfW2vQwBBhwbXyUd5YcEpu1Sv+Il0OqNUEP9YP2hwK+GpuMqWOai5iJ7kbBHnVzhk dCPjJKfiq9bMA== Received: from customer (localhost [127.0.0.1]) by submission (posteo.de) with ESMTPSA id 4S8rRh5V1hz6tv5; Tue, 17 Oct 2023 12:53:04 +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 Subject: [PATCH v4 0/3] Remove secret-size restrictions for hashes Date: Tue, 17 Oct 2023 10:52:48 +0000 Message-Id: <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 fry.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 (fry.vger.email [0.0.0.0]); Tue, 17 Oct 2023 03:53:33 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1779954857812955500 X-GMAIL-MSGID: 1779999719995159614 This relates to the hash functions used to transform the secret. The kernel currently restricts us to using secrets equal in size to the transformation hash function they use. e.g. 32 byte secrets with the SHA-256(32 byte) hash function. This restriction is not required by the spec and means incompatibility with more permissive implementations. With these patches 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. v1: - Initial submission v2: - Added transformed_len as member of struct nvme_dhchap_key v3: - Return a struct nvme_dhchap_key from nvme_auth_transform_key() v4: - added helper to caclulate key struct size using struct_size() - Break up lines which were too long - Replace ternary operator with if - Add missing ERR_CAST() Mark O'Donovan (3): nvme-auth: alloc nvme_dhchap_key as single buffer nvme-auth: use transformed key size to create resp nvme-auth: allow mixing of secret and hash lengths drivers/nvme/common/auth.c | 66 ++++++++++++++++++++++---------------- drivers/nvme/host/auth.c | 30 ++++++++--------- drivers/nvme/target/auth.c | 31 ++++++++++-------- include/linux/nvme-auth.h | 7 ++-- 4 files changed, 75 insertions(+), 59 deletions(-)