From a3b7c0cbf3906f60501fd07e09cd9b7583521088 Mon Sep 17 00:00:00 2001 From: Vadim Sukhomlinov Date: Mon, 11 Nov 2019 14:18:16 -0800 Subject: cr50: Add support for testing SHA-384, SHA-512 with CRYPTO_TEST=1 Added support for SHA-384 and SHA-512 testing by providing direct access to algorithms using TPM extension commands enbaled with CRYPTO_TEST=1. This is used by ACVP tests for completness of SHA2 coverage. ACVP tests to be added separately. BUG=none BRANCH=cr50 TEST=make BOARD=cr50 CRYPTO_TEST=1 -j Change-Id: I3152d5186a5488793f6487ec5d50acdec2813c77 Signed-off-by: Vadim Sukhomlinov Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1910525 Reviewed-by: Vadim Sukhomlinov Reviewed-by: Vadim Bendebury Tested-by: Vadim Sukhomlinov Commit-Queue: Vadim Sukhomlinov Auto-Submit: Vadim Sukhomlinov --- board/cr50/tpm2/hash.c | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/board/cr50/tpm2/hash.c b/board/cr50/tpm2/hash.c index de4116052b..aba5d84a6f 100644 --- a/board/cr50/tpm2/hash.c +++ b/board/cr50/tpm2/hash.c @@ -302,8 +302,8 @@ static void hash_command_handler(void *cmd_body, * field | size | note * =================================================================== * mode | 1 | 0 - start, 1 - cont., 2 - finish, 3 - single - * hash_mode | 1 | 0 - sha1, 1 - sha256 - * handle | 1 | seassion handle, ignored in 'single' mode + * hash_mode | 1 | 0 - sha1, 1 - sha256, 2 - sha384, 3 - sha512 + * handle | 1 | session handle, ignored in 'single' mode * text_len | 2 | size of the text to process, big endian * text | text_len | text to hash */ @@ -321,7 +321,14 @@ static void hash_command_handler(void *cmd_body, case 1: alg = TPM_ALG_SHA256; break; - +#ifdef SHA512_SUPPORT + case 2: + alg = TPM_ALG_SHA384; + break; + case 3: + alg = TPM_ALG_SHA512; + break; +#endif default: return; } -- cgit v1.2.1