From patchwork Thu Apr 8 09:16:37 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ivan Hu X-Patchwork-Id: 1463694 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (no SPF record) smtp.mailfrom=lists.ubuntu.com (client-ip=91.189.94.19; helo=huckleberry.canonical.com; envelope-from=fwts-devel-bounces@lists.ubuntu.com; receiver=) Received: from huckleberry.canonical.com (huckleberry.canonical.com [91.189.94.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4FGFy55WKbz9sTD for ; Thu, 8 Apr 2021 19:16:45 +1000 (AEST) Received: from localhost ([127.0.0.1] helo=huckleberry.canonical.com) by huckleberry.canonical.com with esmtp (Exim 4.86_2) (envelope-from ) id 1lUQmH-0000Oy-Cm; Thu, 08 Apr 2021 09:16:41 +0000 Received: from youngberry.canonical.com ([91.189.89.112]) by huckleberry.canonical.com with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.86_2) (envelope-from ) id 1lUQmG-0000OK-EM for fwts-devel@lists.ubuntu.com; Thu, 08 Apr 2021 09:16:40 +0000 Received: from 61-220-137-37.hinet-ip.hinet.net ([61.220.137.37] helo=canonical.com) by youngberry.canonical.com with esmtpsa (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.86_2) (envelope-from ) id 1lUQmF-0005DB-N8 for fwts-devel@lists.ubuntu.com; Thu, 08 Apr 2021 09:16:40 +0000 From: Ivan Hu To: fwts-devel@lists.ubuntu.com Subject: [PATCH] tpmevlog: print out the TPM event log format type Date: Thu, 8 Apr 2021 17:16:37 +0800 Message-Id: <20210408091637.16534-1-ivan.hu@canonical.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 X-BeenThere: fwts-devel@lists.ubuntu.com X-Mailman-Version: 2.1.20 Precedence: list List-Id: Firmware Test Suite Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: fwts-devel-bounces@lists.ubuntu.com Sender: "fwts-devel" Helps to understand the log implemented by following which version of TPM spec. Signed-off-by: Ivan Hu --- src/tpm/tpmevlog/tpmevlog.c | 5 ++++- src/tpm/tpmevlogdump/tpmevlogdump.c | 5 ++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/src/tpm/tpmevlog/tpmevlog.c b/src/tpm/tpmevlog/tpmevlog.c index 1b952820..12242cf0 100644 --- a/src/tpm/tpmevlog/tpmevlog.c +++ b/src/tpm/tpmevlog/tpmevlog.c @@ -460,9 +460,12 @@ static int tpmevlog_test1(fwts_framework *fw) return FWTS_ABORTED; } else { /* check if the TPM2 eventlog */ - if (strstr((char *)(data + sizeof(fwts_pc_client_pcr_event)), FWTS_TPM_EVENTLOG_V2_SIGNATURE)) + if (strstr((char *)(data + sizeof(fwts_pc_client_pcr_event)), FWTS_TPM_EVENTLOG_V2_SIGNATURE)) { + fwts_log_info_verbatim(fw, "Crypto agile log format(TPM2.0):"); tpmevlog_v2_check(fw, data, length); + } else { + fwts_log_info_verbatim(fw, "SHA1 log format(TPM1.2):"); tpmevlog_check(fw, data, length); } diff --git a/src/tpm/tpmevlogdump/tpmevlogdump.c b/src/tpm/tpmevlogdump/tpmevlogdump.c index 612c1e4e..65cdf383 100644 --- a/src/tpm/tpmevlogdump/tpmevlogdump.c +++ b/src/tpm/tpmevlogdump/tpmevlogdump.c @@ -489,9 +489,12 @@ static int tpmevlogdump_test1(fwts_framework *fw) return FWTS_ABORTED; } else { /* check if the TPM2 eventlog */ - if (strstr((char *)(data + sizeof(fwts_pc_client_pcr_event)), FWTS_TPM_EVENTLOG_V2_SIGNATURE)) + if (strstr((char *)(data + sizeof(fwts_pc_client_pcr_event)), FWTS_TPM_EVENTLOG_V2_SIGNATURE)) { + fwts_log_info_verbatim(fw, "Crypto agile log format(TPM2.0):"); tpmevlogdump_parser(fw, data, length); + } else { + fwts_log_info_verbatim(fw, "SHA1 log format(TPM1.2):"); (void)tpmevlogdump_event_dump(fw, data, length); } free(data);