2015-03-13 18:39:26 +01:00
|
|
|
# -*- Mode: Python -*-
|
|
|
|
#
|
|
|
|
# QAPI crypto definitions
|
|
|
|
|
|
|
|
##
|
|
|
|
# QCryptoTLSCredsEndpoint:
|
|
|
|
#
|
|
|
|
# The type of network endpoint that will be using the credentials.
|
|
|
|
# Most types of credential require different setup / structures
|
|
|
|
# depending on whether they will be used in a server versus a
|
|
|
|
# client.
|
|
|
|
#
|
|
|
|
# @client: the network endpoint is acting as the client
|
|
|
|
#
|
|
|
|
# @server: the network endpoint is acting as the server
|
|
|
|
#
|
|
|
|
# Since: 2.5
|
|
|
|
##
|
|
|
|
{ 'enum': 'QCryptoTLSCredsEndpoint',
|
|
|
|
'prefix': 'QCRYPTO_TLS_CREDS_ENDPOINT',
|
|
|
|
'data': ['client', 'server']}
|
crypto: add QCryptoSecret object class for password/key handling
Introduce a new QCryptoSecret object class which will be used
for providing passwords and keys to other objects which need
sensitive credentials.
The new object can provide secret values directly as properties,
or indirectly via a file. The latter includes support for file
descriptor passing syntax on UNIX platforms. Ordinarily passing
secret values directly as properties is insecure, since they
are visible in process listings, or in log files showing the
CLI args / QMP commands. It is possible to use AES-256-CBC to
encrypt the secret values though, in which case all that is
visible is the ciphertext. For ad hoc developer testing though,
it is fine to provide the secrets directly without encryption
so this is not explicitly forbidden.
The anticipated scenario is that libvirtd will create a random
master key per QEMU instance (eg /var/run/libvirt/qemu/$VMNAME.key)
and will use that key to encrypt all passwords it provides to
QEMU via '-object secret,....'. This avoids the need for libvirt
(or other mgmt apps) to worry about file descriptor passing.
It also makes life easier for people who are scripting the
management of QEMU, for whom FD passing is significantly more
complex.
Providing data inline (insecure, only for ad hoc dev testing)
$QEMU -object secret,id=sec0,data=letmein
Providing data indirectly in raw format
printf "letmein" > mypasswd.txt
$QEMU -object secret,id=sec0,file=mypasswd.txt
Providing data indirectly in base64 format
$QEMU -object secret,id=sec0,file=mykey.b64,format=base64
Providing data with encryption
$QEMU -object secret,id=master0,file=mykey.b64,format=base64 \
-object secret,id=sec0,data=[base64 ciphertext],\
keyid=master0,iv=[base64 IV],format=base64
Note that 'format' here refers to the format of the ciphertext
data. The decrypted data must always be in raw byte format.
More examples are shown in the updated docs.
Reviewed-by: Eric Blake <eblake@redhat.com>
Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
2015-10-14 10:58:38 +02:00
|
|
|
|
|
|
|
|
|
|
|
##
|
|
|
|
# QCryptoSecretFormat:
|
|
|
|
#
|
|
|
|
# The data format that the secret is provided in
|
|
|
|
#
|
|
|
|
# @raw: raw bytes. When encoded in JSON only valid UTF-8 sequences can be used
|
|
|
|
# @base64: arbitrary base64 encoded binary data
|
|
|
|
# Since: 2.6
|
|
|
|
##
|
|
|
|
{ 'enum': 'QCryptoSecretFormat',
|
|
|
|
'prefix': 'QCRYPTO_SECRET_FORMAT',
|
|
|
|
'data': ['raw', 'base64']}
|
2015-11-19 18:09:01 +01:00
|
|
|
|
|
|
|
|
|
|
|
##
|
|
|
|
# QCryptoHashAlgorithm:
|
|
|
|
#
|
|
|
|
# The supported algorithms for computing content digests
|
|
|
|
#
|
|
|
|
# @md5: MD5. Should not be used in any new code, legacy compat only
|
|
|
|
# @sha1: SHA-1. Should not be used in any new code, legacy compat only
|
2016-03-11 19:33:08 +01:00
|
|
|
# @sha224: SHA-224. (since 2.7)
|
2015-11-19 18:09:01 +01:00
|
|
|
# @sha256: SHA-256. Current recommended strong hash.
|
2016-03-11 19:33:08 +01:00
|
|
|
# @sha384: SHA-384. (since 2.7)
|
|
|
|
# @sha512: SHA-512. (since 2.7)
|
|
|
|
# @ripemd160: RIPEMD-160. (since 2.7)
|
2015-11-19 18:09:01 +01:00
|
|
|
# Since: 2.6
|
|
|
|
##
|
|
|
|
{ 'enum': 'QCryptoHashAlgorithm',
|
|
|
|
'prefix': 'QCRYPTO_HASH_ALG',
|
2016-03-11 19:33:08 +01:00
|
|
|
'data': ['md5', 'sha1', 'sha224', 'sha256', 'sha384', 'sha512', 'ripemd160']}
|
2015-11-19 18:09:01 +01:00
|
|
|
|
|
|
|
|
|
|
|
##
|
|
|
|
# QCryptoCipherAlgorithm:
|
|
|
|
#
|
|
|
|
# The supported algorithms for content encryption ciphers
|
|
|
|
#
|
|
|
|
# @aes-128: AES with 128 bit / 16 byte keys
|
|
|
|
# @aes-192: AES with 192 bit / 24 byte keys
|
|
|
|
# @aes-256: AES with 256 bit / 32 byte keys
|
|
|
|
# @des-rfb: RFB specific variant of single DES. Do not use except in VNC.
|
2016-02-10 18:07:42 +01:00
|
|
|
# @cast5-128: Cast5 with 128 bit / 16 byte keys
|
2016-02-10 18:07:42 +01:00
|
|
|
# @serpent-128: Serpent with 128 bit / 16 byte keys
|
|
|
|
# @serpent-192: Serpent with 192 bit / 24 byte keys
|
|
|
|
# @serpent-256: Serpent with 256 bit / 32 byte keys
|
2016-02-10 18:07:42 +01:00
|
|
|
# @twofish-128: Twofish with 128 bit / 16 byte keys
|
|
|
|
# @twofish-192: Twofish with 192 bit / 24 byte keys
|
|
|
|
# @twofish-256: Twofish with 256 bit / 32 byte keys
|
2015-11-19 18:09:01 +01:00
|
|
|
# Since: 2.6
|
|
|
|
##
|
|
|
|
{ 'enum': 'QCryptoCipherAlgorithm',
|
|
|
|
'prefix': 'QCRYPTO_CIPHER_ALG',
|
2016-02-10 18:07:42 +01:00
|
|
|
'data': ['aes-128', 'aes-192', 'aes-256',
|
|
|
|
'des-rfb',
|
2016-02-10 18:07:42 +01:00
|
|
|
'cast5-128',
|
2016-02-10 18:07:42 +01:00
|
|
|
'serpent-128', 'serpent-192', 'serpent-256',
|
|
|
|
'twofish-128', 'twofish-192', 'twofish-256']}
|
2015-11-19 18:09:01 +01:00
|
|
|
|
|
|
|
|
|
|
|
##
|
|
|
|
# QCryptoCipherMode:
|
|
|
|
#
|
|
|
|
# The supported modes for content encryption ciphers
|
|
|
|
#
|
|
|
|
# @ecb: Electronic Code Book
|
|
|
|
# @cbc: Cipher Block Chaining
|
2016-02-11 15:05:21 +01:00
|
|
|
# @xts: XEX with tweaked code book and ciphertext stealing
|
2016-09-26 11:23:22 +02:00
|
|
|
# @ctr: Counter (Since 2.8)
|
2015-11-19 18:09:01 +01:00
|
|
|
# Since: 2.6
|
|
|
|
##
|
|
|
|
{ 'enum': 'QCryptoCipherMode',
|
|
|
|
'prefix': 'QCRYPTO_CIPHER_MODE',
|
2016-09-26 11:23:22 +02:00
|
|
|
'data': ['ecb', 'cbc', 'xts', 'ctr']}
|
2015-10-15 13:35:28 +02:00
|
|
|
|
|
|
|
|
|
|
|
##
|
|
|
|
# QCryptoIVGenAlgorithm:
|
|
|
|
#
|
|
|
|
# The supported algorithms for generating initialization
|
|
|
|
# vectors for full disk encryption. The 'plain' generator
|
|
|
|
# should not be used for disks with sector numbers larger
|
|
|
|
# than 2^32, except where compatibility with pre-existing
|
|
|
|
# Linux dm-crypt volumes is required.
|
|
|
|
#
|
|
|
|
# @plain: 64-bit sector number truncated to 32-bits
|
|
|
|
# @plain64: 64-bit sector number
|
|
|
|
# @essiv: 64-bit sector number encrypted with a hash of the encryption key
|
|
|
|
# Since: 2.6
|
|
|
|
##
|
|
|
|
{ 'enum': 'QCryptoIVGenAlgorithm',
|
|
|
|
'prefix': 'QCRYPTO_IVGEN_ALG',
|
|
|
|
'data': ['plain', 'plain64', 'essiv']}
|
2015-10-24 12:44:13 +02:00
|
|
|
|
|
|
|
##
|
|
|
|
# QCryptoBlockFormat:
|
|
|
|
#
|
|
|
|
# The supported full disk encryption formats
|
|
|
|
#
|
|
|
|
# @qcow: QCow/QCow2 built-in AES-CBC encryption. Use only
|
|
|
|
# for liberating data from old images.
|
2015-10-24 12:55:48 +02:00
|
|
|
# @luks: LUKS encryption format. Recommended for new images
|
2015-10-24 12:44:13 +02:00
|
|
|
#
|
|
|
|
# Since: 2.6
|
|
|
|
##
|
|
|
|
{ 'enum': 'QCryptoBlockFormat',
|
|
|
|
# 'prefix': 'QCRYPTO_BLOCK_FORMAT',
|
2015-10-24 12:55:48 +02:00
|
|
|
'data': ['qcow', 'luks']}
|
2015-10-24 12:44:13 +02:00
|
|
|
|
|
|
|
##
|
|
|
|
# QCryptoBlockOptionsBase:
|
|
|
|
#
|
|
|
|
# The common options that apply to all full disk
|
|
|
|
# encryption formats
|
|
|
|
#
|
|
|
|
# @format: the encryption format
|
|
|
|
#
|
|
|
|
# Since: 2.6
|
|
|
|
##
|
|
|
|
{ 'struct': 'QCryptoBlockOptionsBase',
|
|
|
|
'data': { 'format': 'QCryptoBlockFormat' }}
|
|
|
|
|
|
|
|
##
|
|
|
|
# QCryptoBlockOptionsQCow:
|
|
|
|
#
|
|
|
|
# The options that apply to QCow/QCow2 AES-CBC encryption format
|
|
|
|
#
|
|
|
|
# @key-secret: #optional the ID of a QCryptoSecret object providing the
|
|
|
|
# decryption key. Mandatory except when probing image for
|
|
|
|
# metadata only.
|
|
|
|
#
|
|
|
|
# Since: 2.6
|
|
|
|
##
|
|
|
|
{ 'struct': 'QCryptoBlockOptionsQCow',
|
|
|
|
'data': { '*key-secret': 'str' }}
|
|
|
|
|
2015-10-24 12:55:48 +02:00
|
|
|
##
|
|
|
|
# QCryptoBlockOptionsLUKS:
|
|
|
|
#
|
|
|
|
# The options that apply to LUKS encryption format
|
|
|
|
#
|
|
|
|
# @key-secret: #optional the ID of a QCryptoSecret object providing the
|
|
|
|
# decryption key. Mandatory except when probing image for
|
|
|
|
# metadata only.
|
|
|
|
# Since: 2.6
|
|
|
|
##
|
|
|
|
{ 'struct': 'QCryptoBlockOptionsLUKS',
|
|
|
|
'data': { '*key-secret': 'str' }}
|
|
|
|
|
|
|
|
|
|
|
|
##
|
|
|
|
# QCryptoBlockCreateOptionsLUKS:
|
|
|
|
#
|
|
|
|
# The options that apply to LUKS encryption format initialization
|
|
|
|
#
|
|
|
|
# @cipher-alg: #optional the cipher algorithm for data encryption
|
|
|
|
# Currently defaults to 'aes'.
|
|
|
|
# @cipher-mode: #optional the cipher mode for data encryption
|
|
|
|
# Currently defaults to 'cbc'
|
|
|
|
# @ivgen-alg: #optional the initialization vector generator
|
|
|
|
# Currently defaults to 'essiv'
|
|
|
|
# @ivgen-hash-alg: #optional the initialization vector generator hash
|
|
|
|
# Currently defaults to 'sha256'
|
|
|
|
# @hash-alg: #optional the master key hash algorithm
|
|
|
|
# Currently defaults to 'sha256'
|
2016-09-06 19:43:00 +02:00
|
|
|
# @iter-time: #optional number of milliseconds to spend in
|
|
|
|
# PBKDF passphrase processing. Currently defaults
|
2016-09-07 13:48:32 +02:00
|
|
|
# to 2000. (since 2.8)
|
2015-10-24 12:55:48 +02:00
|
|
|
# Since: 2.6
|
|
|
|
##
|
|
|
|
{ 'struct': 'QCryptoBlockCreateOptionsLUKS',
|
|
|
|
'base': 'QCryptoBlockOptionsLUKS',
|
|
|
|
'data': { '*cipher-alg': 'QCryptoCipherAlgorithm',
|
|
|
|
'*cipher-mode': 'QCryptoCipherMode',
|
|
|
|
'*ivgen-alg': 'QCryptoIVGenAlgorithm',
|
|
|
|
'*ivgen-hash-alg': 'QCryptoHashAlgorithm',
|
2016-09-06 19:43:00 +02:00
|
|
|
'*hash-alg': 'QCryptoHashAlgorithm',
|
|
|
|
'*iter-time': 'int'}}
|
2015-10-24 12:55:48 +02:00
|
|
|
|
|
|
|
|
2015-10-24 12:44:13 +02:00
|
|
|
##
|
|
|
|
# QCryptoBlockOpenOptions:
|
|
|
|
#
|
|
|
|
# The options that are available for all encryption formats
|
|
|
|
# when opening an existing volume
|
|
|
|
#
|
|
|
|
# Since: 2.6
|
|
|
|
##
|
|
|
|
{ 'union': 'QCryptoBlockOpenOptions',
|
|
|
|
'base': 'QCryptoBlockOptionsBase',
|
|
|
|
'discriminator': 'format',
|
2015-10-24 12:55:48 +02:00
|
|
|
'data': { 'qcow': 'QCryptoBlockOptionsQCow',
|
|
|
|
'luks': 'QCryptoBlockOptionsLUKS' } }
|
2015-10-24 12:44:13 +02:00
|
|
|
|
|
|
|
|
|
|
|
##
|
|
|
|
# QCryptoBlockCreateOptions:
|
|
|
|
#
|
|
|
|
# The options that are available for all encryption formats
|
|
|
|
# when initializing a new volume
|
|
|
|
#
|
|
|
|
# Since: 2.6
|
|
|
|
##
|
|
|
|
{ 'union': 'QCryptoBlockCreateOptions',
|
|
|
|
'base': 'QCryptoBlockOptionsBase',
|
|
|
|
'discriminator': 'format',
|
2015-10-24 12:55:48 +02:00
|
|
|
'data': { 'qcow': 'QCryptoBlockOptionsQCow',
|
|
|
|
'luks': 'QCryptoBlockCreateOptionsLUKS' } }
|
2016-07-22 14:53:34 +02:00
|
|
|
|
|
|
|
|
|
|
|
##
|
|
|
|
# QCryptoBlockInfoBase:
|
|
|
|
#
|
|
|
|
# The common information that applies to all full disk
|
|
|
|
# encryption formats
|
|
|
|
#
|
|
|
|
# @format: the encryption format
|
|
|
|
#
|
|
|
|
# Since: 2.7
|
|
|
|
##
|
|
|
|
{ 'struct': 'QCryptoBlockInfoBase',
|
|
|
|
'data': { 'format': 'QCryptoBlockFormat' }}
|
|
|
|
|
|
|
|
|
|
|
|
##
|
|
|
|
# QCryptoBlockInfoLUKSSlot:
|
|
|
|
#
|
|
|
|
# Information about the LUKS block encryption key
|
|
|
|
# slot options
|
|
|
|
#
|
|
|
|
# @active: whether the key slot is currently in use
|
|
|
|
# @key-offset: offset to the key material in bytes
|
|
|
|
# @iters: #optional number of PBKDF2 iterations for key material
|
|
|
|
# @stripes: #optional number of stripes for splitting key material
|
|
|
|
#
|
|
|
|
# Since: 2.7
|
|
|
|
##
|
|
|
|
{ 'struct': 'QCryptoBlockInfoLUKSSlot',
|
|
|
|
'data': {'active': 'bool',
|
|
|
|
'*iters': 'int',
|
|
|
|
'*stripes': 'int',
|
|
|
|
'key-offset': 'int' } }
|
|
|
|
|
|
|
|
|
|
|
|
##
|
|
|
|
# QCryptoBlockInfoLUKS:
|
|
|
|
#
|
|
|
|
# Information about the LUKS block encryption options
|
|
|
|
#
|
|
|
|
# @cipher-alg: the cipher algorithm for data encryption
|
|
|
|
# @cipher-mode: the cipher mode for data encryption
|
|
|
|
# @ivgen-alg: the initialization vector generator
|
|
|
|
# @ivgen-hash-alg: #optional the initialization vector generator hash
|
|
|
|
# @hash-alg: the master key hash algorithm
|
|
|
|
# @payload-offset: offset to the payload data in bytes
|
|
|
|
# @master-key-iters: number of PBKDF2 iterations for key material
|
|
|
|
# @uuid: unique identifier for the volume
|
|
|
|
# @slots: information about each key slot
|
|
|
|
#
|
|
|
|
# Since: 2.7
|
|
|
|
##
|
|
|
|
{ 'struct': 'QCryptoBlockInfoLUKS',
|
|
|
|
'data': {'cipher-alg': 'QCryptoCipherAlgorithm',
|
|
|
|
'cipher-mode': 'QCryptoCipherMode',
|
|
|
|
'ivgen-alg': 'QCryptoIVGenAlgorithm',
|
|
|
|
'*ivgen-hash-alg': 'QCryptoHashAlgorithm',
|
|
|
|
'hash-alg': 'QCryptoHashAlgorithm',
|
|
|
|
'payload-offset': 'int',
|
|
|
|
'master-key-iters': 'int',
|
|
|
|
'uuid': 'str',
|
|
|
|
'slots': [ 'QCryptoBlockInfoLUKSSlot' ] }}
|
|
|
|
|
|
|
|
##
|
|
|
|
# QCryptoBlockInfoQCow:
|
|
|
|
#
|
|
|
|
# Information about the QCow block encryption options
|
|
|
|
#
|
|
|
|
# Since: 2.7
|
|
|
|
##
|
|
|
|
{ 'struct': 'QCryptoBlockInfoQCow',
|
|
|
|
'data': { }}
|
|
|
|
|
|
|
|
|
|
|
|
##
|
|
|
|
# QCryptoBlockInfo:
|
|
|
|
#
|
|
|
|
# Information about the block encryption options
|
|
|
|
#
|
|
|
|
# Since: 2.7
|
|
|
|
##
|
|
|
|
{ 'union': 'QCryptoBlockInfo',
|
|
|
|
'base': 'QCryptoBlockInfoBase',
|
|
|
|
'discriminator': 'format',
|
|
|
|
'data': { 'qcow': 'QCryptoBlockInfoQCow',
|
|
|
|
'luks': 'QCryptoBlockInfoLUKS' } }
|