]> git.proxmox.com Git - swtpm.git/blame - man/man8/swtpm.pod
swtpm: Advertise --migration option in capabilities JSON
[swtpm.git] / man / man8 / swtpm.pod
CommitLineData
f163b202
SB
1=head1 NAME
2
5311e60e 3swtpm - TPM Emulator for TPM 1.2 and 2.0
f163b202
SB
4
5=head1 SYNOPSIS
6
7B<swtpm socket [OPTIONS]>
8
29cfd0a4
SB
9B<swtpm chardev [OPTIONS]>
10
78c5f924
SB
11B<swtpm cuse [OPTIONS]>
12
f163b202
SB
13=head1 DESCRIPTION
14
15B<swtpm> implements a TPM software emulator built on libtpms.
29cfd0a4 16It provides access to TPM functionality over a TCP/IP socket interface
78c5f924
SB
17or it can listend for commands on a character device, or create a CUSE
18(character device in userspace) interface for receiving of TPM commands.
f163b202
SB
19
20Unless corresponding command line parameters are used, the
29cfd0a4 21B<swtpm> socket version requires that the environment variable I<TPM_PORT>
f163b202
SB
22be set to the TCP/IP port the process is supposed to listen on for TPM
23request messages.
24
bc525ccd 25Similarly, the environment variable I<TPM_PATH> can be set and
f163b202 26contain the name of a directory where the TPM can store its persistent
bc525ccd 27state into.
f163b202 28
29cfd0a4 29The B<swtpm> process can be gracefully terminated by sending a
f163b202
SB
30I<SIGTERM> signal to it.
31
78c5f924
SB
32The B<swtpm> cuse version requires root rights to start the TPM.
33
29cfd0a4
SB
34=head1 Options for socket interface
35
f163b202
SB
36The following options are supported if the I<socket> interface is chosen:
37
38=over 4
39
40=item B<-p|--port <port>>
41
42Use the given port rather than using the environment variable TPM_PORT.
43
29cfd0a4
SB
44=item B<-t|--terminate>
45
46Terminate the TPM after the client has closed the connection.
47
fb5256bf 48=item B<--server [type=tcp][,port=E<lt>portE<gt>[,bindaddr=E<lt>addressE<gt> [,ifname=E<lt>ifnameE<gt>]]][,fd=E<lt>fdE<gt>][,disconnect]>
7c0a033f
SB
49
50Expect TCP connections on the given port; if a port is not provided a file descriptor
51must be passed with the fd parameter and the commands are read from this file
52descriptor then.
16eb0ff2
SB
53If a port is provided the I<bind address> on which to listen for TCP connections
54can be provided as well; the default bind address is 127.0.0.1. If a link
2bc601bb 55local IPv6 address is provided, the name of the interface to bind to must be
16eb0ff2 56provided with I<ifname>.
7c0a033f
SB
57
58This parameter enables a persistent connection by default unless the disconnect option
59is given. This parameter should be used rather than the -p and --fd options.
60
fb5256bf 61=item B<--server type=unixio[,path=E<lt>pathE<gt>][,fd=E<lt>fdE<gt>] [,mode=E<lt>0...E<gt>][,uid=E<lt>uidE<gt>][,gid=E<lt>gidE<gt>]>
73823529 62
682fe581 63Expect UnixIO connections on the given path. If no path is provided, a file descriptor
2bc601bb 64must be passed instead. The mode parameter allows a user to set the file mode bits of the
682fe581 65UnixIO path. The mode bits value must be given as an octal number starting with a '0'.
f34e01a5
SB
66The default value is 0770. uid and gid set the ownership of the UnixIO socket's path.
67This operation requires root privileges.
73823529 68
29cfd0a4
SB
69=back
70
71
72=head1 Options for character device interface
73
78c5f924 74The following options are supported if the I<chardev> interface is chosen:
29cfd0a4
SB
75
76=over 4
77
78=item B<-c|--chardev <device path>>
79
80Use the given device to listen for TPM commands and send response on.
81
ee8b6c2d
SB
82=item B<--vtpm-proxy>
83
84Create a Linux vTPM proxy device instance and read TPM commands from its
85backend device.
86
29cfd0a4
SB
87=back
88
89
78c5f924 90=head1 Options for the CUSE interface
29cfd0a4 91
78c5f924 92The following options are supported if the I<cuse> interface is chosen:
29cfd0a4
SB
93
94=over 4
95
78c5f924 96=item B<-n|--name <NAME>>
f163b202 97
78c5f924
SB
98The TPM will use a device with the given name. A device with the given name
99will be created in /dev. This is a mandatory option.
100
101=item B<-M|--maj <MAJOR>>
102
103Create the device with the given major number.
104
105=item B<-m|--min <MINOR>>
106
107Create the device with the given minor number.
108
78c5f924
SB
109=back
110
111
112=head1 Options for socket and character device interfaces:
113
114The following options are supported by the socket and character device interfaces:
115
116=over 4
f163b202
SB
117
118=item B<-f|--fd <fd>>
119
29cfd0a4
SB
120Use the given socket file descriptor or character device file descriptor
121for receiving TPM commands and sending responses.
122For the socket interface, this option automatically assumes -t.
f163b202 123
78c5f924
SB
124=item B<-d|--daemon>
125
126Daemonize the process.
127
fb5256bf 128=item B<--ctrl type=[unixio|tcp][,path=E<lt>pathE<gt>] [,port=E<lt>portE<gt>[,bindaddr=E<lt>addressE<gt>[,ifname=E<lt>ifnameE<gt>]]] [,fd=E<lt>filedescriptorE<gt>|clientfd=E<lt>filedescriptorE<gt>] [,mode=E<lt>0...E<gt>][,uid=E<lt>uidE<gt>][,gid=E<lt>gidE<gt>] >
9ddc6998
SB
129
130This option adds a control channel to the TPM. The control channel can either use a UnixIO socket with
131a given I<path> or I<filedescriptor> or it can use a TCP socket on the given I<port> or I<filedescriptor>.
16eb0ff2
SB
132If a port is provided the I<bind address> on which to listen for TCP connections
133can be provided as well; the default bind address is 127.0.0.1. If a link
2bc601bb 134local IPv6 address is provided, the name of the interface to bind to must be
16eb0ff2 135provided with I<ifname>.
9ddc6998 136
2bc601bb 137The mode parameter allows a user to set the file mode bits of the UnixIO path.
682fe581 138The mode bits value must be given as an octal number starting with a '0'.
f34e01a5
SB
139The default value is 0770. uid and gid set the ownership of the UnixIO socket's path.
140This operation requires root privileges.
682fe581 141
9ddc6998
SB
142The control channel enables out-of-band control of the TPM, such as resetting the TPM.
143
78c5f924
SB
144=back
145
146
147=head1 Options for all interfaces
148
149The following options are support by all interfaces:
150
151=over 4
152
b82eb7e7 153=item B<--tpmstate dir=E<lt>dirE<gt>[,mode=E<lt>0...E<gt>]|backend-uri=E<lt>uriE<gt>>
78c5f924
SB
154
155Use the given path rather than using the environment variable TPM_PATH.
156
b82eb7e7
ET
157If I<dir> is specified, the TPM state files will be written to the I<dir> with
158the given file I<mode> bits. This value must be given as an octal number starting with a '0'.
640f1fab
SB
159The default value is 0640.
160
b82eb7e7 161If I<backend-uri> is specified, the TPM state data will be stored to the URI.
b129b8df
SR
162Currently I<backend-uri=dir://<path_to_dir>> and I<backend-uri=file://<path_to_dir>>
163are available. For 'dir://', the URI should specify the path to the directory where
164files are stored. If I<path_to_dir> starts with a '/' then the path is interpreted
165as an absolute path, otherwise it is a path relative to the current directory.
166For 'file://', the URI should specify a single file or block device where TPM state
167will be stored. A blockdevice must exist already and be big enough to store all
4641f19f 168state. (since v0.7)
b82eb7e7 169
fbc596ab
SB
170=item B<--tpm2>
171
172Choose TPM 2 functionality; by default a TPM 1.2 is chosen.
173
fb5256bf 174=item B<--log [fd=E<lt>fdE<gt>|file=E<lt>pathE<gt>][,level=E<lt>nE<gt>] [,prefix=E<lt>prefixE<gt>][,truncate]>
f163b202
SB
175
176Enable logging to a file given its file descriptor or its path. Use '-' for path to
177suppress the logging.
178
2bc601bb 179The level parameter allows a user to choose the level of logging. Starting at log
e8b5115f
SB
180level 5, libtpms debug logging is activated.
181
93f4a389
SB
182All logged lines will be prefixed with prefix. By default no prefix is prepended.
183
3760c342
SB
184If I<truncate> is passed, the log file will be truncated.
185
a2f81ea2 186=item B<--locality reject-locality-4[,allow-set-locality]>
4a565414
SB
187
188The I<reject-locality-4> parameter will cause TPM error messages to be
189returned for requests to set the TPM into locality 4.
190
a2f81ea2
SB
191The I<allow-set-locality> parameter allows the swtpm to receive
192TPM/TPM2_SetLocality commands. This is parameter is useful if the Linux
193VTPM proxy driver access is enabled by file descriptor passing.
194This option is implied by the I<--vtpm-proxy> option and therefore need not
2bc601bb 195be explicitly set if this option is passed. In all other cases care should be
a2f81ea2
SB
196taken as to who can send the TPM/TPM2_SetLocality command.
197
fb5256bf 198=item B<--key file=E<lt>keyfileE<gt>|fd=E<lt>fdE<gt> [,format=E<lt>hex|binaryE<gt>][,mode=aes-cbc|aes-256-cbc], [remove[=true|false]]>
f163b202
SB
199
200Enable encryption of the state files of the TPM. The keyfile must contain
68a5b241 201an AES key of supported size; 128 bit (16 bytes) and 256 bit (32 bytes) keys are
f163b202
SB
202supported.
203
68a5b241
SB
204The key may be in binary format, in which case the file size must be 16 or
20532 bytes. If the key is in hex format (default), the key may consist of 32
206or 64 hex digits starting with an optional '0x'.
f163b202
SB
207
208The I<mode> parameter indicates which block chaining mode is to be used.
68a5b241
SB
209Currently aes-cbc (aes-128-cbc) and aes-256-cbc are supported.
210The encrypted data is integrity protected using encrypt-then-mac.
f163b202
SB
211
212The I<remove> parameter will attempt to remove the given keyfile once the key
213has been read.
214
fb5256bf 215=item B<--key pwdfile=E<lt>passphrase fileE<gt>|pwdfd=E<lt>fdE<gt> [,mode=aes-cbc|aes-256-cbc][remove[=true|false]][,kdf=sha512|pbkdf2]>
f163b202 216
2bc601bb 217This variant of the key parameter allows a user to provide a passphrase in a file.
a39f098f
SB
218The file is read and a key is derived from it using either a SHA512 hash
219or PBKDF2. By default PBKDF2 is used.
f163b202 220
fb5256bf 221=item B<--migration-key file=E<lt>keyfileE<gt>|fd=E<lt>fdE<gt> [,format=E<lt>hex|binaryE<gt>][,mode=aes-cbc|aes-256-cbc] [,remove[=true|false]]>
84259c17
SB
222
223The availability of a migration key ensures that the state of the TPM
224will not be revealed in unencrypted form when
2bc601bb 225the TPM state blobs are retrieved through the ioctl interface.
84259c17
SB
226The migration key is not used for encrypting TPM state written to files,
227this is what the I<--key> parameter is used for.
228
229The migration key and the key used for encrypting the TPM state files may be the same.
230
231While the key for the TPM state files needs to stay with those files it encrypts, the
232migration key needs to stay with the TPM state blobs. If for example the state of the
233TPM is migrated between hosts in a data center, then the TPM migration key must be
234available at all the destinations, so in effect it may have to be a key shared across
235all machines in the datacenter. In contrast to that, the key used for encrypting the
236TPM state B<files> can be different for each TPM and need only be available
237on the host where the TPM state resides.
238
68a5b241
SB
239The migration key enables the encryption of the TPM state blobs.
240The keyfile must contain an AES key of supported size; 128 bit (16 bytes)
241and 256 bit (32 bytes) keys are supported.
84259c17 242
68a5b241
SB
243The key may be in binary format, in which case the file size must be 16 or
24432 bytes. If the key is in hex format (default), the key may consist of 32
245or 64 hex digits starting with an optional '0x'.
84259c17
SB
246
247The I<mode> parameter indicates which block chaining mode is to be used.
68a5b241
SB
248Currently aes-cbc (aes-128-cbc) and aes-256-cbc are supported.
249The encrypted data is integrity protected using encrypt-then-mac.
84259c17
SB
250
251The I<remove> parameter will attempt to remove the given keyfile once the key
252has been read.
253
fb5256bf 254=item B<--migration-key pwdfile=E<lt>passphrase fileE<gt>|pwdfd=E<lt>fdE<gt> [,mode=aes-cbc|aes-256-cbc][,remove[=true|false]][,pdf=sha512|pbkdf2]>
a39f098f 255
2bc601bb 256This variant of the key parameter allows a user to provide a passphrase in a file.
a39f098f
SB
257The file is read and a key is derived from it using either a SHA512 hash
258or PBKDF2. By default PBKDF2 is used.
84259c17 259
db608775 260=item B<--pid file=E<lt>pidfileE<gt>|fd=E<lt>filedescriptorE<gt>>
b2151737 261
2bc601bb 262This options allows a user to set the name of file where the process ID (pid) of the TPM
db608775
SB
263will be written into. It is also possible to pass a file descriptor to a file that
264has been opened for writing.
b2151737 265
bb420d74
SB
266=item B<-r|--runas E<lt>ownerE<gt>>
267
268Switch to the given user. This option can only be used when swtpm is started as root.
269
68e54284
JH
270=item B<-R|--chroot E<lt>path<gt>>
271
272Chroot to the given directory at startup. This option can only be used when swtpm is
273started as root.
274
08e619ad 275=item B<--seccomp action=none|log|kill> (since v0.2)
9cd723d8 276
2bc601bb 277This option allows a user to select the action to take by the seccomp profile when
9cd723d8
SB
278a syscall is executed that is not allowed. The default is I<kill>. To disable
279the seccomp profile, choose I<none>. The I<log> action logs offending syscalls.
280The I<log> action is only available if libseccomp supports logging.
281
282This option is only available on Linux and only if swtpm was compiled with
283libseccomp support.
284
97e910af 285=item B<--flags [not-need-init][,startup-clear|startup-state|startup-deactivated|startup-none][,disable-auto-shutdown]>
ab40d27a
SB
286
287The I<not-need-init> flag enables the TPM to accept TPM commands right after
288start without requiring an INIT to be sent to it through the command channel
289(see the '-i' option of swtpm_ioctl).
290
291The I<startup> options cause a TPM_Startup or TPM2_Startup command to
292automatically be sent. The I<startup-deactivated> option is only valid for
293a TPM 1.2. These options imply I<not-need-init>, except for the
294I<startup-none> option, which results in no command being sent.
295
296If I<--vtpm-proxy> is used, I<startup-clear> is automatically chosen but
297this can be changed with this option.
298
97e910af
SB
299The I<disable-auto-shutdown> flag prevents swtpm from automatically sending a
300TPM2_Shutdown() before the reset of a TPM 2 or before the swtpm process
301is terminated. When this flag is not provide swtpm will send this command to
302avoid increasing the dictionary attack (DA) lockout counter and ulimately
303a DA lockout by the TPM 2 due to omission of sending a required TPM2_Shutdown()
304before TPM 2 reset or swtpm process termination.
305
14ae05b1
SB
306=item B<--print-capabilities> (since v0.2)
307
308Print capabilities that were added to swtpm after version 0.1. The output
309may contain the following:
310
311 {
312 "type": "swtpm",
313 "features": [
55404e26
MAL
314 "tpm-1.2",
315 "tpm-2.0",
14ae05b1
SB
316 "cmdarg-seccomp",
317 "cmdarg-key-fd",
318 "cmdarg-pwd-fd",
e6cbc55d 319 "cmdarg-print-states",
cdc39fd9 320 "cmdarg-chroot",
e821754b 321 "cmdarg-migration",
86931b4f 322 "nvram-backend-dir",
0716f994 323 "nvram-backend-file",
14ae05b1 324 "tpm-send-command-header",
c6b52d18 325 "flags-opt-startup",
97e910af 326 "flags-opt-disable-auto-shutdown",
c6b52d18
SB
327 "rsa-keysize-1024",
328 "rsa-keysize-2048",
329 "rsa-keysize-3072"
55404e26
MAL
330 ],
331 "version": "0.7.0"
14ae05b1
SB
332 }
333
4641f19f 334The version field is available since v0.7.
55404e26 335
14ae05b1
SB
336The meaning of the feature verbs is as follows:
337
338=over 4
339
4641f19f 340=item B<tpm-1.2> (since v0.7)
55404e26
MAL
341
342TPM 1.2 emulation is supported (libtpms is compiled with 1.2 support).
343
4641f19f 344=item B<tpm-2.0> (since v0.7)
55404e26
MAL
345
346TPM 2 emulation is supported (libtpms is compiled with 2.0 support).
347
348(the I<--tpm2> option is supported)
349
4641f19f 350=item B<cmdarg-seccomp> (since v0.2)
14ae05b1
SB
351
352The I<--seccomp> option is supported.
353
4641f19f 354=item B<cmdarg-key-fd> (since v0.2)
14ae05b1
SB
355
356The I<--key> option supports the I<fd=> parameter.
357
4641f19f 358=item B<cmdarg-pwd-fd> (since v0.2)
14ae05b1
SB
359
360The I<--key> option supports the I<pwdfd=> parameter.
361
4641f19f 362=item B<cmdarg-print-states> (since v0.7)
e6cbc55d
SB
363
364The I<--print-states> option is supported.
365
cdc39fd9
SB
366=item B<cmdarg-chroot> (since v0.8)
367
368The I<--chroot> option is supported.
369
e821754b
SB
370=item B<cmdarg-migration> (since v0.8)
371
372The I<--migration> option is supported.
373
4641f19f 374=item B<nvram-backend-dir> (since v0.7)
86931b4f 375
225d7009
SB
376The I<--tpmstate> option supports the I<backend-uri=dir://...>
377parameter.
378
4641f19f 379=item B<nvram-backend-file> (since v0.7)
225d7009
SB
380
381The I<--tpmstate> option supports the I<backend-uri=file://...>
382parameter.
86931b4f 383
4641f19f 384=item B<tpm-send-command-header> (since v0.2)
14ae05b1
SB
385
386The TPM 2 commands may be prefixed by a header that carries a 4-byte
387command, 1 byte for locality, and 4-byte TPM 2 command length indicator.
388The TPM 2 will respond by preprending a 4-byte response indicator and a
3894-byte trailer. All data is sent in big endian format.
390
4641f19f 391=item B<flags-opt-startup> (since v0.3)
041a70e7
SB
392
393The I<--flags> option supports the I<startup-...> options.
394
97e910af
SB
395=item B<flags-opt-disable-auto-shutdown> (since v0.8)
396
397The I<--flags> option supports the I<disable-auto-shutdown> flag.
398
4641f19f 399=item B<rsa-keysize-2048> (since v0.4)
c6b52d18
SB
400
401The TPM 2 supports the shown RSA key sizes. If none of the
402rsa-keysize verbs is shown then only RSA 2048 bit keys are supported.
403
14ae05b1
SB
404=back
405
4641f19f 406=item B<--print-states> (since v0.7)
e6cbc55d
SB
407
408This option allows to print out the TPM 1.2 or TPM 2 state blobs
409that are currently stored in a storage backend. This option requires
410that the storage backend be specified using the I<--tpmstate> option
411and if TPM 2 state blobs are supposed to be shown, the I<--tpm2>
412option must be passed.
413
414The following shows the JSON output of this option. It indicates that
415the 'permall' and 'volatile' states are available.
416
417 {
418 "type": "swtpm",
419 "states": [
420 {
421 "name": "permall",
422 "size": 6013
423 }, {
424 "name": "volatile",
425 "size": 1087
426 }
427 ]
428 }
429
120d4146 430=item B<--migration [incoming][,release-lock-outgoing]>
8a2bbece
SB
431
432This option allows to control the locking of the NVRAM storage
433for the purpose of supporting migration between hosts that have
434shared storage setup for the swtpm's state directory and if
435locking is supported by the storage backend. The directory storage
436backend for example supports locking and therefore requires usage
437of this option in case of shared storage.
438When providing the I<incoming> option parameter swtpm defers the
439locking of the NVRAM until the state blobs are received or until the
440first TPM command is processed if no state blobs were received.
120d4146
SB
441The I<release-lock-outgoing> option parameter causes swtpm to
442release any NVRAM lock once the TPM's 'savestate' blob is received
443from swtpm. To avoid releasing the lock too early the 'permanent'
444and 'volatile' state blobs must be received before the 'savestate'
445blob.
8a2bbece 446
f163b202
SB
447=item B<-h|--help>
448
449Display usage info.
450
451=back
452
9b3add22
SB
453=head1 NOTES
454
455If a TPM 2 is used, the user is typically required to send a TPM2_Shutdown()
456command to a TPM 2 to avoid possibly increasing the TPM_PT_LOCKOUT_COUNTER
457that may lead to a dictionary attack (DA) lockout upon next startup
458(TPM2_Startup()) of the TPM 2. Whether the TPM_PT_LOCKOUT_COUNTER is
459increased depends on previous commands sent to the TPM 2 as well as
460internal state of the TPM 2. One example that will trigger the counter to
461increase is the omission of a password when trying to access a
462password-protected object or NVRAM location that has the DA attribute set,
463followed by termination of swtpm without sending TPM2_Shutdown(). To avoid
464a DA lockout swtpm will make a best-effort and send a TPM2_Shutdown(SU_STATE)
465or TPM2_Shutdown(SU_CLEAR) if found necessary.
f163b202
SB
466
467=head1 SEE ALSO
468
78c5f924 469B<swtpm_bios>, B<swtpm_cuse>