Commit Graph

1028 Commits

Author SHA1 Message Date
Stefan Berger
5b09de83a2 SELinux: Install policy package files to /usr/share/selinux/packages
Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
2018-09-24 17:48:41 -04:00
Stefan Berger
0f05604869 build-sys: Create compressed policy package files
Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
2018-09-24 17:48:41 -04:00
Stefan Berger
b88244ebeb SELinux: Extend SELinux policy with rules for svirt_tcg
Extend the SELinux policy with rules for svirt_tcg when
QEMU is not being started with KVM by libvirt.

Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
2018-09-24 17:48:41 -04:00
Stefan Berger
b28f585c41 SELinux: Fix title in interface file
Fix the title in the interface file to say 'swtpm'.

Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
2018-09-24 17:48:41 -04:00
Stefan Berger
94bb9f2d71 Travis: Fix the coverity scan build
Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
2018-09-24 17:46:58 -04:00
Stefan Berger
caae7b1ad7 ek-cert: Initialize datum variable to prevent unintialized access
Coverity scan shows an uninitialized access in case an error is
encountered and the cleanup path is taken before datum was initialized.
Fix the error by initializing the variable.

Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
2018-09-24 17:46:58 -04:00
Stefan Berger
cc6c586f78 swtpm_cert: Fix a potential buffer overrun error
Coverity scan discovered a buffer overrun error in case the
datum->size = 0. Fix the error.

The function with the potential error is not called if datum->size == 0.

Also make the 'size' variable larger so there cannot be a overrun in
'size = datum->size + sizeof(buffer) - i'.

Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
2018-09-24 17:46:39 -04:00
Stefan Berger
aded2b6f69 swtpm: Initialize hdrflags to 0 in case no header was read
The hdrflags need to be initialized to 0 in case no header
was read from the file.

Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
2018-09-24 16:42:47 -04:00
Stefan Berger
f98592c590 git: Ignore install-sh
Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
2018-09-17 12:52:05 -04:00
Stefan Berger
a967f79d52 man: Replace bindaddress with bindaddr in swtpm man page
The swtpm man page incorrectly showed binaddress as the option parameter
for the address to bind to. It must be called bindaddr.

Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
2018-09-17 12:23:22 -04:00
Stefan Berger
71d9581aa4 tests: Extend test cases with aes-256-cbc state file encryption
Extend existing test cases with aes-256-cbc state file encryption.

Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
2018-09-17 12:23:22 -04:00
Stefan Berger
2e260468cb swtpm_setup: Add support for choosing the cipher
Implement command line support for choosing the cipher to use for
the TPM state encryption. Either aes-128-cbc or aes-256-cbc can be
used. The same cipher has to be passed on the swtpm command line
when using the TPM.

Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
2018-09-17 11:45:44 -04:00
Stefan Berger
8ce50494c7 swtpm: Check the size of the user's key against expected size
Use the flags in the header to check the size of the provided key(s) against
the one(s) from the user. There are the state and migration keys, each has
a different flag in the header if a 256bit key was used. We display an error
about the mismatching key size against expected size if the given key is of
the wrong size.

Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
2018-09-17 11:45:44 -04:00
Stefan Berger
68a5b24124 swtpm: Add support for aes-256-cbc
Extend the buffer the key is read into to hold an 256bit key.

Add support for aes-256-cbc. Also, aes-128-cbc is now a synonym for
aes-cbc.

Update the man pages to reflect the AES 128 support.

Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
2018-09-17 11:45:44 -04:00
Stefan Berger
6e58cbeae2 swtpm: Extend en- and decryption functions for 256 bit keys
Enable 256 bit AES keys in the en- and decryption functions.
Set a flag in the header to at least indicate whether 128bit
or 256bit keys were used.

Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
2018-09-17 11:45:44 -04:00
Stefan Berger
748df6eea9 swtpm: Prepare key parsing functions to accept 256 bit keys
Prepare the functions that parse or read the key from a file
to accept 256 bit keys.

Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
2018-09-17 11:45:44 -04:00
Stefan Berger
3916364950 swtpm: Remove unnecessary fields from symmetric key structure
Remove the valid field from the symmtric key structure and
user userKeyLength > 0 instead, which is the same.

Also remove the tag and fill fields, which were originally used in
TPM 1.2.

Use function calls to test whether the file or migration key is
available where possible.

Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
2018-09-17 11:45:44 -04:00
Stefan Berger
e7ba49110c swtpm: Add key length to symmetric key structure
To get rid of the hard coded AES key size of 128, we add a filed
userKeyLength that describes the length of the key being used.
We replace TPM_AES_BLOCK_SIZE with userKeyLength where possible.

Rename TPM_AES_BLOCK_SIZE to SWTPM_AES_BLOCK_SIZE.

Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
2018-09-17 11:45:44 -04:00
Stefan Berger
a39f098fd6 swtpm: Use pbkdf2 as default kdf and sha512 for test cases
Use pbkdf2 as the default kdf and sha512 for the existing
test case. Do away with file limit of 32 bytes. This may
break backwards compatibility for some but better to do this
before a release...

Switch the existing test cases to use kdf=sha512 on the command
line where necessary to that the state for these test cases
does not need to be recreated.

Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
2018-09-17 11:45:44 -04:00
Stefan Berger
c1c46dbafc rpm: Point RPM Source URL to github.com
Point the source URL in the rpm spec to github.com where in the future
the tar should be located.

Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
2018-09-13 09:50:38 -04:00
Stefan Berger
dea49eb3e6 debian: Use autogen.sh
Use autogen.sh when building a Debian package.

Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
2018-09-13 09:28:15 -04:00
Stefan Berger
8f0f381f95 scripting: Use #!/usr/bin/env bash rather than /bin/bash
On some systems /bin/bash does not exists but the bash is somewhere
else and can be invoked with /usr/bin/env bash.

Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
2018-09-10 16:49:12 +00:00
Stefan Berger
9e786a3ae5 tests: Enable test_ctrchannel on DragonFly BSD
Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
2018-09-10 16:14:06 +00:00
Stefan Berger
dce95d0d96 header: Add support for DragonFly BSD
Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
2018-09-10 16:13:09 +00:00
Stefan Berger
54854cff1a swtpm_setup: Enable on DragonFly BSD
Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
2018-09-10 16:12:33 +00:00
Stefan Berger
f3a1b29d8b SELinux: Explicitly list policy package file dependencies
The building of rpm files fails due to some issues with the rules. To make
this work we explicily list the policy packages' dependencies and use them
in the rules. This now make 'make distcheck' work and lets us build an RPM.

Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
2018-09-04 12:05:51 -04:00
Stefan Berger
affd80ad6d travis: use 'distcheck' rather than 'check'
To test the creation of the tar and out-of-tree builds all the time, do
'distcheck' rather than a simple 'check'.

Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
2018-09-01 14:49:49 -04:00
Stefan Berger
c51c07a016 tests: Pass top level source dir to test cases for out-of-tree builds
Some test cases that root has to run did not pass the out-of-tree
builds. We need to pass the top level source dir to these test cases
and change some variable accessing config files to the right directory
for the out-of-tree build to work.

Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
2018-09-01 14:49:49 -04:00
Stefan Berger
87668f53f4 SELinux: Fix Makefile.am for out-of-tree builds
Fix the Makefile.am for out-of-tree builds so that 'make distcheck'
runs without errors.

Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
2018-09-01 14:18:23 -04:00
Stefan Berger
9c9ed515f4 build-sys: Include -T$(top_srcdir)/include for out-of-tree builds
For sys_dependencies.h to be found during out-of-tree builds we
need to include -I$(top_srcdir)/include.

Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
2018-09-01 11:45:09 -04:00
Stefan Berger
80f985897c tests: Implement support for OS/X (Darwin)
If the file descriptor 100 is open prior to trying to open
it, it must be closed first on OS/X, otherwise we get test
case failures due to interrupted connections.

Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
2018-08-30 15:44:24 -04:00
Stefan Berger
6e552e9889 swtpm_setup: Implement support for OS/X (Darwin)
Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
2018-08-30 15:40:55 -04:00
Stefan Berger
8aff5f7665 tests: set CERTTOOL to gnutls-certtool on OS/X
Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
2018-08-30 15:40:01 -04:00
Stefan Berger
b63000fa8d samples: set CERTTOOL to gnutls-certtool on OS/X
Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
2018-08-30 15:39:00 -04:00
Stefan Berger
f13d2a045c sample: wrap flock in flock_fd for support on OS/X
OS/X has a flock (v0.2.3) implementation using

brew tap discoteq/discoteq
brew install flock

The current version doesn't support -x as a parameter for
an exclusive lock but uses an exclusive lock when no parameter
is passed at all.

Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
2018-08-30 15:27:25 -04:00
Stefan Berger
bd8f4cae3a swtpm_setup: Use env var '_' to get path of program on OS/X
OS/X also does not have a proc filesystem, so we use the '_'
environment variable to determine the path of the program.

Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
2018-08-30 14:59:37 -04:00
Stefan Berger
af23737e6e swtpm: Work around deprecated daemon() on OS X
The daemon() call is deprecated on OS X. This patch works around it so
that we can compiled with -Wall -Werror and still can use the daemon()
call while avoiding compiler errors due to this function's deprecation
marking in stdlib.h.

Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
2018-08-30 14:22:09 -04:00
Stefan Berger
c7d22cf60a swtpm: Remove unused mainloop parameter from functions
Remove the struct mainLoopParams type of parameter from functions
where it is not needed.

Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
2018-08-30 12:38:08 -04:00
Stefan Berger
1294b307b5 swtpm: Fix typo in name of header guards
OS X compiler detected a typo in the name of the header guards.

Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
2018-08-30 12:33:41 -04:00
Stefan Berger
2559aa9451 Move conditional includes into sys_dependencies.h
Move the OS specific conditional includes into sys_dependencies.h
while adding OS X support.

Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
2018-08-30 11:48:10 -04:00
Stefan Berger
518a042cf7 build-sys: Use X="$X ..." rather than X+="..." in configure.ac
Some configure interpreters do not like X+='...' but need
X="$X ..." instead.

Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
2018-08-29 17:44:21 +00:00
Stefan Berger
526bf3754e tests: Use --cs for swtpm_bios rather than ambiguous -cs
The -cs parameter to swtpm_bios is like -c -s and therefore ambiguous.
Use the unambiguous long version --cs. This makes the test case work
on NetBSD, which does not support getopt_long_only().

Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
2018-08-29 13:10:01 +00:00
Stefan Berger
df9eccd404 tests: Make test_ctrlchannel work on NetBSD
Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
2018-08-29 13:07:20 +00:00
Stefan Berger
89edc2240c swtpm_setup: Support NetBSD
NetBSD support for swptm_setup.sh.in is like OpenBSD and FreeBSD.

Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
2018-08-29 13:05:07 +00:00
Stefan Berger
33bee66cf1 tools: Make compileable on NetBSD
Make the tools compileable on NetBSD.

Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
2018-08-29 13:03:31 +00:00
Stefan Berger
44eac994b6 samples: use flock -x rather than flock -e
flock -e does not work on NetBSD, so replace it with flock -x,
which should work everywhere.

Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
2018-08-29 13:01:40 +00:00
Stefan Berger
33be7be2a0 Replace tests with '==' through '='
On NetBSD configure.ac cannot have '==' in tests. So we have to replace
them with '='.

Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
2018-08-29 12:59:29 +00:00
Stefan Berger
acdf48b0bd tests: Make test_ctrlchannel work on FreeBSD
To get /dev/ptmx on FreeBSD we need to run `kldload pty`.

Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
2018-08-29 02:31:21 +00:00
Stefan Berger
91004268f0 swtpm_setup: Make work on FreeBSD; adapt echo -en
Make swtpm_setup.sh work on FreeBSD.
A common fix for the problem related to echo stopping to write
data into a socket after the first occurrence of \x0a sees to
write it into a pipe and cat the data from there.

Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
2018-08-28 22:16:07 -04:00
Stefan Berger
401e670232 tools: Make compileable on FreeBSD
Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
2018-08-29 01:18:46 +00:00