]> git.proxmox.com Git - grub2.git/commitdiff
efi/tpm: Remove unused functions and structures
authorTianjia Zhang <tianjia.zhang@linux.alibaba.com>
Wed, 29 Jul 2020 13:31:14 +0000 (21:31 +0800)
committerDaniel Kiper <daniel.kiper@oracle.com>
Fri, 18 Sep 2020 20:31:29 +0000 (22:31 +0200)
Although the tpm_execute() series of functions are defined they are not
used anywhere. Several structures in the include/grub/efi/tpm.h header
file are not used too. There is even nonexistent grub_tpm_init()
declaration in this header. Delete all that unneeded stuff.

If somebody needs the functionality implemented in the dropped code then
he/she can re-add it later. Now it needlessly increases the GRUB
code/image size.

Signed-off-by: Tianjia Zhang <tianjia.zhang@linux.alibaba.com>
Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
grub-core/commands/efi/tpm.c
include/grub/tpm.h

index 3ea37a15e40d79fdb52adf21117cbd24a56aab9c..b03b6b2967775e5bf54ccb2dd61c290f6ceefd0e 100644 (file)
@@ -119,103 +119,6 @@ grub_tpm_handle_find (grub_efi_handle_t *tpm_handle,
   return 0;
 }
 
-static grub_err_t
-grub_tpm1_execute (grub_efi_handle_t tpm_handle,
-                   PassThroughToTPM_InputParamBlock *inbuf,
-                   PassThroughToTPM_OutputParamBlock *outbuf)
-{
-  grub_efi_status_t status;
-  grub_efi_tpm_protocol_t *tpm;
-  grub_uint32_t inhdrsize = sizeof (*inbuf) - sizeof (inbuf->TPMOperandIn);
-  grub_uint32_t outhdrsize =
-    sizeof (*outbuf) - sizeof (outbuf->TPMOperandOut);
-
-  tpm = grub_efi_open_protocol (tpm_handle, &tpm_guid,
-                               GRUB_EFI_OPEN_PROTOCOL_GET_PROTOCOL);
-
-  if (!grub_tpm1_present (tpm))
-    return 0;
-
-  /* UEFI TPM protocol takes the raw operand block, no param block header. */
-  status = efi_call_5 (tpm->pass_through_to_tpm, tpm,
-                      inbuf->IPBLength - inhdrsize, inbuf->TPMOperandIn,
-                      outbuf->OPBLength - outhdrsize, outbuf->TPMOperandOut);
-
-  switch (status)
-    {
-    case GRUB_EFI_SUCCESS:
-      return 0;
-    case GRUB_EFI_DEVICE_ERROR:
-      return grub_error (GRUB_ERR_IO, N_("Command failed"));
-    case GRUB_EFI_INVALID_PARAMETER:
-      return grub_error (GRUB_ERR_BAD_ARGUMENT, N_("Invalid parameter"));
-    case GRUB_EFI_BUFFER_TOO_SMALL:
-      return grub_error (GRUB_ERR_BAD_ARGUMENT,
-                        N_("Output buffer too small"));
-    case GRUB_EFI_NOT_FOUND:
-      return grub_error (GRUB_ERR_UNKNOWN_DEVICE, N_("TPM unavailable"));
-    default:
-      return grub_error (GRUB_ERR_UNKNOWN_DEVICE, N_("Unknown TPM error"));
-    }
-}
-
-static grub_err_t
-grub_tpm2_execute (grub_efi_handle_t tpm_handle,
-                   PassThroughToTPM_InputParamBlock *inbuf,
-                   PassThroughToTPM_OutputParamBlock *outbuf)
-{
-  grub_efi_status_t status;
-  grub_efi_tpm2_protocol_t *tpm;
-  grub_uint32_t inhdrsize = sizeof (*inbuf) - sizeof (inbuf->TPMOperandIn);
-  grub_uint32_t outhdrsize =
-    sizeof (*outbuf) - sizeof (outbuf->TPMOperandOut);
-
-  tpm = grub_efi_open_protocol (tpm_handle, &tpm2_guid,
-                               GRUB_EFI_OPEN_PROTOCOL_GET_PROTOCOL);
-
-  if (!grub_tpm2_present (tpm))
-    return 0;
-
-  /* UEFI TPM protocol takes the raw operand block, no param block header. */
-  status = efi_call_5 (tpm->submit_command, tpm,
-                      inbuf->IPBLength - inhdrsize, inbuf->TPMOperandIn,
-                      outbuf->OPBLength - outhdrsize, outbuf->TPMOperandOut);
-
-  switch (status)
-    {
-    case GRUB_EFI_SUCCESS:
-      return 0;
-    case GRUB_EFI_DEVICE_ERROR:
-      return grub_error (GRUB_ERR_IO, N_("Command failed"));
-    case GRUB_EFI_INVALID_PARAMETER:
-      return grub_error (GRUB_ERR_BAD_ARGUMENT, N_("Invalid parameter"));
-    case GRUB_EFI_BUFFER_TOO_SMALL:
-      return grub_error (GRUB_ERR_BAD_ARGUMENT,
-                        N_("Output buffer too small"));
-    case GRUB_EFI_NOT_FOUND:
-      return grub_error (GRUB_ERR_UNKNOWN_DEVICE, N_("TPM unavailable"));
-    default:
-      return grub_error (GRUB_ERR_UNKNOWN_DEVICE, N_("Unknown TPM error"));
-    }
-}
-
-grub_err_t
-grub_tpm_execute (PassThroughToTPM_InputParamBlock *inbuf,
-                 PassThroughToTPM_OutputParamBlock *outbuf)
-{
-  grub_efi_handle_t tpm_handle;
-  grub_uint8_t protocol_version;
-
-  /* Absence of a TPM isn't a failure. */
-  if (!grub_tpm_handle_find (&tpm_handle, &protocol_version))
-    return 0;
-
-  if (protocol_version == 1)
-    return grub_tpm1_execute (tpm_handle, inbuf, outbuf);
-  else
-    return grub_tpm2_execute (tpm_handle, inbuf, outbuf);
-}
-
 static grub_err_t
 grub_tpm1_log_event (grub_efi_handle_t tpm_handle, unsigned char *buf,
                     grub_size_t size, grub_uint8_t pcr,
index 30450795763713591edacbb34e65c27b8e9eb3fb..5c285cbc5256ee7a9929afd90585b487f4e43e59 100644 (file)
 
 #define EV_IPL 0x0d
 
-/* TCG_PassThroughToTPM Input Parameter Block. */
-typedef struct
-{
-  grub_uint16_t IPBLength;
-  grub_uint16_t Reserved1;
-  grub_uint16_t OPBLength;
-  grub_uint16_t Reserved2;
-  grub_uint8_t  TPMOperandIn[1];
-} GRUB_PACKED PassThroughToTPM_InputParamBlock;
-
-/* TCG_PassThroughToTPM Output Parameter Block. */
-typedef struct
-{
-  grub_uint16_t OPBLength;
-  grub_uint16_t Reserved;
-  grub_uint8_t  TPMOperandOut[1];
-} GRUB_PACKED PassThroughToTPM_OutputParamBlock;
-
-typedef struct
-{
-  grub_uint16_t tag;
-  grub_uint32_t paramSize;
-  grub_uint32_t ordinal;
-  grub_uint32_t pcrNum;
-  /* The 160 bit value representing the event to be recorded. */
-  grub_uint8_t  inDigest[SHA1_DIGEST_SIZE];
-} GRUB_PACKED ExtendIncoming;
-
-/* TPM_Extend Outgoing Operand. */
-typedef struct
-{
-  grub_uint16_t tag;
-  grub_uint32_t paramSize;
-  grub_uint32_t returnCode;
-  /* The PCR value after execution of the command. */
-  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);
 #endif