]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
tpm2: declare tpm2_log_debug_*() functions in tpm2_util.h
authorDan Streetman <ddstreet@ieee.org>
Fri, 14 Jul 2023 11:23:55 +0000 (07:23 -0400)
committerDan Streetman <ddstreet@ieee.org>
Fri, 4 Aug 2023 14:57:07 +0000 (10:57 -0400)
Allow other code to use the log debug functions; e.g. they are useful in test
code.

src/shared/tpm2-util.c
src/shared/tpm2-util.h

index 26a67accffa6557f528ef297089a353271bb73a5..f717784a39d07b6c78c279df2f26c071b69bf9ed 100644 (file)
@@ -1833,7 +1833,7 @@ char *tpm2_pcr_values_to_string(const Tpm2PCRValue *pcr_values, size_t n_pcr_val
         return s ? TAKE_PTR(s) : strdup("");
 }
 
-static void tpm2_log_debug_tpml_pcr_selection(const TPML_PCR_SELECTION *l, const char *msg) {
+void tpm2_log_debug_tpml_pcr_selection(const TPML_PCR_SELECTION *l, const char *msg) {
         if (!DEBUG_LOGGING || !l)
                 return;
 
@@ -1841,7 +1841,7 @@ static void tpm2_log_debug_tpml_pcr_selection(const TPML_PCR_SELECTION *l, const
         log_debug("%s: %s", msg ?: "PCR selection", strna(s));
 }
 
-static void tpm2_log_debug_pcr_value(const Tpm2PCRValue *pcr_value, const char *msg) {
+void tpm2_log_debug_pcr_value(const Tpm2PCRValue *pcr_value, const char *msg) {
         if (!DEBUG_LOGGING || !pcr_value)
                 return;
 
@@ -1849,7 +1849,7 @@ static void tpm2_log_debug_pcr_value(const Tpm2PCRValue *pcr_value, const char *
         log_debug("%s: %s", msg ?: "PCR value", strna(s));
 }
 
-static void tpm2_log_debug_buffer(const void *buffer, size_t size, const char *msg) {
+void tpm2_log_debug_buffer(const void *buffer, size_t size, const char *msg) {
         if (!DEBUG_LOGGING || !buffer || size == 0)
                 return;
 
@@ -1857,12 +1857,12 @@ static void tpm2_log_debug_buffer(const void *buffer, size_t size, const char *m
         log_debug("%s: %s", msg ?: "Buffer", strna(h));
 }
 
-static void tpm2_log_debug_digest(const TPM2B_DIGEST *digest, const char *msg) {
+void tpm2_log_debug_digest(const TPM2B_DIGEST *digest, const char *msg) {
         if (digest)
                 tpm2_log_debug_buffer(digest->buffer, digest->size, msg ?: "Digest");
 }
 
-static void tpm2_log_debug_name(const TPM2B_NAME *name, const char *msg) {
+void tpm2_log_debug_name(const TPM2B_NAME *name, const char *msg) {
         if (name)
                 tpm2_log_debug_buffer(name->name, name->size, msg ?: "Name");
 }
index bf8135d0afa0340eec0a65f4cda9292a4fe7ad53..4916620a25a5dd28a43b30f507511bae4ba97114 100644 (file)
@@ -139,6 +139,12 @@ static inline int tpm2_digest_init(TPMI_ALG_HASH alg, TPM2B_DIGEST *digest) {
         return tpm2_digest_many(alg, digest, NULL, 0, false);
 }
 
+void tpm2_log_debug_tpml_pcr_selection(const TPML_PCR_SELECTION *l, const char *msg);
+void tpm2_log_debug_pcr_value(const Tpm2PCRValue *pcr_value, const char *msg);
+void tpm2_log_debug_buffer(const void *buffer, size_t size, const char *msg);
+void tpm2_log_debug_digest(const TPM2B_DIGEST *digest, const char *msg);
+void tpm2_log_debug_name(const TPM2B_NAME *name, const char *msg);
+
 int tpm2_calculate_name(const TPMT_PUBLIC *public, TPM2B_NAME *ret_name);
 int tpm2_calculate_policy_auth_value(TPM2B_DIGEST *digest);
 int tpm2_calculate_policy_authorize(const TPM2B_PUBLIC *public, const TPM2B_DIGEST *policy_ref, TPM2B_DIGEST *digest);