Go to file
Stefan Berger db1fd5948b 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>
2021-05-13 08:53:26 -04:00
.github/ISSUE_TEMPLATE github: Update issues templates 2020-12-27 22:52:39 -05:00
debian debian: Fix build warnings by updating compat to '10' and dh functions 2021-05-07 15:05:58 -04:00
dist Fix many misspellings 2021-03-02 08:20:25 -05:00
include Bump up the revision of the library for next version to 0.9.0 2021-02-24 15:08:38 -05:00
m4 build-sys: Require only autoconf 2.63 for older systems 2019-06-20 13:08:39 -04:00
man Fix many misspellings 2021-03-02 08:20:25 -05:00
src tpm2: Switch to UINT16 for CONTEXT_SLOT and 64k context gap 2021-05-13 08:53:26 -04:00
tests Fix many misspellings 2021-03-02 08:20:25 -05:00
.gitignore man: Remove generated man pages 2020-10-12 19:51:10 -04:00
.travis.yml travis: drop Trusty (14.04) for Xenial (16.04) 2021-02-09 13:33:15 -05:00
autogen.sh build-sys: add a simple autogen.sh 2018-05-26 07:41:18 -04:00
bootstrap.sh Remove config.h.in 2014-06-30 15:04:15 -04:00
CHANGES tpm2: Switch to UINT16 for CONTEXT_SLOT and 64k context gap 2021-05-13 08:53:26 -04:00
configure.ac tpm2: CryptSym: fix AES output IV 2021-03-01 12:54:27 -05:00
CREDITS Add CREDITS file 2013-10-31 16:37:33 -04:00
DCO1.1.txt Replace the CLA with the DCO, simply requiring a Signed-off-by: 2016-12-21 11:09:38 -05:00
INSTALL Fix many misspellings 2021-03-02 08:20:25 -05:00
libtpms.pc.in pkg-config: add cryptolib to libtpms.pc 2018-08-03 13:06:29 -04:00
LICENSE Extend license texts with TPM 2 specifics 2018-06-15 18:07:47 -04:00
Makefile.am configure: support --with-pkgconfigdir 2021-02-09 13:33:15 -05:00
README docs: Update README to include CXX=clang++ for fuzzer build 2019-11-16 15:41:09 -05:00

What is libtpms?
----------------

Libtpms is a library that targets the integration of TPM functionality
into hypervisors, primarily into Qemu. Libtpms provides a very narrow
public API for this purpose so that integration is possible. Only the
minimum of necessary APIs are made publicly available.

It is assumed that the user of libtpms is familiar with the concepts
of the Trusted Platform Module (TPM). For the interaction with libtpms
it is necessary to know how to construct valid TPM commands and to
be able to parse their results. It is not within the scope of libtpms's
documentation to provide background on this. See the section on references
below.


What files does the libtpms package provide?
--------------------------------------------

The main libtpms package provides the following files:

/usr/lib64/libtpms.so.0
/usr/lib64/libtpms.so.0.5.1
/usr/share/doc/libtpms-0.5.1
/usr/share/doc/libtpms-0.5.1/CHANGES
/usr/share/doc/libtpms-0.5.1/LICENSE
/usr/share/doc/libtpms-0.5.1/README

Applications can link with -ltpms.


What files does the libtpms development package provide?
--------------------------------------------------------

The libtpms development package (libtpms-devel) provides the following
include files for applications to use:

tpm_error.h
tpm_library.h
tpm_memory.h
tpm_nvfilename.h
tpm_tis.h
tpm_types.h

These files contain the data structures, data types and API calls supported
by libtpms. It is recommended to not use any other API calls than those
provided in these include files.

All APIs are described in man pages. The man pages are part of the libtpms
development package as well:

TPMLIB_DecodeBlob
TPMLIB_GetTPMProperty
TPMLIB_GetVersion
TPMLIB_MainInit
TPMLIB_Process
TPMLIB_RegisterCallbacks
TPMLIB_Terminate
TPMLIB_VolatileAll_Store
TPM_Free
TPM_IO_Hash_Data
TPM_IO_Hash_End
TPM_IO_Hash_Start
TPM_IO_TpmEstablished_Get
TPM_Malloc
TPM_Realloc


How to contribute?
------------------
The mailing list for libtpms is libtpms@googlegroups.com.

For patch submissions, please use a Signed-off-by: <your email> to indicate
agreement to the DCO1.1.txt.


Fuzzing
-------
Initial fuzzing is possible with clang & libfuzzer.

You have to configure the project with --enable-fuzzer
(--enable-sanitizer can also help spot more issues). Then you can
build fuzz and run it with the testing corpus.

Fuzz testing is known to work with Fedora 28 or later. It requires that the
'clang' package is installed.

Ex:
$ ./configure --with-openssl --with-tpm2 --enable-sanitizers --enable-fuzzer \
    CC=clang CXX=clang++
$ make && make -C tests fuzz
$ tests/run-fuzzer.sh

oss-fuzz builds with its own fuzzer flags, and set $LIB_FUZZING_ENGINE
to be linked with. The script run by oss-fuzz is tests/oss-fuzz.sh.

Maintainers
-----------
libtpms is currently being maintained by Stefan Berger <stefanb@us.ibm.com>.

References:
-----------

Documentation about the Trusted Platform Module (TPM) can be downloaded
from the Trusted Computing Group's website at

http://www.trustedcomputinggroup.org