]> git.proxmox.com Git - libtpms.git/log
libtpms.git
2 years agorpm/debian: Add 0.9.3 entry in changelog v0.9.3
Stefan Berger [Mon, 7 Mar 2022 11:58:09 +0000 (06:58 -0500)]
rpm/debian: Add 0.9.3 entry in changelog

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2 years agoCHANGES: Updated CHANGES document for 0.9.3
Stefan Berger [Mon, 7 Mar 2022 11:53:29 +0000 (06:53 -0500)]
CHANGES: Updated CHANGES document for 0.9.3

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2 years agobuild-sys: Add probing for -fstack-protector
Stefan Berger [Wed, 2 Mar 2022 17:29:59 +0000 (12:29 -0500)]
build-sys: Add probing for -fstack-protector

Add probing for -fstack-protector to the existing
-fstack-protector-strong since not all platforms support either one
of them.

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2 years agotpm2: Do not call EVP_PKEY_CTX_set0_rsa_oaep_label() for label of size 0 (OSSL 3)
Juergen Repp [Sat, 19 Feb 2022 11:59:32 +0000 (12:59 +0100)]
tpm2: Do not call EVP_PKEY_CTX_set0_rsa_oaep_label() for label of size 0 (OSSL 3)

Openssl 3.0 did return an error if EVP_PKEY_CTX_set0_rsa_oaep_label was called
with label size 0. The function should only be called if the size of the label
is greater 0.
With this fix TPM2_RSA_Encrypt/Decrypt did work with OpenSSL 1.1 and 3.0
for encryption without label.

Signed-off-by: Juergen Repp <juergen.repp@sit.fraunhofer.de>
2 years agobuild-sys: Build libtpms v0.9.3
Stefan Berger [Wed, 2 Mar 2022 12:31:41 +0000 (07:31 -0500)]
build-sys: Build libtpms v0.9.3

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2 years agorpm/debian: Add 0.9.2 entry in changelog v0.9.2
Stefan Berger [Wed, 5 Jan 2022 15:53:27 +0000 (10:53 -0500)]
rpm/debian: Add 0.9.2 entry in changelog

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2 years agoCHANGES: Updated CHANGES document for 0.9.1
Stefan Berger [Tue, 4 Jan 2022 20:04:07 +0000 (15:04 -0500)]
CHANGES: Updated CHANGES document for 0.9.1

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2 years agotpm2: When writing state initialize s_ContextSlotMask if not set
Stefan Berger [Tue, 4 Jan 2022 19:45:31 +0000 (14:45 -0500)]
tpm2: When writing state initialize s_ContextSlotMask if not set

If s_ContextSlotMask was not set since the TPM 2 was not initialized
by a call to TPM_Manufacture() or the state was not resumed, then
initialize the s_ContextSlotMask to 0xffff.

This situation can occur if a VM with an attached swtpm was started
and the VM's firmware either doesn't support TPM or didn't get to
initialize the vTPM.

The following commands recreated the issue with a SeaBIOS-only VM that
had no attached hard disk but an attached TPM 2:

virsh start BIOS-only-VM ; virsh save BIOS-only-VM save.bin ; \
 virsh restore save.bin

Error: Failed to restore domain from save.bin
error: internal error: qemu unexpectedly closed the monitor: \
2022-01-04T19:26:18.835851Z qemu-system-x86_64: tpm-emulator: Setting the stateblob (type 2) failed with a TPM error 0x3 a parameter is bad
2022-01-04T19:26:18.835899Z qemu-system-x86_64: error while loading state for instance 0x0 of device 'tpm-emulator'
2022-01-04T19:26:18.835929Z qemu-system-x86_64: load of migration failed: Input/output error

Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=2035731
Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2 years agobuild-sys: Build libtpms v0.9.2
Stefan Berger [Tue, 4 Jan 2022 20:02:01 +0000 (15:02 -0500)]
build-sys: Build libtpms v0.9.2

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2 years agoCHANGES: Updated CHANGES document for 0.9.1 v0.9.1
Stefan Berger [Wed, 24 Nov 2021 12:51:41 +0000 (07:51 -0500)]
CHANGES: Updated CHANGES document for 0.9.1

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2 years agorpm/debian: Add 0.9.1 entry in changelog
Stefan Berger [Wed, 24 Nov 2021 12:50:17 +0000 (07:50 -0500)]
rpm/debian: Add 0.9.1 entry in changelog

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2 years agoFix "maybe-uninitialized" warning
kpcyrd [Fri, 29 Oct 2021 12:17:32 +0000 (14:17 +0200)]
Fix "maybe-uninitialized" warning

exp_array_size is always initialized if `rc == TPM_RC_SUCCESS` and never used
if `rc != TPM_RC_SUCCESS` but some compilers have trouble noticing this.

Signed-off-by: kpcyrd <git@rxv.cc>
2 years agotpm2: Do not write permanent state if only clock changed
Stefan Berger [Fri, 15 Oct 2021 13:20:30 +0000 (09:20 -0400)]
tpm2: Do not write permanent state if only clock changed

To avoid timeouts on short-running commands, such as TPM2_PCR_Extend,
avoid triggering the writing of the permanent state of the TPM 2
if only the clock was updated. So the clock by itself will not cause
the permanent state to be written out anymore but there have to be
other reasons as well.

The state will still be written out upon a TPM2_Shutdown, which is
supposed to be the last command to be sent to the TPM when shutting
down the VM/vTPM. Also, the permanent state will still carry the
latest clock value if it is retrieved via control channel for
VM/VTPM suspend.

The case that may be affected, but is of lesser importance, is the one
where swtpm's volatile state is written to storage using 'swtpm_ioctl -v'
and then swtpm is terminated and restarted (similar to suspend/resume)
and the permanent state file is read from storage but does not contain
the latest clock value. In this case the go.clock will be updated when
the first command after resume is executed.

This fixes the swtpm issue https://github.com/stefanberger/swtpm/issues/597.

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2 years agobuild-sys: Build libtpms v0.9.1
Stefan Berger [Fri, 15 Oct 2021 16:25:40 +0000 (12:25 -0400)]
build-sys: Build libtpms v0.9.1

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2 years agorpm/debian: Add 0.9.0 entry in changelog v0.9.0
Stefan Berger [Tue, 28 Sep 2021 20:01:45 +0000 (16:01 -0400)]
rpm/debian: Add 0.9.0 entry in changelog

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2 years agoCHANGES: Updated CHANGES document for 0.9.0
Stefan Berger [Tue, 28 Sep 2021 20:03:07 +0000 (16:03 -0400)]
CHANGES: Updated CHANGES document for 0.9.0

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2 years agobuild-sys: Use -DOPENSSL_SUPPRESS_DEPRECATED to suppress warning (OSSL 3)
Stefan Berger [Tue, 21 Sep 2021 16:40:39 +0000 (12:40 -0400)]
build-sys: Use -DOPENSSL_SUPPRESS_DEPRECATED to suppress warning (OSSL 3)

Instead of using -Wno-deprecated-declarations use
-DOPENSSL_SUPPRESS_DEPRECATED to only suppress OpenSSL deprecated
declarations warnings.

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2 years agobuild-sys: Add -Wno-deprecated-declarations to default CFLAGS (OSSL 3)
Stefan Berger [Tue, 14 Sep 2021 21:56:19 +0000 (17:56 -0400)]
build-sys: Add -Wno-deprecated-declarations to default CFLAGS (OSSL 3)

To be able to build with OpenSSL 3.0 we need to added
-Wno-deprecated-declarations to the default CFLAGS.

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2 years agobuild-sys: Test for functions if #defines are not found (OSSL 3)
Stefan Berger [Tue, 14 Sep 2021 21:43:46 +0000 (17:43 -0400)]
build-sys: Test for functions if #defines are not found (OSSL 3)

OpenSSL 3.0 has converted several RSA-related #defines to functions, so
that AX_CHECK_DEFINE only works for OpenSSL 1.1.0 but for OpenSSL 3.0.0
we have to also use AC_CHECK_LIB to determine whether the function is
available.

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2 years agotpm2: Only call EVP_PKEY_CTX_set0_rsa_oaep_label when label != NULL (OSSL 3)
Stefan Berger [Wed, 15 Sep 2021 02:23:17 +0000 (22:23 -0400)]
tpm2: Only call EVP_PKEY_CTX_set0_rsa_oaep_label when label != NULL (OSSL 3)

EVP_PKEY_CTX_set0_rsa_oaep_label must only be called with label != NULL.

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2 years agotpm2: Use EVP_PKEY_get1_RSA() rather than EVP_PKEY_get0_RSA (OSSL 3)
Stefan Berger [Wed, 15 Sep 2021 00:53:15 +0000 (20:53 -0400)]
tpm2: Use EVP_PKEY_get1_RSA() rather than EVP_PKEY_get0_RSA (OSSL 3)

OpenSSL 3.0 has changed the signature of EVP_PKEY_get0_RSA() from

struct rsa_st *EVP_PKEY_get0_RSA(EVP_PKEY *pkey);

to

const struct rsa_st *EVP_PKEY_get0_RSA(const EVP_PKEY *pkey);

We now have to use EVP_PKEY_get1_RSA with this signature so that we can
access the RSA key. The signature of that function hasn't changed between
OpenSSL 1.1.0 and 3.0.0.

struct rsa_st *EVP_PKEY_get1_RSA(EVP_PKEY *pkey);

Free the additional reference held on the RSA key.

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2 years agotpm2: Marshal event sequence objects' hash state
Stefan Berger [Thu, 9 Sep 2021 12:44:48 +0000 (08:44 -0400)]
tpm2: Marshal event sequence objects' hash state

Event sequence objects were never properly marshalled and when their state
was saved and later restored their state may have been corrupted. Fix this
now by also marshalling the state of event sequence objects.

Bump up the version of the HASH_OBJECT's header to '3' so that previously
written state can be resumed if an event sequence object is encountered
and we only unmarshal an event sequence object when the version is at least
'3'.

Fixes issue #259.

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2 years agotpm2: Report supported Camellia keysizes in the JSON
Stefan Berger [Wed, 4 Aug 2021 17:49:37 +0000 (13:49 -0400)]
tpm2: Report supported Camellia keysizes in the JSON

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2 years agotpm2: Enable ALG_CAMELLIA in TpmProfile.h
Stefan Berger [Fri, 3 Sep 2021 13:11:27 +0000 (09:11 -0400)]
tpm2: Enable ALG_CAMELLIA in TpmProfile.h

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2 years agotpm2: Add more compile-time constants to array
Stefan Berger [Wed, 4 Aug 2021 17:49:36 +0000 (13:49 -0400)]
tpm2: Add more compile-time constants to array

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2 years agotpm2: Make exp. size of compile-time constants dependent on header version
Stefan Berger [Wed, 4 Aug 2021 17:49:34 +0000 (13:49 -0400)]
tpm2: Make exp. size of compile-time constants dependent on header version

Make the expected array size of compile-time constants dependent on
the version of the header. This way we can add elements to the array
while bumping up the version of the header.

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2 years agogit: Fix erroneous gitignore entries
Stefan Berger [Mon, 30 Aug 2021 07:26:52 +0000 (09:26 +0200)]
git: Fix erroneous gitignore entries

Fix erroneous gitignore entries that previously showed with the
following command line:

git ls-files -i --exclude-standard -c

Resolves #249.

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2 years agotpm2: Extend asym key test case data generation script with sm4
Stefan Berger [Wed, 1 Sep 2021 15:42:55 +0000 (15:42 +0000)]
tpm2: Extend asym key test case data generation script with sm4

Extend the test case data generation script with sm4. Since several
distros' openssl do not support sm4, we need to test for whether sm4
is supported by the installed openssl.

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2 years agoUpdate SymmetricTestData.h
JerryDevis [Wed, 1 Sep 2021 13:01:06 +0000 (21:01 +0800)]
Update SymmetricTestData.h

update the selftest data in dataOut_SM4_CTR

Signed-off-by: JerryDevis <seclab@huawei.com>
2 years agobuild-sys: add with_tpm1/with_tpm2 variables to .pc
Marc-André Lureau [Thu, 5 Aug 2021 15:08:13 +0000 (19:08 +0400)]
build-sys: add with_tpm1/with_tpm2 variables to .pc

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
2 years agobuild-sys: add optional --with-tpm1
Marc-André Lureau [Thu, 5 Aug 2021 11:22:49 +0000 (15:22 +0400)]
build-sys: add optional --with-tpm1

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
2 years agoMove common debug, memory & nvfile units to src/
Marc-André Lureau [Thu, 5 Aug 2021 10:21:54 +0000 (14:21 +0400)]
Move common debug, memory & nvfile units to src/

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
2 years agotpm2: Use EC_POINT_set/get_affine_coordinates on OpenSSL >= 1.1
Stefan Berger [Tue, 3 Aug 2021 12:22:23 +0000 (08:22 -0400)]
tpm2: Use EC_POINT_set/get_affine_coordinates on OpenSSL >= 1.1

Use the EC_POINT_set/get_affine_coordinates function on OpenSSL >= 1.1.
These function are a 1:1 replacement for the
EC_POINT_set/get_affine_coordinates_GFp functions and are available
since OpenSSL 1.1 and are deprecated in OpenSSL 3.0.

This patch addresses one aspect of the OpenSSL 3.0 issues raised in
issue #215.

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2 years agotpm2: Enable supported AES bit size cases using #if AES_<size>
Stefan Berger [Thu, 29 Jul 2021 22:10:49 +0000 (18:10 -0400)]
tpm2: Enable supported AES bit size cases using #if AES_<size>

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2 years agotpm2: Enable supported Camellia bit size cases using #if Camellia_<size>
Stefan Berger [Thu, 29 Jul 2021 22:04:28 +0000 (18:04 -0400)]
tpm2: Enable supported Camellia bit size cases using #if Camellia_<size>

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2 years agotpm2: NVMarshal: Handle index orderly RAM without 0-sized terminating node
Stefan Berger [Fri, 23 Jul 2021 17:29:00 +0000 (13:29 -0400)]
tpm2: NVMarshal: Handle index orderly RAM without 0-sized terminating node

The NVRAM entries in s_indexOrderlyRam array do not need to contain a
0-sized terminating node. Instead, the entries may fill up this 512
byte array so that no NV_RAM_HEADER structure fits anymore. The fact
that no more NV_RAM_HEADER structure fits is also an indicator for the
last entry. We need to account for this in the code marshalling and
unmarshalling the entries so that we stop marshalling the entries
then and similarly stop unmarshalling.

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2 years agotpm2: Initialize a whole OBJECT before using it
Stefan Berger [Fri, 23 Jul 2021 01:23:58 +0000 (21:23 -0400)]
tpm2: Initialize a whole OBJECT before using it

Initialize a while OBJECT before using it. This is necessary since
an OBJECT may also be used as a HASH_OBJECT via the ANY_OBJECT
union and that HASH_OBJECT can leave bad size inidicators in TPM2B
buffer in the OBJECT. To get rid of this problem we reset the whole
OBJECT to 0 before using it. This is as if the memory for the
OBJECT was just initialized.

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2 years agotests: fuzz: Store initialized permall state blob
Stefan Berger [Thu, 22 Jul 2021 22:58:19 +0000 (18:58 -0400)]
tests: fuzz: Store initialized permall state blob

We have to store the permall state blob once it has been initialized since
otherwise some fields are not having proper values in the internal state.

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2 years agotests: fuzz: Have state suspended and resumed after every fuzz step
Stefan Berger [Thu, 22 Jul 2021 15:44:46 +0000 (11:44 -0400)]
tests: fuzz: Have state suspended and resumed after every fuzz step

Have the TPM 2's state suspended and resumed at every step to
ensure that we can marshal and unmarshal it.

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2 years agotests: fuzz: Register callbacks to avoid creating NVChip file
Stefan Berger [Thu, 22 Jul 2021 15:02:09 +0000 (11:02 -0400)]
tests: fuzz: Register callbacks to avoid creating NVChip file

Register callbacks so that we don't create the NVChip file.

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2 years agotests: fuzz: Call die() when an error from an API call was returned
Stefan Berger [Thu, 22 Jul 2021 14:59:16 +0000 (10:59 -0400)]
tests: fuzz: Call die() when an error from an API call was returned

Call die() causing as assert() to be triggered if an API call
returned an unexpected failure result.

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2 years agoDebian packaging improvements
Nick Chevsky [Thu, 22 Jul 2021 19:02:31 +0000 (14:02 -0500)]
Debian packaging improvements
- debian/clean: Clean up files not automatically caught by
  `debian/rules clean`.
- debian/control:
  - Add new recommended/required fields and bump Standards-Version.
  - Remove redundant build dependences that are implied transitively.
  - Move libtpms0's ${misc:Pre-Depends} dependency to `Pre-Depends`.
    Resolves `depends-on-misc-pre-depends` Lintian warning.
  - Sort packages and dependency lists alphabetically as per
    wrap-and-sort(1).
- debian/not-installed: List non-installed files to avoid
  dh_missing(1) warnings.
- debian/rules:
  - Remove unused architecture variable.
  - Remove redundant --parallel, --with autoreconf flags.
  - Remove redundant `dh_update_autotools_config` call.
- debian/*.install:
  - Remove redundant `#! /usr/bin/dh-exec` lines.
  - Sort entries alphabetically as per wrap-and-sort(1).

Signed-off-by: Nick Chevsky <nchevsky@users.noreply.github.com>
2 years agoman3: Fix errors in code example in TPMLIB_RegisterCallbacks
Stefan Berger [Thu, 22 Jul 2021 14:47:30 +0000 (10:47 -0400)]
man3: Fix errors in code example in TPMLIB_RegisterCallbacks

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2 years agotpm2: Use #if ALG_CAMELLIA rather than #if 0
Stefan Berger [Wed, 21 Jul 2021 18:26:17 +0000 (14:26 -0400)]
tpm2: Use #if ALG_CAMELLIA rather than #if 0

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2 years agoImprovements to .gitignore
Nick Chevsky [Tue, 20 Jul 2021 19:48:24 +0000 (14:48 -0500)]
Improvements to .gitignore
- Add auto-generated files *.gch, debian/autoreconf.*, tests/NVChip
- Add .pc/ (temporary directory used by Quilt for patch management)
- Remove *.patch (Quilt requires these under debian/patches/)
- Change incorrect debian/libtpms/ to debian/libtpms0/

Signed-off-by: Nick Chevsky <nchevsky@users.noreply.github.com>
2 years agotpm2: Avoid compiler warning by using memcpy instead of MemoryCopy (gcc 10.3)
Stefan Berger [Fri, 9 Jul 2021 19:08:36 +0000 (15:08 -0400)]
tpm2: Avoid compiler warning by using memcpy instead of MemoryCopy (gcc 10.3)

Fix the following compiler warning from gcc 10.3.0 by using memcpy
instead of MemoryCopy (fixes issue #229).

tpm2/NVDynamic.c: In function 'NvRamGetEnd':
tpm2/NVDynamic.c:378:12: warning: function may return address of local variable [-Wreturn-local-addr]
  378 |     return iter;
      |            ^
tpm2/NVDynamic.c:339:26: note: declared here
  339 |     NV_RAM_HEADER        header;
      |                          ^
tpm2/NVDynamic.c: In function 'NvRamGetIndex':
tpm2/NVDynamic.c:411:12: warning: function may return address of local variable [-Wreturn-local-addr]
  411 |     return currentAddr;
      |            ^
tpm2/NVDynamic.c:339:26: note: declared here
  339 |     NV_RAM_HEADER        header;
      |                          ^

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2 years agotpm2: Restore original value if unmarsalled value was illegal
Stefan Berger [Thu, 24 Jun 2021 00:54:44 +0000 (20:54 -0400)]
tpm2: Restore original value if unmarsalled value was illegal

Restore the original value of the memory location where data from
a stream was unmarshalled and the unmarshalled value was found to
be illegal. The goal is to not keep illegal values in memory.

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2 years agotpm2: Add maxSize parameter to TPM2B_Marshal for sanity checks
Stefan Berger [Mon, 21 Jun 2021 19:10:14 +0000 (15:10 -0400)]
tpm2: Add maxSize parameter to TPM2B_Marshal for sanity checks

Add maxSize parameter to TPM2B_Marshal and assert on it checking
the size of the data intended to be marshaled versus the maximum
buffer size.

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2 years agotpm2: Reset TPM2B buffer sizes after test fails for valid buffer size
Stefan Berger [Mon, 21 Jun 2021 18:04:34 +0000 (14:04 -0400)]
tpm2: Reset TPM2B buffer sizes after test fails for valid buffer size

Reset the buffer size indicator in a TPM2B type of buffer after it failed
the test for the maximum buffer size it allows. This prevents having bad
buffer sizes in memory that can come to haunt us when writing the volatile
state for example.

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2 years agobuild-sys: Run autoupdate on configure.ac for autconf 2.71
Stefan Berger [Mon, 21 Jun 2021 21:51:14 +0000 (17:51 -0400)]
build-sys: Run autoupdate on configure.ac for autconf 2.71

Run autoupdate and address the following issue:

configure.ac:10: warning: 'AM_CONFIG_HEADER': this macro is obsolete.
configure.ac:10: You should use the 'AC_CONFIG_HEADERS' macro instead.

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2 years agotpm2: Consume padding bytes in TPM2_ContextLoad() (Win2k19, issue #217)
Stefan Berger [Fri, 28 May 2021 22:32:25 +0000 (18:32 -0400)]
tpm2: Consume padding bytes in TPM2_ContextLoad() (Win2k19, issue #217)

Windows 2019 Server padds the TPM_ContextLoad() command with additional
bytes up to TPM_PT_MAX_OBJECT_CONTEXT for the TPMS_CONTEXT part. Since
libtpms does not use an OBJECT to serialize the keys (anymore) it now
uses less bytes than the MAXimum of TPM_PT_MAX_OBJECT_CONTEXT bytes and
the padding leaves some unconsumed bytes that end up failing the command
since no left-over bytes are allowed in any command.

When unconsumed bytes are left in TPMS_CONTEXT_Unmarshal() we check that
the original passed in size was that of TPM_PT_MAX_OBJECT_CONTEXT and
only then consume the additional padding bytes. Luckily only one command
calls TPMS_CONTEXT_Unmarshal() so that no unwanted side effects should
occur anywhere else, such as no bytes left for unmarshalling the next
structure.

The wisdom behind the padding is not quite clear but it feels like
ill-fixing the code to work around a Windows 2019 server bug...

This patch fixes issed #217

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2 years agoTravis: Install libjson-glib-dev and drop a few python dependencies
Stefan Berger [Fri, 28 May 2021 17:37:31 +0000 (13:37 -0400)]
Travis: Install libjson-glib-dev and drop a few python dependencies

Since swtpm_setup has been rewritten in 'C' now we can drop a few
python dependencies but need libjson-glib-dev as a new dependency
for testing with swtpm's master branch.

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
3 years agobuild-sys: leave CFLAGS/LDFLAGS for user to be defined
Marc-André Lureau [Tue, 18 May 2021 13:10:52 +0000 (17:10 +0400)]
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>
3 years agotpm2: Switch to UINT16 for CONTEXT_SLOT and 64k context gap
Stefan Berger [Fri, 30 Apr 2021 20:44:03 +0000 (16:44 -0400)]
tpm2: Switch to UINT16 for CONTEXT_SLOT and 64k context gap

This patch addresses issue #209.

The context gap for libtpms is currently only 0xff due to the CONTEXT_SLOT
being a UINT8. To extend this to 0xffff, we need to define the CONTEXT_SLOT
as UINT16 and introduce a global variable s_ContextArrayMask that takes on
two valid values, 0xff for simulating the CONTEXT_SLOT when it was UINT8
and 0xffff for usage with the new CONTEXT_SLOT of type UINT16. All
occurrences of casts to CONTEXT_SLOT are replaced with a macro
CONTEXT_SLOT_MASKED that applies this mask to a value instead of using the
cast. We also use it for some calculations to avoid spilling over from
1 byte into 2 bytes for example. The cast with the new code is the same as
applying the mask 0xffff, and using the 0xff mask we can simulate the old
CONTEXT_SLOT (1 byte), which we need for seamlessly resuming old state. We
switch from the 0xff mask to the 0xffff mask when the TPM is reset.

There's one place where the s_ContextArrayMask is initialized to 0xff, and
this is when we resume 'old' STATE_RESET_DATA. The places where it is
intialized to 0xffff are in TPM_Manufacture() and
TPM_SessionStartup(SU_CLEAR), both of which are not called after resuming
state.

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
3 years agodebian: Fix build warnings by updating compat to '10' and dh functions
Stefan Berger [Fri, 7 May 2021 01:02:17 +0000 (21:02 -0400)]
debian: Fix build warnings by updating compat to '10' and dh functions

This patch fixes the following issue pointed out in issue #212:

dh clean --parallel --with autotools-dev --with autoreconf
dh: warning: Compatibility levels before 10 are deprecated (level 9 in use)
dh: warning: The autotools-dev sequence is deprecated and replaced by dh in debhelper (>= 9.20160115)
dh: warning: This feature will be removed in compat 12.
   dh_auto_clean -O--parallel
dh_auto_clean: warning: Compatibility levels before 10 are deprecated (level 9 in use)
make -j4 distclean

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
3 years agotpm2: Surround all occurrences of BLOCK_SKIP_READ() with tests of 'rc'
Stefan Berger [Tue, 4 May 2021 15:37:29 +0000 (11:37 -0400)]
tpm2: Surround all occurrences of BLOCK_SKIP_READ() with tests of 'rc'

Do not call BLOCK_SKIP_READ once rc has been set to any error value.
Therefore, surround all occurrences of BLOCK_SKIP_READ() with tests
of 'rc'.

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
3 years agotpm2: Implement a cache for the private exponent D and prime Q
Stefan Berger [Thu, 25 Feb 2021 19:05:28 +0000 (14:05 -0500)]
tpm2: Implement a cache for the private exponent D and prime Q

Implement a cache for the private exponent 'D' and prime 'Q' so that we
do not have to recalculate 'Q' and 'D' every time an RSA key is used. For
a cache hit we now use ~34000 cycles and on a cache miss it needs around
130000 cycles. Previously it needed around 100000 cycles to calcuate 'Q'
and 'D'. Assuming that keys will be reused and the cache is big enough
for the number of keys being use (64 entries), it seems well worth it.

This solution is better than extending the OBJECT with 'D' since OBJECT is
kept in the TPM's NVRAM and we would then need more memory to store OBJECTs
there.

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
3 years agorev164: Bump spec version, year, and day to rev164
Stefan Berger [Mon, 15 Mar 2021 19:01:21 +0000 (15:01 -0400)]
rev164: Bump spec version, year, and day to rev164

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
3 years agorev164: Introduce FOR_EACH_SYM and use it
Stefan Berger [Tue, 23 Feb 2021 00:33:10 +0000 (19:33 -0500)]
rev164: Introduce FOR_EACH_SYM and use it

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
3 years agorev164: Sync TpmToOsslHash.h SM3_256 support
Stefan Berger [Tue, 23 Feb 2021 01:04:18 +0000 (20:04 -0500)]
rev164: Sync TpmToOsslHash.h SM3_256 support

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
3 years agorev164: Adjust SMAC_IMPLEMENTED define
Stefan Berger [Tue, 23 Feb 2021 01:01:30 +0000 (20:01 -0500)]
rev164: Adjust SMAC_IMPLEMENTED define

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
3 years agorev164: Sync DebugHelpers.c
Stefan Berger [Tue, 23 Feb 2021 00:58:12 +0000 (19:58 -0500)]
rev164: Sync DebugHelpers.c

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
3 years agorev164: Change AGL_XYZ_VALUE to equivalend TPM_ALG_XYZ
Stefan Berger [Mon, 22 Feb 2021 23:47:24 +0000 (18:47 -0500)]
rev164: Change AGL_XYZ_VALUE to equivalend TPM_ALG_XYZ

$ grep -En "ALG_[A-Z]*_VALUE" src/tpm2/TpmTypes.h
71:#define     ALG_ERROR_VALUE             0x0000
72:#define TPM_ALG_ERROR                   (TPM_ALG_ID)(ALG_ERROR_VALUE)
73:#define     ALG_RSA_VALUE               0x0001
74:#define TPM_ALG_RSA                     (TPM_ALG_ID)(ALG_RSA_VALUE)
[...]

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
3 years agorev164: Introduce FOR_EACH_HASH and use it
Stefan Berger [Mon, 22 Feb 2021 22:04:38 +0000 (17:04 -0500)]
rev164: Introduce FOR_EACH_HASH and use it

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
3 years agorev164: Change return types from BOOL to bool
Stefan Berger [Mon, 22 Feb 2021 21:50:47 +0000 (16:50 -0500)]
rev164: Change return types from BOOL to bool

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
3 years agorev164: Use multiple BOOLs to evaluate rather than single one
Stefan Berger [Mon, 22 Feb 2021 21:49:08 +0000 (16:49 -0500)]
rev164: Use multiple BOOLs to evaluate rather than single one

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
3 years agorev164: Remove unreachable return statement
Stefan Berger [Mon, 22 Feb 2021 21:47:54 +0000 (16:47 -0500)]
rev164: Remove unreachable return statement

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
3 years agorev164: Fix a comparison (< to <=) in unused code (bugfix?)
Stefan Berger [Mon, 22 Feb 2021 21:46:53 +0000 (16:46 -0500)]
rev164: Fix a comparison (< to <=) in unused code (bugfix?)

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
3 years agorev164: sync NvFileSize.c
Stefan Berger [Mon, 22 Feb 2021 21:21:50 +0000 (16:21 -0500)]
rev164: sync NvFileSize.c

3 years agorev164: Resolve long chain of logical ands (trivial)
Stefan Berger [Mon, 22 Feb 2021 21:17:23 +0000 (16:17 -0500)]
rev164: Resolve long chain of logical ands (trivial)

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
3 years agorev164: Add (unused) SM3 and SHA3 related digests to HashTestData
Stefan Berger [Mon, 22 Feb 2021 21:00:19 +0000 (16:00 -0500)]
rev164: Add (unused) SM3 and SHA3 related digests to HashTestData

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
3 years agorev164: Add (unused) SHA3 related defines for CONTEXT_HASH_ALGORITHM
Stefan Berger [Mon, 22 Feb 2021 20:56:32 +0000 (15:56 -0500)]
rev164: Add (unused) SHA3 related defines for CONTEXT_HASH_ALGORITHM

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
3 years agorev164: Rename DebugFileOpen to DebugFileInit
Stefan Berger [Mon, 22 Feb 2021 20:50:57 +0000 (15:50 -0500)]
rev164: Rename DebugFileOpen to DebugFileInit

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
3 years agorev164: Comment, commented code, and whitespace changes only
Stefan Berger [Mon, 22 Feb 2021 20:45:24 +0000 (15:45 -0500)]
rev164: Comment, commented code, and whitespace changes only

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
3 years agorev164: Rename GetHeriarchy to GetHierarchy
Stefan Berger [Mon, 22 Feb 2021 20:22:09 +0000 (15:22 -0500)]
rev164: Rename GetHeriarchy to GetHierarchy

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
3 years agorev164: Rename unmarshal/marhsalArray to Unmarshal/MarshalArray
Stefan Berger [Mon, 22 Feb 2021 19:58:33 +0000 (14:58 -0500)]
rev164: Rename unmarshal/marhsalArray to Unmarshal/MarshalArray

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
3 years agoFix many misspellings
Nicolas Iooss [Tue, 2 Mar 2021 12:51:42 +0000 (13:51 +0100)]
Fix many misspellings

When testing downgrading from libtpms 0.8 to 0.7 (which is not
possible), the error message which is reported is:

    libtpms/tpm2: Unexpect value for MAX_RSA_KEY_BITS; its value 3072 is
    not = 2048; (version: 2).

codespell (https://github.com/codespell-project/codespell) reports a
misspelling for "Unexpect", which should be "Unexpected". As the project
contains many more misspellings in comments, error messages and
documentation, fix all misspellings reported by codespell.

Signed-off-by: Nicolas Iooss <nicolas.iooss@ledger.fr>
3 years agotpm2: CryptSym: fix AES output IV
Stefan Berger [Mon, 1 Mar 2021 14:19:02 +0000 (09:19 -0500)]
tpm2: CryptSym: fix AES output IV

The TPM is supposed to provide the output IV in the ivInOut parameter in
CryptSymmetricEncrypt. In the case of using the openssl routines, the
output IV is missed, and the resulting output from the TPM is in the
input IV.

OpenSSL unfortunately does not export EVP_CIPHER_CTX_iv() until
tags/OpenSSL_1_1_0, so we have to fall back to the reference code for
previous OpenSSL versions.

Signed-off-by: William Roberts <william.c.roberts@intel.com>
Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
3 years agotpm2: Fix public key context save due to ANY_OBJECT_Marshal usage
Stefan Berger [Fri, 26 Feb 2021 14:24:22 +0000 (09:24 -0500)]
tpm2: Fix public key context save due to ANY_OBJECT_Marshal usage

This patch addresses the bug reported in issue #195 where the saving of
an externally loaded public key's context doesn't work due to the usage of
ANY_CONTEXT_SAVE for saving key contexts. This patch fixes the issue by
creating local versions of TPM_SENSITIVE_Marshal/_Unmarshal that deals
with the case where sensitiveType is not a type of private key but a
public key instead that basically doesn't have much information in
TPM_SENSITIVE but is all zeros instead.

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
3 years agodebian: Add missing pkg-config to debian/control
Stefan Berger [Thu, 25 Feb 2021 21:58:01 +0000 (16:58 -0500)]
debian: Add missing pkg-config to debian/control

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
3 years agoBump up the revision of the library for next version to 0.9.0
Stefan Berger [Wed, 24 Feb 2021 18:49:16 +0000 (13:49 -0500)]
Bump up the revision of the library for next version to 0.9.0

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
3 years agorpm/debian: Adjust date of 0.8.0 entry in changelog
Stefan Berger [Wed, 24 Feb 2021 15:59:24 +0000 (10:59 -0500)]
rpm/debian: Adjust date of 0.8.0 entry in changelog

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
3 years agotpm2: Test RSA private keys when -DDO_CHECK_RSA_KEY=1 is used
Stefan Berger [Tue, 23 Feb 2021 20:39:12 +0000 (15:39 -0500)]
tpm2: Test RSA private keys when -DDO_CHECK_RSA_KEY=1 is used

For some peace-of-mind add a function that allows us to check the RSA keys
that are generated, especially the primary keys that are not generated by
OpenSSL.

Use the following configure line to compile libtpms:

CFLAGS="-DDO_RSA_CHECK_KEY=1" ./autogen.sh --prefix=/usr \
  --with-tpm2 --with-openssl

Start swtpm after installing libtpms:

swtpm socket --tpmstate dir=/tmp/myvtpm --tpm2 --ctrl type=tcp,port=2322  \
  --server type=tcp,port=2321 --flags not-need-init --log level=0

We can now run this test program to check keys by using an RSA primary key
for signing.

export TPM_COMMAND_PORT=2321 TPM_PLATFORM_PORT=2322 \
  TPM_SERVER_NAME=localhost TPM_INTERFACE_TYPE=socsim \
  TPM_SERVER_TYPE=raw

echo "test" > input

swtpm_ioctl --tcp :${TPM_PLATFORM_PORT} -i
tssstartup

while :; do
  for keysize in 2048 3072; do

    tsscreateprimary -rsa $keysize -si -hi n
    tsssign -hk 80000000 -if input
    tssflushcontext -ha 80000000
  done
done

Libtpms has passed multiple hours of testing.

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
3 years agotpm2: Add #error gate for SM3 and SHA3 to NVMarshal.c
Stefan Berger [Tue, 23 Feb 2021 15:17:35 +0000 (10:17 -0500)]
tpm2: Add #error gate for SM3 and SHA3 to NVMarshal.c

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
3 years agotpm2: Add statement about unsupported modifications to TpmProfile.h
Stefan Berger [Tue, 23 Feb 2021 01:28:49 +0000 (20:28 -0500)]
tpm2: Add statement about unsupported modifications to TpmProfile.h

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
3 years agotpm2: Add comment to HASH_ALIGNMENT define
Stefan Berger [Tue, 23 Feb 2021 01:27:07 +0000 (20:27 -0500)]
tpm2: Add comment to HASH_ALIGNMENT define

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
3 years agoCHANGES: Updated CHANGES document for 0.8.0
Stefan Berger [Tue, 7 Jul 2020 13:12:53 +0000 (09:12 -0400)]
CHANGES: Updated CHANGES document for 0.8.0

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
3 years agotpm2: Add define for static_assert in case it doesn't exist in assert.h
Stefan Berger [Sat, 20 Feb 2021 21:39:28 +0000 (16:39 -0500)]
tpm2: Add define for static_assert in case it doesn't exist in assert.h

Some older systems do not define static_assert, so we have to provide
our own static_assert that does 'nothing'.

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
3 years agotpm2: Add missing swap defines for FreeBSD
Stefan Berger [Sat, 20 Feb 2021 21:35:52 +0000 (16:35 -0500)]
tpm2: Add missing swap defines for FreeBSD

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
3 years agotpm2: Sanitize values read from TPM state stream (Coverity)
Stefan Berger [Sun, 21 Feb 2021 13:44:38 +0000 (08:44 -0500)]
tpm2: Sanitize values read from TPM state stream (Coverity)

Sanitize some of the values read from the TPM state stream.
All Coverity discoveries seem to be false positives.

Coverity doesn't like to see array_size being used in the loop even
though it was compared against ARRAY_SIZE() before. We solve this by
using ARRAY_SIZE() as the loop limit now rather than array size.

Compare seed.b.size against PRIMARY_SEED_SIZE even though this is
already being done in TPM2B_Unmarshal().

The num_bytes parameter is sanitized via a comparison involving a
sum over a sum of values, but Coverity doesn't seem to detect this.
Then we have to use it as a loop limit. I don't see another way.

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
3 years agotpm2: Prevent a potential buffer overrun (Coverity)
Stefan Berger [Sun, 21 Feb 2021 13:24:35 +0000 (08:24 -0500)]
tpm2: Prevent a potential buffer overrun (Coverity)

Prevent a potential buffer overrun by checking that EVP_DecryptUpdate()
has not overrun the buffer it was passed in, so this overrun should
never occurr unless EVP_DecryptUpdate() was wrong. Also the pAssert above
it should have taken care of it already.

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
3 years agotpm2: Initialize keyschedule before AES_set_encrypt_key (overity)
Stefan Berger [Sun, 21 Feb 2021 13:21:28 +0000 (08:21 -0500)]
tpm2: Initialize keyschedule before AES_set_encrypt_key (overity)

Coverity complains that the *output* variable passed to
AES_set_encrypt_key contains uninitialized bytes, so we initialize
the variables now.

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
3 years agotpm2: Initialize variable and check rc before accessing nrh.size (Coverity)
Stefan Berger [Sun, 21 Feb 2021 13:04:21 +0000 (08:04 -0500)]
tpm2: Initialize variable and check rc before accessing nrh.size (Coverity)

Coverity complains that nrh may not be initialize when copying nrh.size
from it into the buffer pointer to by nrhp. So resolve this by clearing
nrh at the beginning of the loop and checking 'rc' after the Unmarshal.

Previously we could have copied an uninitialized nrh.size but would have
propagated the rc error code from UINT32_Unmarshal(), so this fix doesn't
really change anything.

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
3 years agotpm2: Fix a double-free in case of unlikely error (Coverity)
Stefan Berger [Sun, 21 Feb 2021 12:57:02 +0000 (07:57 -0500)]
tpm2: Fix a double-free in case of unlikely error (Coverity)

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
3 years agotpm2: Save key and hash contexts using ANY_OBJECT_Marshal
Stefan Berger [Wed, 17 Feb 2021 18:29:00 +0000 (13:29 -0500)]
tpm2: Save key and hash contexts using ANY_OBJECT_Marshal

Save key and hash contexts using the ANY_OBJECT_Marshal function and try
to load it using ANY_OBJECT_Unmarshal(). Unfortunately older contexts were
written out as plain OBJECTs, so we have to accomodate this case as well
so that we can restore key contexts from libtpms-0.7.x. We do not support
resuming HASH contexts from libtpms-0.7.x.

Before this modification context files written out by the IBM TSS stack
were 2692 bytes independent of content. Now an RSA 2048 key is 1222 bytes
and a NIST p384 key is 982 bytes.

Several of the original TPM 2 function exporting Sequence state and
importing it can now be disabled.

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
3 years agotpm2: Make ANY_OBJECT_Marshal/Unmarshal non-static
Stefan Berger [Wed, 17 Feb 2021 18:19:06 +0000 (13:19 -0500)]
tpm2: Make ANY_OBJECT_Marshal/Unmarshal non-static

Make the functions ANY_OBJECT_Marshal/Unmarshal non-static so that we can
call it from other places. Also allow passing a parameter 'verbose' to the
ANY_OBJECT_Unmarshal function that allows us to call this function without
it logging errors. We need this when trying to load a context from an older
libtpms versions that did not use ANY_OBJECT_Marshal to write out the
OBJECT (but copied it right from memory).

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
3 years agotpm2: Return properly sized array for b parameter for NIST P521 (HLK)
Stefan Berger [Mon, 15 Feb 2021 14:44:51 +0000 (09:44 -0500)]
tpm2: Return properly sized array for b parameter for NIST P521 (HLK)

This patch ensures that the leading zeros in the b parameter for NIST P521
are being kept so that HLK accepts the returned parameters from
TPM2_ECC_Parameters. Now 66 bytes are reported for 'b' rather than only 65.
Do the same for the 'a' parameter, though that one was properly reported
already because it didn't have any leading zeros.

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
3 years agotpm2: Fix typos and error reporting inconsitencies in NVMarshal.c
Stefan Berger [Sat, 13 Feb 2021 13:18:59 +0000 (08:18 -0500)]
tpm2: Fix typos and error reporting inconsitencies in NVMarshal.c

This patch addresses issue #177 by fixing some typos and error
reporting inconsistencies (how structures are spelled) in NVMarhsal.c.

Reported-by: Nicolas Iooss <nicolas.iooss@ledger.fr>
Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
3 years agotravis: drop Trusty (14.04) for Xenial (16.04)
William Roberts [Tue, 9 Feb 2021 15:09:45 +0000 (09:09 -0600)]
travis: drop Trusty (14.04) for Xenial (16.04)

PKG_INSTALLDIR is missing from 14.04, so switch to 16.04 to pick it up.

Signed-off-by: William Roberts <william.c.roberts@intel.com>
3 years agoconfigure: support --with-pkgconfigdir
William Roberts [Mon, 8 Feb 2021 20:33:21 +0000 (14:33 -0600)]
configure: support --with-pkgconfigdir

Support setting different install paths for package config files
using the --with-pkgconfigdir option.

Drop the hardcoded pkgconfigdir variable in the Makefile.am as per the
manpage http://manpages.ubuntu.com/manpages/cosmic/man7/pkg.m4.7.html
the macro PKG_INSTALLDIR defaults to $libdir/pkgconfig.

Signed-off-by: William Roberts <william.c.roberts@intel.com>