Skip to content

Support for full disk encryption

Daniel P. Berrange qemu-devel 1 version In review

Get series with b4
b4 am [email protected]

Versions newest first

  1. v1 Latest30 patches 6 repliesIn review

Patches in v1 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/30crypto: add QCryptoSecret object class for password/key handlingcrypto/Makefile.objs crypto/secret.c include/crypto/secret.h +5 more+1257 -04 replies
2/30crypto: add support for loading encrypted x509 keyscrypto/tlscredsx509.c include/crypto/tlscredsx509.h qemu-options.hx+55 -10 replies
3/30qcow: add a 'keyid' parameter to qcow optionsblock/qcow.c qapi/block-core.json+87 -240 replies
4/30qcow2: add a 'keyid' parameter to qcow2 optionsblock/qcow2.c block/qcow2.h qapi/block-core.json+64 -252 replies
5/30qom: add user_creatable_add & user_creatable_del methodshmp.c include/monitor/monitor.h include/qom/object_interfaces.h +3 more+127 -770 replies
6/30qemu-img: add support for --object command line argqemu-img-cmds.hx qemu-img.c qemu-img.texi+322 -300 replies
7/30qemu-nbd: add support for --object command line argqemu-nbd.c qemu-nbd.texi+92 -00 replies
8/30qemu-io: add support for --object command line argqemu-io.c+87 -00 replies
9/30qemu-io: allow specifying image as a set of options argsqemu-io.c+36 -10 replies
10/30qemu-nbd: allow specifying image as a set of options argsqemu-nbd.c+50 -70 replies
11/30qemu-img: allow specifying image as a set of options argsinclude/qemu/option.h qemu-img.c util/qemu-option.c+407 -740 replies
12/30block: rip out all traces of password promptingblock/qcow.c block/qcow2.c hmp.c +15 more+72 -3090 replies
13/30block: remove all encryption handling APIsblock.c block/qapi.c block/qcow.c +4 more+7 -1620 replies
14/30block: remove support for writing to qcow/qcow2 encrypted imagesblock.c block/qcow.c block/qcow2.c +3 more+29 -580 replies
15/30qcow2: make qcow2_encrypt_sectors encrypt in placeblock/qcow2-cluster.c block/qcow2.c block/qcow2.h+8 -170 replies
16/30crypto: add ability to query the cipher key, block & IV lenscrypto/cipher.c include/crypto/cipher.h tests/test-crypto-cipher.c+95 -00 replies
17/30crypto: add method for querying hash digest sizecrypto/hash.c include/crypto/hash.h tests/test-crypto-hash.c+31 -00 replies
18/30crypto: move QCryptoHashAlgorithm enum definition into QAPIcrypto/hash.c include/crypto/hash.h qapi/crypto.json+18 -100 replies
19/30crypto: move QCryptoCipherAlgorithm/Mode enum definitions into QAPIcrypto/cipher.c include/crypto/cipher.h qapi/crypto.json+36 -190 replies
20/30crypto: ensure qapi/crypto.json is listed in qapi-modulesMakefile+2 -10 replies
21/30crypto: add cryptographic random byte sourcecrypto/Makefile.objs crypto/random.c include/crypto/random.h+94 -00 replies
22/30crypto: add support for PBKDF2 algorithmcrypto/Makefile.objs crypto/pbkdf-gcrypt.c crypto/pbkdf-nettle.c +6 more+776 -00 replies
23/30crypto: add support for generating initialization vectorscrypto/Makefile.objs crypto/ivgen-essiv.c crypto/ivgen-essiv.h +11 more+842 -00 replies
24/30crypto: add support for anti-forensic split algorithmcrypto/Makefile.objs crypto/afsplit.c include/crypto/afsplit.h +3 more+507 -00 replies
25/30crypto: fix transposed arguments in cipher error messagecrypto/cipher.c+1 -10 replies
26/30crypto: add block encryption frameworkcrypto/Makefile.objs crypto/block-qcowaes.c crypto/block-qcowaes.h +4 more+779 -00 replies
27/30crypto: implement the LUKS block encryption formatcrypto/Makefile.objs crypto/block-luks.c crypto/block-luks.h +2 more+1126 -30 replies
28/30block: add generic full disk encryption driverblock/Makefile.objs block/fde.c+524 -00 replies
29/30qcow2: convert QCow2 to use QCryptoBlock for encryptionblock/qcow2-cluster.c block/qcow2.c block/qcow2.h+48 -1110 replies
30/30qcow2: add LUKS full disk encryption supportblock/qcow2.c block/qcow2.h docs/specs/qcow2.txt+347 -110 replies

Reviews trailers per patch

No Reviewed-by, Acked-by or Tested-by trailers for v1 yet.

Read the v1 thread

Cover letter [Qemu-devel] [PATCH WIP 00/30] Support for full disk encryption

This Work-In-Progress series introduces a framework for full disk encryption, and implements the LUKS encryption format using it. It provides a new block driver that can use this directly, but also aims to integrate it natively into the qcow2 file format (more on that later).

For convenience, this series includes of the patches I've previously sent wrt introducing a secure framework for passing secrets (passwords, keys, etc) to QEMU:

https://lists.gnu.org/archive/html/qemu-devel/2015-10/msg04365.html

Patches 1-> 15 are the basic secret handling related patches

Patches 16-25 are preparatory work in the crypto codebase. This is some bug fixing, some QAPI-ification, and some new support modules for generating initialization vectors, the PBKDF2 algorithm and LUKS anti-forensic split algorithm.

Patches 26 & 27 provide the full disk encryption framework and LUKS implementation respectively.

Finally, patch 28 provides a general purpose encrypted block driver, that can be used in any place you'd currently use dm-crypt with QEMU), and 29/30 start to extend QCow2 to support LUKS as an embedded encryption method. Patch 28 quickly illustrates the qemu-img commands for dealing with encrypted volumes.

The block/fde.c driver is a fairly clean example of how to make use of the full disk encryption framework to implement a block driver. So a good place to look. The crypto/block-luks.c file is the actual LUKS implementation. Its creation code will generate volumes with pretty much the same parameters as the reference cryptsetup impl will.

The QCow2 support is non-functional, because I hit a small problem. The QCow2 header and all header extensions appear to need to fit into the first cluster. The LUKS header is typically set to be 2 MB in size, which is clearly not going to fit. The actual QCow2 header appears to include offsets for all the various data tables, so it /appears/ that the first cluster limit for headers is just an implementation limit, not a specification limit. Assuming that's correct, I'd aim to extend the permitted size of the header to be much larger.

The main limitation of the LUKS impl is that it currently lacks support for the XTS cipher mode, so only CBC can be used. This is because I'm yet to find any attractive impl of XTS that QEMU can reuse, as either gcrypt/nettle provide it yet. TBD...

Daniel P. Berrange (30):
crypto: add QCryptoSecret object class for password/key handling
crypto: add support for loading encrypted x509 keys
qcow: add a 'keyid' parameter to qcow options
qcow2: add a 'keyid' parameter to qcow2 options
qom: add user_creatable_add & user_creatable_del methods
qemu-img: add support for --object command line arg
qemu-nbd: add support for --object command line arg
qemu-io: add support for --object command line arg
qemu-io: allow specifying image as a set of options args
qemu-nbd: allow specifying image as a set of options args
qemu-img: allow specifying image as a set of options args
block: rip out all traces of password prompting
block: remove all encryption handling APIs
block: remove support for writing to qcow/qcow2 encrypted images
qcow2: make qcow2_encrypt_sectors encrypt in place
crypto: add ability to query the cipher key, block & IV lens
crypto: add method for querying hash digest size
crypto: move QCryptoHashAlgorithm enum definition into QAPI
crypto: move QCryptoCipherAlgorithm/Mode enum definitions into QAPI
crypto: ensure qapi/crypto.json is listed in qapi-modules
crypto: add cryptographic random byte source
crypto: add support for PBKDF2 algorithm
crypto: add support for generating initialization vectors
crypto: add support for anti-forensic split algorithm
crypto: fix transposed arguments in cipher error message
crypto: add block encryption framework
crypto: implement the LUKS block encryption format
block: add generic full disk encryption driver
qcow2: convert QCow2 to use QCryptoBlock for encryption
qcow2: add LUKS full disk encryption support

 Makefile                        |    3 +-
 block.c                         |   88 +---
 block/Makefile.objs             |    2 +
 block/fde.c                     |  522 +++++++++++++++++++
 block/qapi.c                    |    2 +-
 block/qcow.c                    |  122 +++--
 block/qcow2-cluster.c           |   55 +-
 block/qcow2.c                   |  403 ++++++++++++---
 block/qcow2.h                   |   18 +-
 blockdev.c                      |   40 +-
 crypto/Makefile.objs            |   11 +
 crypto/afsplit.c                |  194 +++++++
 crypto/block-luks.c             | 1056 +++++++++++++++++++++++++++++++++++++++
 crypto/block-luks.h             |   28 ++
 crypto/block-qcowaes.c          |  150 ++++++
 crypto/block-qcowaes.h          |   28 ++
 crypto/block.c                  |  253 ++++++++++
 crypto/blockpriv.h              |   87 ++++
 crypto/cipher.c                 |   54 +-
 crypto/hash.c                   |   17 +-
 crypto/ivgen-essiv.c            |  116 +++++
 crypto/ivgen-essiv.h            |   28 ++
 crypto/ivgen-plain.c            |   60 +++
 crypto/ivgen-plain.h            |   28 ++
 crypto/ivgen-plain64.c          |   60 +++
 crypto/ivgen-plain64.h          |   28 ++
 crypto/ivgen.c                  |  117 +++++
 crypto/ivgenpriv.h              |   47 ++
 crypto/pbkdf-gcrypt.c           |   64 +++
 crypto/pbkdf-nettle.c           |   63 +++
 crypto/pbkdf-stub.c             |   39 ++
 crypto/pbkdf.c                  |   76 +++
 crypto/random.c                 |   50 ++
 crypto/secret.c                 |  567 +++++++++++++++++++++
 crypto/tlscredsx509.c           |   47 ++
 docs/specs/qcow2.txt            |   53 ++
 hmp.c                           |   42 +-
 hw/usb/dev-storage.c            |   34 --
 include/block/block.h           |    5 +-
 include/crypto/afsplit.h        |  133 +++++
 include/crypto/block.h          |  199 ++++++++
 include/crypto/cipher.h         |   54 +-
 include/crypto/hash.h           |   20 +-
 include/crypto/ivgen.h          |  167 +++++++
 include/crypto/pbkdf.h          |  152 ++++++
 include/crypto/random.h         |   43 ++
 include/crypto/secret.h         |  148 ++++++
 include/crypto/tlscredsx509.h   |    1 +
 include/monitor/monitor.h       |   10 -
 include/qemu/option.h           |    1 +
 include/qemu/osdep.h            |    2 -
 include/qom/object_interfaces.h |   31 ++
 monitor.c                       |   69 ---
 qapi/block-core.json            |   23 +-
 qapi/crypto.json                |  173 +++++++
 qemu-img-cmds.hx                |   44 +-
 qemu-img.c                      |  788 +++++++++++++++++++++++++----
 qemu-img.texi                   |    8 +
 qemu-io.c                       |  145 +++++-
 qemu-nbd.c                      |  142 +++++-
 qemu-nbd.texi                   |    7 +
 qemu-options.hx                 |   86 +++-
 qmp.c                           |   84 +---
 qom/object_interfaces.c         |   76 +++
 tests/.gitignore                |    4 +
 tests/Makefile                  |    8 +
 tests/qemu-iotests/087          |   20 +
 tests/qemu-iotests/087.out      |   26 +-
 tests/qemu-iotests/134          |   17 +-
 tests/qemu-iotests/134.out      |   44 +-
 tests/qemu-iotests/common.rc    |    4 +-
 tests/test-crypto-afsplit.c     |  176 +++++++
 tests/test-crypto-cipher.c      |   10 +
 tests/test-crypto-hash.c        |    5 +
 tests/test-crypto-ivgen.c       |  168 +++++++
 tests/test-crypto-pbkdf.c       |  378 ++++++++++++++
 tests/test-crypto-secret.c      |  446 +++++++++++++++++
 util/oslib-posix.c              |   66 ---
 util/oslib-win32.c              |   24 -
 util/qemu-option.c              |    6 +
 vl.c                            |    8 +-
 81 files changed, 7829 insertions(+), 844 deletions(-)
 create mode 100644 block/fde.c
 create mode 100644 crypto/afsplit.c
 create mode 100644 crypto/block-luks.c
 create mode 100644 crypto/block-luks.h
 create mode 100644 crypto/block-qcowaes.c
 create mode 100644 crypto/block-qcowaes.h
 create mode 100644 crypto/block.c
 create mode 100644 crypto/blockpriv.h
 create mode 100644 crypto/ivgen-essiv.c
 create mode 100644 crypto/ivgen-essiv.h
 create mode 100644 crypto/ivgen-plain.c
 create mode 100644 crypto/ivgen-plain.h
 create mode 100644 crypto/ivgen-plain64.c
 create mode 100644 crypto/ivgen-plain64.h
 create mode 100644 crypto/ivgen.c
 create mode 100644 crypto/ivgenpriv.h
 create mode 100644 crypto/pbkdf-gcrypt.c
 create mode 100644 crypto/pbkdf-nettle.c
 create mode 100644 crypto/pbkdf-stub.c
 create mode 100644 crypto/pbkdf.c
 create mode 100644 crypto/random.c
 create mode 100644 crypto/secret.c
 create mode 100644 include/crypto/afsplit.h
 create mode 100644 include/crypto/block.h
 create mode 100644 include/crypto/ivgen.h
 create mode 100644 include/crypto/pbkdf.h
 create mode 100644 include/crypto/random.h
 create mode 100644 include/crypto/secret.h
 create mode 100644 tests/test-crypto-afsplit.c
 create mode 100644 tests/test-crypto-ivgen.c
 create mode 100644 tests/test-crypto-pbkdf.c
 create mode 100644 tests/test-crypto-secret.c
Signature · 1 line
2.5.0