From 2552fec248c665f3417a5d36840555da6bbe96a4 Mon Sep 17 00:00:00 2001
From: John Ferlan
Date: Wed, 1 Jun 2016 19:21:26 -0400
Subject: [PATCH] encryption: Add and to encryption
For a luks device, allow the configuration of a specific cipher to be
used for encrypting the volume.
Signed-off-by: John Ferlan
---
docs/formatstorageencryption.html.in | 83 ++++++++++-
docs/schemas/storagecommon.rng | 44 +++++-
src/conf/domain_conf.c | 11 ++
src/util/virstorageencryption.c | 136 ++++++++++++++++++
src/util/virstorageencryption.h | 14 ++
.../qemuxml2argv-luks-disk-cipher.xml | 45 ++++++
.../qemuxml2xmlout-luks-disk-cipher.xml | 1 +
tests/qemuxml2xmltest.c | 1 +
tests/storagevolxml2xmlin/vol-luks-cipher.xml | 23 +++
.../storagevolxml2xmlout/vol-luks-cipher.xml | 23 +++
tests/storagevolxml2xmltest.c | 1 +
11 files changed, 376 insertions(+), 6 deletions(-)
create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-luks-disk-cipher.xml
create mode 120000 tests/qemuxml2xmloutdata/qemuxml2xmlout-luks-disk-cipher.xml
create mode 100644 tests/storagevolxml2xmlin/vol-luks-cipher.xml
create mode 100644 tests/storagevolxml2xmlout/vol-luks-cipher.xml
diff --git a/docs/formatstorageencryption.html.in b/docs/formatstorageencryption.html.in
index 380763e99e..f2b0ffdf12 100644
--- a/docs/formatstorageencryption.html.in
+++ b/docs/formatstorageencryption.html.in
@@ -68,6 +68,60 @@
be used as the passphrase to decrypt the volume.
Since 2.1.0.
+
+ For volume creation, it is possible to specify the encryption
+ algorithm used to encrypt the luks volume. The following two
+ optional elements may be provided for that purpose. It is hypervisor
+ dependent as to which algorithms are supported. The default algorithm
+ used by the storage driver backend when using qemu-img to create
+ the volume is 'aes-256-cbc' using 'essiv' for initialization vector
+ generation and 'sha256' hash algorithm for both the cipher and the
+ initialization vector generation.
+
+
+
+ cipher
+ - This element describes the cipher algorithm to be used to either
+ encrypt or decrypt the luks volume. This element has the following
+ attributes:
+
+ name
+ - The name of the cipher algorithm used for data encryption,
+ such as 'aes', 'des', 'cast5', 'serpent', 'twofish', etc.
+ Support of the specific algorithm is storage driver
+ implementation dependent.
+ size
+ - The size of the cipher in bits, such as '256', '192', '128',
+ etc. Support of the specific size for a specific cipher is
+ hypervisor dependent.
+ mode
+ - An optional cipher algorithm mode such as 'cbc', 'xts',
+ 'ecb', etc. Support of the specific cipher mode is
+ hypervisor dependent.
+ hash
+ - An optional master key hash algorithm such as 'md5', 'sha1',
+ 'sha256', etc. Support of the specific hash algorithm is
+ hypervisor dependent.
+
+
+ ivgen
+ - This optional element describes the initialization vector
+ generation algorithm used in conjunction with the
+
cipher
. If the cipher
is not provided,
+ then an error will be generated by the parser.
+
+ name
+ - The name of the algorithm, such as 'plain', 'plain64',
+ 'essiv', etc. Support of the specific algorithm is hypervisor
+ dependent.
+ hash
+ - An optional hash algorithm such as 'md5', 'sha1', 'sha256',
+ etc. Support of the specific ivgen hash algorithm is hypervisor
+ dependent.
+
+
+
+
@@ -81,9 +135,12 @@
</encryption>
- Here is a simple example, specifying use of the luks
format
- where it's assumed that a secret
has been defined using a
- usage
element with a id
of "luks_example":
+ Assuming a
+ luks secret
is already defined using a
+ usage
element with an name
of "luks_example",
+ a simple example specifying use of the luks
format
+ for either volume creation without a specific cipher being defined or
+ as part of a domain volume definition:
<encryption format='luks'>
@@ -91,5 +148,25 @@
</encryption>
+
+ Here is an example, specifying use of the luks
format for
+ a specific cipher algorihm for volume creation:
+
+
+ <volume>
+ <name>twofish.luks</name>
+ <capacity unit='G'>5</capacity>
+ <target>
+ <path>/var/lib/libvirt/images/demo.luks</path>
+ <format type='luks'/>
+ <encryption format='luks'>
+ <secret type='passphrase' usage='luks_example'/>
+ <cipher name='twofish' size='256' mode='cbc' hash='sha256'/>
+ <ivgen name='plain64' hash='sha256'/>
+ </encryption>
+ </target>
+ </volume>
+
+