Skip to contentSkip to conversation

tpm: Remove redundant function grub_tpm_measure

PATCH In review Tianjia Zhang 2 participants 3 messages May 13, 2020

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 tpm: Remove redundant function grub_tpm_measure

The grub_tpm_measure() is only used by tpm.c, and this function is the simple wrapper of grub_tpm_event_log(). So remove it and keep the code cleaner.

---
 grub-core/commands/tpm.c | 12 ++----------
 include/grub/tpm.h       |  2 --
 2 files changed, 2 insertions(+), 12 deletions(-)
grub-core/commands/tpm.c +2 -10
index 1441c494d..cbe4116ec 100644
@@ -29,13 +29,6 @@
 
 GRUB_MOD_LICENSE ("GPLv3+");
 
-grub_err_t
-grub_tpm_measure (unsigned char *buf, grub_size_t size, grub_uint8_t pcr,
-		  const char *description)
-{
-  return grub_tpm_log_event (buf, size, pcr, description);
-}
-
 static grub_err_t
 grub_tpm_verify_init (grub_file_t io,
 		      enum grub_file_type type __attribute__ ((unused)),
@@ -49,7 +42,7 @@ grub_tpm_verify_init (grub_file_t io,
 static grub_err_t
 grub_tpm_verify_write (void *context, void *buf, grub_size_t size)
 {
-  return grub_tpm_measure (buf, size, GRUB_BINARY_PCR, context);
+  return grub_tpm_log_event (buf, size, GRUB_BINARY_PCR, context);
 }
 
 static grub_err_t
@@ -77,8 +70,7 @@ grub_tpm_verify_string (char *str, enum grub_verify_string_type type)
   grub_memcpy (description, prefix, grub_strlen (prefix));
   grub_memcpy (description + grub_strlen (prefix), str,
 	       grub_strlen (str) + 1);
-  status =
-    grub_tpm_measure ((unsigned char *) str, grub_strlen (str),
+  status = grub_tpm_log_event ((unsigned char *) str, grub_strlen (str),
 		      GRUB_STRING_PCR, description);
   grub_free (description);
   return status;
include/grub/tpm.h +0 -2
index dfcbe8372..8a686214a 100644
@@ -72,8 +72,6 @@ typedef struct
   grub_uint8_t  outDigest[SHA1_DIGEST_SIZE];
 } GRUB_PACKED ExtendOutgoing;
 
-grub_err_t grub_tpm_measure (unsigned char *buf, grub_size_t size,
-			     grub_uint8_t pcr, const char *description);
 grub_err_t grub_tpm_init (void);
 grub_err_t grub_tpm_execute (PassThroughToTPM_InputParamBlock *inbuf,
 			     PassThroughToTPM_OutputParamBlock *outbuf);
Signature · 1 line
2.17.1
#1 lore raw
Quoted 5 lines · Tianjia Zhang

The grub_tpm_measure() is only used by tpm.c, and this function is the simple wrapper of grub_tpm_event_log(). So remove it and keep the code cleaner.

I would prefer if you drop existing grub_tpm_measure() and rename grub_tpm_log_event() to grub_tpm_measure().

Daniel

#2 lore raw
Quoted 5 lines · Daniel Kiper
Quoted 4 lines · Tianjia Zhang

The grub_tpm_measure() is only used by tpm.c, and this function is the simple wrapper of grub_tpm_event_log(). So remove it and keep the code cleaner.

Quoted 7 lines
Quoted 1 line

I would prefer if you drop existing grub_tpm_measure() and rename grub_tpm_log_event() to grub_tpm_measure().

Daniel

Yes, this is a good idea, I will make another v2 patch.

Thanks and best,
Tianjia