Commit Graph

900 Commits

Author SHA1 Message Date
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
Stefan Berger
187b09b431 Fix logging of prefix for TPM_PrintAll 2017-03-30 08:24:18 -04:00
Stefan Berger
563eb905d8 Convert another vdprintf to dprintf
Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
2017-03-15 08:10:11 -04:00
Stefan Berger
f94b80e0d6 Use format '%s' for call to dprintf
Fix the dprintf call to use a format parameter that otherwise causes
errors with gcc on certain platforms.

Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
2017-03-15 08:10:00 -04:00
Stefan Berger
a89da16e69 Add missing include for stdarg.h
Fix compilation problems like the following:

 /usr/local/lib/libtpms.so: undefined reference to `va_start'
 /usr/local/lib/libtpms.so: undefined reference to `va_end'

Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
2017-02-11 21:06:29 -05:00
Stefan Berger
ad44846dda Move TPMLIB_SetDebug* symbols under 0.6.0 release
Move the TPMLIB_SetDebug* symbols under the 0.6.0 release.

Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
2017-01-24 11:23:09 -05:00
Stefan Berger
942501e3b2 Replace vdprintf with dprintf where possible
vdprintf with a NULL parameter on the 3rd position crashes
on Linux. Replace it with dprintf.

Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
2017-01-23 19:46:49 -05:00
Stefan Berger
7fb176bcc4 Implement API calls for enabling debug output
Add API calls TPMLIB_SetDebugFD(), TPMLIB_SetDebugLevel(),
TPMLIB_SetDebugPrefix().

Convert the internal printing of debugging strings to
correspond to the log level. Print the prefix in front
of every line.

Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
2017-01-23 18:53:31 -05:00
Stefan Berger
a0eaeb8921 Replace the CLA with the DCO, simply requiring a Signed-off-by:
Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
2016-12-21 11:09:38 -05:00
Stefan Berger
e5dc628043 Allow choice of crypto subsystem via rpmbuild parameter
Use 'rpmbuild -ba --define "crypto_subsystem openssl" dist/libtpms.spec'
to build libtpms with openssl.

Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
2016-06-26 13:19:59 -04:00
Stefan Berger
f74cf06b06 Adding CLAs for corporate and individual contributors.
Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
2016-02-01 11:57:39 -05:00
Stefan Berger
37d9432a4e build: run bootstrap.sh as part of Debian build
Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
2016-01-13 17:07:52 -05:00
Stefan Berger
4a65fc6dbd debian: add copyright notice
Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
2016-01-13 17:05:05 -05:00
Stefan Berger
c82ef4f44e build: Some improvement to the Debian packaging
Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
2016-01-13 17:02:10 -05:00
Stefan Berger
7c51a9cfed build: Enable building of Debian package
Add debian build files to enable building of Debian package using for example

debuild -b   or   dpkg-buildpackage -us -uc

Extend the .gitignore.

The debhelper checks show warnings and errors that will need to be addressed
some other time. For some I don't know how to solve them at the moment.

Signed-off-by: Stefan Berger <stefanb@linux.watson.ibm.com>
2016-01-12 16:30:31 -05:00
Stefan Berger
a1cde166f9 build: disable -Wstack-protector
Some version of gcc fail with -Wstack-protector due to some functions
not being protectable. Disable this option.

Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
2016-01-12 15:40:32 -05:00
Stefan Berger
39c9604a92 Introduce internal interface to reach TPM functionality
Introduce an internal interface that allows us to reach TPM functionality
from the libary's API layer. This prepares the code for the addition
of a new API function that lets us choose which TPM to use, TPM 1.2 or
TPM2. Currently only TPM 1.2 functionality is available.

Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
2015-12-08 09:07:54 -05:00
Stefan Berger
2c6ceaed6f Add include file containering library version
Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
2015-12-07 19:36:49 -05:00
Stefan Berger
23b958af05 Move TPM1.2 code to src/tpm12 directory
Move all TPM1.2 code to src/tpm12 directory. Adapt the Makefile.am
to point to tpm12 directory for the TPM1.2 sources.

Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
2015-12-07 19:14:30 -05:00