Commit Graph

145 Commits

Author SHA1 Message Date
Stefan Berger
14e8d022eb man: Add missing .config directory to path description when using ${HOME}
When the ${HOME} directory is used for finding swtpm_setup.conf it is
to be found in ${HOME}/.config/swtpm_setup.conf.

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
Resolves: https://github.com/stefanberger/swtpm/issues/664
2022-03-07 09:16:11 -05:00
Stefan Berger
25d4ac2d3a swtpm_setup: Add support for --reconfigure flag to change active PCR banks
Add support for --reconfigure option for the swtpm_setup to be able to
change the active PCR banks. This option only works with --tpm2 and does
not allow to pass several other options such --create-ek or
--create-ek-cert or --create-platform-cert that would alter the state of
the TPM 2 in other ways.

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2021-11-05 06:39:49 -04:00
Stefan Berger
a5cc0bf6e2 swtpm_setup: Get active PCR banks from swtpm_setup.conf
If the user did not provide the PCR banks to activate through the command
line options, try to read it from the config file and if nothing is found
there, fall back to the DEFAULT_PCR_BANKS as set during configure time.

Move the check for the PCR banks after the access check to the
configuration file.

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2021-10-29 15:36:35 -04:00
Stefan Berger
4641f19f21 man: Add version when feature was added when missing fix some others
Add the version to items indicating when the feature was added.
Fix and unify some other ones.

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2021-10-29 15:16:15 -04:00
Stefan Berger
db61aeddeb man: Improve the documentation of swtpm_setup's --create-config-files
Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2021-10-19 10:42:46 -04:00
Stefan Berger
a7254fab5e swtpm_setup: Implement --create-user-config skip-if-exist
Implement support for skipping over creating the files
if any one of the config files already exist.

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2021-10-07 14:27:10 -04:00
Stefan Berger
2b60723766 swtpm_setup: Implement option --create-config-files to create config files
Implement the option --create-config-files to create config files
for swtpm_setup and swtpm-localca for a user account. The files will
be created under the $XDG_CONFIG_HOME or $HOME/.config directories.

This option supports optional arguments 'overwrite' to allow overwriting
existing config files as well as the optional argument 'root' to create
config files under root's home directory. Both options can be passed
by separating them with a ','.

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2021-10-07 14:27:10 -04:00
Stefan Berger
225d7009ba man: Enumerate the nvram-backend-dir separately
Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2021-10-06 19:25:41 -04:00
Stefan Berger
e6cbc55df6 swtpm: Display the --print-states capability and document it
Display the --print-states capability in the --print-capabilites
output as cmdarg-print-states.

Document availability in the man page.

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2021-10-06 19:25:41 -04:00
Stefan Reiter
a4555cb887 swtpm_setup: mention dir:// and file:// in man page and usage
Signed-off-by: Stefan Reiter <stefan@pimaker.at>
2021-10-05 11:54:42 -04:00
Stefan Reiter
0716f994be swtpm: Add "nvram-backend-linear" capability
Signed-off-by: Stefan Reiter <stefan@pimaker.at>
2021-10-05 09:01:30 -04:00
Stefan Reiter
b129b8dfd1 swtpm: Add "file://" backend to man page
Signed-off-by: Stefan Reiter <stefan@pimaker.at>
2021-10-05 09:01:30 -04:00
Eiichi Tsukata
86931b4f30 swtpm: Add "nvram-backend-dir" capability
Append "nvram-backend-dir" to --print-capabilities output.

Signed-off-by: Eiichi Tsukata <eiichi.tsukata@nutanix.com>
2021-08-13 06:35:18 -04:00
Eiichi Tsukata
b82eb7e788 swtpm: Add options for pluggable backend (--tpmstate backend-uri)
Add an options to specify pluggable backend URI.

Ex:
  --tpmstate backend-uri=dir://<path_to_dir>

Backend URI is specific to each backend plugin which points to the
location of the NVRAM files.
Currently, "dir" is the only one available backend. In this case
backend-uri should be a path to the directory where files are stored.

This option is designed to compatible with existing "dir" option.
If "dir" is specified, swtpm prioritize "dir" ignoring "backend-uri".

Signed-off-by: Eiichi Tsukata <eiichi.tsukata@nutanix.com>
2021-08-13 06:35:18 -04:00
Stefan Berger
3eac247752 swtpm_setup: Add support for checking for TPM 1.2 and TPM 2 support
Implement get_supported_tpm_versions to get swtpm's support for TPM 1.2
and TPM 2 and use it error out in case user choose a TPM version that
is not supported. Also display the supported TPM versions in the
capabilites JSON.

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2021-08-10 09:38:48 -04:00
Marc-André Lureau
55404e260b man: update man pages with new capabilities
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
2021-08-10 07:13:24 -04:00
Stefan Berger
78559edde9 swtpm_setup: Support --write-ek-cert-files as an option
Write the EK certificate files into the directory specified as parameter
to the --write-ek-cert-files option.

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2021-07-30 16:45:22 -04:00
Nick Chevsky
3d5ae5e1d6 Change swtpm-localca to swtpm_localca in manpages
- Move content of swtpm-localca(8) manual page to swtpm_localca(8)
  and make swtpm-localca(8) an alias for swtpm_localca(8), mirroring
  the fact that /usr/bin/swtpm_localca is the actual program and
  /usr/share/swtpm/swtpm-localca a wrapper for it.
- Change references to `swtpm-localca` in manual pages' content to
  `swtpm_localca`, reflecting the actual name of the program they are
  meant to document.

Signed-off-by: Nick Chevsky <nchevsky@users.noreply.github.com>
2021-07-27 20:05:41 -04:00
Nick Chevsky
bb6d019a2e Remove obsolete manpage for swtpm_setup.sh(8)
swtpm_setup.sh was replaced by swtpm_setup in v0.5.0.

Signed-off-by: Nick Chevsky <nchevsky@users.noreply.github.com>
2021-07-21 16:05:54 -04:00
Nick Chevsky
aab15ef386 Correct old reference to swtpm_setup.sh in manpage
swtpm_setup.sh(8) was replaced by swtpm_setup(8) in v0.5.0.

Signed-off-by: Nick Chevsky <nchevsky@users.noreply.github.com>
2021-07-21 07:55:32 -04:00
Nick Chevsky
cbd3d39d0e Add missing title to swtpm-create-tpmca(8) manual page
Fixes `bad-whatis-entry` Lintian warning [1].

[1] https://lintian.debian.org/tags/bad-whatis-entry

Signed-off-by: Nick Chevsky <nchevsky@users.noreply.github.com>
2021-07-21 07:34:26 -04:00
Stefan Berger
3d75c96537 man8: Add missing '\' to list of pod files and reduce EXTRA_DIST files
Add a missing '\' to the list of pod files and reduce the EXTRA_DIST
files list to only those that available via git and not generated.

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2021-07-13 22:19:38 -04:00
Stefan Berger
9b37371807 build-sys: Fix cleanup issue complain by 'make distcheck'
Fix the following `make distcheck` cleanup issue:

ERROR: files left in build directory after distclean:
./man/man8/swtpm_cuse.8

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2021-05-24 12:29:18 -04:00
Stefan Berger
ef1407f56d swtpm_setup: Write note about non-standard EK when using --allow-signing
Write a note in swtpm_setup's help screen and man page that the usage
of --allow-signing will lead to a non-standard EK. Be more precise in the
man page.

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2021-03-01 07:54:27 -05:00
Stefan Berger
4d8b2c9c71 man: Change 'shell variable' to 'environment variable' in swtpm-localca.conf
Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
2021-02-19 15:06:52 -05:00
Lili Zhu
b199d8084e Update the doc of the flag to connect to TPM via UnixIO socket
Modify the flag from "--unixio" to "--unix"

Signed-off-by: Lili Zhu <lizhu@redhat.com>
2021-01-13 07:02:18 -05:00
Stefan Berger
5e9e47337e man8: Mark device parameter as optional
Since the device can be passed using --tpm-device <device>, we now
mark the last parameter, which can also be the device, as optional.

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2020-12-30 08:11:14 -05:00
наб
755881ba27 man: Fix enc[yr]ption typo in swtpm_setup manpage
Signed-off-by: Ahelenia Ziemiańska <nabijaczleweli@nabijaczleweli.xyz>
2020-10-27 22:27:36 -04:00
Stefan Berger
ab40d27ab1 man: Extend man pages with --flags support for CUSE TPM
Also fix an error in the man page on the way. 'startup-deactivated'
can only be used with a TPM 1.2, not a TPM 2.

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2020-10-13 17:08:05 -04:00
Stefan Berger
7b72dfedec samples: swtpm-localca: Pass password via template file when possible
Pass the CA's private key password via the template file. Remove recently
added old GnuTLS support. Extend man page with a paragraph about short-
comings of certtool that doesn't seem to allow private key password being
passed either as environment variable or template file.

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2020-09-21 16:01:20 -04:00
Stefan Berger
14d2d4381d samples: Add support for pkcs11 module environment variables to config file
Add support for pkcs11 module environment variables to the config file.
These variables may have the following format:

   env:VARNAME=VALUE

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2020-09-18 12:09:11 -04:00
Stefan Berger
4cd9390bed man: Extend man pages with further locations of options and config files
Extend the man pages with further locations for the options and config
files in ${XDG_CONFIG_HOME} or ${HOME}/.confg.

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2020-09-18 12:09:11 -04:00
Stefan Berger
cc410ca91b swtpm_setup: Switch over to new python tool and get rid of the bash script
Switch over to the new python implementation of swtpm_setup. We need to
also adjust test cases that involved the tcsd that otherwise fail for
various reasons. For in-place testing we need to adjust the PYTHONPATH
and PATH so that swtpm_setup.py can be found and so that swtpm_setup.py
then finds swtpm if it is not explicitly passed as parameter.

Adjust the man page for swtpm_setup to reflect the changes.

We now can run swtpm_setup as any user. However, libvirt still runs it
as tss:tss (for example), which is then creating the signing key as tss:tss
as well. Ideally libvirt would run it as tss:root or any other combination
since the tss group may be used for user wanting to access /dev/tpmrm0 for
example. We at least change the directory ownership of /var/lib/swtpm-localca
to tss:root and keep the world out of this directory.

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2020-08-28 16:27:15 -04:00
Stefan Berger
0dd19b92f9 man: Adjust and improve the man page for swtpm_setup
Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2020-08-27 13:04:38 -04:00
Stefan Berger
4f56102e96 man: Improve the man page for swtpm_ioctl and add example
Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2020-08-24 13:26:52 -04:00
Stefan Berger
5e39c27f55 man: Update swtpm-localca.options to reflect expected contents and format
Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2020-08-24 13:26:52 -04:00
Stefan Berger
68a1d5943b man: Remove generated man pages from repo and ignore created ones
Remove the generated man pages from the repo and add the file patterns
to .gitignore.

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2020-08-20 09:49:33 -04:00
Stefan Berger
a12b09b1ea samples: Implement script to create user config files and extend man page
Implement a script that creates the user config files in the
${XDG_CONFIG_HOME} directory and sub-directories.

Extend swtpm_setup.pod showing swtpm-create-user-config-files usage.

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2020-08-20 09:49:33 -04:00
Stefan Berger
b6aef51ff3 samples: Escape many more characters before calling eval on an entry
Escape many more special shell characters before calling eval on
an entry to convert a variable to its value. Uncareful writing of
a swtpm-local.conf config file could have lead to files being over-
written using '>' for example.

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2020-08-11 15:01:59 -04:00
Stefan Berger
3392e3ed87 man: Add missing -- to --rsa-keysize in documentation
Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2020-08-09 21:10:25 -04:00
Seunghun Han
2bc601bba5 Fix typos in code and man pages
This patch fixes typos of code and man pages reported by lintian.

Signed-off-by: Seunghun Han <kkamagui@gmail.com>
2020-06-15 08:11:34 -04:00
Seunghun Han
fb5256bfcb Add line breaks in a man page
This patch fixes line break warnings reported by the lintian tool.

Signed-off-by: Seunghun Han <kkamagui@gmail.com>
2020-06-15 08:11:34 -04:00
Stefan Berger
7dc24c2f8c swtpm_setup: Allow to create largest possible EK
By passing '--rsa-keysize max' allow to create the largest possible RSA
EK key.

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2020-05-05 09:12:21 -04:00
Stefan Berger
6c5b7c2d86 swtpm_setup: Add support for RSA 3072 bit EK keys
Extend the creation of the EK key to support also 3072 bits RSA keys.

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2020-05-05 09:12:21 -04:00
Stefan Berger
80d7bb488c swtpm_setup: Report supported RSA key sizes useful for EK key creation
Extend the --print-capabilities option to also report supported RSA
key sizes. Only the TPM 2 may support anything else than 2048 bit RSA
keys, so we only consult 'swtpm socket --tpm2 --print-capabilities'
and grep for 2048 and 3072 key sizes and report them.
If nothing is found, nothing is reported, as before, and 2048 bit RSA
keys should be assumed.

'swtpm_setup --tpm2 --print-capabilities' may now show the following:
{
  "type": "swtpm_setup",
  "features": [
    "cmdarg-keyfile-fd",
    "cmdarg-pwdfile-fd",
    "tpm2-rsa-keysize-2048",
    "tpm2-rsa-keysize-3072"
  ]
}

Also adjust a test case to use a regular expression for matching
against an expected string that may nor may not have rsa-keysize
verbs.

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2020-05-05 09:12:21 -04:00
Stefan Berger
c6b52d18e0 swtpm: Construct RSA key size capabilities from TPMLIB_GetInfo()
Construct RSA key size capability strings from libtpms TPMLIB_GetInfo()
string so that we can easily show which RSA key sizes are supported by
the TPM 2 implementation. If none are advertised, 1024 & 2048 can be
assumed to be supported.

'swtpm socket --tpm2 --print-capabilities' may now print the following:
{
  "type": "swtpm",
  "features": [
    "tpm-send-command-header",
    "flags-opt-startup",
    "cmdarg-seccomp",
    "cmdarg-key-fd",
    "cmdarg-pwd-fd",
    "no-tpm12-tools",
    "rsa-keysize-1024",
    "rsa-keysize-2048",
    "rsa-keysize-3072"
  ]
}

We need to adapt the related test case to use a regular expression since
the rsa-keysize-xyz strings may or may not be there depending on libtpms
version.

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2020-05-04 18:12:24 -04:00
Stefan Berger
1974f2ce20 swtpm_setup: Report 'no-tpm12-tools' if tcsd or tpm-tools missing
If the host is missing tcsd (trousers) or the tpm-tools, swtpm_setup
will now report the 'no-tpm12-tools' verb like this:

> swtpm_setup --print-capabilities | jq

{
  "type": "swtpm_setup",
  "features": [
    "cmdarg-keyfile-fd",
    "cmdarg-pwdfile-fd",
    "no-tpm12-tools"
  ]
}

The only TPM 1.2 setup parameter that requires interaction with
the TPM 1.2 that can be pass is then '--createek'.

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2020-05-01 17:47:03 -04:00
Stefan Berger
72aac899fa samples: Parse optional id= for ECC curve IDs
Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2020-04-29 20:35:04 -04:00
Stefan Berger
fbc42b8d9f swtpm_cert: Support --ecc-curveid option to pass curve id
Implement support for passing the curve id via the --curve-id
option. Default assumes secp256r1. secp384r1 is also supported.

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2020-04-29 20:35:04 -04:00
Stefan Berger
f30e202df6 samples: Extend script to create a CA using a TPM 2 for signing
Extend the script that creates a CA that uses a TPM 2 for signing.
For this we have to create tokens using the TPM 2 pkcs11 module's
tpm2_ptool and can then use the p11tool for creating keys.

Add a test case that requires a running tpm2-abrmd and tpm2_ptool.
Eventually the test case should (try to) start its own tpm2-abrmd
and talk to swtpm directly but the tcti module to do that isn't
available as a package, yet.

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2020-04-14 13:09:00 -04:00