Commit Graph

1150 Commits

Author SHA1 Message Date
Andrea Bolognani
4608cc333a rpm: Move spec file and include it in dist archives
Having the spec file in the top-level directory of the dist
archive makes it possible to build rpms with a single,
convenient command.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
2021-06-03 16:09:00 -04:00
Andrea Bolognani
d66adbae5e rpm: Drop git information
Using these instead of the regular version number makes it
more complicated than necessary to perform builds, and there
doesn't seem to be any advantage in keeping them around.

After this change, the rpm building instructions contained in
the INSTALL file actually work.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
2021-06-03 16:09:00 -04:00
Andrea Bolognani
3ec34c2b8a rpm: Remove unnecessary string substitution
These are never going to change, so using string substitution
serves no purpose beyon mild obfuscation.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
2021-06-03 16:09:00 -04:00
Andrea Bolognani
5dd316bc34 rpm: Use HTTPS URL
Signed-off-by: Andrea Bolognani <abologna@redhat.com>
2021-06-03 16:09:00 -04:00
Andrea Bolognani
f747974b43 rpm: Drop swtpm.spec
This file is generated from swtpm.spec.in, and as such should
not be tracked in git; in fact, an entry for it exists in the
gitignore file.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
2021-06-03 16:09:00 -04:00
Andrea Bolognani
94af033e58 INSTALL: Don't make the user run configure twice
autogen.sh will automatically invoke configure passing it any
command line arguments it received, so we shouldn't instruct
the user to unnecessarily run it again immediately afterwards.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
2021-06-03 16:09:00 -04:00
Andrea Bolognani
a6db0e2696 gitignore: Ignore .gch files
Configure generates include/swtpm/tpm_ioctl.h.gch when trying
to figure out which hardening options can be enabled.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
2021-06-03 16:09:00 -04:00
Stefan Berger
4ec17885c4 utils: Have logit and logerr call alog to unify their code
Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2021-06-01 09:31:43 -04:00
Stefan Berger
0df3ec7180 tests: Test resolving env. variabels in swtpm_setup config file
Modify a test case and write an environment variable into the
swtpm_setup.conf config file to test that it gets resolved.

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2021-06-01 09:31:43 -04:00
Stefan Berger
e689684c57 samples: Rewrite of swtpm_localca in 'C' (addresses issue #437)
This is a 1:1 rewrite of swtpm_localca in 'C' as a final step to get
rid of the python dependency. It addresses issue #437.

Tested on: Cygwin, Fedora 33, Ubuntu Xenial & Bionic, FreeBSD,
           DragonFlyBSD, OpenBSD (i386), Mac, Debian (recent), Centos-8,
           CentOS (recent), Alpine (recent), OpenSUSE (recent),
           Fedora 28 PPC Big Endian

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2021-06-01 09:31:43 -04:00
Stefan Berger
b1cde69b09 swtpm_setup: Add proper DEPENDENCY for swtpm_setup on swtpm_utils.la
Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2021-06-01 09:31:43 -04:00
Stefan Berger
c125e34bf2 swtpm_setup: Rewrite in 'C' (addresses issue #437)
This is a 1:1 rewrite of swtpm_setup in 'C' as a first step to get
rid of the python dependency. It addresses issue #437.

Tested on: Cygwin, Fedora 33, Ubuntu Xenial & Bionic, FreeBSD,
           DragonFlyBSD, OpenBSD (i386), Mac, Debian (recent), Centos-8,
           CentOS (recent), Alpine (recent), OpenSUSE (recent)

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2021-05-28 13:08:16 -04:00
Stefan Berger
38c5cce2e6 headers: Add defines for GetInfo flags
Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2021-05-28 13:08:16 -04:00
Stefan Berger
b11da814a8 sample: swtpm-local: Fix a few minor issues
Have the statedir created in case it doesn't exist before checking for read
and write access to it.

Set the default directory where to write the results into to the current
directory '.' rather than to what would result in the root directory.

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2021-05-27 15:03:48 -04:00
Stefan Berger
eb178f87c6 swtpm_setup: Fix TPM 1.2 default SRK and owner password and help screen
Some of the wording in the help screen was odd, so rephrase it.

Fix the default owner and SRK passwords for the TPM 1.2 case.

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2021-05-26 19:52:06 -04:00
Stefan Berger
a56a3c027f swtpm_setup: Fix some minor issue
Fix some typos. The value for TPM2_ALG_SHA3_512 was wrong but also is
currently not used since libtpms does not support it yet.

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2021-05-26 19:52:06 -04:00
Stefan Berger
de69778966 build-sys: Only define single .PHONY
Fix the following issue due to multiple .PHONY definitions.

Makefile.am:34: warning: .PHONY was already defined in condition WITH_SELINUX, which is included in condition TRUE ...
Makefile.am:28: ... '.PHONY' previously defined here

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2021-05-24 12:29:18 -04:00
Stefan Berger
9b37371807 build-sys: Fix cleanup issue complain by 'make distcheck'
Fix the following `make distcheck` cleanup issue:

ERROR: files left in build directory after distclean:
./man/man8/swtpm_cuse.8

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2021-05-24 12:29:18 -04:00
Stefan Berger
3be2ad2855 swtpm: Initialize key structure before calling OpenSSL function (Coverity)
Initialize the key structure before loading the key into it. This
resolves an issue raised by Coverity, but doesn't seem to be really
necessary.

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2021-05-22 11:28:53 -04:00
Jonas Witschel
4b825a3d94 swtpm_cert: rename deprecated libtasn1 types
These types have been renamed in libtasn1 version 3.0 (released 2012-10-28).
The most recent libtasn1 version 4.17.0 (released 2021-05-13) now prints
deprecation warnings that are made fatal by -Werror:

ek-cert.c:76:13: error: 'ASN1_ARRAY_TYPE' macro is deprecated, use 'asn1_static_node' instead. [-Werror]
   76 | extern const ASN1_ARRAY_TYPE tpm_asn1_tab[];
      |             ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
[...]

The new types were introduced almost ten years ago, so they should be pretty
universally available by now.

Signed-off-by: Jonas Witschel <diabonas@archlinux.org>
2021-05-21 13:26:10 -04:00
Marc-André Lureau
da2d2f3996 build-sys: leave CFLAGS/LDFLAGS for user to be defined
This allows user to set specific flags during compilation, without
overriding configure-time cflags necessary for compilation.

See also:
https://www.gnu.org/software/automake/manual/html_node/User-Variables.html
https://www.gnu.org/software/automake/manual/html_node/Flag-Variables-Ordering.html

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
2021-05-18 18:24:51 -04:00
Stefan Berger
527a9b6063 tests: Allow volatile state file >= 9000 bytes in test_tpm2_migration_key
Changes to libtpms will require that the volatile state files
during this test may be larger than 9000 bytes.

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2021-05-12 16:03:19 -04:00
Stefan Berger
d321bfa6b4 Debian: Fix build warnings by updating compat to '10'
Thos patch fixes the following issue when building a Debian package:

dh clean --parallel
dh: warning: Compatibility levels before 10 are deprecated (level 9 in use)
   dh_auto_clean -O--parallel
dh_auto_clean: warning: Compatibility levels before 10 are deprecated (level 9 in use)
   dh_clean -O--parallel
dh_clean: warning: Compatibility levels before 10 are deprecated (level 9 in use)
 dpkg-source -b .

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2021-05-07 16:56:15 -04:00
Stefan Berger
debdb13648 swtpm: Free error that was set by failed options_parse
Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2021-03-21 08:18:23 -04:00
Stefan Berger
8e30907db2 tests: Add a Readme describing how to run the swtpm tests
Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2021-03-17 19:19:10 -04:00
Stefan Berger
be6ba388a2 tests: Store and also restore the volatile state at every step
Add restoring of the volatile state after having it stored.

Since this is now taking a long time it must be explicitly enabled
by setting the environment variable SWTPM_TEST_STORE_VOLATILE=1.

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2021-03-17 19:19:10 -04:00
Stefan Berger
b91575e7da tests: Set test-check local user.name and user.email before git am
If we are running the tests as a user that doesn't have a git config
setup we run into the following issue when trying to apply patches
suing 'git am':

Committer identity unknown

*** Please tell me who you are.

Run

  git config --global user.email "you@example.com"
  git config --global user.name "Your Name"

to set your account's default identity.
Omit --global to set the identity only in this repository.

This patch fixes this by setting the git config on the local checkout
before using 'git am'.

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2021-03-17 19:19:10 -04:00
Stefan Berger
e9fd0142df build-sys: Check for minimum required gnutls 3.4.0
RHEL 7's gnutls 3.3.29 does not take the private key passwords like later
versions take it. We require at least 3.4.0, though I am not entirely sure
when that change occurred. We may actually require >3.4.0.

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2021-03-15 14:41:24 -04:00
Stefan Berger
e78c9db255 tests: Apply patches to IBM TSS2 test suite
Apply patches to the IBM TSS2 test suite rather than using sed on its
files and other types of file manipulations.

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2021-03-01 07:54:27 -05:00
Stefan Berger
e5bb6f4ec5 tests: Move setting CERRTOOL variable to tests-common
Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2021-03-01 07:54:27 -05:00
Stefan Berger
ef1407f56d swtpm_setup: Write note about non-standard EK when using --allow-signing
Write a note in swtpm_setup's help screen and man page that the usage
of --allow-signing will lead to a non-standard EK. Be more precise in the
man page.

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2021-03-01 07:54:27 -05:00
Stefan Berger
12c35fd016 tests: Add test for libtpms issue number 195 (needs latest libtpms now)
This patch adds a test case for testing the fix for libtpms
issue 195: https://github.com/stefanberger/libtpms/issues/195

This patch now requires that the latest TPM version from master or the
branches is installed.

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2021-02-26 16:22:02 -05:00
Stefan Berger
20524cb213 swtpm_ioctl: Use timeouts for communicating with swtpm (Unix socket)
Start using timeouts when communicating with swtpm over Unix sockets so
that swtpm_ioctl does not just hang when it cannot communicate with swtpm
such as establishing a connection or reading results. This is because swtpm
listens to nlye one control channel connections.

This patch addresses an aspect of the problem reported in issue #415
but may also starting hiding bugs if certain operations are done in
the wrong order, as was the case in libvirt (6.10 & 7.0).

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2021-02-25 07:28:47 -05:00
Stefan Berger
4d4d24fb56 tests: Use the IBM TSS2 v1.6.0's test suite
Upgrade to use the IBM TSS2 tests from v1.6.0.

Add a patch that eliminates all testing of 3072 bit RSA keys in case
libtpms does not support such keys. Also disable a test case related
to ACT for older revisions.

This test passes with libtpms 0.8.0 as well libtpms 0.6.0 and 0.7.0.

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2021-02-24 12:23:27 -05:00
Stefan Berger
eeb87a8673 tests: Wait a bit for pid file content; dump log on failure
test_samples_create_tpmca needs to wait longer for the pid file content
to be there not just until the file is available.

test_tpm2_save_load_state_2 needs to dump the TPM log file on failure.
Failures occurred rarely because the previous instance of swtpm had
not shut down yet and released the lock file while the new instance
wanted to lock the lockfile. So we have to wait a bit until the
previous instance is gone.

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2021-02-21 11:52:05 -05:00
Stefan Berger
4d8b2c9c71 man: Change 'shell variable' to 'environment variable' in swtpm-localca.conf
Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
2021-02-19 15:06:52 -05:00
Stefan Berger
468f7e61c3 tests: Fix spelling error swptm->swtpm
This patch fixes issue #410.

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2021-02-05 16:48:55 -05:00
Stefan Berger
90e2be928d swtpm: Fix spelling in comment (SWPTM->SWTPM)
This patch fixes issue #410.

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2021-02-05 16:48:55 -05:00
Stefan Berger
554f52ae0a swtpm_setup: Fix typo in project URL (swptm->swtpm)
This fixes issue #410.

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2021-02-05 16:48:55 -05:00
Stefan Berger
57a5df07e1 samples: Fix typo in project URL (swptm->swtpm)
This patch fixes issue #410.

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2021-02-05 16:48:55 -05:00
Stefan Berger
fa1b93904e swtpm_setup: Replace OSError with ValueError (Cygwin bugfix)
A wrong domain to socketpair() causes a ValueError, not an OSError.

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2021-02-02 12:37:00 -05:00
Stefan Berger
224ee05163 swtpm_setup: Probe for supported socketpair domain (cygwin bugfix)
We need to probe for the support socketpair() domain. On Linux only
socket.AF_UNIX is support and on Cygwin AF_INET works.

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2021-02-01 14:48:32 -05:00
Stefan Berger
e3c6f2ffd6 Travis: Upgrade pip to v20.3.3
Pip 21.0.0 seems to be broken when upgraded to on Xenial. So
let's just only upgrade to 20.3.3.

$ sudo pip3 install --upgrade cryptography
Traceback (most recent call last):
  File "/usr/local/bin/pip3", line 7, in <module>
    from pip._internal.cli.main import main
  File "/usr/local/lib/python3.5/dist-packages/pip/_internal/cli/main.py", line 60
    sys.stderr.write(f"ERROR: {exc}")

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2021-01-29 10:51:30 -05:00
Stefan Berger
526c9facf6 build-sys: Check for python cryptography version
We need at least 2.1.x, 2.1.4, that supports OAEP.

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2021-01-19 09:57:54 -05:00
Stefan Berger
c396f23f50 swtpm: Fix --print-capabilities for 'swtpm chardev'
This patch fixes the following issue:

$ ./src/swtpm/swtpm chardev --print-capabilities --tpm2
swtpm: Error: Missing character device or file descriptor

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2021-01-13 11:32:16 -05:00
Lili Zhu
b199d8084e Update the doc of the flag to connect to TPM via UnixIO socket
Modify the flag from "--unixio" to "--unix"

Signed-off-by: Lili Zhu <lizhu@redhat.com>
2021-01-13 07:02:18 -05:00
Stefan Berger
024073c5cc swtpm_cuse: Support parial reads (issue #376)
This patch adds support for partial reads to the CUSE swtpm.

We introduce a ptm_read_offset variable that holds the offset where to read
from next. It is reset every time a command has been processed as part of a
write() so that subsequent read()s start reading from offset 0. It is
advanced by the number of bytes that were read.

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2021-01-04 07:51:50 -05:00
Stefan Berger
e753128b27 swtpm: Remove unused file_ops_lock from threadpool.c (asan)
Asan reports this error for the CUSE TPM. The file_ops_lock was accidentally
duplicated in a code move of threadpool related code out of cuse_tpm.c
This patch removes the unused file_ops_lock from threadpool.c to resolve
the ASAN issue.

=================================================================
==545493==ERROR: AddressSanitizer: odr-violation (0x000000419340):
  [1] size=8 'file_ops_lock' cuse_tpm.c:112:8
  [2] size=8 'file_ops_lock' threadpool.c:55:8
These globals were registered at these points:
  [1]:
    #0 0x14f6c27f3cc8  (/lib64/libasan.so.6+0x37cc8)
    #1 0x40c2c3 in _sub_I_00099_1 (/home/stefanb/tmp/swtpm/src/swtpm/.libs/lt-swtpm+0x40c2c3)
    #2 0x40c31c in __libc_csu_init (/home/stefanb/tmp/swtpm/src/swtpm/.libs/lt-swtpm+0x40c31c)

  [2]:
    #0 0x14f6c27f3cc8  (/lib64/libasan.so.6+0x37cc8)
    #1 0x14f6c27aad1a in _sub_I_00099_1 (/home/stefanb/tmp/swtpm/src/swtpm/.libs/libswtpm_libtpms.so.0+0x25d1a)
    #2 0x14f6c31dc7b1 in call_init.part.0 (/lib64/ld-linux-x86-64.so.2+0x117b1)

==545493==HINT: if you don't care about these errors you may set ASAN_OPTIONS=detect_odr_violation=0
SUMMARY: AddressSanitizer: odr-violation: global 'file_ops_lock' at cuse_tpm.c:112:8
==545493==ABORTING

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2021-01-03 18:42:05 -05:00
Stefan Berger
4450856d6d swtpm: Free buffer after failure to realloc (cppcheck)
Free the original buffer after failure to realloc().

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2021-01-02 12:16:39 -05:00
Stefan Berger
6b50772217 swtpm: Remove global unused variable input (issue #395)
Remove the global unused variable with name input. This was detected
by cppcheck.

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2021-01-02 12:16:39 -05:00