Commit Graph

1373 Commits

Author SHA1 Message Date
Stefan Berger
0126131766 tpm2: Include stdint.h/def.h in BaseTypes.h and some other changes
Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2026-02-11 11:23:18 -05:00
Stefan Berger
ed2b79d556 Sync: Fix some build issues, reformat code and add more comments
Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2026-02-11 11:23:18 -05:00
Stefan Berger
d8b0639716 Sync: Use clang-format 19.1.4 to reformat sources
Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2026-02-11 11:23:18 -05:00
Stefan Berger
02dad542a9 Sync: Reformat some files
Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2026-02-11 11:23:18 -05:00
Stefan Berger
ef41366e24 Sync: Introduce PolicyTransportSPDM command but do not activate it
Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2026-02-11 11:23:18 -05:00
Stefan Berger
a968a53c92 Sync: Introduce ReadOnlyControl command but do not activate it
Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2026-02-11 11:23:18 -05:00
Stefan Berger
3433a7fcf5 Sync: Sync on white space changes
Resolve only white space changes on a previously applied patch resolving a
CVE where my version looked slightly different.

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2026-02-11 11:23:18 -05:00
Stefan Berger
8592c6384a Sync: Remove TABLE_DRIVEN_DISPATCH build switch
Remove the TABLE_DRIVEN_DISPATCH build switch that was set to 'YES'.
Remove code that assumed it to be set to 'NO'.

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2026-02-11 11:23:18 -05:00
Stefan Berger
f9d285f483 tpm2: Get rid of IS_IMPLEMENTED flag for CC attributes
Upstream has gotten rid of the IS_IMPLEMENTED flag but upstream is also
using compressed lists where each element in the command lists represents
an implemented command. Libtpms does not use compressed lists but we may
have a list with gaps in it due to unimplemented commands where this flag
may be the only one set and help identify an implemented command. However,
since profiles indicate enablement and implementation of commands, and
nearly all tests for the IS_IMPLEMENTED flag are paired with a check on
the profile with RuntimeCommandsCheckEnabled(), we can get rid of tests for
IS_IMPLEMENTED and finally the flag altogether since it is redundant.

Also get rid of NOT_IMPLEMENTED flag that was not used anywhere.

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2026-02-11 11:23:18 -05:00
Stefan Berger
c489b289f8 Sync: Remove USE_MARSHALING_DEFINES build switch
The build swtich was not used anywhere else.

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2026-02-11 11:23:18 -05:00
Stefan Berger
83f5656ecb Sync: Remove USE_BIT_FIELD_STRUCTURES build switch and bit fields
Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2026-02-11 11:23:18 -05:00
Stefan Berger
542c02becc LICENSE: Add copyright notices and BSD license for newer TPM 2 code
Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2026-02-11 11:23:18 -05:00
Stefan Berger
4fba21bdb5 scripts: Add help screen to meld-all and display if file is 'not upstream'
Add a help screen to meld-all and display if a file is not found in the
upstream repo.

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2026-02-11 11:22:30 -05:00
Stefan Berger
deef2301e3 scripts: Implement meld-commit to meld by commit Id
Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2026-01-21 11:50:56 -05:00
Stefan Berger
c2a8109f8b tpm2: Change license of some non-TCG files to BSD-2-clause
Now that Helpers.c is clean of contributions, change its license to
BSD-2-clause. Change license in some other files as well.

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2026-01-19 18:16:12 -05:00
Stefan Berger
363b4989d9 tpm2: Remove ALG_TDES conditional compilation (clean files)
Remove the contributed conditional compilation of a TDES related function
and fields in a structure based on definition of ALG_TDES.

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2026-01-19 18:16:12 -05:00
Stefan Berger
154fb6166e tpm2: Implement retrieval of updated IV after crypto operation
Implement the retrieval of the updated IV in a single function which is
to be called after a symmetric key encryption or decryption operation.

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2026-01-19 18:16:12 -05:00
Stefan Berger
62e5303e50 tpm2: Remove retrieval of IV after crypto operations (clean file)
Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2026-01-19 18:16:12 -05:00
Stefan Berger
6c0e325a91 tpm2: Revert some minor comment changes (clean files)
To get some files into the state so that they can be easily replaced with
the BSD-licensed code, revert:

- spelling changes that were introduced by nicolas.iooss@ledger.fr in
  bbd7b75d71. Many of the changes introduced in that change were replaced
  in subsequence changes with the original spelling errors in the upstream
  code.

- LibreSSL support introduced by orbea <orbea@riseup.net> in 95fff22c9b
  and 7310725524.

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2026-01-19 18:16:12 -05:00
Stefan Berger
dc7d694ab8 tpm2: Activate unused defines to reduce diff with upstream
To reduce the diffs with the upstream code, remove the deactivation of
ECC related defines.

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2026-01-19 17:01:01 -05:00
Stefan Berger
7947b1b115 tpm2: Remove usage of TPM_WINDOWS
TPM_WINDOWS is not set anywhere in the build system and therefore assumed
to not be used. We can get rid of whatever assumed it may have been set.
Also rool back some other changes to Windows-specific code.

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2026-01-19 16:41:38 -05:00
Stefan Berger
9820b0a68f tpm2: Move assert right to the result of fseek
Reduce the diff with upstream by removing the usage of variable 'irc' and
apply the assert right to the fseek statement.

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2026-01-19 16:29:09 -05:00
Stefan Berger
5fbcb81933 tpm2: Set cast of calculation to UINT32
Upstream uses a cast to 'int', which is not right, since the datatype of
availRAMSpaxe is a UINT32. Therefore, set the cast of the calculation to
UINT32.

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2026-01-19 16:23:01 -05:00
Stefan Berger
ebe60433c8 tpm2: Remove unnecessary inclusion of PlatformACT_fp.h
Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2026-01-19 16:18:59 -05:00
Stefan Berger
77cfa95b5e tpm2: Remove some unsupported vendor-specific definitions of command codes
NTC2 vendor commands are not supported. Entirely remove their definition to
reduce diffs with 'upstream'.
Mark CC_Policy_AC_SendSelect as changed by libtpms.

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2026-01-19 16:16:05 -05:00
Stefan Berger
a1aff1f45e tpm2: Uncomment forward reference of tpmCrypyKeySchedule_t
The forward reference for tpmCryptKeySchedule_t does not need to be
commented. This reduces the diff with 'upstream'.

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2026-01-19 16:13:22 -05:00
Stefan Berger
253be24a07 tpm2: Move inclusion of Unmarshal_fp.h into Marshal.h
Upstream defines all marshalling and unmarshalling prototypes in
Marshal_fp.h, inlcuding this header from Marshal.h. Since we have
Unmarshal_fp.h, include it also from Marshal.h. Adapt some other
code to these changes.

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2026-01-19 15:38:31 -05:00
Stefan Berger
b38789c851 tpm2: Remove unnecessary modification to include TpmTypes.h
It is not necessary to include TpmTypes.h. Remove the modification.

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2026-01-19 15:38:31 -05:00
Stefan Berger
fbafd0b566 tpm2: Check for NULL pointer of *value due to out-of-memory before using it
Move the block checking for a NULL pointer returned from strndup() up
so that we do not pass the NULL pointer in a call to
RuntimeProfileDedupStrItems().

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2026-01-10 14:49:22 -05:00
Stefan Berger
fc8820cfaa Fix a compilation error in TPMLIB_GetPlaintext
Fix a compilation error that newer gcc versions may complain about:

tpm_library.c: In function 'TPMLIB_GetPlaintext':
tpm_library.c:441:11: error: assignment discards 'const' qualifier from pointer target type [-Werror=discarded-qualifiers]
  441 |     start = strstr(stream, starttag);
      |           ^
At top level:
cc1: note: unrecognized command-line option '-Wno-self-assign' may have been intended to silence earlier diagnostics
cc1: all warnings being treated as errors

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2026-01-02 12:00:41 -05:00
Stefan Berger
ee31b0b235 tpm2: Fix retrieval of updated IV when using OpenSSL >= 3.0
Fix the retrieval of the updated IV for when OpenSSL >= 3.0 is used.
The previously used OSSL_PARAM_octet_ptr allocated a new buffer and then
returned the IV but this newly allocated buffer did not make it back to
the caller. We have to use OSSL_PARAM_octet_string instead to write the
data into the buffer.

Resolves: https://github.com/stefanberger/libtpms/issues/541
Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2025-12-29 13:11:10 -05:00
Stefan Berger
4f71e9b45d scripts: Also diff .inl files in meld-all and suppress diff error message
Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2025-12-03 13:40:30 -05:00
Stefan Berger
b2974e70d5 tpm2: Again reduce whitespace and comment differences with upstream
Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2025-12-03 13:40:30 -05:00
Stefan Berger
c2eb52e192 tpm2: Remove contributed SM4 support
Due to the license change in the 'new' upstream repo (versus the 'old'
upstream repo), remove the SM4 support contributed under the previous
license. We can remove this since SM4 is not enabled by default.
SM4 support can be re-added under BSD license before the next release.

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2025-12-03 13:40:30 -05:00
Stefan Berger
f1e488a59c tpm2: Remove contributed Camellia 192 test cases
Due to the license change in the 'new' upstream repo (versus the 'old'
upstream repo), remove the Camellia-192 test cases contributed under the
previous license. The test will be re-added from data generated by the
script src/tpm2/gensymtestdata.sh before the next release.

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2025-12-03 13:40:30 -05:00
orbea
7310725524 tpm2: use BN_BIT2 to determine RADIX_BITS
With LibreSSL 4.2.0 the THIRTY_TWO_BIT and SIXTY_FOUR_BIT_LONG defines
were removed, but BN_BITS2 has the correct value for RADIX_BITS.

Signed-off-by: orbea <orbea@riseup.net>
2025-10-15 22:20:12 -04:00
Stefan Berger
e064e54082 Remove generated tpm_library.h from repo
Add the tpm_library.h file to the files to be ignored.

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2025-09-23 09:19:00 -04:00
Luca Boccassi
4504f47c67 automake: remove generated files on dist-clean
Signed-off-by: Luca Boccassi <luca.boccassi@gmail.com>
2025-09-23 08:59:17 -04:00
Luca Boccassi
22855f184b man: make build reproducible via SOURCE_DATE_EPOCH
The manpages include the current build date, so they are not reproducible.
If defined, use the SOURCE_DATE_EPOCH as defined here:

https://reproducible-builds.org/docs/source-date-epoch/

Signed-off-by: Luca Boccassi <luca.boccassi@gmail.com>
2025-09-22 14:08:04 -04:00
Luca Boccassi
2c1deb52aa man: fix various typos found by Lintian
Signed-off-by: Luca Boccassi <luca.boccassi@gmail.com>
2025-09-22 13:29:39 -04:00
Ernst Schwaiger
e96a61c1ef add pkg-config to ubuntu prerequisites
Signed-off-by: ernst.schwaiger@chello.at
2025-08-31 14:16:37 -04:00
Stefan Berger
b7c81f960a tpm2: Fix memory leak by freeing KDF context
Fix a memory leak by freeing the KDF context after usage.

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2025-08-28 09:16:47 -04:00
Stefan Berger
b4d81572c1 tpm2: Define TPMI_RH_NV_DEFINED_INDEX_H_UNMARSHAL and use it
Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2025-08-07 11:05:51 -04:00
Stefan Berger
c9ed596fe4 tpm2: Add missing ADD_FLAG to X509Certificate definition
Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2025-08-07 11:05:51 -04:00
Stefan Berger
e7e8c38281 tpm2: Rename PlatformPCR.c to PlatformPcr.c and sync
Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2025-08-06 13:55:46 -04:00
Stefan Berger
04bd7d4b2b tpm2: Sync (unused) structures and defines related to FIPS-140
Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2025-08-06 10:24:30 -04:00
Stefan Berger
e02951cd05 tpm2: Add or remove empty lines to reduce diffs
Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2025-08-05 10:47:24 -04:00
Stefan Berger
7eb43b9ebe tpm2: Remove commented-out blocks
Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2025-08-05 10:47:24 -04:00
Stefan Berger
8fd1293d60 tpm2: Sync defines for unsupported AC_GetCapability
Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2025-08-05 10:47:24 -04:00
Stefan Berger
bee52fbed3 tpm2: Add definitions for new algorithms and curves
Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2025-08-05 10:47:24 -04:00