Commit Graph

1150 Commits

Author SHA1 Message Date
Stefan Berger
0194fb22a5 Travis: Run IBM TSS2 for coverage; use Bionic
The IBM TSS2 is available starting with Bionic. Use it there
to extend the test coverage of the code.

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2020-04-09 19:39:38 -04:00
Stefan Berger
3e7555c469 tests: Change localhost to 127.0.0.1 or explicityly set 127.0.0.1
To make the test cases work on Travis on Bionic replace all occurrences of
localhost with 127.0.0.1. The only affected client tools seem to be those
related to the TPM 1.2 and the IBM TSS2. For some reason the API used
there cannot resolve localhost to 127.0.0.1.

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2020-04-09 19:39:38 -04:00
Stefan Berger
029e9d4638 swtpm_setup: Explicitly set TCSD_TCP_DEVICE_HOSTNAME=127.0.0.1
To make swtpm_setup.sh work on Travis on Bionic we need to
explicitly set TCSD_TCP_DEVICE_HOSTAME=127.0.0.1 since lookup
of localhost (with the API the tcsd is using) does not work.
It doesn't negatively affect any other use case, so no problem
setting it.

Also replace localhost in the bash tcp device path with 127.0.0.1.

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2020-04-09 19:39:38 -04:00
Stefan Berger
b5b48d4134 tests: Run all tests again in run_test
Previous commit broke the run_test script and only ended up running
the first test. This  patch fixes it and displays an success message
at the end.

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2020-04-07 17:14:10 -04:00
Stefan Berger
80b0943a4f tests: Disable CUSE interface testing in run_test.sh
Diable testing with the CUSE interface in run_test.sh. The CUSE driver
in Linux seems to have some stability problems.

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2020-04-07 16:10:28 -04:00
Stefan Berger
4931b93890 tests: Better detect a 32 bit TPM for the TPM2 derived keys test
The simplest way to detect whether SWTPM_EXE is a 64 bit application on
Linux is to check whether it links against any library in a */lib64/*
directory and only if this is the case we run a particular test case for
which we know what keys 64 bit TPMs are producing given a pre-created
state.

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2020-04-07 16:10:28 -04:00
Stefan Berger
8415d39d5f tests: Use the IBM TSS2 v1.4.0's test suite
Upgrade to use the IBM TSS2 tests from v1.4.0 but eliminate all testing
with 3072 bit RSA keys.

This test also passes with libtpms 0.6.0 and 0.7.0.

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2020-04-07 12:59:27 -04:00
Stefan Berger
8ee811f98b RPM: Adjust version to 0.4.0 at beginning of dev cycle
Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2020-04-07 11:16:49 -04:00
Stefan Berger
728af8972a Debian: Adjust changelog for 0.4.0~dev1 developer release
Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2020-04-07 11:16:49 -04:00
Stefan Berger
3e3d2c82dd build-sys: Bump up version to 0.4.0 at beginning of dev cycle
Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2020-04-07 11:16:49 -04:00
Stefan Berger
ba65323def Travis: Checkout a certain libtpms revision
Allow specifying a libtpms revision to test with, defaulting to
master branch.

Have the OS X test use the stable-0.6.0 branch.

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2020-03-18 09:20:50 -04:00
Stefan Berger
cb5ab582d1 swtpm: Fix vtpm proxy case without startup flags
'swtpm chardev --vptm-proxy' currently requires a '--flag startup-xyz'
to be passed since otherwise the need_init_cmd variable would not be
set to false and swtpm would terminate after sending the startup
command. To maintain backwards compatibility we have to always
set the need_init_cmd variable to false for the --vtpm-proxy case
and must not require a startup flag to be passed.

Roll back one of the test case to not use the startup flag.

Fixes: e6bc4bdf0 ('swtpm: Enable sending startup commands ...')
Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2020-03-07 09:09:14 -05:00
Stefan Berger
dfd36eb387 tests: Skip test 4 of derived keys in case an allowed error is encounterd
libtpms may not support TDES, so we have to skip test case 4 in
case we encounter an allowed error message.

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2020-02-26 10:15:50 -05:00
Stefan Berger
74ae43bd8e RPM: Update gitcommit for a useful 0.3.0 checkout
Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2020-02-17 13:58:03 -05:00
Stefan Berger
3b269659df Travis: Run make check with VERBOSE=1
Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2020-02-17 13:58:03 -05:00
Stefan Berger
38f36f30e3 Debian: Adjust changelog for 0.3.0 release
Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2020-02-17 12:11:31 -05:00
Stefan Berger
27d3fc877b Debian: Remove CUSE TPM from build and adjust rules file
Remove the CUSE TPM from the build and adjust the rules file
so that the build works on Ubuntu servers for example.

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2020-02-17 12:11:31 -05:00
Stefan Berger
9c72780580 RPM: Adjust changelog for 0.3.0 release
Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2020-02-17 12:11:31 -05:00
Stefan Berger
2e187bc299 build-sys: Set version to 0.3.0 for next release
Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2020-02-17 12:11:31 -05:00
Stefan Berger
16952a5fdc CHANGES: Add documentation for changes in 0.3.0
Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2020-02-17 12:11:31 -05:00
Stefan Berger
d1083d1164 swtpm: Only call memcpy if tocopy != 0 (coverity)
Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2020-02-14 09:53:32 -05:00
Stefan Berger
195353de60 tests: Skip swtpm_cert --print-capabilities test if not compiled
If swtpm_cert is not compiled, do not attempt the --print-capabilities
test.

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2020-02-13 20:38:48 -05:00
Stefan Berger
695274e024 tests: Adjust tests to use new startup options
Adjust the vtpm proxy test case and others to make use of the new
startup options. Make sure that subsequent Startups sent to the
TPM fail with the expected error code.

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2020-02-08 18:19:08 -05: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
e6bc4bdf0a swtpm: Enable sending startup commands before processing commands
The vtpm proxy device requires that the TPM be 'Startup' otherwise it
fails sending the first command to it and will send the 'Startup'
(SU_CLEAR/TPM_ST_CLEAR) itself while adding a log entry. We want to
avoid the kernel log entry.

Add options to the existing --flags option that allows one to start
up the TPM 1.2 or TPM 2.0 with the startup types 'clear', 'state'
and 'deactivate' (TPM 1.2 only). Extend the --print-capabilities to
advertise the availability of these options with the string
'flags-opt-startup'.

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2020-02-08 18:19:08 -05:00
Stefan Berger
99f442f37c tests: Wait longer for port to close when running with valgrind
Give swtpm more time to close the port. This became an issue when running
the tests and all executables are valgrind'ed.

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2020-02-04 19:55:47 -05:00
Stefan Berger
28f1209816 tests: Display SWTPM_CERT that's being used during test
Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2020-01-30 08:52:58 -05:00
Stefan Berger
6eef00e416 swtpm_cert: Accept serial numbers that use up to 64bits
Accept serial number that use up to 64bits.

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2020-01-30 08:52:58 -05:00
Stefan Berger
a718f2a9e7 swtpm_cert: Use getopt_long_only to parse options
Convert the code to use getopt_long_only for parsing the options.

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2020-01-30 08:52:58 -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
961bb827a4 samples: Use new pwd format option for secretly passing passwords
Use the swtpm_cert --signkey-pwd and --parentkey-pwd to pass key passwords
using files rather than using the command line options.

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
b291eb83ed samples: Protect variables in swtpm-create-tpmca
Address several issues reported by shellcheck and protect
variables with quotes so we now can have filenames with spaces.

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2020-01-27 09:16:16 -05:00
Stefan Berger
f9547ddc2c swtpm_setup: Enable spaces in paths and other variables
This patch addresses several issues found with shellcheck. In particular
it now enables variables with spaces in them, such as file paths that
contain spaces.

Adjust one of the accompanying test cases to use spaces in the path.

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2020-01-27 09:16:16 -05:00
Stefan Berger
77819bb2e6 samples: Protect variables with quotes and address shellcheck issues
Protect variables with quotes so that pathnames with spaces are now
supported.

Adjust the accompanying test case to make use of spaces in file paths.

Address several issues found by shellcheck. Some of them are false
positives especially when it comes to protecting variables passed
to a commaned in an 'eval' line. They must not be protected, otherwise
they are not passed correctly.

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2020-01-27 09:16:16 -05:00
Stefan Berger
d66f4d1e03 swtpm_ioctl: Calculate strlen(input) only once
Calculate the strlen(input) only once at the beginning.

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2020-01-22 19:32:24 -05:00
Stefan Berger
3eef9811b9 swtpm_ioctl: Block SIGPIPE so we can get EPIPE on write()
Block the SIGPIPE so that a failing write() can return an EPIPE
rather than killing the process with a SIGPIPE.

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2020-01-22 19:32:24 -05:00
Stefan Berger
f27256f154 swtpm_bios: Block SIGPIPE so we can get EPIPE on write()
Block the SIGPIPE so that a failing write() can return an EPIPE
rather than killing the process with a SIGPIPE.

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2020-01-22 19:32:24 -05:00
Stefan Berger
abadb408a9 swtpm: Only accept() new client ctrl connection if we have none
Only accept new client connection on the control channel if we
currently do not have a client on the control channel.

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2020-01-22 19:32:24 -05:00
Stefan Berger
de10d7cd59 swtpm_setup: Do not fail on future PCR banks' hashes
swtpm_setup will fail once libtpms starts supporting other PCR
hash banks than sha1, sha256, sha384, sha512, and sm3-256. So,
this patch allows to choose active PCR banks of the SHA3 series.
Further, unknown hash banks will not fail the tool anymore when
it tries to determine which hash banks are supported by the TPM
since it will then add the hex number of the hash algorithm to
the collection of supported hashes.

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2020-01-17 20:07:37 -05:00
Stefan Berger
930c7ba16e tests: Allow seccomp override w/ SWTPM_TEST_SECCOMP_OPT env var
The Ubuntu (PPA) build system executes the build on an environment that
has problems with seccomp profiles. It does not allow us to run the test
suite with swtpm applying its seccomp profile since it fails with a
'bad system call' error. To work around this we introduce the env. variable
SWTPM_TEST_SECCOMP_OPT that we can set to "--seccomp action=none" to avoid
having swtpm apply it seccomp profile.

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2020-01-15 15:49:51 -05:00
Stefan Berger
194bfc66b9 debian: Fix issues reported by lintian and changelog format issues
Fix several issues reported by lintian and the format of
the changelog.

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2020-01-14 20:26:36 -05:00
Stefan Berger
0232f78f0d build-sys: Display check result for build with libseccomp
Display the check result of 'yes' or 'no' for whether we build
with libseccomp.

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2020-01-14 20:26:36 -05:00
Stefan Berger
c5748a5354 tests: Move local functions to common file and handle errors better
Move wait_port_open and wait_port_closed to common file and handle
the timeout errors in test_commandline.

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2020-01-13 15:03:01 -05:00
Stefan Berger
f59c33009d tests: Wait for PID file rather than reading it right away
Wait for the PID file to appear rather than reading it right away.
This addresses an issue when runnin the test suite under valgrind
(make -j $(nproc) check).

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2020-01-13 15:03:01 -05:00
Stefan Berger
9c2e4dc58a tests: Protect ${SWTPM_EXE} with quotes when passing to function
SWTPM_EXE may be 'valgrind ... swtpm', so we have to protect it with quotes
when passing it as a parameter to a function.

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2020-01-13 15:03:01 -05:00
Stefan Berger
84f350dace swtpm_setup: Use 1st part of SWTPM_EXE/SWTPM_IOCTL to determine executable
Search for the SWTPM_EXE / SWTPM_IOCTL executable using 'type -P' to
determine whether it is an executable rather than assuming a full path
is given on which we can check -x.

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2020-01-13 15:03:01 -05:00
Stefan Berger
996ad55fbc tests: delay reading of pidfile if found empty
Delay the reading of the PID file if it is found to be empty.
This can happend if swtpm is run by valgrind.

Also, use the passed parameters rather than the global ones to check
the PID file contents against the expected pid. So far this worked
because PID and PID_FILE were variables used by every caller.

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2020-01-13 15:03:01 -05:00
Stefan Berger
41cae9e1bd tests: Adjust timeouts for running executables with valgrind
When running the TPM 1.2 vtpm_proxy test cases by launching the
swtpm with valgrind it may take a long time for the log to be
written and the device to appear. This is due to the self test
of the TPM 1.2 taking a while. So we need to move the reading
of the device into a loop and set the timeout of the loop to 10s
so that it passed under these circumstances.

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2020-01-13 15:03:01 -05:00
Stefan Berger
fa0ecd9951 swtpm_setup: Keep reserved range of file descriptors for swtpm_setup.sh
swtpm_setup.sh uses file descriptor 100 for 'exec 100 <> ...'.
So we have to make sure that the file descriptor inherited from
the caller of swtpm_setup does not overlap with a reserved range
to be used by swtpm_setup.sh, which we declare to be [100..109].

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2020-01-09 14:22:50 -05:00