Commit Graph

726 Commits

Author SHA1 Message Date
Stefan Berger
e47bd065ff swtpm: remove pidfile after process exits
Remove the pidfile once swtpm process exits.

Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
2015-11-15 13:55:06 -05:00
Stefan Berger
29cfd0a4fd swtpm: add support for listening on chardev
Add support for 'swtpm chardev' that listens for TPM commands on a given
character device and sends responses through it.

Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
2015-11-08 14:13:23 -05:00
Stefan Berger
27a3c23967 swtpm: make all possible variables static
Some of the variables in swtpm.c were not static, fix this.

Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
2015-11-08 13:46:17 -05:00
Stefan Berger
c4ac0a11e9 build: remove hardcoded tss user and group
Remove the hardcodes tss user and group and to configure with
--with-tss-user=tss --with-tss-group=tss to set the tss user
and group to be used.

Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
2015-11-02 20:47:37 -05:00
Stefan Berger
118cc15230 swtpm: Check for existing device
Check for an existing device with the same name and print an error
if the device already exists.

Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
2015-10-29 11:00:56 -04:00
Stefan Berger
6e710866f3 swtpm: report missing TPM state path
Report missing TPM state path as soon as possible.

Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
2015-10-29 10:48:30 -04:00
Stefan Berger
bc525ccdab swtpm: Add support for --tpmstate dir=<dir> command line parameter
Add support for the --tpmstate dir=<dir> command line parameter.
It will be used instead of the TPM_PATH, unless it is not set.

Adapt two test cases for the new parameter.

Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
2015-10-27 21:58:10 -04:00
Stefan Berger
b215173767 swtpm: Add command line parameter for pidfile
Add support for --pid file=<pidfile> command line parameter support.
The swtpm_cuse and swtpm now write their process IDs (pids) into
a file.

Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
2015-10-26 06:34:14 -04:00
Stefan Berger
7d4b4514a3 build: enable RPM building for non-root users
Disable the chown commands when building an RPM; we try to detect this
by the usage of DESTDIR.

Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
2015-10-16 19:08:43 -04:00
Stefan Berger
373a9be985 Some more changes to the ioctl's
Some more changes to tpm_ioctl.h including
- comment for request and response part of an ioctl
- unified format
- prefix all constants with PTM_

Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
2015-10-03 18:41:33 -04:00
Stefan Berger
8e45d3e25e swtpm_cert: remove unnecessary file
Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
2015-07-02 18:05:17 -04:00
Stefan Berger
84d2e89a74 swtpm_setup: remove PATH extension to local dir
Remove the extension of PATH to the local dir('.') from swtpm_setup.sh
and adapt test cases accordingly.

Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
2015-07-02 10:50:05 -04:00
Stefan Berger
4f185f6e45 swtpm_setup: cleanup
Cleanup the code a bit:
 o added description to several functions
 o remove empty lines between functions
 o cleanup the usage screen
 o fix the parameters to logerr

Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
2015-07-01 21:01:59 -04:00
Stefan Berger
a209a01816 swtpm_cuse: be more consistent with input buffer size checks
Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
2015-06-23 14:04:59 -04:00
Stefan Berger
ff1a99d7e6 swtpm: receiving of TPM state blob ends once last byte has been copied
The receiving of TPM state blob ends when the last byte has been copied
into a response to the user. No more request need to be sent afterwards.

Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
2015-06-05 16:28:09 -04:00
Stefan Berger
c896156107 swtpm: delete blob file if set blob has length 0
If a blob with length 0 is set, we make sure the corresponding file
that would hold this blob is not available.

Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
2015-06-05 16:25:33 -04:00
Stefan Berger
05cd79b843 Support read()/write() for TPM state blob transfer
Support the read/write interface and POSIX API calls for transfer of
TPM state blobs.

Extend the swtpm_ioctl program to support this as well. Use the
environment variable SWTPM_IOCTL_BUFFERSIZE to set the size of the
buffer to use and enable the read/write interface in this (test)
program.

Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
2015-06-04 18:49:25 -04:00
Stefan Berger
5e60c24f40 remove the tpm_number from the public interface
Remove the tpm_number from the public interface (while we still can do that)

Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
2015-05-28 12:55:30 -04:00
Stefan Berger
31380fe68e tpm_ioctl: Remove _t from the types
Since POSIX reserves the *_t namespace of types, remove it from
all our typedefs. While doing that, adjust the typedefs to all have
the prefix ptm_ .

Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
2015-05-28 12:55:30 -04:00
Stefan Berger
857daa32b9 tpm_ioctl: convert blob type to 32 bit int
Convert the blob type to 32bit int (while we still can do that ... )

Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
2015-05-28 12:55:30 -04:00
Stefan Berger
8f3b270ab0 swtpm: move code to set state blob into own function
Move the code that sets the TPM's state blob into its own function.

Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
2015-05-28 12:55:30 -04:00
Stefan Berger
22fda83bf9 swtpm: move code to get the TPM state blobs into own function
Move the code to get the TPM state blobs into is own function and introduce
a caching layer that retrieves the state blob from the TPM once and has
subsequent requests to copy the state work on the cached blob.

Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
2015-05-28 12:55:30 -04:00
Stefan Berger
ad976d1a2e Add copyright stanza where missing; update date
Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
2015-05-26 20:52:40 -04:00
Stefan Berger
bd98690a4a Add ioctl to get configuration flags about keys in use
Add an ioctl that lets an application retrieve which keys are in use by the
TPM, i.e., file encryption or migration key

Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
2015-05-26 07:30:38 -04:00
Stefan Berger
1680c41d9e swtpm: Add a command line option for a migration key
The migration key ensures that TPM state blobs, when retrieved using the
ioctl for getting state blobs, are always encrypted with this key.
When the state is later on loaded back into the TPM using the ioctl
to set the state blobs, the migration key is used to decrypt them.

Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
2015-05-25 11:18:44 -04:00
Stefan Berger
082533af22 swtpm: Have crypto functions use a key as parameter
Have the crypto functions use a key as a parameter rather than having them
operate on a specific fixed key.

Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
2015-05-25 11:12:23 -04:00
Stefan Berger
81264f7356 swtpm: break apart key parsing function
Break the key parsing function apart into a common parsing function
and one specific to the file encryption key.

Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
2015-05-25 11:12:23 -04:00
Stefan Berger
bed4894cd7 swtpm: prepend a header in front of all blobs retrieved from the TPM
Prepend a header in front of all blobs retrieved from the TPM.
Write flags into this header indicating whether the blob is
encrypted.

Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
2015-05-25 11:12:23 -04:00
Stefan Berger
b902468900 swtpm: integrity protect the encrypt TPM state
Integrity protect the TPM state when it is written in entrypted form.
libtpms state (for TPM1.2) is also integrity protecting the blobs, but
we better determine the integrity of the decrypted data on the layer
above it.
2015-05-19 16:35:08 -04:00
Stefan Berger
fdbc203585 swtpm: more precise error message if setuid doesn't work
Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
2015-05-16 17:59:39 -04:00
Stefan Berger
af0ef0205a swtpm: assign value to saveptr used in strtok_r
Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
2015-05-12 14:59:16 -04:00
Stefan Berger
c6ba40fc53 swtpm: Ignore the return value of a write op before closing connection
Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
2015-05-12 14:54:45 -04:00
Stefan Berger
0a7e8d236d swtpm_setup: Annotate that we pass argv to execv intentionately
Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
2015-05-12 14:51:16 -04:00
Stefan Berger
74e53a6268 swtpm: No need to compare locality with negative values
Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
2015-05-12 14:48:20 -04:00
Stefan Berger
0268ef45d2 swtpm: change type of len from size_t to ssize_t
Change the type of the len variable from size_t to ssize_t for
comparison against neg. values to work.

Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
2015-05-12 14:48:20 -04:00
Stefan Berger
414e0e8960 swtpm_ioclt: no need to compare locality with values < 0
Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
2015-05-12 14:48:11 -04:00
Stefan Berger
38a9453322 swtpm_cert: change variable type from unsigned char to char
Change variable type of val1 and val2 from unsigned char to char for
the comparison with neg. numbers to work.

Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
2015-05-12 14:24:27 -04:00
Stefan Berger
3df8cbf91b swtpm_cuse: no need to compare uint8_t locality with < 0.
Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
2015-05-12 14:20:16 -04:00
Stefan Berger
da521f048b swtpm: replace size_t with ssize_t for variable taking read() return value
Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
2015-05-12 14:18:23 -04:00
Stefan Berger
fddbb58d48 swtpm: Check file descriptor >= 0 before closing
Check the file descriptor for >= 0 before closing it. Hopefully
this makes Coverity happy.

Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
2015-05-12 14:09:05 -04:00
Stefan Berger
9e89ffa12d swtpm_bios: Remove UNIXIO socket related code since not used
We do not support UNIXIO sockets for communicatin with the swtpm
yet, so remove this.

Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
2015-05-12 14:04:03 -04:00
Stefan Berger
e387a34eab swtpm_ioctl: Move code for loading TPM stateblobs to own function
Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
2015-05-11 06:42:27 -04:00
Stefan Berger
eafb7054d8 swtpm_ioctl: Move code for saving TPM stateblobs to own function
Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
2015-05-11 06:41:42 -04:00
Stefan Berger
5ef047fedf swtpm_ioctl: move hashing code into own function
Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
2015-05-10 10:28:57 -04:00
Stefan Berger
6b7aefa9c2 swtpm: cleanup and commented ptm_ioctl
Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
2015-05-09 08:44:11 -04:00
Stefan Berger
6d7d0dd5e6 swtpm_ioctl: source formatting
Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
2015-05-09 08:41:04 -04:00
Stefan Berger
cdbfb7be1a swtpm_setup: Print error in case 'eval' fails on file permissions etc.
Also have the log function print out all parameters.

Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
2015-05-04 01:27:48 -04:00
Stefan Berger
798694516e swtpm_setup: fix variable name typo
Fix a typo in a variable name.

Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
2015-05-04 02:58:17 -04:00
Stefan Berger
58548ac677 swtpm: document some more code
Add documentation to the include file and some functions in  the source
code files.

Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>jo
2015-03-30 10:06:49 -04:00
Stefan Berger
337247ef6c swtpm: add documentation to options source code
Add documentation to the options source code and introduce an explicit
default value to return in case an option was not found while parsing.

Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
2015-03-30 07:24:08 -04:00
Stefan Berger
292fc83f3e swtpm_cuse: automatically remove volatile state after retireval
Automatically remove the volatile state file after retrieval.
2015-03-19 15:44:22 -04:00
Stefan Berger
950040f03c swtpm_cuse: implement STOP ioctl
Implement a STOP ioctl in the swtpm and swtpm_ioctl client.
Modify test cases to used swtpm_ioctl --stop.
2015-03-16 11:50:03 -04:00
Stefan Berger
33e241b562 swtpm_ioctl: if blob cannot be found TPM_NON_FATAL is returned
It's not a fatal error if a blob is not returned and the CUSE TPM replies
with TPM_NON_FATAL error code.
2015-03-16 11:19:44 -04:00
Stefan Berger
c552bcdca3 swtpm_setup: reuse existing function to stop processes 2015-03-16 11:14:53 -04:00
Stefan Berger
36a7d09481 swtpm_setup: check swtpm port
Also check the port of the swtpm before proceeding.
Fix a typo in the code.
2015-03-14 20:43:10 -04:00
Stefan Berger
ba3535aa9c swtpm_setup: remove debugging code 2015-03-13 14:52:11 -04:00
Stefan Berger
3e5085efff swtpm_setup: Test connection with tcsd
On rare occassions TCSD refuses connections after start and nothing
works; so we test the connection with TCSD and kill it if it doesn't
work.

This now seems to fix the tests/test_parameters that occosionally
had been reporting an error.
2015-03-13 12:35:59 -04:00
Stefan Berger
f55b697663 Only allow a single command per TCP connection to be sent
Only allow a single command per TCP connection to be sent to
the socket TPM. This solves a problem with the test_parameters
testcase where the TPM seems to get stuck in the poll().
However, the testcase still is not entirely error-free.
2015-03-12 21:45:34 -04:00
Stefan Berger
bba74db294 Only list LISTEN sockets when checking on tcsd
Only list LISTEN sockets when checking whether tcsd has started
listening on a socket, yet.

Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
2015-03-12 14:21:59 -04:00
Stefan Berger
198ebab3c1 Add new ioctls for getting and setting state blobs
Add new ioctls to get and set the 3 different types of state blobs
from and to the CUSE TPM. Add test cases for testing the new ioctl's
on a CUSE TPM that stores the state encrypted and on a CUSE TPM that
stores it non-encrypted.

Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
2015-03-12 09:32:28 -04:00
Stefan Berger
5fd9856094 Show error message when not installing as root
Only root can change the ownership of swtpm_setup.sh to tss:tss, so
only root can install the file.

Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
2015-02-20 18:44:47 -05:00
Stefan Berger
f97114cc4c Fix build on RHEL6 where we need -lgthread-2.0
Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
2015-01-30 18:16:09 -05:00
Stefan Berger
ca84b6cde7 Allocate TPM command buffer on heap rather than on the stack
Allocate the TPM command buffer on the heap. Previously it was
allocated on the stack.

Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
2015-01-30 17:56:26 -05:00
Stefan Berger
a84f2372ba Change void * to concrete structure.
Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
2015-01-30 17:29:54 -05:00
Stefan Berger
e6085e9615 Add some hardening flags to compiler and linker
Protect the stack, create position indep. executables, use Relocation
Read-Only (RELRO) and have the linker resolve all symbols upon
program start.

Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
2015-01-30 17:08:40 -05:00
Stefan Berger
410683fa05 Remove unused wrapper tcsd-launcher.c
Remove the unused wrapper program tcsd-launcher.c.

Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
2015-01-19 14:47:35 -05:00
Stefan Berger
ec37bb56cb Make SELinux policy extension support chooseable
Extend configure.ac to make SELinux policy extension support
chooseable. By default configure will check whether SELinux
support is installed on the local system and will add SELinux
policy extension support if support is found.

Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
2014-12-19 09:28:47 -05:00
Stefan Berger
3bbdd7bc76 Support for openssl
Also support swtpm using OpenSSL library. 
Introduce --with-openssl in configure.

Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
2014-12-18 22:19:57 -05:00
Stefan Berger
ba2f0af638 Enable building of rpms on RHEL 7
Some tweaks to enable building of RPMs on RHEL 7.
2014-12-09 20:37:27 -05:00
Stefan Berger
09c58b7003 Make compileable on RHEL 7 for ppc64
There are some tiny adjustments needed for linking on RHEL 7 for ppc64.
Otherwise it works there now as well.
2014-12-09 20:10:00 -05:00
Stefan Berger
baecda4040 Link programs with minimal set of libraries
Don't build up a global LIBS variable but put the libraries into
individual variables that can be used for linking individual programs
with. Do the same for CFLAGS.
2014-12-09 19:59:27 -05:00
Stefan Berger
0321a3808d Add ioctl to reset the establishment bit
Add an ioctl to reset the establishment bit. It takes as an
argument the locality to use.
2014-12-08 11:35:16 -05:00
Stefan Berger
6e93fdef0f add new README files for the tools and modify main README file 2014-12-05 15:11:15 -05:00
Stefan Berger
e46a2b6686 merging swtpm-tools into this project 2014-12-05 13:43:21 -05:00
Stefan Berger
6fc8fb9f4c initialize errno to 0 before strtoul call 2014-12-05 12:43:45 -05:00
Stefan Berger
f163b20210 initial check-in 2014-12-05 11:16:03 -05:00