Commit Graph

1150 Commits

Author SHA1 Message Date
Stefan Berger
e3d8093b00 swtpm_ioctl: enable state migration for socket interface 2017-06-15 18:53:31 -04:00
Stefan Berger
dc1111362b 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>
2017-06-06 16:51:45 -04:00
Stefan Berger
3b563487b6 Extend help screen with allow-set-locality option
Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
2017-06-06 16:42:39 -04:00
Stefan Berger
a2f81ea2c6 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>
2017-06-06 14:10:01 -04:00
Stefan Berger
cb35cba105 tests: Extend existing test with one for rejection of locality 4
Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
2017-06-01 16:59:20 -04:00
Stefan Berger
4a56541491 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>
2017-06-01 16:59:20 -04:00
Stefan Berger
bbf12ed918 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>
2017-05-31 17:47:11 -04:00
Stefan Berger
f071d82071 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>
2017-05-31 17:45:54 -04:00
Stefan Berger
9606607075 tests: create unix_tx function to use socat to talk to Unix socket
Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
2017-05-31 17:26:44 -04:00
Stefan Berger
768d657b69 Fix compilation errors on Debian Jessie 32bit ARM
Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
2017-05-31 13:45:44 -04:00
Stefan Berger
b12d77106c swtpm: Refactor error response creation
Refactor the function creating the error response.

Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
2017-04-19 19:16:29 -04:00
Stefan Berger
811a255869 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>
2017-04-19 18:45:35 -04:00
Stefan Berger
43153f3d26 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>
2017-04-19 18:44:47 -04:00
Stefan Berger
073e71f99e 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>
2017-04-07 11:23:30 -04:00
Stefan Berger
510f184896 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>
2017-03-31 08:55:08 -04:00
Stefan Berger
cba815690c 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>
2017-03-31 08:55:08 -04:00
Stefan Berger
93f4a38940 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>
2017-03-31 08:55:08 -04:00
Stefan Berger
8e794c635a 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>
2017-03-31 08:28:21 -04:00
Amarnath Valluri
87d56f936c 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>
2017-03-31 08:17:05 -04:00
Amarnath Valluri
0a0885cf9d 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>
2017-03-31 08:17:05 -04:00
Amarnath Valluri
93edca48a2 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>
2017-03-31 08:15:51 -04:00
Amarnath Valluri
4cb30804d6 mainloop: enumerate the pollfd indexes.
Signed-off-by: Amarnath Valluri <amarnath.valluri@intel.com>
2017-03-31 08:14:33 -04:00
Stefan Berger
3f37cc3e5f swtpm: Set errno to 0 before calling strtoul
Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
2017-03-31 08:14:33 -04:00
Stefan Berger
d7bbe3de5c 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>
2017-03-14 08:37:56 -04:00
Stefan Berger
faceb515c4 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>
2017-03-14 08:37:56 -04:00
Stefan Berger
753770033a 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>
2017-03-14 08:37:56 -04:00
Stefan Berger
5569ab5674 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>
2017-03-14 08:37:56 -04:00
Stefan Berger
f5b286fc7d swtpm_ioctl: initialize locality variable
Initialize the locality variable.

Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
2017-03-14 08:37:34 -04:00
Stefan Berger
1d450b8db2 Merge pull request #25 from pohly/patch-1
README: clarify status of qemu tpm patches
2017-03-01 10:03:28 -05:00
Stefan Berger
89d85f9a93 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>
2017-02-03 15:15:31 -05:00
Stefan Berger
51c41a4862 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>
2017-02-03 11:21:31 -05:00
Stefan Berger
380763be6b 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>
2017-02-03 10:23:38 -05:00
Stefan Berger
65d8e4d834 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>
2017-02-02 17:53:17 -05:00
Stefan Berger
c7c657ec3d 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>
2017-02-02 17:52:30 -05:00
Stefan Berger
540a9a9632 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>
2017-02-02 13:07:32 -05:00
Stefan Berger
624b11d860 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>
2017-02-02 10:50:35 -05:00
Stefan Berger
cde5f608e5 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>
2017-02-02 09:01:55 -05:00
Stefan Berger
4994a97e52 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>
2017-02-01 17:28:18 -05:00
Stefan Berger
70ee833604 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>
2017-01-31 20:06:52 -05:00
Stefan Berger
ca906a0212 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>
2017-01-24 08:43:50 -05:00
Stefan Berger
e8b5115f1a 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>
2017-01-23 19:09:50 -05:00
Stefan Berger
a167784102 swtpm: Support unsigned int option
Implement support for an unsigned int option.

Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
2017-01-23 18:20:18 -05:00
Stefan Berger
e34f4ef8eb 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>
2017-01-23 18:20:17 -05:00
Stefan Berger
f44aec27e0 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>
2017-01-23 17:52:25 -05:00
Stefan Berger
2308308b5f 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>
2017-01-15 09:47:01 -05:00
Stefan Berger
8047b5d62d 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>
2017-01-15 08:55:53 -05:00
Stefan Berger
4c6fc24467 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>
2017-01-15 08:55:49 -05:00
Stefan Berger
c751e32ec7 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>
2017-01-15 08:55:07 -05:00
Stefan Berger
099c9cb64b 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>
2017-01-14 15:28:05 -05:00
Stefan Berger
794f84982d 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>
2017-01-13 21:48:12 -05:00