On 6/15/21 7:53 AM, Stefan Berger wrote:
On 6/15/21 4:36 AM, Paul Menzel wrote:
Dear Stefan,
Am 14.06.21 um 19:35 schrieb Stefan Berger:
Signed-off-by: Stefan Berger stefanb@linux.ibm.com
Makefile | 2 +- src/sha.h | 11 +++ src/sha1.c | 8 +- src/sha1.h | 8 -- src/sha256.c | 211 +++++++++++++++++++++++++++++++++++++++++++ src/sha512.c | 244 ++++++++++++++++++++++++++++++++++++++++++++++++++ src/tcgbios.c | 2 +- src/x86.h | 7 ++ 8 files changed, 479 insertions(+), 14 deletions(-) create mode 100644 src/sha.h delete mode 100644 src/sha1.h create mode 100644 src/sha256.c create mode 100644 src/sha512.c
Thank you for the patch. As the diffstatt is quite big, I am wondering how the correctness can be verified? Did you run some tests? Can I reproduce this in QEMU somehow?
I had tested the sha implementations with the first 3 of these vectors here and some other test data measured by trusted grub (on SLOF):
A critical input case for sha512 is at 112 and 113 bytes for example. This is where the input block contains too many bytes to append the 1024 bit length indicator. This is tested for here and I verify it via shell 'echo -en "${i}" | sha512sum':
https://github.com/stefanberger/SLOF-tpm/commit/bdddbb16a0d8215552d8b6a4447b...
Stefan