Commit Graph

1150 Commits

Author SHA1 Message Date
Stefan Berger
353ede4a17 debian: add a few more files to the tools package
Add a few more config files and the swtpm-localca tool to the
tools package.

Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
2018-01-18 17:26:58 -05:00
Marc Kleine-Budde
3f548f90a0 treewide: remove executable bit from config files and c-code
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
2018-01-17 10:45:25 -05:00
Stefan Berger
e5477e193f swtpm_setup: fix typo in help screen
--no-overwrite -> --not-overwrite

Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
2018-01-12 09:48:40 -05:00
Stefan Berger
be5557f3ff swtpm_cert: Sign cert using SHA256
Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
2018-01-02 09:41:34 -05:00
Stefan Berger
5ceed802cc samples: pass --subject to swtpm_cert since certtool needs a subject
Certtool seems to not verify a certificate chain properly unless
the certificate has a distinguished name.

Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
2017-12-21 21:14:48 -05:00
Stefan Berger
a8bc74fd01 swtpm_setup: Only pass through vmid parameter if it was set
Only pass through the vmid parameter to the tool creating the cert
if this parameter was set. The tool creating the cert may require
it or ignore it and is supposed to be able to track certificates
for which it minted certs using this parameter.

Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
2017-12-20 20:18:54 -05:00
Stefan Berger
863d1a157c samples: error if swtpm-localca gets an unsupported option passed
Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
2017-12-20 20:18:54 -05:00
Stefan Berger
5b1090a583 swtpm_cert: Fix broken certificate verification
The certificate chain could not be verified due to a wrong
API call for getting the authority key id where the key id
was gotten instead.

Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
2017-12-20 11:12:15 -05:00
Stefan Berger
d0f4f18352 tests: Also TPM 1.2 a valid buffer size range
Adapt the test case to check whether the TPM accepted the 4000 byte
buffer size.

Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
2017-12-18 20:45:56 -05:00
Stefan Berger
8e9edf696a swtpm: reformat iovec and initialize input variable with zeros
Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
2017-12-10 11:28:59 -05:00
Stefan Berger
7306ee278a swtpm: check for invalid file descriptor (< 0)
Check for an invalid file descriptor in SWTPM_IO_Read before accessing
it.

Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
2017-12-08 09:44:17 -05:00
Stefan Berger
a56a22540e swtpm_bios: only copy the size of the source string + 1 byte
Determine the size of the unix_path parameter and then only copy
those number of bytes + terminating null into the destination.

Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
2017-12-07 19:53:41 -05:00
Stefan Berger
f42eec69f3 swtpm_ioctl: only copy the size of the source string + 1 byte
Determine the size of the unix_path parameter and then only copy
those number of bytes + terminating null into the destination.

Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
2017-12-07 18:06:38 -05:00
Stefan Berger
3bb2b4675a swtpm_ioctl: check for filename and input NULL pointers
Check whether filename and input pointers are NULL pointers.
Per previous code this is currently not possibly but should
resolve some issues with Coverity.

Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
2017-12-07 17:52:27 -05:00
Stefan Berger
5d62484fb7 swtpm_ioctl: in get_blobtype() check for blobtype NULL pointer
Check whether the passed blobtype is a NULL pointer

Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
2017-12-07 17:45:20 -05:00
Stefan Berger
aaab5d0b16 swtpm_bios: Coverity: use void * for the command
Use void * for the command rather than tpm_header *, which we do
not need. This addresses a few Coverity complaints.

Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
2017-12-07 17:06:00 -05:00
Stefan Berger
4f4f2f0a7e swtpm: Remove usage of TPMVersion enum
To allow it to compile with libtpms's master, remove the usage of
TPMLIB_TPMVersion type.

Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
2017-12-05 12:50:21 -05:00
Stefan Berger
182fbb20d6 swtpm_ioctl: explicitly check for numbytes < 0
Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
2017-12-05 12:45:31 -05:00
Stefan Berger
6c441a5272 swtpm: Do not pass a negative file descriptor
Do not a pass a negative file descriptor to getsockopt(). This fixes
a Coverity issue.

Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
2017-11-21 12:45:53 -05:00
Stefan Berger
ee40c13aaf tests: Extend encrypted state test to check for unmodified state
Extend the encrypted state test with a test case using a wrong key
for decrypting the state and make sure that the init fails and the
state files remain unmodified.

Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
2017-11-14 07:59:04 -05:00
Stefan Berger
3ca520fd1c swtpm_ioctl: print error message in case setting state blob fails
Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
2017-11-13 20:44:08 -05:00
Stefan Berger
e396140204 swtpm: log when the decryption of a state blob fails
Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
2017-11-13 20:43:11 -05:00
Stefan Berger
cf47149f88 swtpm: log when the decryption of the NVRAM file fails
Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
2017-11-13 19:35:23 -05:00
Stefan Berger
4c046e0b46 build: add missing EXTRA_DIST files
Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
2017-11-13 13:49:24 -05:00
Stefan Berger
9cf37cbfae tests: extend INIT test with case where state file is inaccessible
Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
2017-11-12 17:14:33 -05:00
Stefan Berger
3760c34251 swtpm: Add truncate parameter for --log option
Enable the resetting of the log using a truncate parameter for the
--log option.

Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
2017-11-11 14:47:27 -05:00
Stefan Berger
41deaf616e swtpm: always set the logging file descriptor on libtpms
Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
2017-11-11 14:24:12 -05:00
Stefan Berger
addf7c5e45 swtpm: Also log the control channel exchanges
Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
2017-11-10 21:48:17 -05:00
Stefan Berger
ccd1aeb15b swtpm: also log control channel commands 2017-11-10 21:32:44 -05:00
Stefan Berger
60afebf116 swtpm: Log an error if data encryption failed
Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
2017-11-10 19:04:57 -05:00
Stefan Berger
73fb0412ea swtpm: Remove file if errors occured writing it
Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
2017-11-10 19:04:57 -05:00
Stefan Berger
f1389afb87 swtpm: Move debugging output into own function
Move some of the debugging output into its own function and
differentiate output by TPM Version number.

Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
2017-11-10 18:55:54 -05:00
Stefan Berger
eff9cc1672 swtpm_setup: Add options to overwrite or not overwrite TPM state
Add options --overwrite and --not-overwrite to allow or prevent
overwriting of existing TPM state. If neiter of the options is
given and existing state is found, an error is returned.

Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
2017-11-09 10:54:07 -05:00
Stefan Berger
38304e9c81 swtpm: remove debug include file
Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
2017-11-05 15:38:13 -05:00
Stefan Berger
688c8e2400 swtpm: Implemented support for PTM_SET_BUFFERSIZE command
Implement a command for setting and querying the buffer size the
TPM implementation (libtpms) is using. The setting of the
buffersize allows to reduce the size of the buffer to a size
that the interface can support so that these two sizes match
and the TPM will not produce larger responses than what the
interface can support.

Extend swtpm_ioctl with an option to set the buffersize.

Adapt the existing tests to reflect the newly supported command.
Implement a new test for getting/setting of the buffer size.

Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
2017-11-05 14:53:00 -05:00
Stefan Berger
ca7f7a4006 swtpm: fix segfault introduced in aa3999
Changeset aa3999 introduced a segfault when calling
ctrlchannel_set_client_fd() with a NULL pointer. Like all the other
functions, we return with -1 in this case.

Since the segfault occurred on process shutdown no problems were
noticeable through bad test results or so.

Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
2017-10-30 12:02:56 -04:00
Stefan Berger
061f9dce5e swtpm: Install SIGPIPE signal handler to ignore signal
Install a SIGPIPE signal handler to ignore the signal from trying
to write to a broken pipe.

Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
2017-10-27 08:37:40 -04:00
Stefan Berger
e09966f603 swtpm_setup: Fix a couple of typos
Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
2017-10-27 08:37:40 -04:00
Stefan Berger
6098d7baae tests: implement missing wait_file_gone function
Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
2017-10-17 17:33:23 -04:00
Stefan Berger
ead37845d8 tests: replace plain sleep with wait for PID file to be gone
Replace the short sleeps with waits for the PID file to be gone.

Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
2017-10-16 14:19:48 -04:00
Stefan Berger
6d33f6eb08 tests: increase socat timeout for slow machines
Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
2017-10-16 14:19:48 -04:00
Stefan Berger
bd8f3581ef tests: Wait for previous socket or device to have disappeared
Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
2017-10-16 14:19:48 -04:00
Stefan Berger
298d17822c swtpm: clean up server and ctrlchannel at the end
Introduce another parameter to ctrlchannel_new and server_new
to pass the Unix socket's path. Implement ctrlchannel_free and
server_free to clean up and remove the Unix socket's path.

Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
2017-10-16 14:19:48 -04:00
Stefan Berger
aa3999d387 swtpm: Implement ctrlchannel_set_client_fd()
Implement ctrlchannel_set_client_fd() to set a new client
fd and return its current value.

Use this new function to set the file descriptor to -1 upon
closing its associate file descriptor in the main loop.

Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
2017-10-16 14:19:48 -04:00
Stefan Berger
75f9f0d300 swtpm: Implement server_set_fd()
Implement server_set_fd() function to get the current file descriptor
and set a new one on the server structure.

Use this function to transfer the server file descriptor from the
server structure to the mainloop structure and have the main loop
close the file descriptor.

Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
2017-10-16 14:19:48 -04:00
Stefan Berger
fa3d8e4910 swtpm_ioctl: Display error in case of read() returns < 0
Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
2017-10-16 14:19:48 -04:00
Stefan Berger
35e571b43c tests: Wait for swtpm to open socket or chardev
Rather than waiting for some time poll for the swtpm to either
open a socket or chardev.

Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
2017-10-16 14:19:48 -04:00
Stefan Berger
0f648eda0b tests: Fix filename used for volatilestate
Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
2017-10-16 14:19:48 -04:00
Stefan Berger
06b8d0327b build: fix linker SEARCH_DIR extraction for OpenBSD and Cygwin
Signed-off-by: Stefan Berger <stefanb@linx.vnet.ibm.com>
2017-10-12 13:07:46 -04:00
Stefan Berger
6ee0bd79d7 swtpm: Fix header inclusion for OpenBSD
Signed-off-by: Stefan Berger <stefanb@linx.vnet.ibm.com>
2017-10-12 13:07:46 -04:00