[SLOF] [PATCH v3 0/7] tcgbios: Use the proper hashes for the TPM 2 PCR banks

Stefan Berger stefanb at linux.vnet.ibm.com
Fri Jul 9 12:53:06 AEST 2021

From: Stefan Berger <stefanb at linux.ibm.com>

This PR adds the implementations for sha{1, 384, 512} and makes use
of the hash implementation when extending the PCRs of the respective
banks rather than always using the sha256 and either truncating the
hash or zero-padding it to fit the hash for a PCR bank.

Another patch in this series converts the S_CTRM_VERSION string to ucs_2
format (following a long-term TCG contributor) commonly used for this

Test cases for the sha implementations are added in the last patch. They
require OpenSSL's -lcrypto on the host since they use its hashing functions
for producing comparable results. A test script to run the tests is also


  - Add patch for Travis
  - Adjustments to test code to not have to include openssl/sha.h

  - split out type fix in sha256 documentation into own patch
  - replace rotr in sha256 implementation with assembly macro
  - Added test cases needing -lcrypto on host; added test script

Stefan Berger (7):
  tcgbios: Change format of S_CRTM_VERSION string to ucs-2
  tcgbios: Use assembly for 32 bit rotr in sha256
  tcgbios: Fix a typo in the sha256 algo description
  tcgbios: Add implementations for sha1, sha384, and sha512
  tcgbios: Use The proper sha function for each PCR bank
  tcgbios: Add test cases and test script to run them
  Travis: Add script for running tests on Travis

 .travis.yml                    |  15 ++
 lib/libtpm/Makefile            |   2 +-
 lib/libtpm/sha.c               | 231 +++++++++++++++++++++++++++
 lib/libtpm/{sha256.h => sha.h} |   9 +-
 lib/libtpm/sha256.c            |  43 ++++-
 lib/libtpm/sha512.c            | 281 +++++++++++++++++++++++++++++++++
 lib/libtpm/sha_test.h          |  58 +++++++
 lib/libtpm/tcgbios.c           |  89 ++++++++---
 lib/libtpm/test.sh             |  29 ++++
 9 files changed, 728 insertions(+), 29 deletions(-)
 create mode 100644 .travis.yml
 create mode 100644 lib/libtpm/sha.c
 rename lib/libtpm/{sha256.h => sha.h} (70%)
 create mode 100644 lib/libtpm/sha512.c
 create mode 100644 lib/libtpm/sha_test.h
 create mode 100755 lib/libtpm/test.sh


More information about the SLOF mailing list