From patchwork Mon Dec 25 05:26:54 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yong Huang X-Patchwork-Id: 13504471 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id DAEA4C4706F for ; Mon, 25 Dec 2023 05:31:40 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rHdX1-00052j-5Q; Mon, 25 Dec 2023 00:29:39 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rHdX0-00052Z-6I for qemu-devel@nongnu.org; Mon, 25 Dec 2023 00:29:38 -0500 Received: from mail-pj1-x1034.google.com ([2607:f8b0:4864:20::1034]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rHdWy-0007I2-Lm for qemu-devel@nongnu.org; Mon, 25 Dec 2023 00:29:37 -0500 Received: by mail-pj1-x1034.google.com with SMTP id 98e67ed59e1d1-28beb1d946fso2878731a91.0 for ; Sun, 24 Dec 2023 21:27:36 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=smartx-com.20230601.gappssmtp.com; s=20230601; t=1703482055; x=1704086855; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=qJQlTzAWPO+/klEeEAp+k9zko8Nhs/GsMEahvb4ufUs=; b=dt5+r3J0j8fKD6pkedFoM8wCLjs5C7Rsd3juuK0YegK9+WZyVTq4aLMH456NZAxMAJ JqdUUH96FEReACY6W+HvXPxya+voFSijbZKhqf/FDR1KThPG35pjJJaM8I3HRwwZUtmw 69zxsAXD7TSwEkL4XNkWUwqw50Td2f0UIMNoOho84MTA6S1gtC9PQUp/Eemdec2K9N7x aI9tft4JB+gtaAPuGK3UPJAyeR8LjRhJnHzdeMwBZZw2Fqv2OO+EeOIDrw3AgPkpZ9wh z9VA0ohCOv0WVW7kpW2sRWN2KZhNkzzYBsQAGURK4AYHpVzvX3AxnIgTLffh8sV888gV 2aCQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1703482055; x=1704086855; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=qJQlTzAWPO+/klEeEAp+k9zko8Nhs/GsMEahvb4ufUs=; b=t+qndHC0kuAFiHI/r6PeU/KSsc5QtSbFOd9j8rt0cScz11+Ffpn3JqeT20oLJaiiPV Zr+0M2f7dvXWL9FvI0nHV+3Wvta3+5KNeM39ACHzSy6Y7eCYyWoWGgfXSXnRp61dyDq1 cNqFQ9I50UJstrmvq5mUNA1PFlLZ7qLCO9bCZd4ElBMtgGhMsx037SWuWNUZ40pnYCmY HoHEcrazPnludBrQRaKQ0nd4GK5asn2nAZljH0AJSzNuMwqaBxex7RqbPjwdIWc8uCDS AHp/AX43fzZXJXNlStoM6567ztwoejECQ8TtB2j58LPH6Ye9ZpsZ+hCUTtXrqFhxcos3 nHhQ== X-Gm-Message-State: AOJu0YxAh2xhxdbMyzDkt43xu/dnPwvd54PojZBpRmAixh3KxcoMKJbJ KOQVpmrOb8J8T3mzThhs3tR6UrUYn+0jxKTFTlqaq0Xrq9KrNw== X-Google-Smtp-Source: AGHT+IFPE5GzdDtMg6A3zWm6NTcGG1EF+Kh5Z205xLGf0YWvsqtPk8A/rYGKdYB453VMjpOzqVWIwA== X-Received: by 2002:a05:6a20:12c9:b0:195:1df1:dd89 with SMTP id v9-20020a056a2012c900b001951df1dd89mr6789081pzg.95.1703482054686; Sun, 24 Dec 2023 21:27:34 -0800 (PST) Received: from localhost.localdomain ([118.114.58.28]) by smtp.gmail.com with ESMTPSA id f7-20020aa79d87000000b006d991505b4csm4555800pfq.76.2023.12.24.21.27.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 24 Dec 2023 21:27:34 -0800 (PST) From: Hyman Huang To: qemu-devel Cc: Kevin Wolf , =?utf-8?q?Daniel_P_=2E_Berrang=C3=A9?= , Hanna Reitz , Eric Blake , Markus Armbruster , Hyman Huang Subject: [v3 04/10] crypto: Introduce creation option and structure for detached LUKS header Date: Mon, 25 Dec 2023 13:26:54 +0800 Message-Id: <57ccc93a05f69973d41b571615f9ef13fd9b2983.1703481380.git.yong.huang@smartx.com> X-Mailer: git-send-email 2.39.1 In-Reply-To: References: MIME-Version: 1.0 Received-SPF: none client-ip=2607:f8b0:4864:20::1034; envelope-from=yong.huang@smartx.com; helo=mail-pj1-x1034.google.com X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_NONE=0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Introduce 'header' field in BlockdevCreateOptionsLUKS to support detached LUKS header creation. Meanwhile, introduce header-related field in QCryptoBlock. Signed-off-by: Hyman Huang --- crypto/blockpriv.h | 3 +++ qapi/block-core.json | 3 +++ qapi/crypto.json | 5 ++++- 3 files changed, 10 insertions(+), 1 deletion(-) diff --git a/crypto/blockpriv.h b/crypto/blockpriv.h index 3c7ccea504..6289aea961 100644 --- a/crypto/blockpriv.h +++ b/crypto/blockpriv.h @@ -42,6 +42,9 @@ struct QCryptoBlock { size_t niv; uint64_t payload_offset; /* In bytes */ uint64_t sector_size; /* In bytes */ + + bool detached_header; /* True if disk has a detached LUKS header */ + uint64_t detached_header_size; /* LUKS header size plus key slot size */ }; struct QCryptoBlockDriver { diff --git a/qapi/block-core.json b/qapi/block-core.json index 9ac256c489..8aec179926 100644 --- a/qapi/block-core.json +++ b/qapi/block-core.json @@ -4948,6 +4948,8 @@ # @file: Node to create the image format on, mandatory except when # 'preallocation' is not requested # +# @header: Detached LUKS header node to format. (since 9.0) +# # @size: Size of the virtual disk in bytes # # @preallocation: Preallocation mode for the new image (since: 4.2) @@ -4958,6 +4960,7 @@ { 'struct': 'BlockdevCreateOptionsLUKS', 'base': 'QCryptoBlockCreateOptionsLUKS', 'data': { '*file': 'BlockdevRef', + '*header': 'BlockdevRef', 'size': 'size', '*preallocation': 'PreallocMode' } } diff --git a/qapi/crypto.json b/qapi/crypto.json index fd3d46ebd1..6b4e86cb81 100644 --- a/qapi/crypto.json +++ b/qapi/crypto.json @@ -195,10 +195,13 @@ # decryption key. Mandatory except when probing image for # metadata only. # +# @detached-header: if true, disk has detached LUKS header. +# # Since: 2.6 ## { 'struct': 'QCryptoBlockOptionsLUKS', - 'data': { '*key-secret': 'str' }} + 'data': { '*key-secret': 'str', + '*detached-header': 'bool' }} ## # @QCryptoBlockCreateOptionsLUKS: