Received: from list by lists.gnu.org with archive (Exim 4.90_1) id 1k0mBS-0007mC-KA for mharc-grub-devel@gnu.org; Wed, 29 Jul 2020 09:31:50 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:43556) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1k0mBR-0007lw-4M for grub-devel@gnu.org; Wed, 29 Jul 2020 09:31:49 -0400 Received: from out4436.biz.mail.alibaba.com ([47.88.44.36]:33527) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1k0mBL-0001py-3V for grub-devel@gnu.org; Wed, 29 Jul 2020 09:31:45 -0400 X-Alimail-AntiSpam: AC=PASS; BC=-1|-1; BR=01201311R521e4; CH=green; DM=||false|; DS=||; FP=0|-1|-1|-1|0|-1|-1|-1; HT=e01e01355; MF=tianjia.zhang@linux.alibaba.com; NM=1; PH=DS; RN=2; SR=0; TI=SMTPD_---0U49dgaj_1596029474; Received: from localhost(mailfrom:tianjia.zhang@linux.alibaba.com fp:SMTPD_---0U49dgaj_1596029474) by smtp.aliyun-inc.com(127.0.0.1); Wed, 29 Jul 2020 21:31:15 +0800 From: Tianjia Zhang To: grub-devel@gnu.org Cc: tianjia.zhang@linux.alibaba.com Subject: [PATCH] tpm: Remove unused functions and structures Date: Wed, 29 Jul 2020 21:31:14 +0800 Message-Id: <20200729133114.53308-1-tianjia.zhang@linux.alibaba.com> X-Mailer: git-send-email 2.17.1 Received-SPF: pass client-ip=47.88.44.36; envelope-from=tianjia.zhang@linux.alibaba.com; helo=out4436.biz.mail.alibaba.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/07/29 09:31:36 X-ACL-Warn: Detected OS = Linux 3.1-3.10 X-Spam_score_int: -105 X-Spam_score: -10.6 X-Spam_bar: ---------- X-Spam_report: (-10.6 / 5.0 requ) BAYES_00=-1.9, ENV_AND_HDR_SPF_MATCH=-0.5, RCVD_IN_DNSWL_LOW=-0.7, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, UNPARSEABLE_RELAY=0.001, USER_IN_DEF_SPF_WL=-7.5 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: grub-devel@gnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: The development of GNU GRUB List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 29 Jul 2020 13:31:49 -0000 Although the tpm_execute() series of functions are defined, they are not used anywhere, and several structures in the header file `tpm.h` are also not used. Delete them here. Signed-off-by: Tianjia Zhang --- grub-core/commands/efi/tpm.c | 97 ------------------------------------ include/grub/tpm.h | 41 --------------- 2 files changed, 138 deletions(-) diff --git a/grub-core/commands/efi/tpm.c b/grub-core/commands/efi/tpm.c index 3ea37a15e..b03b6b296 100644 --- a/grub-core/commands/efi/tpm.c +++ b/grub-core/commands/efi/tpm.c @@ -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, diff --git a/include/grub/tpm.h b/include/grub/tpm.h index 304507957..5c285cbc5 100644 --- a/include/grub/tpm.h +++ b/include/grub/tpm.h @@ -34,47 +34,6 @@ #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 -- 2.17.1