diff mbox series

tpmevlog: print out the TPM event log format type

Message ID 20210408091637.16534-1-ivan.hu@canonical.com
State Superseded
Headers show
Series tpmevlog: print out the TPM event log format type | expand

Commit Message

Ivan Hu April 8, 2021, 9:16 a.m. UTC
Helps to understand the log implemented by following which version of TPM spec.

Signed-off-by: Ivan Hu <ivan.hu@canonical.com>
---
 src/tpm/tpmevlog/tpmevlog.c         | 5 ++++-
 src/tpm/tpmevlogdump/tpmevlogdump.c | 5 ++++-
 2 files changed, 8 insertions(+), 2 deletions(-)

Comments

Colin Ian King April 8, 2021, 9:25 a.m. UTC | #1
On 08/04/2021 10:16, Ivan Hu wrote:
> Helps to understand the log implemented by following which version of TPM spec.
> 
> Signed-off-by: Ivan Hu <ivan.hu@canonical.com>
> ---
>  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):");

Perhaps a space between format and the (TPM2.0), e.g:
    "Crypto agile log format (TPM2.0):")

>  						tpmevlog_v2_check(fw, data, length);
> +					}
>  					else {
> +						fwts_log_info_verbatim(fw, "SHA1 log format(TPM1.2):");

and space between format and (TPM1.2): too

>  						tpmevlog_check(fw, data, length);
>  					}


Minor nit-pick, can you use the K&R fwts coding style with the if/else, e.g.

	if (....) {
	} else {
	}

Ta.

>  
> 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):");

and space here between  format and (TPM2.0)

>  						tpmevlogdump_parser(fw, data, length);
> +					}
>  					else {

K&R else format:

} else {



> +						fwts_log_info_verbatim(fw, "SHA1 log format(TPM1.2):");

and here too

>  						(void)tpmevlogdump_event_dump(fw, data, length);
>  					}
>  					free(data);
> 

Thanks
diff mbox series

Patch

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);