Commit Graph

918 Commits

Author SHA1 Message Date
Stefan Berger
4ffc27dd4c Fix TPM_PROOF to work with older versions 2018-06-15 18:07:47 -04:00
Stefan Berger
6dfef61a1e Choose build switches for TPM2
Choose build switches:
- do not build with SIMULATION; fix the code to avoid missing symbols

Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
2018-06-15 18:07:47 -04:00
Stefan Berger
487f6fa98d tpm2: Make RADIX_BITS dependent on openssl #defines
Make the #define RADIX_BITS dependent on #defines set by the
OpenSSL library: THIRTY_TWO_BIT and SIXTY_FOUR_BIT_LONG

Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
2018-06-15 18:07:47 -04:00
Stefan Berger
bd2c540c3f tpm2: fix a bug in rev146 of the TPM2 code 2018-06-15 18:07:47 -04:00
Stefan Berger
b19b6ed343 Fix compilation errors in the TPM 2 code
Fix compilation errors in the TPM 2 code.

Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
2018-06-15 18:07:47 -04:00
Stefan Berger
5e64f96378 Extend license texts with TPM 2 specifics
Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
2018-06-15 18:07:47 -04:00
Stefan Berger
992a5bfad8 Upgrade from rev 142 to rev 146
This is the diff patch between rev 142 and 146.

Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
2018-06-15 18:07:47 -04:00
Stefan Berger
ccce8b5f49 Add TPM 2 code
Add TPM 2 code.

This is rev. 142 code.

Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
2018-06-15 18:07:47 -04:00
Stefan Berger
707a9046cd Use malloc/free rather than TPM_Malloc/TPM_Free in library code
Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
2018-06-15 18:02:04 -04:00
Stefan Berger
d9d83de2d3 build-sys: Add AC_CONFIG_AUX_DIR to configure.ac
The Travis build of swtpm now has a problem due to missing ltmain.sh. Add
AC_CONFIG_AUX_DIR to configure.ac to resolve the issue.

Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
2018-05-27 20:37:34 -04:00
Marc-André Lureau
9081bbc459 build-sys: add a simple autogen.sh
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
2018-05-26 07:41:18 -04:00
Marc-André Lureau
c6c2a38b6e tpm12: fix uninitialized variable warning
clang complains:

tpm12/tpm_init.c:666:9: error: variable 'tag' is used uninitialized whenever 'if' condition is false [-Werror,-Wsometimes-uninitialized]
    if (rc == 0) {
        ^~~~~~~
tpm12/tpm_init.c:746:9: note: uninitialized use occurs here
    if (tag == TPM_TAG_STCLEAR_DATA) {
        ^~~
tpm12/tpm_init.c:666:5: note: remove the 'if' if its condition is always true
    if (rc == 0) {
    ^~~~~~~~~~~~~
tpm12/tpm_init.c:662:28: note: initialize the variable 'tag' to silence this warning
    TPM_STRUCTURE_TAG   tag;
                           ^
                            = 0

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
2018-05-25 22:25:46 -04:00
Marc-André Lureau
72e86cb081 build-sys: remove generated files
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
2018-05-25 22:25:34 -04:00
Stefan Berger
ee69f37801 Dereference the pointer rather than the pointer to the pointer
A bug discovered by coverity. This fixes the bug.

Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
2018-05-14 16:48:22 -04:00
Stefan Berger
f031191a1d Load permanent state before testing volatile or save state
The permanent state has to be loaded before the volatile or save state blobs
can be tested since they are connected to the permanenent state.

We implement TPM_PermanentAll_NVLoad_Preserve that makes a copy of any
cached permanent state blobs before we load the permanent state via
TPM_PermanentAll_NVLoad, which would consume and free any cached state blob,
if there was one (would fall back to reading from file otherwise). We then
set the copy of any cached permanent state blob back so that it can be used
when the TPM 1.2 start.

Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
2018-05-13 19:32:33 -04:00
Stefan Berger
7071a43bab Clear the cached blobs if SetState fails on checking one of them
Clear all the cached states blobs set using TPMLIB_SetState if one
of them cannot be accepted.

Signed-off-by: Stfean Berger <stefanb@linux.vnet.ibm.com>
2018-05-13 19:23:23 -04:00
Stefan Berger
ec672b4e37 Expose the two new API calls TPMLIB_Get/SetState
Expose the two new API calls TPMLIB_GetState() and TPMLIB_SetState().
Fix one parameter in the TPMLIB_GetState() call.

Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
2018-05-11 16:10:09 -04:00
Stefan Berger
51f7c2f0b7 Fix a bug introduced in 3238742947 (TPMLIB_ValidateState)
The permanent state has to be loaded before either the volatile
or the save state can be validated.

Also fix another bug that was testing for whether there was no
cached state. It should test whether there is a cached state.

Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
2018-05-10 23:48:16 -04:00
Stefan Berger
8bedcb30cb TPM_MainInit write permanent state blob if SetState() blob was used
If the permanent state was set using SetState() write the permanent
state once we successfully read the volatile state and can use it.
This way we have the state in a file.

Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
2018-05-10 16:35:09 -04:00
Stefan Berger
7bbb41a1fd Modify TPM_NVRAM_LoadData() to try to get cached state blob
Modify TPM_NVRAM_LoadData() to try to get the cached state blob before trying
to read the state blob from the file. We clear the state blob as part of
passing it to the TPM.

A side effect is now that if TPMLIB_ValidateState is called on a blob that
this call would not remove the cached blob. So we have to save a copy before
reading (and parsing) the state blob so we still have it when TPM_MainInit()
is called.

Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
2018-05-10 16:35:09 -04:00
Stefan Berger
c76f52efd3 Add APIs for getting and setting all state blobs
This patch adds APIs for getting and setting all types of state
blobs. We cache these blobs and allow them to be picked up when
the TPM starts. It will get any of these state blobs, if they
were set, before we go out and try to read the state blob from
a file.

Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
2018-05-10 16:35:09 -04:00
Stefan Berger
3238742947 Refactor TPM12_ValidateState to implement loop
Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
2018-05-10 16:06:15 -04:00
Stefan Berger
fe481765b9 Add TPMAttributes JSON object to GetInfo interface
Requesting TPMLIB_INFO_TPMATTRIBUTES returns:

{
  "TPMAttributes": {
    "manufacturer": "id:00001014",
    "version": "id:00740001",
    "model": "swtpm"
  }
}

Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
2018-05-04 19:36:05 -04:00
Stefan Berger
70547a758b Implement TPMLIB_GetInfo() to for example get TPM spec. info
The EK certificates need information about the TPM specification that was
implemented. The best place to get the information from seems the TPM itself.
So we implement a function TPMLIB_GetInfo() to allow to query for the TPM
specification information and possibly other information in the future.

Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
2018-04-23 07:10:01 -04:00
Stefan Berger
aef3e6fd6b Fix logic invoking validation of state
The logic for invoking the validation of the TPM 1.2 state was
broken. The validation of volatile and save state state requires
that the permanent state is available, so we always load it
first.

Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
2018-03-27 21:56:54 -04:00
Stefan Berger
f9d920470d Fix typos for logical and
Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
2018-03-27 19:56:03 -04:00
Stefan Berger
e11dbf255b Implement TPMLIB_ValidateState() to test state blobs early
Implement TPMLIB_ValidateState(), which is supposed to be used
for checking usability of state blobs before TPMLIB_MainInit()
is called or TPM_Startup has been sent to the TPM.

This function is useful to be called once TPM state blobs
have been migrated to a destination and we need to check
whether libtpms can use these state blobs and if not
we have a chance to fall back to the migration source host.

Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
2018-02-17 15:00:39 -05:00
Stefan Berger
d77f29d64e Always return minimum and maximum buffer sizes
Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
2017-12-26 10:17:53 -05:00
Stefan Berger
ccdf2457c7 Support a range of 3k to 4k for TPM 1.2 buffer size
Extend the previous support of a fixed buffer size to work
with a minimum of 3k and a maximum of 4k.

Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
2017-12-18 19:33:51 -05:00
Stefan Berger
3388d45082 build: fix Cygwin compiler warning
Cygwin compiler complains about comparison of signed and unsigned
integer on the ~0.

Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
2017-11-13 10:15:39 -05:00
Stefan Berger
02db69c85a Add unsuppressable internal logging using ~0 indent
Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
2017-11-11 10:44:02 -05:00
Stefan Berger
ae3f105ac3 Extend TPMLIB_SetBufferSize() call with min/max size parameters
Also allow to get the minimum and maximum supported buffer size
with the TPMLIB_SetBufferSize() call.

Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
2017-11-05 11:57:07 -05:00
Stefan Berger
d1e71620dd Make TPMLIB_SetBufferSize function visible
Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
2017-11-04 02:08:15 -04:00
Stefan Berger
bc195a3452 Implement TPMLIB_SetBufferSize() for setting the size of the I/O buffer
Implement TPMLIB_SetBufferSize() for setting the size of the I/O buffer
that the TPM may advertise. For TPM 1.2 the size remains fixed since the
TIS interface can handle the current 4096 bytes.

This function will be important for TPM 2 with a CRB interface that cannot
handle 4096 bytes.

Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
2017-11-04 00:52:30 -04:00
Stefan Berger
46727502fc build: add -lc when checking for missing symbols on OpenBSD
When checking for missing symbols we need to add -lc to the libraries
passed to gcc otherwise we always see lots of missing symbols even if
there aren't any.

Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
2017-10-12 12:46:34 -04:00
Stefan Berger
1279e39eb8 build: Only add -Wall -Werror etc. if user did not set CFLAGS explicitly
Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
2017-10-12 12:46:34 -04:00
Stefan Berger
6b9d222bc1 tests: work around possibly missing tools
Implement a work-around for seq and base64 for OpenBSD where these
tools may be missing.

Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
2017-10-12 12:46:34 -04:00
Stefan Berger
c525dad4e4 tpm12: LibreSSL seems to not have the new OpenSSL 1.1 API
LibreSSL on OpenBSD seems to not support the new API of OpenSSL 1.1.
So create a new #define OPENSSL_OLD_API that is set if the old API
is to be used.

Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
2017-10-12 12:46:34 -04:00
André Draszik
9649f4b866 build: fix out of tree builds
../libtool  --tag=CC   --mode=link gcc -include tpm_library_conf.h -I../../include/libtpms -fstack-protector-strong -Wl,-z,relro -Wl,-z,now  -DTPM_V12 -DTPM_PCCLIENT -DTPM_VOLATILE_LOAD -DTPM_ENABLE_ACTIVATE -DTPM_AES -DTPM_LIBTPMS_CALLBACKS -DTPM_NV_DISK -DTPM_POSIX  -g -O2 -Wall -Werror -Wreturn-type -Wsign-compare -Wl,--version-script=./libtpms.syms -version-info 6:0:6 -no-undefined  -o libtpms.la -rpath /usr/local/lib libtpms_la-tpm_library.lo libtpms_tpm12.la -lcrypto
libtool: link: gcc -shared  -fPIC -DPIC  .libs/libtpms_la-tpm_library.o  -Wl,--whole-archive ./.libs/libtpms_tpm12.a -Wl,--no-whole-archive  -lcrypto  -fstack-protector-strong -Wl,-z -Wl,relro -Wl,-z -Wl,now -g -O2 -Wl,--version-script=./libtpms.syms   -Wl,-soname -Wl,libtpms.so.0 -o .libs/libtpms.so.0.6.0
/usr/bin/ld: cannot open linker script file ./libtpms.syms: No such file or directory

libtpms.syms is inside the source directory, so when doing out
of tree builds it can't be found - fix the libtool invocation.

Signed-off-by: André Draszik <adraszik@tycoint.com>
2017-10-09 08:19:02 -04:00
Stefan Berger
4ea0a044ca tpm12: Use latests tpm_delegate fixing code format
Signed-off-by: Stefan Berger <stefanb@linxu.vnet.ibm.com>
2017-10-05 09:40:11 -04:00
Stefan Berger
c5ec1eaee0 tpm12: use latest tpm_pcr.c fixing return code assignment
Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
2017-10-05 09:37:50 -04:00
Stefan Berger
569408f12a build: integrate Travis CI automation with Coverty Scan
Integrate the Travis CI automated build & test with Coverity Scan.
Automatically submit a Coverity Scan if we push to the coverity_scan
branch.

Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
2017-09-22 11:27:35 -04:00
Stefan Berger
53e75ba814 ci: add .travis.yml
Add Travis build script.

Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
2017-07-31 12:40:43 -04:00
Stefan Berger
ddba883aa3 tpm12: use latest tpm_crypto.c for OpenSSL 1.1 support
Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
2017-07-28 17:14:39 -04:00
Stefan Berger
57996002ec tpm12: use latest tpm_pcr.c adding more debugging output
Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
2017-07-28 17:14:28 -04:00
Stefan Berger
98e9b92325 tpm12: use latest tpm_daa.c fixing return code assignments and a bug
Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
2017-07-28 17:14:24 -04:00
Stefan Berger
9da4b2802f tpm12: use latest tpm_nvram.c that display additional error message
Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
2017-07-28 17:14:19 -04:00
Stefan Berger
8c95adc480 tpm12: use latest tpm_svnrevision.c that increase major and minor numbers
Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
2017-07-28 17:14:13 -04:00
Stefan Berger
2855c5abfb tpm12: use latest tpm_transport.c with a return code assigned
Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
2017-07-28 17:14:08 -04:00
Stefan Berger
8128367045 Ignore a few more files and delete depcomp
Ignore *.log and *.trs files from the test suite.
Ignore compile and the 'missing' file.
Remove the depcomp file.

Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
2017-04-06 14:21:18 -04:00