Commit Graph

1269 Commits

Author SHA1 Message Date
Stefan Berger
2c270f0407 sample: swtpm-localca: Add missing else branch for pkcs11 and PIN
Add a missing else branch that was forgotten about when the code was trans-
lated from python. This now also gets the test case
test_tpm2_samples_create_tpmca to work again when it is run from the command
line. This test case doesn't work as part of the test suite due to
concurreny issues with other test cases using tpm2-abrmd at the same.

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2021-06-21 19:58:49 -04:00
Stefan Berger
53a81d0c9c tests: Kill tpm2-abrmd with SIGKILL rather SIGTERM
Kill an unterminated tpm2-abrmd with SIGKILL rather than SIGTERM

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2021-06-21 19:58:49 -04:00
Stefan Berger
a59eead4bc swtpm_setup: Initialize Gerror and free it
Gerror was not initialized to NULL in one place. In the other it wasn't
freed.

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2021-06-16 18:01:35 -04:00
Stefan Berger
3252334cba tests: Use common vars for executables in swtpm_setup_create_cert tests
Use the variables from tests/common for executables used in the
swtpm_setup_create_cert tests.

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2021-06-16 14:00:18 -04:00
Felipe Franciosi
4a96c7f54a swtpm: Fix SWTPM names in comments and messages
Some of the code comes from libtpms, where various methods are named
"TPM_Something". The swtpm version of these methods are named
"SWTPM_Something". However, certain debug/log messages and comments were
updated accordingly to reflect that.

This is a cosmetic change that fixes that.

Signed-off-by: Felipe Franciosi <felipe@nutanix.com>
2021-06-15 08:35:53 -04:00
Stefan Berger
2bf68cc4be swtpm_setup: Replace '\\s' in regex with [[:space:]] to fix cygwin
Cygwin's regex implementation doesn't seem to understand '\\s'
but needs [[:space:]] instead to properly skip over spaces.

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2021-06-11 07:53:28 -04:00
Stefan Berger
ec49cac756 build-sys: Bump up version to 0.7.0 at beginning of dev cycle
Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2021-06-11 07:53:28 -04:00
Stefan Berger
ea627b3b5e debian/rpm: Adjust changelog for 0.6.0 release
Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2021-06-04 16:04:09 -04:00
Stefan Berger
1415cfaa1b CHANGES: Add more documentation for changes in 0.6.0
Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2021-06-04 16:04:09 -04:00
Stefan Berger
932dc4e270 build-sys: Add HARDENING_CFLAGS and _LDFLAGS to all C programs
Add the HARDENING_CFLAGS and _LDFLAGS to all C programs.

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2021-06-04 16:04:09 -04:00
Stefan Berger
c86be8d960 swtpm: Add 2021 as year in the Copyright notice
Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2021-06-04 16:04:09 -04:00
Stefan Berger
d37095af6c Travis: Remove much of the python related stuff
Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2021-06-04 16:04:09 -04:00
Stefan Berger
8658bdf102 debian/rpm: Remove left-over python files that do not exist anymore
Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2021-06-04 16:04:09 -04:00
Stefan Berger
b570103473 build-sys: Display json-glib and glib related cflags and libs
Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2021-06-04 16:04:09 -04:00
Stefan Berger
80271b5f26 swtpm_setup: Fix the strjoin for the PID file path
The path for the PID file was not joined correctly and was missing
a '/'. Fix this now.

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2021-06-04 16:04:09 -04:00
Stefan Berger
71c353a728 swtpm_localca: Adjust expiration days for 32-bit platforms
GnuTLS on 32-bit platforms complains about the long expiration time
of the certificates since they overflow the 32-bit time_t. Reduce
the duration to 12 years.

This system expresses time with a 32-bit time_t; that prevents dates after 2038 to be expressed by GnuTLS.
Overflow while parsing days

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2021-06-04 16:04:09 -04:00
Stefan Berger
c8c3bb4170 swtpm_setup: Initialize autfreed variables with NULL (gcc-11)
This patch addresses the following gcc-11 compiler issues:

In file included from /usr/include/glib-2.0/glib.h:114,
                 from swtpm_setup_utils.c:14:
swtpm_setup_utils.c: In function 'get_config_value':
/usr/include/glib-2.0/glib/glib-autocleanups.h:28:3: error: 'tmp' may be used uninitialized in this function [-Werror=maybe-uninitialized]
   28 |   g_free (*pp);
      |   ^~~~~~~~~~~~
swtpm_setup_utils.c:36:31: note: 'tmp' was declared here
   36 |             g_autofree gchar *tmp;
      |                               ^~~

swtpm.c: In function 'swtpm_start':
/usr/include/glib-2.0/glib/glib-autocleanups.h:28:3: error: 'pidfile_file' may be used uninitialized in this function [-Werror=maybe-uninitialized]
   28 |   g_free (*pp);
      |   ^~~~~~~~~~~~
swtpm.c:54:23: note: 'pidfile_file' was declared here
   54 |     g_autofree gchar *pidfile_file;
      |                       ^~~~~~~~~~~~

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2021-06-04 16:04:09 -04:00
Stefan Berger
4165421a9d swtpm_localca: Initialize autofreed variables to NULL (gcc-11)
This patch addresses the following gcc-11 compiler issues:

In file included from /usr/include/glib-2.0/glib.h:114,
                 from ../src/utils/swtpm_utils.h:13,
                 from swtpm_localca_utils.c:24:
swtpm_localca_utils.c: In function 'get_config_envvars':
/usr/include/glib-2.0/glib/glib-autocleanups.h:28:3: error: 'value' may be used uninitialized in this function [-Werror=maybe-uninitialized]
   28 |   g_free (*pp);
      |   ^~~~~~~~~~~~
swtpm_localca_utils.c:98:37: note: 'value' was declared here
   98 |             g_autofree gchar *key, *value;
      |                                     ^~~~~
In file included from /usr/include/glib-2.0/glib.h:114,
                 from ../src/utils/swtpm_utils.h:13,
                 from swtpm_localca_utils.c:24:
/usr/include/glib-2.0/glib/glib-autocleanups.h:28:3: error: 'key' may be used uninitialized in this function [-Werror=maybe-uninitialized]
   28 |   g_free (*pp);
      |   ^~~~~~~~~~~~
swtpm_localca_utils.c:98:31: note: 'key' was declared here
   98 |             g_autofree gchar *key, *value;
      |                               ^~~

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2021-06-04 16:04:09 -04:00
Stefan Berger
7f1f1fff46 rpm: Readd swtpm.spec to be able to easily install dependencies
Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2021-06-04 16:04:09 -04:00
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