Commit Graph

1150 Commits

Author SHA1 Message Date
Stefan Berger
5196855ad1 swtpm_setup: Log about encryption and fix c&p error in err msg
Fix a cut and paste error in the error message output and be more
verbose in log about encryption when using file descriptors.

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2020-01-07 20:06:03 -05:00
Stefan Berger
a7c4f3734a swtpm: Add --print-capabilities to help screen of 'swtpm chardev'
The --print-capabilities is missing in the 'swtpm chardev' help screen
but the code is there to interpret the command line flag. This patch
adds the missing lines to the help screen.

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2020-01-07 11:18:10 -05:00
Stefan Berger
d396839543 tests: Fix key derivation TDES test cases to actually create TDES keys
The byte stream contained the TDES identifier at the wrong position,
so no TDES key was created. This patch fixes this but needs an update
to libtpms since some unmarshalling/marshaling code related to TDES
was missing there as well.

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2019-12-26 00:08:35 -05:00
Stefan Berger
8330ccd07e swtpm_ioctl: Fix uninitialized variable 'pgi'
Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2019-12-23 15:06:33 -05:00
Stefan Berger
8e95c996d2 tests: Add test cases for new CrytpAdjustPrimeCandidate algo
Extend the existing key derivation test case for TPM 2 with test cases
that use a newer TPM 2 state where we now exercise the new
CryptAdjustPrimeCandidate algorithm that produces the same results on
big and little enidan 32 bit and 64 bit machines. This newer algorithm
is available in libtpms with revision 155 of the TPM 2 code.

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2019-12-23 14:14:25 -05:00
Stefan Berger
8dc2415d53 tests: Have IBM TSS2 test case use tags/v1.3.0 of the TPM 2.0 TSS repo
Use v1.3.0 of the IBM TSS 2.0 repo.

Depending on the revision that libtpms implements, some test cases have to be
replaced with empty files.

The test suite now works with the libtpms stable-0.6.0 and stable-0.7.0
branches. A patch fixing an NV PIN issue needed to be applied to those
branches.

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2019-12-20 23:11:06 -05:00
George Almasi
b3c0b158e6 Fix a 1 letter typo in INSTALL instructions
Signed-off-by: George Almasi <gheorghe@us.ibm.com>
2019-12-04 16:13:53 -05:00
Stefan Berger
60e3abc3c8 Travis: Add asan build for non-openssl usage in libtpms
Since I am not often using the non-openssl crypto function usage
in libtpms, add a build to Travis that exercises the old code.

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2019-11-27 11:20:26 -05:00
Stefan Berger
c359fed0a2 tests: Protect variable with executable with quotes
The test_print_capability is failing if SWTPM_EXE is for example
holding more than one parameter like 'valgrind ... /bin/swtpm' since the
variable was not protected with quotes. This patch fixes this.

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2019-11-18 07:34:19 -05:00
Stefan Berger
0151abba99 Travis: Work around failing OsX builds due to brew error
The Travis build on OSX was failing due to the following error:

/usr/local/Homebrew/Library/Homebrew/brew.rb:23:in `require_relative': \
   /usr/local/Homebrew/Library/Homebrew/global.rb:110: \
   syntax error, unexpected keyword_rescue, expecting keyword_end (SyntaxError)

	from /usr/local/Homebrew/Library/Homebrew/brew.rb:23:in `<main>'

The command "brew tap discoteq/discoteq" failed and exited with 1 during .

This patch resolves the issue.

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2019-10-25 10:54:54 -04:00
Stefan Berger
132bbf7b7a swtpm_cert: Use gnutls_x509_crt_get_subject_key_id API call for subj keyId
Use the gnutls_x509_crt_get_subject_key_id() API call to get the subject
key ID of the signer's certificate rather than gnutls_x509_crt_get_key_id().
The latter returns the same result most of the time but there are instances
when this is not the case and the returned result is wrong.

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2019-10-22 12:39:29 -04:00
Jeremy Liu
36bfbb7432 Correct parameter name typo
Signed-off-by: Jeremy Liu <liujiong@gohighsec.com>
2019-10-17 12:29:38 -04:00
Stefan Berger
a85b7d2823 swtpm_cert: Fix OIDs for TPM 2 platforms data
The OIDs for the TPM 1.2 and TPM 2 platform data
are different (though have the same name in the spec).
Adapt them for the TPM 2 case.

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2019-10-11 08:34:30 -04:00
Stefan Berger
1ce7293d3c tests: Skip seccomp check if env. sets up seccomp profile
If the test environment is running in a seccomp profile do not check
that the seccomp profile of the swtpm process runs with the action
provided in --seccomp action=... since the environment may override
this.

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2019-08-08 09:36:04 -04:00
Stefan Berger
ab1b346ef0 SELinux: Need more rules for QEMU and KVM type of VMs on F30
More rules are needed for QEMU and KVM type VMs on F30.

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2019-07-26 20:38:46 -04:00
Stefan Berger
bea37691ac swtpm: Fix typo in error report: HMAC instead of hash
Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2019-07-25 10:09:25 -04:00
Stefan Berger
5c5d3b793b swtpm: Use writev_full rather than writev; fixes --vtpm-proxy EIO error
We have to use writev_full() when --vtpm-proxy is used since writev()
does not seem to work and we get an EIO error. writev_full() uses write(),
so we can use it.

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2019-07-23 10:06:20 -04:00
Stefan Berger
7491ed0f2a SELinux: A few more rules needed for F30
A few more rules are needed on Fedora 30 to have libvirt start swtpm.

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2019-07-23 10:06:20 -04:00
Stefan Berger
bac3fc7ce1 rpm: Adjust the RPM spec for 0.2.0 release
Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2019-07-19 13:47:02 -04:00
Stefan Berger
817d3a8863 tests: Fix spelling of call to function validate_pidfile
Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2019-07-19 10:31:07 -04:00
Stefan Berger
c487ba77e5 debian: Adjust changelog for 0.2.0 release
Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2019-07-16 14:28:28 -04:00
Stefan Berger
e6512b84c6 CHANGES: Write changelog for v0.2.0
Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2019-07-16 14:26:32 -04:00
Stefan Berger
374b66913f swtpm: Address Coverity's dead code complaint
Signed-off-by: stefan Berger <stefanb@linux.ibm.com>
2019-07-13 21:53:13 -04:00
Stefan Berger
a38cb19b97 Travis: Only clone libtpms if libtpms dir does not exist
Only build the libtpms dir if it doesn't exist. When we do a Coverity
scan build it looks like we are now running the script afterwards as
well and this creates a build failure due to the 2nd clone.

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2019-07-13 21:26:10 -04:00
Stefan Berger
ad2fb40077 swtpm: Loop over poll() in case of EINTR
Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
2019-07-13 12:48:36 -04:00
Stefan Berger
a442092d8e swtpm: Convert read() to read_eintr() which handles EINTR
Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
2019-07-13 12:48:36 -04:00
Stefan Berger
37ac6aec73 swtpm: Implement read_eintr() to read into a buffer and handle EINTR
Implement read_eintr() to read into a buffer and handle EINTR on
the way.

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
2019-07-13 12:48:36 -04:00
Stefan Berger
ec355ee80c swtpm: Use write_full instead of plain write
Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
2019-07-13 12:48:36 -04:00
Stefan Berger
2d921e663c swtpm: Implement write_full and writev_full
Implement write_full and writev_full that handle partial writes.

Implement writev_full using write_full since handling partial writes
with iovec's can become quite complicated.

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
2019-07-13 12:48:36 -04:00
Stefan Berger
01ad1d03f1 tests: Get swtpm PID from shell and validate against pidfile after
Get the PID of the started swtpm from the shell and validate it
against the contents of the pidfile afterwards.

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2019-07-13 12:48:36 -04:00
Stefan Berger
30e12eae27 SELinux: Add rule for passing pass phrase via file descriptor
Add a rule so we can pass a passphrase from libvirt to swtpm using
a file descriptor.

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2019-07-12 14:18:20 -04:00
Stefan Berger
0db8249cf1 tests: Extend --print-capabilities tests with test of swtpm_setup
Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2019-07-12 14:18:20 -04: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
1edad44acd swtpm_setup: Add --print-capabilities option
Extend swtpm_setup with the --print-capabilities option which
prints a JSON object describing supported features.

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2019-07-12 14:18:20 -04:00
Stefan Berger
c11bf8c5f8 swtpm_setup: Test filenames for empty string before trying to remove
rm on NetBsd prints out an error message when trying to remove a file
with an empty filename. Avoid this situation by checking for non-empty
filenames first.

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2019-07-12 14:18:20 -04:00
Stefan Berger
95bed8ceb4 tests: Add test case for --print-capabilities test
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
11114ba745 swtpm: Add --print-capabilities option to command line
Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2019-07-12 14:18:20 -04:00
Stefan Berger
1d5e07974b swtpm: Implement support for printing newly added capabilities
Implement support for printing newly added capabilities, such as
being able to read the key and password from a file descriptor.

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2019-07-12 14:18:20 -04:00
Stefan Berger
0676fedb23 swtpm: Add missing include file to ctrlchannel.h
Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2019-07-12 14:18:20 -04:00
Stefan Berger
c2bae74975 swtpm: Stub handle_seccomp_options if WITH_SECCOMP is not defined
Stub out the handle_seccomp_options function and other unused
code and data if WITH_SECCOMP is not defined.

Currently the handle_seccomp_options would always be called with
a NULL string to parse if WITH_SECCOMP is not defined, so this just
eliminates the code that will never be called.

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2019-07-12 14:18:20 -04:00
Stefan Berger
a794d0fe48 swtpm_setup: Avoid calling getpwnam() if change_user == false
Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2019-07-12 14:18:20 -04:00
Stefan Berger
51f3860dfe swtpm: Have swtpm report PTM_CAP_SEND_COMMAND_HEADER flag
Have swtpm report PTM_CAP_SEND_COMMAND_HEADER flag for a TPM 2
indicating that it knows how to handle the TCG header prefix
for the data channel.

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2019-07-09 10:38:07 -04:00
Stefan Berger
e2558a8bea swtpm: Have get_ptm_caps_supported return supported PTM_CAPs
Create function get_ptm_caps_supported and have it return the
supported PTM_CAPs.

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2019-07-09 10:38:07 -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
cb80f52036 swtpm: Set missing PTM_CAP_GET_INFO capability flag for CUSE TPM
CUSE TPM did not report the PTM_CAP_GET_INFO flag. This patch fixes
it.

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2019-07-09 10:38:07 -04:00
Stefan Berger
22ecb5ce5a tests: Have IBM TSS2 test not use the raw interface anymore
Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2019-07-08 07:09:16 -04:00
Stefan Berger
065bca4e18 swtpm: Handle TPM 2 command header prefix
Add support for handling the TPM 2 command header prefix that looks like this:

struct tpm2_send_command_prefix {
    uint32_t cmd;
    uint8_t  locality;
    uint32_t size;
};

This patch converts the existing send function to use an array of struct iovec
using writev() where we can optinally prepend a response header and trailer.
We detect whether the command had the above type of header prefixed and if so
indicate this with an offset into the byte stream where the normal TPM command
starts, which follows right after this header. In case such a header was found
we prepend a header in the response and append a 4-byte trailer. For TPM 1.2
there are no changes and for raw TPM 2 commands there are no changes, either.

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2019-07-08 07:09:16 -04:00
Stefan Berger
dc2895812a swtpm: Have SWTPM_IO_Read read at least the 10 bytes from the TPM header
Have SWTPM_IO_Read() read at leat the 10 bytes from the (regular) TPM
header. This solves a particular problem with the TPM 2 header prefix for
which we will add support in the subsequent patch. In the prefix case the IBM
TSS 2 stack sends 4 bytes for the command, then 1 byte for the locality, and then
4 bytes for the length indicator followed by the command. If we just read once
we would only then get 4 bytes. Reading 10 bytes gets all of these plus the sub-
sequent TPM command or the whole TPM command in case this prefix header is
missing.

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2019-07-08 07:09:16 -04:00
Stefan Berger
71beceeda4 swtpm: Re-add header includes for BSD
Some BSDs need more #includes than Linux does. Re-add them as I removed too many
before.

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2019-07-08 07:09:16 -04:00