Commit Graph

852 Commits

Author SHA1 Message Date
Stefan Berger
236a2fd119 tpm2: Sync with TPM 2 code comments or commented code (part 2)
Sync with TPM 2 code where the only difference is now comments
or commented/dead code.

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2020-04-14 16:03:45 -04:00
Stefan Berger
18924c6bde tpm2: sync: keep PRIVATE_VENDOR_SPECIFIC_BYTES at size from rev 150
Keep the size of PRIVATE_VENDOR_SPECIFIC_BYTES. Changing its size would
change the size of an Object, which we don't want since Objects are in
NVRAM memory and now more would fit than before. Fitting more is not the
problem but the state cannot be downgraded anymore since an earlier
implementation would require more bytes per Object and would not allow
fitting them all anymore.

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2020-04-14 16:03:45 -04:00
Stefan Berger
9865d9014c tpm2: sync: Initalize gc.platformAlg to ALG_NULL
Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2020-04-14 16:03:45 -04:00
Stefan Berger
19a12fbf79 tpm2: sync: Return error code in case of shutdown type != SU_CLEAR
Return an error code from TPM2_Shutdown in case an unknown shutdown
type code was given. Before that a failure was returned, which should
never have happened since the unmarshal function for parsing the shutdown
code would have caused an error when the command was parsed.

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2020-04-14 16:03:45 -04:00
Stefan Berger
675b53db61 tpm2: sync: Change variable to UINT16 as returned by CryptHashGetDigestSize
Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2020-04-14 16:03:45 -04:00
Stefan Berger
6a04c24a3d tpm2: sync: Change size parameter to CryptRandomGenerate to UINT16
Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2020-04-14 16:03:45 -04:00
Stefan Berger
c5546b5d76 tpm2: sync: Change #if defined SELF_TEST to #if SELF_TEST
This change has no negative effect on what branch of code gets
compiled.

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2020-04-14 16:03:45 -04:00
Stefan Berger
cfd12a7458 tpm2: sync: Add Windows specific includes
Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2020-04-14 16:03:45 -04:00
Stefan Berger
58d8971db0 tpm2: sync: Fix typo in comment
Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2020-04-14 16:03:45 -04:00
Stefan Berger
21742dea1e Tests: Add a check for arrays that expand with new commands
Add 2 more tests checking the size of arrays in the PERSISTENT_DATA
structure which expand with new commands.

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2020-04-13 08:56:37 -04:00
Stefan Berger
12a35bb511 Travis: Run additional IBM TSS2 related test; use Bionic
Run some additional IBM TSS2 related tests for better code
coverage. We need to switch to Bionic to get the tss2 package.

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2020-04-09 20:56:15 -04:00
Neil Roza
3476560a44 make debhelper play nice with autotools
We need to inform debhelper that it will be driving the action using autotools.

edit `debian/control` field `Build-Depends`: add `autotools-dev` and
`dh-autoreconf`

edit `debian/rules`:

* change the default target `%` to invoke `dh` with `autotools-dev` and
  `autoreconf`

* remove from `override_dh_auto_configure` the invocation to `./autogen.sh`
  obsoleted by `dh-autoreconf`
2020-04-06 12:22:48 -04:00
Neil Roza
d4d01a1f73 fix debian/{control,changelog} 2020-04-06 11:01:07 -04:00
Stefan Berger
a74bcc1649 Travis: Use -O3 in one of the builds
Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2020-01-30 08:39:03 -05:00
Stefan Berger
6de06a596c tpm12: Fix yet some more -O3 compilation errors (Trusty)
This patch addresses the following false positives on Ubuntu Trusty
on x86_64:

tpm12/tpm_process.c: In function ?TPM_Process_GetCapability?:
tpm12/tpm_process.c:3521:35: error: ?transportEncrypt? may be used uninitialized in this function [-Werror=maybe-uninitialized]
      returnCode = TPM_ProcessAudit(tpm_state,
                                   ^

tpm12/tpm_counter.c: In function ?TPM_Process_IncrementCounter?:
tpm12/tpm_counter.c:421:27: error: ?counterValue? may be used uninitialized in this function [-Werror=maybe-uninitialized]
  rc = TPM_Sbuffer_Append32(sbuffer, tpm_counter_value->counter);
                           ^
tpm12/tpm_counter.c:791:24: note: ?counterValue? was declared here
     TPM_COUNTER_VALUE *counterValue; /* The counter value */
                        ^

tpm12/tpm_key.c: In function ?TPM_KeyParms_CheckProperties?:
tpm12/tpm_key.c:1959:42: error: ?tpm_rsa_key_parms? may be used uninitialized in this function [-Werror=maybe-uninitialized]
   rc = TPM_KeyParams_CheckDefaultExponent(&(tpm_rsa_key_parms->exponent));

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2020-01-30 08:39:03 -05:00
Stefan Berger
49f3b55de9 tpm12: Initialize a few variables for x86 gcc -O3
gcc (Ubuntu 5.4.0-6ubuntu1~16.04.12) 5.4.0 20160609

The above gcc on x86 with -O3 reports the following false positives:

 gcc -DHAVE_CONFIG_H -I. -I.. -include tpm_library_conf.h -I../include/libtpms -I../include/libtpms -fstack-protector-strong -DTPM_V12 -DTPM_PCCLIENT -DTPM_VOLATILE_LOAD -DTPM_ENABLE_ACTIVATE -DTPM_AES -DTPM_LIBTPMS_CALLBACKS -DTPM_NV_DISK -DTPM_POSIX -DTPM_NOMAINTENANCE_COMMANDS -O3 -DUSE_OPENSSL_FUNCTIONS_SYMMETRIC=1 -DUSE_OPENSSL_FUNCTIONS_EC=1 -DUSE_OPENSSL_FUNCTIONS_ECDSA=0 -DUSE_OPENSSL_FUNCTIONS_RSA=0 -Wall -Werror -Wreturn-type -Wsign-compare -Wno-self-assign -MT tpm12/libtpms_tpm12_la-tpm_nvram.lo -MD -MP -MF tpm12/.deps/libtpms_tpm12_la-tpm_nvram.Tpo -c tpm12/tpm_nvram.c -o tpm12/libtpms_tpm12_la-tpm_nvram.o
tpm12/tpm_nvram.c: In function ‘TPM_Process_NVReadValue’:
tpm12/tpm_nvram.c:1539:38: error: ‘isGPIO’ may be used uninitialized in this function [-Werror=maybe-uninitialized]
      if ((returnCode == TPM_SUCCESS) && !isGPIO) {
                                      ^
tpm12/tpm_nvram.c: In function ‘TPM_Process_NVWriteValue’:
tpm12/tpm_nvram.c:2323:6: error: ‘isGPIO’ may be used uninitialized in this function [-Werror=maybe-uninitialized]
   if (!isGPIO) {
      ^

gcc -DHAVE_CONFIG_H -I. -I.. -include tpm_library_conf.h -I../include/libtpms -I../include/libtpms -fstack-protector-strong -DTPM_V12 -DTPM_PCCLIENT -DTPM_VOLATILE_LOAD -DTPM_ENABLE_ACTIVATE -DTPM_AES -DTPM_LIBTPMS_CALLBACKS -DTPM_NV_DISK -DTPM_POSIX -DTPM_NOMAINTENANCE_COMMANDS -O3 -DUSE_OPENSSL_FUNCTIONS_SYMMETRIC=1 -DUSE_OPENSSL_FUNCTIONS_EC=1 -DUSE_OPENSSL_FUNCTIONS_ECDSA=0 -DUSE_OPENSSL_FUNCTIONS_RSA=0 -Wall -Werror -Wreturn-type -Wsign-compare -Wno-self-assign -MT tpm12/libtpms_tpm12_la-tpm_process.lo -MD -MP -MF tpm12/.deps/libtpms_tpm12_la-tpm_process.Tpo -c tpm12/tpm_process.c -o tpm12/libtpms_tpm12_la-tpm_process.o
tpm12/tpm_process.c: In function ‘TPM_Process_GetCapabilitySigned’:
tpm12/tpm_process.c:5089:19: error: ‘transportEncrypt’ may be used uninitialized in this function [-Werror=maybe-uninitialized]
      returnCode = TPM_ProcessAudit(tpm_state,
                   ^
tpm12/tpm_process.c: In function ‘TPM_Process_SetCapability’:
tpm12/tpm_process.c:5309:19: error: ‘transportEncrypt’ may be used uninitialized in this function [-Werror=maybe-uninitialized]
      returnCode = TPM_ProcessAudit(tpm_state,
                   ^
tpm12/tpm_process.c: At top level:

gcc -DHAVE_CONFIG_H -I. -I.. -include tpm_library_conf.h -I../include/libtpms -I../include/libtpms -fstack-protector-strong -DTPM_V12 -DTPM_PCCLIENT -DTPM_VOLATILE_LOAD -DTPM_ENABLE_ACTIVATE -DTPM_AES -DTPM_LIBTPMS_CALLBACKS -DTPM_NV_DISK -DTPM_POSIX -DTPM_NOMAINTENANCE_COMMANDS -O3 -DUSE_OPENSSL_FUNCTIONS_SYMMETRIC=1 -DUSE_OPENSSL_FUNCTIONS_EC=1 -DUSE_OPENSSL_FUNCTIONS_ECDSA=0 -DUSE_OPENSSL_FUNCTIONS_RSA=0 -Wall -Werror -Wreturn-type -Wsign-compare -Wno-self-assign -MT tpm12/libtpms_tpm12_la-tpm_transport.lo -MD -MP -MF tpm12/.deps/libtpms_tpm12_la-tpm_transport.Tpo -c tpm12/tpm_transport.c -o tpm12/libtpms_tpm12_la-tpm_transport.o
tpm12/tpm_transport.c: In function ‘TPM_Process_ReleaseTransportSigned’:
tpm12/tpm_transport.c:2810:42: error: ‘t1TpmTransportInternal’ may be used uninitialized in this function [-Werror=maybe-uninitialized]
  returnCode = TPM_TransportLogOut_Extend(t1TpmTransportInternal->transDigest,
                                          ^

This patch initializes the variables.

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2020-01-17 15:21:32 -05:00
Stefan Berger
9781c71743 tpm2: Initialize a variable for gcc-5 ppc64el compiler
Another false positive report by a gcc-5 pcc64el compiler.

gcc-5 -DHAVE_CONFIG_H -I. -I.. -include tpm_library_conf.h -I../include/libtpms -I../include/libtpms -fstack-protector-strong -D_POSIX_ -DTPM_POSIX -DTPM_LIBTPMS_CALLBACKS -I ./tpm2 -I ./tpm2/crypto -I ./tpm2/crypto/openssl -g -O3 -fstack-protector-strong -DUSE_OPENSSL_FUNCTIONS_SYMMETRIC=1 -DUSE_OPENSSL_FUNCTIONS_EC=1 -DUSE_OPENSSL_FUNCTIONS_ECDSA=0 -DUSE_OPENSSL_FUNCTIONS_RSA=0 -Wall -Werror -Wreturn-type -Wsign-compare -Wno-self-assign -MT tpm2/libtpms_tpm2_la-Marshal.lo -MD -MP -MF tpm2/.deps/libtpms_tpm2_la-Marshal.Tpo -c tpm2/Marshal.c -o tpm2/libtpms_tpm2_la-Marshal.o
tpm2/Marshal.c: In function ‘TPM2B_PUBLIC_Marshal’:
tpm2/Marshal.c:96:19: error: ‘sizePtr’ may be used uninitialized in this function [-Werror=maybe-uninitialized]
      (*buffer)[1] = (BYTE)((*source >> 0) & 0xff);
                   ^
tpm2/Marshal.c:2023:11: note: ‘sizePtr’ was declared here
     BYTE *sizePtr;
           ^

This patch initializes the variable to NULL.

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2020-01-17 15:21:32 -05:00
Stefan Berger
86118eb13c tpm12: Initialize some variables for gcc-5 ppc64el compiler
The -O3 passed to the ppc64el gcc-5 compiler on Ubuntu 16.04 causes
the following false positives:

gcc-5 -DHAVE_CONFIG_H -I. -I.. -include tpm_library_conf.h -I../include/libtpms -I../include/libtpms -fstack-protector-strong -DTPM_V12 -DTPM_PCCLIENT -DTPM_VOLATILE_LOAD -DTPM_ENABLE_ACTIVATE -DTPM_AES -DTPM_LIBTPMS_CALLBACKS -DTPM_NV_DISK -DTPM_POSIX -DTPM_NOMAINTENANCE_COMMANDS -g -O3 -fstack-protector-strong -DUSE_OPENSSL_FUNCTIONS_SYMMETRIC=1 -DUSE_OPENSSL_FUNCTIONS_EC=1 -DUSE_OPENSSL_FUNCTIONS_ECDSA=0 -DUSE_OPENSSL_FUNCTIONS_RSA=0 -Wall -Werror -Wreturn-type -Wsign-compare -Wno-self-assign -MT tpm12/libtpms_tpm12_la-tpm_session.lo -MD -MP -MF tpm12/.deps/libtpms_tpm12_la-tpm_session.Tpo -c tpm12/tpm_session.c -o tpm12/libtpms_tpm12_la-tpm_session.o
tpm12/tpm_session.c: In function ‘TPM_Process_SaveContext’:
tpm12/tpm_session.c:3056:16: error: ‘contextIndex’ may be used uninitialized in this function [-Werror=maybe-uninitialized]
     uint32_t   contextIndex;  /* free index in context list */
                ^
tpm12/tpm_session.c: In function ‘TPM_Process_SaveAuthContext’:
tpm12/tpm_session.c:4934:16: error: ‘contextIndex’ may be used uninitialized in this function [-Werror=maybe-uninitialized]
     uint32_t   contextIndex;  /* free index in context list */
                ^

This patch initializes these variables to 0.

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2020-01-17 15:21:32 -05:00
Stefan Berger
0d22a7aea2 tpm12: Initialize some variables for gcc ppc64el compiler
gcc (Ubuntu 9.2.1-21ubuntu1) 9.2.1 20191130

The gcc compiler on Ubuntu Focal reports several false positives for
potentially uninitialized variables:

tpm12/tpm_session.c: In function ‘TPM_Process_SaveContext’:
tpm12/tpm_session.c:3229:19: error: ‘tpm_auth_session_data’ may be used uninitialized in this function [-Werror=maybe-uninitialized]
 3229 |      returnCode = TPM_AuthSessionData_Store(&r1ContextSensitive, tpm_auth_session_data);
      |                   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

tpm12/tpm_delegate.c: In function ‘TPM_Process_DelegateManage’:
tpm12/tpm_delegate.c:1787:49: error: ‘familyRow’ may be used uninitialized in this function [-Werror=maybe-uninitialized]
 1787 |  if ((opCode != TPM_FAMILY_CREATE) && (familyRow->flags & TPM_DELEGATE_ADMIN_LOCK)) {
      |                                        ~~~~~~~~~^~~~~~~
tpm12/tpm_delegate.c: In function ‘TPM_Process_DelegateUpdateVerification’:
tpm12/tpm_delegate.c:3575:48: error: ‘d1DelegateTableRow’ may be used uninitialized in this function [-Werror=maybe-uninitialized]
 3575 |      d1DelegateTableRow->pub.verificationCount = familyRow->verificationCount;
      |      ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

All of the variables are initialize under the same condition as they are
accessed.

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2020-01-14 20:25:19 -05:00
Stefan Berger
62c93cf0d3 debian: Address linitian issues in control file
Address a few issues in the control file as reported by lintian.

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2020-01-14 14:53:00 -05:00
Stefan Berger
9ccad78596 tpm2: Initialize variable to address valgrind complaint
This patch addresses the following valgrind issue detetcted by swtpm test suite:

== Syscall param write(buf) points to uninitialised byte(s)
==3515669==    at 0x4DC14B7: write (in /usr/lib64/libc-2.30.so)
==3515669==    by 0x48547FB: write_full (utils.c:242)
==3515669==    by 0x48548F3: writev_full (utils.c:301)
==3515669==    by 0x48520A6: SWTPM_IO_Write (swtpm_io.c:229)
==3515669==    by 0x4850662: mainLoop (mainloop.c:282)
==3515669==    by 0x402BE7: swtpm_main (swtpm.c:497)
==3515669==    by 0x4CF61A2: (below main) (in /usr/lib64/libc-2.30.so)
==3515669==  Address 0x52413a2 is 34 bytes inside a block of size 2,006 alloc'd
==3515669==    at 0x483980B: malloc (vg_replace_malloc.c:309)
==3515669==    by 0x48548A1: writev_full (utils.c:287)
==3515669==    by 0x48520A6: SWTPM_IO_Write (swtpm_io.c:229)
==3515669==    by 0x4850662: mainLoop (mainloop.c:282)
==3515669==    by 0x402BE7: swtpm_main (swtpm.c:497)
==3515669==    by 0x4CF61A2: (below main) (in /usr/lib64/libc-2.30.so)
==3515669==  Uninitialised value was created by a stack allocation
==3515669==    at 0x4953993: TPM2_Load (ObjectCommands.c:132)
==3515669==

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2020-01-10 08:34:27 -05:00
Stefan Berger
048e207b8e tpm12: Revert changes using strncpy to now use strcpy again
Revert the changes trying to use strncpy to now use strcpy again.
Recent compilers complain like this:

tpm12/tpm_nvfile.c: In function ‘TPM_NVRAM_Init’:
tpm12/tpm_nvfile.c:138:9: error: ‘strncpy’ specified bound depends on the length of the source argument [-Werror=stringop-overflow=]
  138 |         strncpy(state_directory, tpm_state_path, length + 1);
      |         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
tpm12/tpm_nvfile.c:130:18: note: length computed here
  130 |         length = strlen(tpm_state_path);
      |                  ^~~~~~~~~~~~~~~~~~~~~~
tpm12/tpm_nvfile.c: At top level:
cc1: error: unrecognized command line option ‘-Wno-self-assign’ [-Werror]
cc1: all warnings being treated as errors

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2020-01-10 07:54:57 -05:00
Stefan Berger
d186b753c8 tpm12: coverity: Use length + 1 for strncpy() parameter
Use length + 1 as size parameter to strncpy() to address a Coverity
issue (false positive).

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2020-01-04 13:47:00 -05:00
Stefan Berger
6c0144be4b tpm2: Convert CMAC test to SMAC test for better coverage
The SMAC test now covers CMAC as well but covers more code paths.

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2019-12-27 10:48:52 -05:00
Stefan Berger
1243d534a4 tpm2: Fix TDES key creation by adding missing un-/marshalling functions
Some TDES related marshalling and unmarshalling functions were
missing, so add them. Now TDES keys can be created.

Signed-off-by: stefan Berger <stefanb@linux.ibm.com>
2019-12-26 00:09:35 -05:00
Stefan Berger
e58cbdd4fd tpm2: Fix a bug in CheckAuthSession
This patch fixes a bug described in the following TCG Document

ERRATA; Errata Version 1.9, August 23, 2019; For TCG Trusted Platform
Module Library; Family "2.0", Level 00, Revision 1.38, Sept 29, 2016

section 2.34: NV PIN Indices

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2019-12-20 19:15:40 -05:00
Stefan Berger
75a2cd1a78 tpm12: Replace strcpy with safer strncpy
Replace the strcpy with the safer strncpy version.

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2019-12-19 13:23:25 -05:00
Stefan Berger
f289817a61 tpm2: Clarify that PRIMARY_SEED_SIZE is 64 per USE_SPEC_COMPLIANT_PROOFS
We define USE_SPEC_COMPLIANT_PROOFS which overrides PRIMARY_SEED_SIZE in
Implentation.h and cause PRIMARY_SEED_SIZE to be set to 64. Nevertheless,
adjust the value in Implementation.h.

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2019-12-05 21:04:47 -05:00
Stefan Berger
df2a7f9d75 tpm2: Always test implemented symmetric modes
Do not go by the toTest vector when it comes to testing symmetric
crypto modes since those bits may have been cleared elsewhere.
Check the implemented algorithm vector instead for whether the
mode is implemented.

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2019-11-20 09:35:40 -05:00
Stefan Berger
8d68e403b3 tpm2: Add missing break statement to EVP function selectors
Add a missing break statement to the EVP function selectors
based on algorithm. So far this missing break statement had
not negative effect since no other algoritms are in use in
case statements below the TDES.

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2019-11-20 09:35:40 -05:00
Stefan Berger
3909f211ac tpm12: Use TPM_PrintFourLimit where <= 4 bytes may exist
Use TPM_PrintFourLimit in those cases where less than 4 bytes of
valid data may exist. Hashes, nonces, encrypted data, and others
typically have more than 4 bytes but data read from NVRAM or
to be encrypted data may have less.

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2019-11-18 11:18:34 -05:00
Stefan Berger
653a524330 tpm12: Implement TPM_PrintFourLimit to print 4 or less bytes
Implement TPM_PrintFourLimit to print only up to 4 bytes or less.

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2019-11-18 11:18:34 -05:00
Stefan Berger
de7072edf1 docs: Update README to include CXX=clang++ for fuzzer build
We were missing CXX=clang++ in the docs for the fuzzer build. Add it.

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2019-11-16 15:41:09 -05:00
Stefan Berger
4c1dfefa7b build-sys: Avoid accumulation of -lcrypto
Avoid the accumulation of -lcrypto while testing for symbols in the -lcrypto
library by saving the LIBS variable before doing the series of tests.

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2019-10-23 16:10:13 -04:00
Stefan Berger
57d628a5ce tpm12: Get rid of usage of sprintf and use snprintf instead
Get rid of the usage of an sprintf and use snprintf instead. In this
case the buffer is 128, so big enough to not cause problems, though.

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2019-10-17 11:06:48 -04:00
Stefan Berger
7bd2fb0d42 tpm12: Fix potential buffer overflow in filename creation
Fix a potential buffer overflow bug in the creation of filenames
that were using sprintf() rather than snprintf(). The buffer overflow
could occurr if the buffer is longer than 4096 bytes. The state path
may alone be 4096 bytes and could possibly trigger the overflow.

Swtpm for example is not affected from this since it uses the callbacks
that are invoked before the faulty function is called.

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2019-10-17 11:06:48 -04:00
Stefan Berger
8ddc460ad1 tpm2: Check data size to be at least size of hash
Check the size of the available data before hashing them. A minimum
of 20 bytes needs to be passed into the function so that we can hash
the data 'before' it.

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
Reported-by: Yi Ren <yunye.ry@alibaba-inc.com>
2019-08-06 09:30:52 -04:00
Stefan Berger
625abcc688 Bump up the revision of the library for next version to 0.8.0
Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2019-07-19 13:54:18 -04:00
Stefan Berger
d061d8065b debian: Build now also requires g++ for fuzz test
Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2019-07-19 12:27:37 -04:00
Stefan Berger
c962433be0 RPM: Build now also requires gcc-c++ for fuzz test
Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2019-07-19 12:27:37 -04:00
Stefan Berger
39b1301d64 CHANGES: Add entry about significant changes for 0.7
Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2019-07-19 12:03:52 -04:00
Stefan Berger
2c0249e06d RPM: Set the release number to 0.7.0-0
Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2019-07-19 12:03:52 -04:00
Stefan Berger
0ea02181e5 debian: Adapt changelog for 0.7.0 release
Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2019-07-19 12:03:52 -04:00
Stefan Berger
24a22ef733 tpm2: Fix Coverity complaint by using iv.t.buffer
Fix a Coverity complaint by using iv.t.buffer rather than the
1-byte synonym (due to union) iv.b.buffer.

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2019-07-09 10:46:42 -04:00
Stefan Berger
a60df6fe56 build-sys: Require only autoconf 2.63 for older systems
autoconf 2.63 is sufficient as a dependency for AX_CHECK_DEFINE

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2019-06-20 13:08:39 -04:00
Stefan Berger
763d7a89de build-sys: Implement AX_CHECK_DEFINE and use for OpenSSL #define's
Some of the functions that OpenSSL uses are #define's for which
we need to check using a new AX_CHECK_DEFINE. We need to check for
them also because they were added at different points in time.

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2019-06-20 12:42:58 -04:00
Stefan Berger
6ae0d8c52c tpm2: Implement key creation with OpenSSL for rand == NULL
Implement key creation with OpenSSL if rand == NULL, meaning
that we create a non-KDF-derived key, so a purely random key.

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2019-06-20 12:23:29 -04:00
Stefan Berger
e793051573 tpm2: Use OpenSSL for decryption and signature verification
Use OpenSSL funtions now also for decryption and signature verification.

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2019-06-19 15:10:19 -04:00
Stefan Berger
05dc373b59 tpm2: Use OpenSSL functions for encrypting and signing using RSA keys
Use the CRT (Chinese Remainder Theorem) method for doing the RSA
operations. Unfortunately it is not sufficient to just pass the
precalculated dP, dQ, and qInv parameters to OpenSSL private key
crypto functions but it also needs D, which is a bit more involved
to calculate.

We are not caching D (private exponent) as part of the OBJECT since
the OBJECT lives in size-limited NVRAM and we would need to add
'D' to the privateExponent_t, which would make it bigger and which
would allow less keys to fit into memory, which in turn could be-
come an issue if we wanted to resume a TPM that filled up the NVRAM
with keys and now less keys would fit into the NVRAM.

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2019-06-19 13:57:45 -04:00
Stefan Berger
a572dbc424 tpm2: Implement helpers for creating OpenSSL RSA keys
Implement helper functions to create an RSA public and private
key. Create the latter with the CRT parameters.

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2019-06-19 13:57:45 -04:00