]> git.proxmox.com Git - swtpm.git/log
swtpm.git
6 years agotests: Use python twisted for sendmsg on python 2
Stefan Berger [Fri, 29 Sep 2017 17:53:06 +0000 (13:53 -0400)]
tests: Use python twisted for sendmsg on python 2

Rather than sending two separate messages with the bare python 2
API, use the python twisted package to send the control and data
in one sendmsg() call. This avoids occasional test failures in
the ctrlchannel test case that is currently sending the data and
control part of the message in 2 steps, which can lead to the
recpient not seeing the whole message.

Add python-twisted as a build dependency to the rpm and Debian
builds and the .travis.yml.

Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
6 years agoswtpm: remove whitespace error
Stefan Berger [Fri, 29 Sep 2017 17:28:42 +0000 (13:28 -0400)]
swtpm: remove whitespace error

Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
6 years agotravis: Add pep8 test for python code
Stefan Berger [Fri, 29 Sep 2017 17:35:50 +0000 (13:35 -0400)]
travis: Add pep8 test for python code

Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
6 years agotests: reformat .py code to have pep8 pass without errors
Stefan Berger [Fri, 29 Sep 2017 17:28:07 +0000 (13:28 -0400)]
tests: reformat .py code to have pep8 pass without errors

Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
6 years agoRemove code duplication related to TCP socket creation
Amarnath Valluri [Thu, 21 Sep 2017 12:11:42 +0000 (15:11 +0300)]
Remove code duplication related to TCP socket creation

Consider TPM_PORT environment at the time of parsing server options. This way we
can avoid the code duplication, hence removed obslote code.

Signed-off-by: Amarnath Valluri <amarnath.valluri@intel.com>
6 years agoSupport added to receive data socket over control socket
Amarnath Valluri [Wed, 20 Sep 2017 13:09:46 +0000 (16:09 +0300)]
Support added to receive data socket over control socket

As objected by QEMU upstream developers to use two different sockets for
starting/using of swtpm, This commit adds support for passing unix domain
socket over control channel.

The summary of the changes include:
 - Defined new control command CMD_SET_DATAFD, using this clients can send data
   socket.
 - set mlp.fd and mlp.flags outside of the mainloop
 - updated the testcases

Signed-off-by: Amarnath Valluri <amarnath.valluri@intel.com>
7 years agoswtpm: switch to recvmsg for receiving data
Stefan Berger [Wed, 27 Sep 2017 20:13:51 +0000 (16:13 -0400)]
swtpm: switch to recvmsg for receiving data

In preparation for receiving control messages via UnixIO sockets,
switch to recvmsg() for receiving the first chunk of data.

Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
7 years agoswtpm: enable receiving control commands in chunks
Stefan Berger [Wed, 27 Sep 2017 16:08:24 +0000 (12:08 -0400)]
swtpm: enable receiving control commands in chunks

Enable receiving control commands in small chnunks. Allow 500ms
for the whole control command to be received.

Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
7 years agoswtpm: add missing PTM_CAP_GET_CONFIG to returned flags
Stefan Berger [Wed, 27 Sep 2017 11:11:13 +0000 (07:11 -0400)]
swtpm: add missing PTM_CAP_GET_CONFIG to returned flags

Add the missing PTM_CAP_GET_CONFIG to the returned flags.

Fix the order of the flags on the way.

Fix the test cases that test for the flags.

Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
7 years agoswtpm: Make 32bit CUSE swtpm work on 64bit host
Stefan Berger [Tue, 26 Sep 2017 15:39:28 +0000 (11:39 -0400)]
swtpm: Make 32bit CUSE swtpm work on 64bit host

Remove the check for the FUSE_IOCTL_COMPAT flag to make a 32bit
CUSE swtpm work on 64bit host.

Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
7 years agoBuild: Fix coverity_scan parameters
Stefan Berger [Fri, 22 Sep 2017 14:04:55 +0000 (10:04 -0400)]
Build: Fix coverity_scan parameters

Use a new and encrypted token. Fix other parameters. Build works now
and submits to coverity if coverty_scan branch is pushed to.

Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
7 years agoExtend Travis integration with Coverity Scans
Stefan Berger [Fri, 22 Sep 2017 13:46:23 +0000 (09:46 -0400)]
Extend Travis integration with Coverity Scans

Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
7 years agoci: add .travis.yml
Stefan Berger [Mon, 31 Jul 2017 16:49:49 +0000 (12:49 -0400)]
ci: add .travis.yml

Add script for integration with Travis.

Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
7 years agoswtpm: raise error on unhandle command line parameters
Stefan Berger [Tue, 25 Jul 2017 14:59:12 +0000 (10:59 -0400)]
swtpm: raise error on unhandle command line parameters

Raise an error on unhandled non-option command line parameters.

Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
7 years agoFix possible illegal buffer access
Stefan Berger [Tue, 18 Jul 2017 21:02:59 +0000 (17:02 -0400)]
Fix possible illegal buffer access

Fix possible illegal buffer access in case a character device
is used via ioctl. In this case we have to make sure we only
access the number of bytes in the ioctl structure itself.

In case of a socket, make sure we received enough bytes to
be able to access the payload.

Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
7 years agoFix memory leak of tpmstatedir in case of error
Stefan Berger [Tue, 18 Jul 2017 20:40:05 +0000 (16:40 -0400)]
Fix memory leak of tpmstatedir in case of error

Fix memory leak of tpmstatedir in case of error.

Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
7 years agoFix memory leak of pidfile in case of error
Stefan Berger [Tue, 18 Jul 2017 20:37:39 +0000 (16:37 -0400)]
Fix memory leak of pidfile in case of error

Fix memory leak of pidfile in case of error.

Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
7 years agotests: Run tests also on socket interfaces
Stefan Berger [Sun, 9 Jul 2017 08:05:51 +0000 (04:05 -0400)]
tests: Run tests also on socket interfaces

Refactor the tests so that they all run on socket interfaces as well.

Use socket ports in the range of 65400-65499 for TPM 1.2 tests.

Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
7 years agotests: add functions for running swtpm and swtpm_ioctl
Stefan Berger [Thu, 15 Jun 2017 17:14:17 +0000 (13:14 -0400)]
tests: add functions for running swtpm and swtpm_ioctl

To be able to run tests with either one of the interfaces, add function
for running swtpm and swtpm_ioctl commands and form the command line
parameters dependent on the type of interface being passed. We rely on
environment variables to provide the specific parameters that are needed
to run the program with the appropriate parameters.

Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
7 years agoIntroduce '--flag not-need-init' for socket and chardev
Stefan Berger [Mon, 10 Jul 2017 14:29:10 +0000 (10:29 -0400)]
Introduce '--flag not-need-init' for socket and chardev

Change the startup behavior with respect to requiring an INIT command
via control channel. We change this for the socket and chardev
interfaces so that the behavior now is the same as that of the CUSE
interface.

Introduce the --flag not-need-init command line option for the socket
and chardev interfaces to allow the old behavior using this option.

Adapt some of the test cases and swtpm_setup.sh.in that now need this
command line flag.

Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
7 years agoswtpm_setup: Allow running swtpm_setup as tss directly
Stefan Berger [Tue, 11 Jul 2017 17:19:40 +0000 (13:19 -0400)]
swtpm_setup: Allow running swtpm_setup as tss directly

Allow running swtpm_setup directly as tss user using the following
command lines as an example for how to do it:

mkdir /tmp/test-tss
chown tss:tss /tmp/test-tss
chmod 770 /tmp/test-tss
su -c "swtpm_setup --tpm-state /tmp/test-tss" -s /bin/sh tss

This change prevents us from requiring invocation under the root
user.

Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
7 years agoswtpm_setup: replace show_help variable by change_user
Stefan Berger [Tue, 11 Jul 2017 17:12:01 +0000 (13:12 -0400)]
swtpm_setup: replace show_help variable by change_user

Replace the show_help variable with change_user varaible with
opposite logic. The name of the variable is better for upcoming
changes.

Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
7 years agoFix return code for ResetEstablishmentBit
Stefan Berger [Sun, 9 Jul 2017 15:20:16 +0000 (11:20 -0400)]
Fix return code for ResetEstablishmentBit

If the return code from the command processing function is 0,
get the error code from the command response and return that one
instead. The problem was that clients though resetting the
establishment bit worked in locality 0 for example, while it did
not.

Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
7 years agoFix a parameter problem in non-Linux function prototype
Stefan Berger [Sun, 9 Jul 2017 15:21:21 +0000 (11:21 -0400)]
Fix a parameter problem in non-Linux function prototype

A parameter from the TPM2 backport had not been removed. Fix it so
it compiles on cygwin.

Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
7 years agoswtpm_ioctl: fix ctrlcmd return parameter and fix state recv logic
Stefan Berger [Fri, 30 Jun 2017 19:52:32 +0000 (15:52 -0400)]
swtpm_ioctl: fix ctrlcmd return parameter and fix state recv logic

Return the number of bytes received in case ctrlcmd does not
use an ioctl because in this case we need to know how many bytes
we received in the response.

The receiving of the state blob also needs to take into account
how many bytes were received in the initial response so we write
the proper amount of bytes from that response into the file.

Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
7 years agoswtpm: silence printf's in TPM1.2 inherited code
Stefan Berger [Thu, 29 Jun 2017 19:49:06 +0000 (15:49 -0400)]
swtpm: silence printf's in TPM1.2 inherited code

Silence the printf's in code taken from TPM1.2.

Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
7 years agotests: Increase sleep time to accomocate slow ARM
Stefan Berger [Thu, 29 Jun 2017 18:27:54 +0000 (14:27 -0400)]
tests: Increase sleep time to accomocate slow ARM

Increase the timeout from 0.2 to 1 seconds so that a tests
passes on ARM.

Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
7 years agoswtpm: Enable --migration-key for socket and chardev interfaces
Stefan Berger [Thu, 15 Jun 2017 23:07:07 +0000 (19:07 -0400)]
swtpm: Enable --migration-key for socket and chardev interfaces

Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
7 years agoswtpm: log error if broken header is detected
Stefan Berger [Thu, 15 Jun 2017 23:01:37 +0000 (19:01 -0400)]
swtpm: log error if broken header is detected

Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
7 years agoswtpm: work on a copy of argv[] variables
Stefan Berger [Thu, 15 Jun 2017 22:59:25 +0000 (18:59 -0400)]
swtpm: work on a copy of argv[] variables

While parsing the options we modified the argv[] values and
the commas disappeared, which showed when checking for the
swtpm processes using 'ps'. So, work on a copy of the options
parameter.

Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
7 years agoswtpm: Fix an endianess issue in ctrlchannel and offset bug
Stefan Berger [Thu, 15 Jun 2017 22:54:12 +0000 (18:54 -0400)]
swtpm: Fix an endianess issue in ctrlchannel and offset bug

There was an offset bug in the code getting the state blobs
from a client.

Also fix an endianess bug in a control channel command.

Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
7 years agoswtpm_ioctl: enable state migration for socket interface
Stefan Berger [Thu, 15 Jun 2017 22:53:31 +0000 (18:53 -0400)]
swtpm_ioctl: enable state migration for socket interface

7 years agoImplement allow-set-locality for CUSE TPM and extend test case.
Stefan Berger [Tue, 6 Jun 2017 20:44:16 +0000 (16:44 -0400)]
Implement allow-set-locality for CUSE TPM and extend test case.

Implement allow-set-locality for CUSE TPM and extend the existing
locality test case with commands that try to write the SetLocality
comamnd to the device.

Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
7 years agoExtend help screen with allow-set-locality option
Stefan Berger [Tue, 6 Jun 2017 20:42:37 +0000 (16:42 -0400)]
Extend help screen with allow-set-locality option

Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
7 years agoImplement support for --locality allow-set-locality option
Stefan Berger [Tue, 6 Jun 2017 18:09:59 +0000 (14:09 -0400)]
Implement support for --locality allow-set-locality option

Implement support for --locality allow-set-locality option that
is primarily useful in cases when the VTPM proxy access is enabled
by file descriptor passing.

Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
7 years agotests: Extend existing test with one for rejection of locality 4
Stefan Berger [Thu, 1 Jun 2017 20:29:14 +0000 (16:29 -0400)]
tests: Extend existing test with one for rejection of locality 4

Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
7 years agoAdd options for locality handling and SetLocality command
Stefan Berger [Thu, 1 Jun 2017 20:00:15 +0000 (16:00 -0400)]
Add options for locality handling and SetLocality command

Add options for locality handling so that commands in locality
4 for example are rejected per command line parameter. This is
useful when the vTPM is used with containers.

Also implement the custom TPM/TPM2_SetLocality command to allow
the Linux vTPM proxy driver to set the locality in which subsequent
TPM commands will be executed.

Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
7 years agotests: Increase socat timeout to avoid errors on slow ARM
Stefan Berger [Wed, 31 May 2017 21:47:09 +0000 (17:47 -0400)]
tests: Increase socat timeout to avoid errors on slow ARM

Avoid getting useless test failures on ARM due to low timeout settings
of socat.

Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
7 years agobuild: test for linux-* rather than linux-gnu
Stefan Berger [Wed, 31 May 2017 21:45:51 +0000 (17:45 -0400)]
build: test for linux-* rather than linux-gnu

Check for linux-* when testing $host_os so we properly detect
when to set WITH_VTPM_PROXY.

Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
7 years agotests: create unix_tx function to use socat to talk to Unix socket
Stefan Berger [Wed, 31 May 2017 21:26:00 +0000 (17:26 -0400)]
tests: create unix_tx function to use socat to talk to Unix socket

Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
7 years agoFix compilation errors on Debian Jessie 32bit ARM
Stefan Berger [Wed, 31 May 2017 17:45:42 +0000 (13:45 -0400)]
Fix compilation errors on Debian Jessie 32bit ARM

Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
7 years agoswtpm: Refactor error response creation
Stefan Berger [Wed, 19 Apr 2017 23:12:56 +0000 (19:12 -0400)]
swtpm: Refactor error response creation

Refactor the function creating the error response.

Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
7 years agoswtpm: Have the tpm_req_header struct packed
Stefan Berger [Wed, 19 Apr 2017 21:46:56 +0000 (17:46 -0400)]
swtpm: Have the tpm_req_header struct packed

Add missing __attribute__((packed) to tpm_req_header struct.

Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
7 years agoswtpm: Check return code < 0 from handle_server_options
Stefan Berger [Tue, 18 Apr 2017 23:44:57 +0000 (19:44 -0400)]
swtpm: Check return code < 0 from handle_server_options

Fix the missing check of return code from handle_server_options
to check for negative value like all the other checks also do.

Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
7 years agoswtpm: Add missing space after hex number
Stefan Berger [Fri, 7 Apr 2017 15:23:27 +0000 (11:23 -0400)]
swtpm: Add missing space after hex number

Add a missing space character after display of a hex number.

Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
7 years agoswtpm: Fix memory leak related to option parameters
Stefan Berger [Thu, 30 Mar 2017 00:41:37 +0000 (20:41 -0400)]
swtpm: Fix memory leak related to option parameters

Fix a memory leak related to the option parameters.

Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
7 years agoswtpm: Use logprintf wherever possible
Stefan Berger [Fri, 31 Mar 2017 12:41:08 +0000 (08:41 -0400)]
swtpm: Use logprintf wherever possible

Use logprintf wherever possible. While the logging is not set up,
print error messages to stderr and prefix them with 'swtpm: '. After
the logging has been set up all error messages go into the log file.

Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
7 years agoswtpm: add logging option prefix=<prefix>
Stefan Berger [Wed, 29 Mar 2017 19:13:56 +0000 (15:13 -0400)]
swtpm: add logging option prefix=<prefix>

Add support for logging each line of output with a prefix.

Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
7 years agoswtpm: Use buffer printing for TPM_PrintAll
Stefan Berger [Wed, 29 Mar 2017 19:06:13 +0000 (15:06 -0400)]
swtpm: Use buffer printing for TPM_PrintAll

Use a buffer for printing in TPM_PrintAll. Emit the buffer
upon a new line. This prepares for printing every line with
a prefix.

Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
7 years agoRead all data at once incase of non-stream sockets.
Amarnath Valluri [Mon, 27 Mar 2017 08:24:59 +0000 (11:24 +0300)]
Read all data at once incase of non-stream sockets.

Add MAIN_LOOP_FLAG_READALL for non SOCK_STREAM client sockets. This allows
reading all socket data once.

Signed-off-by: Amarnath Valluri <amarnath.valluri@intel.com>
7 years agoswtpm: Keep client data connection alive
Amarnath Valluri [Fri, 31 Mar 2017 06:54:38 +0000 (09:54 +0300)]
swtpm: Keep client data connection alive

swtpm server is closing the client data connection after serving a single
request, which shall not happen. Hence added MAIN_LOOP_FLAG_KEEP_CONNECTION
mainloop flag to keep the client data connection alive, till client is alive.

Signed-off-by: Amarnath Valluri <amarnath.valluri@intel.com>
7 years agoswtpm: Added support for passing control channel client fd.
Amarnath Valluri [Wed, 15 Mar 2017 20:10:29 +0000 (22:10 +0200)]
swtpm: Added support for passing control channel client fd.

New option '--ctrl clientfd=<fd>' is added to the control socket parameters.
The passed 'fd' is used as control channel client-fd and treated as single
client mode.

Signed-off-by: Amarnath Valluri <amarnath.valluri@intel.com>
7 years agomainloop: enumerate the pollfd indexes.
Amarnath Valluri [Tue, 21 Mar 2017 13:30:57 +0000 (15:30 +0200)]
mainloop: enumerate the pollfd indexes.

Signed-off-by: Amarnath Valluri <amarnath.valluri@intel.com>
7 years agoswtpm: Set errno to 0 before calling strtoul
Stefan Berger [Fri, 31 Mar 2017 12:11:25 +0000 (08:11 -0400)]
swtpm: Set errno to 0 before calling strtoul

Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
7 years agoswtpm_ioctl: Rearrange code for Unix client socket setup
Stefan Berger [Tue, 14 Mar 2017 11:32:08 +0000 (07:32 -0400)]
swtpm_ioctl: Rearrange code for Unix client socket setup

Rearrange the code of the setup of the Unix client socket.

Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
7 years agoswtpm_bios: Rearrange code for Unix client socket setup
Stefan Berger [Tue, 14 Mar 2017 12:28:24 +0000 (08:28 -0400)]
swtpm_bios: Rearrange code for Unix client socket setup

Rearrange the code of the setup of the Unix client socket.

Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
7 years agoswtpm: Initialize variables in ctrlchannel_return_state
Stefan Berger [Tue, 14 Mar 2017 11:58:32 +0000 (07:58 -0400)]
swtpm: Initialize variables in ctrlchannel_return_state

Initialize variables in ctrlchannel_return_state so that all error cases
are properly handled.

Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
7 years agoswtpm: describe ctrlchannel_process_fd function
Stefan Berger [Tue, 14 Mar 2017 11:53:58 +0000 (07:53 -0400)]
swtpm: describe ctrlchannel_process_fd function

Describe purpose and parameters of the ctrlchannel_process_fd function.

Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
7 years agoswtpm_ioctl: initialize locality variable
Stefan Berger [Tue, 14 Mar 2017 11:32:08 +0000 (07:32 -0400)]
swtpm_ioctl: initialize locality variable

Initialize the locality variable.

Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
7 years agoMerge pull request #25 from pohly/patch-1
Stefan Berger [Wed, 1 Mar 2017 15:03:28 +0000 (10:03 -0500)]
Merge pull request #25 from pohly/patch-1

README: clarify status of qemu tpm patches

7 years agotest: Add --log parameter to test logging
Stefan Berger [Fri, 3 Feb 2017 20:09:41 +0000 (15:09 -0500)]
test: Add --log parameter to test logging

Add the --log parameter to test log levels 1 and 20.

Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
7 years agoswtpm: set default log level to 1
Stefan Berger [Fri, 3 Feb 2017 16:21:29 +0000 (11:21 -0500)]
swtpm: set default log level to 1

Set the default log level to 1 so that console output is shown.
This can be turned off with --log level=0

Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
7 years agoswtpm: Set loglevel to 1 if log file or file descriptor is given
Stefan Berger [Fri, 3 Feb 2017 15:22:27 +0000 (10:22 -0500)]
swtpm: Set loglevel to 1 if log file or file descriptor is given

Set the default log level to 1 if log file or file descriptors are
given.

Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
7 years agoman pages: make log level bold
Stefan Berger [Thu, 2 Feb 2017 22:53:15 +0000 (17:53 -0500)]
man pages: make log level bold

Fix the log level parameter to appear in bold.

Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
7 years agoswtpm_cuse: Add log level parameter to help screen and man page
Stefan Berger [Thu, 2 Feb 2017 22:45:40 +0000 (17:45 -0500)]
swtpm_cuse: Add log level parameter to help screen and man page

Add the log level parameter to the CUSE TPM's help screen and man
page.

Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
7 years agoswtpm_cert: Create sets of items
Stefan Berger [Thu, 2 Feb 2017 18:07:29 +0000 (13:07 -0500)]
swtpm_cert: Create sets of items

Following the example in the Appendix A.1 of the TCG EK Credential
Profile Spec Version 2.0, a ASN.1 SET is supposed to be created for
each one of the items. This patch fixes the format.

Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
7 years agoswtpm_cert: use GNUTLS 3.5 function to set TPM data
Stefan Berger [Thu, 2 Feb 2017 15:49:58 +0000 (10:49 -0500)]
swtpm_cert: use GNUTLS 3.5 function to set TPM data

Use the GNUTLS 3.5 function gnutls_x509_crt_set_subject_alt_othername
to set the TP<M and platform manufacturer info since the other function
does not accept binary data.

Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
7 years agotests: Skip CUSE TPM related tests if cuse module is not available
Stefan Berger [Thu, 2 Feb 2017 14:01:37 +0000 (09:01 -0500)]
tests: Skip CUSE TPM related tests if cuse module is not available

Skip the CUSE TPM related tests if the CUSE kernel module is not
available. Return similar error messages for both CUSE and VTPM proxy
module if they are not available.

Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
7 years agotests: Fix return code to skip test
Stefan Berger [Wed, 1 Feb 2017 22:25:48 +0000 (17:25 -0500)]
tests: Fix return code to skip test

Fix the return code indicating that the test code be skipped.
We need to return 77.

Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
7 years agoImprove the build and install instructions
Stefan Berger [Wed, 1 Feb 2017 01:06:50 +0000 (20:06 -0500)]
Improve the build and install instructions

Improve the instruction for building the project on Debian and
RPM based systems.

Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
7 years agotests: Wait for chardev to appear
Stefan Berger [Tue, 24 Jan 2017 13:43:48 +0000 (08:43 -0500)]
tests: Wait for chardev to appear

Wait for the chardev the VTPM proxy device creates to actually appear.
In some cases the exec statement opening the file would otherwise
create a file /dev/tpm0 for example and subsequently tests then ended
up failing.

Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
7 years agoswtpm: Expose logging level to command line
Stefan Berger [Mon, 23 Jan 2017 23:18:59 +0000 (18:18 -0500)]
swtpm: Expose logging level to command line

Expose the logging level to the command line by extending the
log option with a level parameter.
Extend the man swtpm man page with the level parameter.

Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
7 years agoswtpm: Support unsigned int option
Stefan Berger [Mon, 23 Jan 2017 23:05:04 +0000 (18:05 -0500)]
swtpm: Support unsigned int option

Implement support for an unsigned int option.

Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
7 years agoswtpm: Implement logging following indentation level
Stefan Berger [Mon, 23 Jan 2017 22:56:07 +0000 (17:56 -0500)]
swtpm: Implement logging following indentation level

Introduce a log level for the logging functions. The log level
is defined by the number of spaces used for indentation. Adapt
the log functions to only log when the number of leading spaces
in a string is appropriate for logging.

Call the log function of libtpms to set the file descriptor to
log to, the log level, and log line prefix.

Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
7 years agoswtpm: Fix buffer used in logging output
Stefan Berger [Mon, 23 Jan 2017 22:52:23 +0000 (17:52 -0500)]
swtpm: Fix buffer used in logging output

Fix the buffer used in the logging output.

Signed-off-b: Stefan Berger <stefanb@linux.vnet.ibm.com>

7 years agotests: Add a test case for swtpm using the vTPM proxy device
Stefan Berger [Sun, 15 Jan 2017 04:05:40 +0000 (23:05 -0500)]
tests: Add a test case for swtpm using the vTPM proxy device

Add a test case for swtpm chardev using the vTPM proxy device.

Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
7 years agoAdd bindaddr and ifname parameters to --server option on help screen
Stefan Berger [Sun, 15 Jan 2017 03:58:47 +0000 (22:58 -0500)]
Add bindaddr and ifname parameters to --server option on help screen

Fix the missing mentioning of the bindaddr and ifname parameters for
the --server option on the help screen.

Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
7 years agoErrno is not set after inet_pton
Stefan Berger [Sun, 15 Jan 2017 03:52:55 +0000 (22:52 -0500)]
Errno is not set after inet_pton

Do not call strerror(errno) after failure from inet_pton.

Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
7 years agoOnly compile vTPM proxy support if available on platform
Stefan Berger [Sun, 15 Jan 2017 02:57:54 +0000 (21:57 -0500)]
Only compile vTPM proxy support if available on platform

Support for vTPM proxy is only available on Linux.

Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
7 years agoAnnounce the TPM frontend device name and major/minor numbers
Stefan Berger [Sat, 14 Jan 2017 20:28:01 +0000 (15:28 -0500)]
Announce the TPM frontend device name and major/minor numbers

Announce the TPM frontend device name and major/minor numbers.

Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
7 years agoswtpm: print TPM commands read from file descriptor
Stefan Berger [Sat, 14 Jan 2017 02:48:08 +0000 (21:48 -0500)]
swtpm: print TPM commands read from file descriptor

Print TPM commands read from the file descriptor.

Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
7 years agoImplement option --vtpm-proxy to create Linux vtpm proxy device
Stefan Berger [Fri, 13 Jan 2017 23:32:57 +0000 (18:32 -0500)]
Implement option --vtpm-proxy to create Linux vtpm proxy device

Implement the option --vtpm-proxy that create a Linux vtpm proxy device
and makes the chardev TPM listen on the anaonymous file descriptor that
is returned from the ioctl creating the device.

Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
7 years agoREADME: clarify status of qemu tpm patches
Patrick Ohly [Tue, 10 Jan 2017 16:21:32 +0000 (17:21 +0100)]
README: clarify status of qemu tpm patches

Makes it easier to find them and learn about the upstream status.

Signed-off-by: Patrick Ohly <patrick.ohly@intel.com>
7 years agoDisplay chardev choice only if compiled in
Stefan Berger [Tue, 3 Jan 2017 13:22:50 +0000 (08:22 -0500)]
Display chardev choice only if compiled in

Only display the chardev choice if chardev support has been
compiled in.

Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
7 years agoDetect whether to build with chardev
Stefan Berger [Tue, 3 Jan 2017 12:13:19 +0000 (07:13 -0500)]
Detect whether to build with chardev

Detect whether to build with the chardev interface and only run tests that
need the chardev if it is supported on a particular platform.

Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
7 years agoConditionally run tests
Stefan Berger [Tue, 3 Jan 2017 01:55:00 +0000 (20:55 -0500)]
Conditionally run tests

Conditionally run tests if building with CUSE interface or if
building with swtpm_setup.

Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
7 years agoReturn EXIT_FAILURE if unknown command was given
Stefan Berger [Tue, 3 Jan 2017 00:44:33 +0000 (19:44 -0500)]
Return EXIT_FAILURE if unknown command was given

Return EXIT_FAILURE to the caller if an unknown command was given.

Signed-off-by: Stefan Berger <stefan@linux.vnet.ibm.com>
7 years agoEnable building on cygwin
Stefan Berger [Mon, 2 Jan 2017 23:50:47 +0000 (18:50 -0500)]
Enable building on cygwin

Enable building the swtpm on cygwin.

Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
7 years agoSkip swtpm_setup build if NVRAM tools are not available
Stefan Berger [Mon, 2 Jan 2017 23:36:53 +0000 (18:36 -0500)]
Skip swtpm_setup build if NVRAM tools are not available

When NVRAM tools are not available we skip building swtpm_setup.

Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
7 years agoAdd configure option --with-cuse to enable building without CUSE
Stefan Berger [Mon, 2 Jan 2017 23:32:48 +0000 (18:32 -0500)]
Add configure option --with-cuse to enable building without CUSE

Enable building without CUSE interface using --without-cuse.

Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
7 years agoReplace the CLA with the DCO, simply requiring a Signed-off-by:
Stefan Berger [Wed, 21 Dec 2016 16:11:48 +0000 (11:11 -0500)]
Replace the CLA with the DCO, simply requiring a Signed-off-by:

Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
7 years agobuild: search for nonstandard libtpms locations using LIBRARY_PATH
Stefan Berger [Tue, 6 Dec 2016 20:45:51 +0000 (15:45 -0500)]
build: search for nonstandard libtpms locations using LIBRARY_PATH

Allow setting the LIBRARY_PATH variable when running configure so
that we can find libtpms in non-standard locations.

Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
8 years agobuild: fix Debian packaging if swtpm_cert is missing
Stefan Berger [Tue, 27 Sep 2016 21:26:03 +0000 (17:26 -0400)]
build: fix Debian packaging if swtpm_cert is missing

Fix the Debian packaging if swtpm_cert is missing. We convert
swtpm-tools.install into an executable shell script that displays
all files to package.

Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
8 years agobuild: Package swtpm_ioctls.3 in swtpm-dev package
Stefan Berger [Tue, 27 Sep 2016 21:24:11 +0000 (17:24 -0400)]
build: Package swtpm_ioctls.3 in swtpm-dev package

Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
8 years agoMerge pull request #10 from nicholasbishop/patch-1
Stefan Berger [Sun, 17 Jul 2016 23:04:29 +0000 (19:04 -0400)]
Merge pull request #10 from nicholasbishop/patch-1

Fix two typos in the README

8 years agoFix two typos in the README
Nicholas Bishop [Tue, 12 Jul 2016 17:37:23 +0000 (13:37 -0400)]
Fix two typos in the README

8 years agorpm: kernel-modules-extra only required on Fedora
Stefan Berger [Mon, 27 Jun 2016 11:02:24 +0000 (07:02 -0400)]
rpm: kernel-modules-extra only required on Fedora

The kernel-moudles-extra packages is only required on Fedora.

Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
8 years agoAllow choice of crypto subsystem via rpmbuild parameter
Stefan Berger [Mon, 27 Jun 2016 10:38:39 +0000 (06:38 -0400)]
Allow choice of crypto subsystem via rpmbuild parameter

Use 'rpmbuild -ba --define "crypto_subsystem openssl" dist/swtpm.spec'
to build swtpm with openssl.

Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
8 years agoswtpm_setup: support --tpmstate as alias for --tpm-state
Stefan Berger [Mon, 27 Jun 2016 00:26:50 +0000 (20:26 -0400)]
swtpm_setup: support --tpmstate as alias for --tpm-state

Support --tpm-state option as an alias for the --tpmstate option.
--tpm-state is a parameter that is also supported by the swtpm
program, so for consistency reasons we should have the same name
for the option here.

Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
8 years agoswtpm_ioctl: Add missing option descriptions to usage page
Stefan Berger [Mon, 27 Jun 2016 00:14:48 +0000 (20:14 -0400)]
swtpm_ioctl: Add missing option descriptions to usage page

Add missing --unix and tcp option descriptions to the usage page.

Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>