mbox series

[v2,0/6] tcgbios: Use the proper hashes for the TPM 2 PCR banks

Message ID 20210708144601.437435-1-stefanb@linux.vnet.ibm.com
Headers show
Series tcgbios: Use the proper hashes for the TPM 2 PCR banks | expand

Message

Stefan Berger July 8, 2021, 2:45 p.m. UTC
From: Stefan Berger <stefanb@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
purpose.

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
added.

Regards,
    Stefan

v2:
  - 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 (6):
  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

 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          |  53 +++++++
 lib/libtpm/tcgbios.c           |  89 ++++++++---
 lib/libtpm/test.sh             |  23 +++
 8 files changed, 702 insertions(+), 29 deletions(-)
 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

Comments

Stefan Berger July 9, 2021, 2:53 a.m. UTC | #1
Please disregard this v2 series.