From: Lennart Poettering Date: Sat, 21 Oct 2023 14:33:41 +0000 (+0200) Subject: tpm2-util: make tpm2_read_public() static, as we use it only internally in tpm2-util.c X-Git-Tag: v255-rc1~163^2 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=refs%2Fpull%2F29674%2Fhead;p=thirdparty%2Fsystemd.git tpm2-util: make tpm2_read_public() static, as we use it only internally in tpm2-util.c --- diff --git a/src/shared/tpm2-util.c b/src/shared/tpm2-util.c index 8f5725c5307..43e04c6518f 100644 --- a/src/shared/tpm2-util.c +++ b/src/shared/tpm2-util.c @@ -749,6 +749,35 @@ int tpm2_handle_new(Tpm2Context *context, Tpm2Handle **ret_handle) { return 0; } +static int tpm2_read_public( + Tpm2Context *c, + const Tpm2Handle *session, + const Tpm2Handle *handle, + TPM2B_PUBLIC **ret_public, + TPM2B_NAME **ret_name, + TPM2B_NAME **ret_qname) { + + TSS2_RC rc; + + assert(c); + assert(handle); + + rc = sym_Esys_ReadPublic( + c->esys_context, + handle->esys_handle, + session ? session->esys_handle : ESYS_TR_NONE, + ESYS_TR_NONE, + ESYS_TR_NONE, + ret_public, + ret_name, + ret_qname); + if (rc != TSS2_RC_SUCCESS) + return log_debug_errno(SYNTHETIC_ERRNO(ENOTRECOVERABLE), + "Failed to read public info: %s", sym_Tss2_RC_Decode(rc)); + + return 0; +} + /* Create a Tpm2Handle object that references a pre-existing handle in the TPM, at the handle index provided. * This should be used only for persistent, transient, or NV handles; and the handle must already exist in * the TPM at the specified handle index. The handle index should not be 0. Returns 1 if found, 0 if the @@ -1003,35 +1032,6 @@ static int tpm2_credit_random(Tpm2Context *c) { return 0; } -int tpm2_read_public( - Tpm2Context *c, - const Tpm2Handle *session, - const Tpm2Handle *handle, - TPM2B_PUBLIC **ret_public, - TPM2B_NAME **ret_name, - TPM2B_NAME **ret_qname) { - - TSS2_RC rc; - - assert(c); - assert(handle); - - rc = sym_Esys_ReadPublic( - c->esys_context, - handle->esys_handle, - session ? session->esys_handle : ESYS_TR_NONE, - ESYS_TR_NONE, - ESYS_TR_NONE, - ret_public, - ret_name, - ret_qname); - if (rc != TSS2_RC_SUCCESS) - return log_debug_errno(SYNTHETIC_ERRNO(ENOTRECOVERABLE), - "Failed to read public info: %s", sym_Tss2_RC_Decode(rc)); - - return 0; -} - /* Get one of the legacy primary key templates. * * The legacy templates should only be used for older sealed data that did not use the SRK. Instead of a diff --git a/src/shared/tpm2-util.h b/src/shared/tpm2-util.h index 80629ef9fa6..ce75563e583 100644 --- a/src/shared/tpm2-util.h +++ b/src/shared/tpm2-util.h @@ -187,8 +187,6 @@ void tpm2_log_debug_name(const TPM2B_NAME *name, const char *msg); int tpm2_index_to_handle(Tpm2Context *c, TPM2_HANDLE index, const Tpm2Handle *session, TPM2B_PUBLIC **ret_public, TPM2B_NAME **ret_name, TPM2B_NAME **ret_qname, Tpm2Handle **ret_handle); int tpm2_index_from_handle(Tpm2Context *c, const Tpm2Handle *handle, TPM2_HANDLE *ret_index); -int tpm2_read_public(Tpm2Context *c, const Tpm2Handle *session, const Tpm2Handle *handle, TPM2B_PUBLIC **ret_public, TPM2B_NAME **ret_name, TPM2B_NAME **ret_qname); - int tpm2_pcr_read(Tpm2Context *c, const TPML_PCR_SELECTION *pcr_selection, Tpm2PCRValue **ret_pcr_values, size_t *ret_n_pcr_values); int tpm2_pcr_read_missing_values(Tpm2Context *c, Tpm2PCRValue *pcr_values, size_t n_pcr_values);