From: Max Reitz <mreitz@redhat.com>
To: "Daniel P. Berrange" <berrange@redhat.com>, qemu-devel@nongnu.org
Cc: qemu-block@nongnu.org, Kevin Wolf <kwolf@redhat.com>
Subject: Re: [Qemu-devel] [PATCH v3 12/18] qcow2: extend specification to cover LUKS encryption
Date: Thu, 9 Feb 2017 00:33:39 +0100 [thread overview]
Message-ID: <6e203e3e-11b1-ff0d-9c05-6b4e8e37d281@redhat.com> (raw)
In-Reply-To: <20170126101827.22378-13-berrange@redhat.com>
[-- Attachment #1: Type: text/plain, Size: 5871 bytes --]
On 26.01.2017 11:18, Daniel P. Berrange wrote:
> Update the qcow2 specification to describe how the LUKS header is
> placed inside a qcow2 file, when using LUKS encryption for the
> qcow2 payload instead of the legacy AES-CBC encryption
>
> Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
> ---
> docs/specs/qcow2.txt | 96 ++++++++++++++++++++++++++++++++++++++++++++++++++++
> 1 file changed, 96 insertions(+)
>
> diff --git a/docs/specs/qcow2.txt b/docs/specs/qcow2.txt
> index 80cdfd0..ab07e99 100644
> --- a/docs/specs/qcow2.txt
> +++ b/docs/specs/qcow2.txt
> @@ -45,6 +45,7 @@ The first cluster of a qcow2 image contains the file header:
> 32 - 35: crypt_method
> 0 for no encryption
> 1 for AES encryption
> + 2 for LUKS encryption
>
> 36 - 39: l1_size
> Number of entries in the active L1 table
> @@ -135,6 +136,7 @@ be stored. Each extension has a structure like the following:
> 0xE2792ACA - Backing file format name
> 0x6803f857 - Feature name table
> 0x23852875 - Bitmaps extension
> + 0x0537be77 - Full disk encryption header pointer
> other - Unknown header extension, can be safely
> ignored
>
> @@ -207,6 +209,100 @@ The fields of the bitmaps extension are:
> Offset into the image file at which the bitmap directory
> starts. Must be aligned to a cluster boundary.
>
> +== Full disk encryption header pointer ==
> +
> +The full disk encryption header must be present if, and only if, the
> +'crypt_method' header requires metadata. Currently this is only true
> +of the 'LUKS' crypt method. The header extension must be absent for
> +other methods.
> +
> +This header provides the offset at which the crypt method can store
> +its additional data, as well as the length of such data.
> +
> + Byte 0 - 7: Offset into the image file at which the encryption
> + header starts in bytes. Must be aligned to a cluster
> + boundary.
> + Byte 8 - 15: Length of the written encryption header in bytes.
> + Note actual space allocated in the qcow2 file may
> + be larger than this value, since it will be rounded
> + to the nearest multiple of the cluster size. Any
> + unused bytes in the allocated space will be initialized
> + to 0.
> +
> +For the LUKS crypt method, the encryption header works as follows.
> +
> +The first 592 bytes of the header clusters will contain the LUKS
> +partition header. This is then followed by the key material data areas.
> +The size of the key material data areas is determined by the number of
> +stripes in the key slot and key size. Refer to the LUKS format
> +specification ('docs/on-disk-format.pdf' in the cryptsetup source
> +package) for details of the LUKS partition header format.
> +
> +In the LUKS partition header, the "payload-offset" field will be
> +calculated as normal for the LUKS spec. ie the size of the LUKS
> +header, plus key material regions, plus padding. Its value is not
> +used, however, since the qcow2 file format itself defines where
> +the real payload offset is.
> +
> +In the LUKS key slots header, the "key-material-offset" is relative
> +to the start of the LUKS header clusters in the qcow2 container,
> +not the start of the qcow2 file.
> +
> +Logically the layout looks like
> +
> + +-----------------------------+
> + | QCow2 header |
> + +-----------------------------+
> + | QCow2 header extension X |
> + | QCow2 header extension FDE |
> + | QCow2 header extension ... |
> + | QCow2 header extension Z |
Thanks for dropping the lines between the header extensions, but it
would be good if you could also drop the line after "QCow2 header" (or
replace it by an empty line), because the header extensions are part of
the header cluster.
With that done:
Reviewed-by: Max Reitz <mreitz@redhat.com>
> + +-----------------------------+
> + | ....other QCow2 tables.... |
> + . .
> + . .
> + +-----------------------------+
> + | +-------------------------+ |
> + | | LUKS partition header | |
> + | +-------------------------+ |
> + | | LUKS key material 1 | |
> + | +-------------------------+ |
> + | | LUKS key material 2 | |
> + | +-------------------------+ |
> + | | LUKS key material ... | |
> + | +-------------------------+ |
> + | | LUKS key material 8 | |
> + | +-------------------------+ |
> + +-----------------------------+
> + | QCow2 cluster payload |
> + . .
> + . .
> + . .
> + | |
> + +-----------------------------+
> +
> +== Data encryption ==
> +
> +When an encryption method is requested in the header, the image payload
> +data must be encrypted/decrypted on every write/read. The image headers
> +and metadata is never encrypted.
> +
> +The algorithms used for encryption vary depending on the method
> +
> + - AES:
> +
> + The AES cipher, in CBC mode, with 256 bit keys.
> +
> + Initialization vectors generated using plain64 method, with
> + the virtual disk sector as the input tweak.
> +
> + - LUKS:
> +
> + The algorithms are specified in the LUKS header.
> +
> + Initialization vectors generated using the method specified
> + in the LUKS header, with the physical disk sector as the
> + input tweak.
>
> == Host cluster management ==
>
>
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 512 bytes --]
next prev parent reply other threads:[~2017-02-08 23:33 UTC|newest]
Thread overview: 39+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-01-26 10:18 [Qemu-devel] [PATCH v3 00/18] Convert QCow[2] to QCryptoBlock & add LUKS support Daniel P. Berrange
2017-01-26 10:18 ` [Qemu-devel] [PATCH v3 01/18] block: expose crypto option names / defs to other drivers Daniel P. Berrange
2017-02-08 15:26 ` [Qemu-devel] [Qemu-block] " Alberto Garcia
2017-01-26 10:18 ` [Qemu-devel] [PATCH v3 02/18] block: add ability to set a prefix for opt names Daniel P. Berrange
2017-02-09 13:30 ` [Qemu-devel] [Qemu-block] " Alberto Garcia
2017-01-26 10:18 ` [Qemu-devel] [PATCH v3 03/18] qcow: document another weakness of qcow AES encryption Daniel P. Berrange
2017-02-08 15:30 ` [Qemu-devel] [Qemu-block] " Alberto Garcia
2017-02-08 22:49 ` [Qemu-devel] " Max Reitz
2017-01-26 10:18 ` [Qemu-devel] [PATCH v3 04/18] qcow: require image size to be > 1 for new images Daniel P. Berrange
2017-02-08 19:29 ` Eric Blake
2017-02-09 11:30 ` [Qemu-devel] [Qemu-block] " Alberto Garcia
2017-01-26 10:18 ` [Qemu-devel] [PATCH v3 05/18] iotests: skip 042 with qcow which dosn't support zero sized images Daniel P. Berrange
2017-02-09 11:47 ` [Qemu-devel] [Qemu-block] " Alberto Garcia
2017-01-26 10:18 ` [Qemu-devel] [PATCH v3 06/18] iotests: skip 048 with qcow which doesn't support resize Daniel P. Berrange
2017-02-09 11:50 ` [Qemu-devel] [Qemu-block] " Alberto Garcia
2017-01-26 10:18 ` [Qemu-devel] [PATCH v3 07/18] iotests: fix 097 when run with qcow Daniel P. Berrange
2017-01-26 10:18 ` [Qemu-devel] [PATCH v3 08/18] qcow: make encrypt_sectors encrypt in place Daniel P. Berrange
2017-02-08 19:35 ` Eric Blake
2017-02-08 22:57 ` Max Reitz
2017-02-10 10:44 ` [Qemu-devel] [Qemu-block] " Alberto Garcia
2017-02-10 16:19 ` Daniel P. Berrange
2017-01-26 10:18 ` [Qemu-devel] [PATCH v3 09/18] qcow: convert QCow to use QCryptoBlock for encryption Daniel P. Berrange
2017-01-26 10:18 ` [Qemu-devel] [PATCH v3 10/18] qcow2: make qcow2_encrypt_sectors encrypt in place Daniel P. Berrange
2017-02-09 14:24 ` [Qemu-devel] [Qemu-block] " Alberto Garcia
2017-01-26 10:18 ` [Qemu-devel] [PATCH v3 11/18] qcow2: convert QCow2 to use QCryptoBlock for encryption Daniel P. Berrange
2017-02-08 16:15 ` [Qemu-devel] [Qemu-block] " Alberto Garcia
2017-02-08 16:23 ` Daniel P. Berrange
2017-02-08 23:26 ` [Qemu-devel] " Max Reitz
2017-01-26 10:18 ` [Qemu-devel] [PATCH v3 12/18] qcow2: extend specification to cover LUKS encryption Daniel P. Berrange
2017-02-08 23:33 ` Max Reitz [this message]
2017-01-26 10:18 ` [Qemu-devel] [PATCH v3 13/18] qcow2: add support for LUKS encryption format Daniel P. Berrange
2017-02-09 0:28 ` Max Reitz
2017-01-26 10:18 ` [Qemu-devel] [PATCH v3 14/18] qcow2: add iotests to cover LUKS encryption support Daniel P. Berrange
2017-02-09 0:36 ` Max Reitz
2017-01-26 10:18 ` [Qemu-devel] [PATCH v3 15/18] iotests: enable tests 134 and 158 to work with qcow (v1) Daniel P. Berrange
2017-01-26 10:18 ` [Qemu-devel] [PATCH v3 16/18] block: rip out all traces of password prompting Daniel P. Berrange
2017-01-26 10:18 ` [Qemu-devel] [PATCH v3 17/18] block: remove all encryption handling APIs Daniel P. Berrange
2017-01-26 10:18 ` [Qemu-devel] [PATCH v3 18/18] block: pass option prefix down to crypto layer Daniel P. Berrange
2017-02-09 0:51 ` Max Reitz
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=6e203e3e-11b1-ff0d-9c05-6b4e8e37d281@redhat.com \
--to=mreitz@redhat.com \
--cc=berrange@redhat.com \
--cc=kwolf@redhat.com \
--cc=qemu-block@nongnu.org \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).