Commit Graph

997 Commits

Author SHA1 Message Date
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
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
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
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
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
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
Stefan Berger
bfb1c7739a Use hardening CFLAGS
Add hardening CFLAGS -D_FORTIFY_SOURCE=2 and stack protector.

Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
2015-02-02 06:58:59 -05:00
Stefan Berger
d987a4b844 Fix a memory leak in the TPMLibrary interface
Fix a memory leak in TPMLIB_Terminate.

Signed-off-by: Stefan Berger <stefanb@us.ibm.com>
2014-07-02 21:56:58 -04:00
Stefan Berger
9b392bf3fb Fix support for ARM64
Fix support for ARM64 by testing for whether __aarch64__ is defined.

Also see http://sourceforge.net/p/predef/wiki/Architectures for the
gcc preprocessor defines.

Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
2014-06-30 15:04:15 -04:00
Stefan Berger
b886be8010 Clear NVRAM area before deleting it
Clear the NVRAM area before deleting it.

Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
2014-06-30 15:04:15 -04:00
Stefan Berger
38e1c44281 Build dll on cygwin and build OpenSSL build cleanup
Fix the build process to build a dll on cygwin and remove
freebl specific shell calls when building for OpenSSL.

Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
Acked-by: Corey Bryant <coreyb@linux.vnet.ibm.com>
2014-01-13 16:41:06 -05:00
Stefan Berger
54c5659647 Remove unnecessary build files from repository
Remove unnecessary files in the repository and add boostrap.sh to create the
configure file and other files we are removing here. Users have to run
bootstrap.sh to have those files created in their build environment.
Update the INSTALL instructions.

Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
Acked-by: Corey Bryant <coreyb@linux.vnet.ibm.com>
2014-01-13 16:39:13 -05:00
Stefan Berger
55c0004468 Fix compile error on cygwin
Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
Acked-by: Corey Bryant <coreyb@linux.vnet.ibm.com>
2014-01-08 11:44:01 -05:00
Stefan Berger
30a95c3c82 Make libtpms compileable with OpenSSL
Implement missing base64 decoder support when using OpenSSL library.

Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
Acked-by: Corey Bryant <coreyb@linux.vnet.ibm.com>
2014-01-08 11:43:51 -05:00
Stefan Berger
ba95ec6290 Address coverity warnings
Fixed typing errors.

Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
Acked-by: Corey Bryant <coreyb@linux.vnet.ibm.com>
2014-01-07 15:18:02 -05:00
Stefan Berger
337717ab32 Address coverity warnings
Handle function return codes.

Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
Acked-by: Corey Bryant <coreyb@linux.vnet.ibm.com>
2014-01-07 15:16:54 -05:00
Stefan Berger
ebcefd0548 Rename function TPM_SBuffer_Set to TPM_Sbuffer_Set
Minor typo in function name

Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
Acked-by: Corey Bryant <coreyb@linux.vnet.ibm.com>
2013-12-20 16:41:39 -05:00
Stefan Berger
93a6459a8e Fix spacing in tpm_audit.c
Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
Acked-by: Corey Bryant <coreyb@linux.vnet.ibm.com>
2013-12-20 16:40:36 -05:00
Stefan Berger
f1eb496720 A fix related to the physical presence flag
The physical presence flag should not be used if CMD enable is false

Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
Acked-by: Corey Bryant <coreyb@linux.vnet.ibm.com>
2013-12-20 16:40:20 -05:00
Stefan Berger
4e3500d5d5 Fix a typo in tpm_crypto.c
Trivial typo in comment

Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
Acked-by: Corey Bryant <coreyb@linux.vnet.ibm.com>
2013-12-20 16:39:59 -05:00
Corey Bryant
a0098eda2d Initial import of project
This is the initial import of the libtpms library.  The libtpms library
provides software emulation of a Trusted Platform Module (TPM).  It is
intended to be used by applications when a hardware TPM is not adequate.
For example, a hypervisor can use libtpms to emulate an independent TPM
for each of it's virtual machine guests.  The library provides a high-
level API for developers to integrate the emulated TPM support into
their application.

The code was originally written by Kenneth Goldman <kgoldman@us.ibm.com>
and Stefan Berger <stefanb@us.ibm.com>.

The code is licensed under the Modified BSD License.

Signed-off-by: Corey Bryant <coreyb@linux.vnet.ibm.com>
2013-10-31 15:33:22 -05:00