xref: /qemu/qapi/crypto.json (revision 33848cee)
1# -*- Mode: Python -*-
2#
3# QAPI crypto definitions
4
5##
6# @QCryptoTLSCredsEndpoint:
7#
8# The type of network endpoint that will be using the credentials.
9# Most types of credential require different setup / structures
10# depending on whether they will be used in a server versus a
11# client.
12#
13# @client: the network endpoint is acting as the client
14#
15# @server: the network endpoint is acting as the server
16#
17# Since: 2.5
18##
19{ 'enum': 'QCryptoTLSCredsEndpoint',
20  'prefix': 'QCRYPTO_TLS_CREDS_ENDPOINT',
21  'data': ['client', 'server']}
22
23
24##
25# @QCryptoSecretFormat:
26#
27# The data format that the secret is provided in
28#
29# @raw: raw bytes. When encoded in JSON only valid UTF-8 sequences can be used
30# @base64: arbitrary base64 encoded binary data
31# Since: 2.6
32##
33{ 'enum': 'QCryptoSecretFormat',
34  'prefix': 'QCRYPTO_SECRET_FORMAT',
35  'data': ['raw', 'base64']}
36
37
38##
39# @QCryptoHashAlgorithm:
40#
41# The supported algorithms for computing content digests
42#
43# @md5: MD5. Should not be used in any new code, legacy compat only
44# @sha1: SHA-1. Should not be used in any new code, legacy compat only
45# @sha224: SHA-224. (since 2.7)
46# @sha256: SHA-256. Current recommended strong hash.
47# @sha384: SHA-384. (since 2.7)
48# @sha512: SHA-512. (since 2.7)
49# @ripemd160: RIPEMD-160. (since 2.7)
50# Since: 2.6
51##
52{ 'enum': 'QCryptoHashAlgorithm',
53  'prefix': 'QCRYPTO_HASH_ALG',
54  'data': ['md5', 'sha1', 'sha224', 'sha256', 'sha384', 'sha512', 'ripemd160']}
55
56
57##
58# @QCryptoCipherAlgorithm:
59#
60# The supported algorithms for content encryption ciphers
61#
62# @aes-128: AES with 128 bit / 16 byte keys
63# @aes-192: AES with 192 bit / 24 byte keys
64# @aes-256: AES with 256 bit / 32 byte keys
65# @des-rfb: RFB specific variant of single DES. Do not use except in VNC.
66# @3des: 3DES(EDE) with 192 bit / 24 byte keys (since 2.9)
67# @cast5-128: Cast5 with 128 bit / 16 byte keys
68# @serpent-128: Serpent with 128 bit / 16 byte keys
69# @serpent-192: Serpent with 192 bit / 24 byte keys
70# @serpent-256: Serpent with 256 bit / 32 byte keys
71# @twofish-128: Twofish with 128 bit / 16 byte keys
72# @twofish-192: Twofish with 192 bit / 24 byte keys
73# @twofish-256: Twofish with 256 bit / 32 byte keys
74# Since: 2.6
75##
76{ 'enum': 'QCryptoCipherAlgorithm',
77  'prefix': 'QCRYPTO_CIPHER_ALG',
78  'data': ['aes-128', 'aes-192', 'aes-256',
79           'des-rfb', '3des',
80           'cast5-128',
81           'serpent-128', 'serpent-192', 'serpent-256',
82           'twofish-128', 'twofish-192', 'twofish-256']}
83
84
85##
86# @QCryptoCipherMode:
87#
88# The supported modes for content encryption ciphers
89#
90# @ecb: Electronic Code Book
91# @cbc: Cipher Block Chaining
92# @xts: XEX with tweaked code book and ciphertext stealing
93# @ctr: Counter (Since 2.8)
94# Since: 2.6
95##
96{ 'enum': 'QCryptoCipherMode',
97  'prefix': 'QCRYPTO_CIPHER_MODE',
98  'data': ['ecb', 'cbc', 'xts', 'ctr']}
99
100
101##
102# @QCryptoIVGenAlgorithm:
103#
104# The supported algorithms for generating initialization
105# vectors for full disk encryption. The 'plain' generator
106# should not be used for disks with sector numbers larger
107# than 2^32, except where compatibility with pre-existing
108# Linux dm-crypt volumes is required.
109#
110# @plain: 64-bit sector number truncated to 32-bits
111# @plain64: 64-bit sector number
112# @essiv: 64-bit sector number encrypted with a hash of the encryption key
113# Since: 2.6
114##
115{ 'enum': 'QCryptoIVGenAlgorithm',
116  'prefix': 'QCRYPTO_IVGEN_ALG',
117  'data': ['plain', 'plain64', 'essiv']}
118
119##
120# @QCryptoBlockFormat:
121#
122# The supported full disk encryption formats
123#
124# @qcow: QCow/QCow2 built-in AES-CBC encryption. Use only
125#        for liberating data from old images.
126# @luks: LUKS encryption format. Recommended for new images
127#
128# Since: 2.6
129##
130{ 'enum': 'QCryptoBlockFormat',
131#  'prefix': 'QCRYPTO_BLOCK_FORMAT',
132  'data': ['qcow', 'luks']}
133
134##
135# @QCryptoBlockOptionsBase:
136#
137# The common options that apply to all full disk
138# encryption formats
139#
140# @format: the encryption format
141#
142# Since: 2.6
143##
144{ 'struct': 'QCryptoBlockOptionsBase',
145  'data': { 'format': 'QCryptoBlockFormat' }}
146
147##
148# @QCryptoBlockOptionsQCow:
149#
150# The options that apply to QCow/QCow2 AES-CBC encryption format
151#
152# @key-secret: #optional the ID of a QCryptoSecret object providing the
153#              decryption key. Mandatory except when probing image for
154#              metadata only.
155#
156# Since: 2.6
157##
158{ 'struct': 'QCryptoBlockOptionsQCow',
159  'data': { '*key-secret': 'str' }}
160
161##
162# @QCryptoBlockOptionsLUKS:
163#
164# The options that apply to LUKS encryption format
165#
166# @key-secret: #optional the ID of a QCryptoSecret object providing the
167#              decryption key. Mandatory except when probing image for
168#              metadata only.
169# Since: 2.6
170##
171{ 'struct': 'QCryptoBlockOptionsLUKS',
172  'data': { '*key-secret': 'str' }}
173
174
175##
176# @QCryptoBlockCreateOptionsLUKS:
177#
178# The options that apply to LUKS encryption format initialization
179#
180# @cipher-alg: #optional the cipher algorithm for data encryption
181#              Currently defaults to 'aes'.
182# @cipher-mode: #optional the cipher mode for data encryption
183#               Currently defaults to 'cbc'
184# @ivgen-alg: #optional the initialization vector generator
185#             Currently defaults to 'essiv'
186# @ivgen-hash-alg: #optional the initialization vector generator hash
187#                  Currently defaults to 'sha256'
188# @hash-alg: #optional the master key hash algorithm
189#            Currently defaults to 'sha256'
190# @iter-time: #optional number of milliseconds to spend in
191#             PBKDF passphrase processing. Currently defaults
192#             to 2000. (since 2.8)
193# Since: 2.6
194##
195{ 'struct': 'QCryptoBlockCreateOptionsLUKS',
196  'base': 'QCryptoBlockOptionsLUKS',
197  'data': { '*cipher-alg': 'QCryptoCipherAlgorithm',
198            '*cipher-mode': 'QCryptoCipherMode',
199            '*ivgen-alg': 'QCryptoIVGenAlgorithm',
200            '*ivgen-hash-alg': 'QCryptoHashAlgorithm',
201            '*hash-alg': 'QCryptoHashAlgorithm',
202            '*iter-time': 'int'}}
203
204
205##
206# @QCryptoBlockOpenOptions:
207#
208# The options that are available for all encryption formats
209# when opening an existing volume
210#
211# Since: 2.6
212##
213{ 'union': 'QCryptoBlockOpenOptions',
214  'base': 'QCryptoBlockOptionsBase',
215  'discriminator': 'format',
216  'data': { 'qcow': 'QCryptoBlockOptionsQCow',
217            'luks': 'QCryptoBlockOptionsLUKS' } }
218
219
220##
221# @QCryptoBlockCreateOptions:
222#
223# The options that are available for all encryption formats
224# when initializing a new volume
225#
226# Since: 2.6
227##
228{ 'union': 'QCryptoBlockCreateOptions',
229  'base': 'QCryptoBlockOptionsBase',
230  'discriminator': 'format',
231  'data': { 'qcow': 'QCryptoBlockOptionsQCow',
232            'luks': 'QCryptoBlockCreateOptionsLUKS' } }
233
234
235##
236# @QCryptoBlockInfoBase:
237#
238# The common information that applies to all full disk
239# encryption formats
240#
241# @format: the encryption format
242#
243# Since: 2.7
244##
245{ 'struct': 'QCryptoBlockInfoBase',
246  'data': { 'format': 'QCryptoBlockFormat' }}
247
248
249##
250# @QCryptoBlockInfoLUKSSlot:
251#
252# Information about the LUKS block encryption key
253# slot options
254#
255# @active: whether the key slot is currently in use
256# @key-offset: offset to the key material in bytes
257# @iters: #optional number of PBKDF2 iterations for key material
258# @stripes: #optional number of stripes for splitting key material
259#
260# Since: 2.7
261##
262{ 'struct': 'QCryptoBlockInfoLUKSSlot',
263  'data': {'active': 'bool',
264           '*iters': 'int',
265           '*stripes': 'int',
266           'key-offset': 'int' } }
267
268
269##
270# @QCryptoBlockInfoLUKS:
271#
272# Information about the LUKS block encryption options
273#
274# @cipher-alg: the cipher algorithm for data encryption
275# @cipher-mode: the cipher mode for data encryption
276# @ivgen-alg: the initialization vector generator
277# @ivgen-hash-alg: #optional the initialization vector generator hash
278# @hash-alg: the master key hash algorithm
279# @payload-offset: offset to the payload data in bytes
280# @master-key-iters: number of PBKDF2 iterations for key material
281# @uuid: unique identifier for the volume
282# @slots: information about each key slot
283#
284# Since: 2.7
285##
286{ 'struct': 'QCryptoBlockInfoLUKS',
287  'data': {'cipher-alg': 'QCryptoCipherAlgorithm',
288           'cipher-mode': 'QCryptoCipherMode',
289           'ivgen-alg': 'QCryptoIVGenAlgorithm',
290           '*ivgen-hash-alg': 'QCryptoHashAlgorithm',
291           'hash-alg': 'QCryptoHashAlgorithm',
292           'payload-offset': 'int',
293           'master-key-iters': 'int',
294           'uuid': 'str',
295           'slots': [ 'QCryptoBlockInfoLUKSSlot' ] }}
296
297##
298# @QCryptoBlockInfoQCow:
299#
300# Information about the QCow block encryption options
301#
302# Since: 2.7
303##
304{ 'struct': 'QCryptoBlockInfoQCow',
305  'data': { }}
306
307
308##
309# @QCryptoBlockInfo:
310#
311# Information about the block encryption options
312#
313# Since: 2.7
314##
315{ 'union': 'QCryptoBlockInfo',
316  'base': 'QCryptoBlockInfoBase',
317  'discriminator': 'format',
318  'data': { 'qcow': 'QCryptoBlockInfoQCow',
319            'luks': 'QCryptoBlockInfoLUKS' } }
320