Commit Graph

114 Commits

Author SHA1 Message Date
Lili Zhu
504db951ca 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 10:26:34 -05: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
Stefan Berger
041a70e7b0 man: Document new startup options and capabilities advertisement
Add documentation about the new startup options support as well
as the new capability and its meaning.

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2020-02-08 18:19:08 -05:00
Stefan Berger
88c7bdc9e3 swtpm_cert: Add support for --print-capabilities option
Add support for the --print-capabilities option to display newly
added capabilities. Adpat the man page and related test case.

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2020-01-30 08:52:58 -05:00
Stefan Berger
b35eb9fcd5 swtpm_cert: Allow passing signing key and parent key via new option
Allow passing signing key and parent key via files and file descriptors
and environment variables. Adapt a test case to exercise this new
functionality.

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2020-01-30 08:52:58 -05:00
Stefan Berger
166d7b4204 man: Document swtpm_setup --print-capabilities option
Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2019-07-12 14:18:20 -04:00
Stefan Berger
14ae05b18b man: Update man pages with --print-capabilities option
Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2019-07-12 14:18:20 -04:00
Stefan Berger
08e619ad76 man: Add 'since v0.2' to --seccomp option documentation
--seccomp option was added in v0.2. Add this to the man page.

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2019-07-09 10:38:07 -04:00
Stefan Berger
e36d7915a5 man: Fix typos in swtpm_setup man page
Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2019-07-03 11:19:23 -04:00
Stefan Berger
ace4a68416 man: Update swtpm_setup page with the new options for passing file descriptors
Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2019-06-28 21:48:40 -04:00
Stefan Berger
6f57af7a03 man: Update man pages to document file descriptor for reading password
Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
2019-06-24 07:27:39 -04:00
Stefan Berger
87448aada5 man: Update man pages to document file descriptor for reading key
Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
2019-06-24 07:27:39 -04:00
Stefan Berger
9cd723d8e1 man: Add documentation about --seccomp option to man pages
Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2019-03-18 15:43:44 -04:00
Stefan Berger
5311e60e55 man: Fix man pages to include short summary in NAME section
Fix the man pages to include a short summary in the NAME section.

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2019-01-07 13:16:30 -05:00
Stefan Berger
8b9484a350 man: Extend man pages for swtpm-localca.conf for pkcs11 URIs
The signingkey entry can also be a pkcs11: URI. The semilcolons in the URI
have to be escaped due to the shell reading the entries.

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2018-12-11 15:25:00 -05:00
Stefan Berger
79edd90c90 swtpm_setup: Implement option to backup TCSD's system_ps_file
Implement the --tcsp-system-ps-file option to make a backup of
TCSD's system_ps_file for later use of the setup TPM with the
TCSD. We need this for a test case.

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2018-11-05 15:15:48 -05:00
Stefan Berger
15a14c552a samples: Add support for password protected root CA priv. key
Support creation and usage of the root CA with a password protected
private key. The root CA's key password can be set using the environment
variable SWTPM_ROOTCA_PASSWORD.

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2018-10-25 10:32:36 -04:00
Stefan Berger
05f4d55f1f samples: Add a script to create a TPM 1.2 intermediate CA
This (experimental) script uses GnuTLS tpmtool to create a TPM 1.2
intermediate CA that can sign a vTPM's EK and platform certificates.

Add a man page for this tool.

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2018-10-15 20:45:48 -04:00
Stefan Berger
07c786d1a0 samples: Enable support for TPM 1.2 signing keys for cert signing via GnuTLS
GnuTLS can use TPM 1.2 keys for signing. For this we just need to support
key URLs in the GnuTLS format:

tpmkey:uuid=...
tpmkey:file=...

We don't try to read these URLs as files but pass them through as URLs to
the swtpm_cert tool that will then try to sign with the TPM 1.2 key by
passing the URL to GnuTLS API calls.

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2018-10-15 20:45:48 -04:00
Stefan Berger
fea8979648 swtpm_cert: Allow using a TPM 1.2 signing key for signing cert
Gnutls supports TPM 1.2 keys in its API and we can use a TPM 1.2
signing key for signing the EK or platform certs.

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2018-10-15 20:45:48 -04:00
Stefan Berger
3041f38769 build-sys: Do not build man page or SELinux policy for CUSE if --without-cuse is used
To make the RPM building easier for the --without-cuse case we have to omit
a couple of files from being built so that they are not left-overs when
packing the RPM without building swtpm-cuse.

Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
2018-09-25 08:35:45 -04:00
Stefan Berger
a967f79d52 man: Replace bindaddress with bindaddr in swtpm man page
The swtpm man page incorrectly showed binaddress as the option parameter
for the address to bind to. It must be called bindaddr.

Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
2018-09-17 12:23:22 -04:00
Stefan Berger
2e260468cb swtpm_setup: Add support for choosing the cipher
Implement command line support for choosing the cipher to use for
the TPM state encryption. Either aes-128-cbc or aes-256-cbc can be
used. The same cipher has to be passed on the swtpm command line
when using the TPM.

Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
2018-09-17 11:45:44 -04:00
Stefan Berger
68a5b24124 swtpm: Add support for aes-256-cbc
Extend the buffer the key is read into to hold an 256bit key.

Add support for aes-256-cbc. Also, aes-128-cbc is now a synonym for
aes-cbc.

Update the man pages to reflect the AES 128 support.

Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
2018-09-17 11:45:44 -04:00
Stefan Berger
a39f098fd6 swtpm: Use pbkdf2 as default kdf and sha512 for test cases
Use pbkdf2 as the default kdf and sha512 for the existing
test case. Do away with file limit of 32 bytes. This may
break backwards compatibility for some but better to do this
before a release...

Switch the existing test cases to use kdf=sha512 on the command
line where necessary to that the state for these test cases
does not need to be recreated.

Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
2018-09-17 11:45:44 -04:00
Stefan Berger
9f4d8af2f0 swtpm_setup: Enable allocation of initially active PCR banks
Implement --pcr-banks to allow a user to choose the set of active
PCR banks. We determine the PCR banks available and enable those
that the user chose and that are available.

The log will now print out the following:

Successfully activated PCR banks sha1,sha256 among sha1,sha256,sha384.

Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
2018-08-07 12:19:47 -04:00
Stefan Berger
55caf3716f manpages: Extend swtpm_setup man page with example for non-root user
Extend the swtpm_setup man page with an example for how a non-root
user can create a TPM 2 with an EK and platform certificate.

Document the default locations of the config file swtpm_setup uses.

Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
2018-08-07 12:19:47 -04:00
Stefan Berger
6833255094 man pages: add paragraph about --allow-signing to swtpm_setup.pod
Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
2018-08-07 12:19:47 -04:00
Stefan Berger
a3b68edd6d samples: add support for signing key password
Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
2018-08-07 12:19:47 -04:00
Stefan Berger
bab61563af swtpm_setup: Add --decryption for enabling key encipherment
Add the --decryption option to enable key encipherment separately
from enabling signing for the EK. The key encipherment is not set
but needs to be set if --allow-signing is used and key encipherment
is also requested.

Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
2018-08-07 12:19:46 -04:00
Stefan Berger
aaefebcf96 samples: add support for signing and key encipherment options
To allow the creation of EKs with signing and/or key encipherment
capabilities, add the --allow-signing and --decryption options
to swtpm-localca program.

Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
2018-08-07 12:19:46 -04:00
Stefan Berger
770e7b8189 swtpm_cert: Add option --decryption to use for key encipherment
In case of a TPM 2 we allow the creation of a signing key by passing
--allow signing. To also enable key encipherment, we add the --decryption
option to allow key encipherment and signing at the same time.

Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
2018-08-07 12:19:46 -04:00
Stefan Berger
08da93a96f swtpm_setup: Implement support for ECC keys
Implement support in swtpm_setup.sh so that the TPM's primary key
can be an ECC key.

Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
2018-08-07 12:19:46 -04:00