You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
systemd/SOURCES/0560-tpm2-add-debug-logging...

54 lines
1.9 KiB

From 73f1ef0adb005695b7feca7e5568a41baf29e6fb Mon Sep 17 00:00:00 2001
From: Dan Streetman <ddstreet@ieee.org>
Date: Tue, 1 Aug 2023 14:09:04 -0400
Subject: [PATCH] tpm2: add debug logging to functions converting hash or asym
algs to/from strings or ids
Add debug log message if the algorithm name or id is not known.
(cherry picked from commit 240774f5ce70f0bcbf64999a3db5c25be3f44a9c)
Related: RHEL-16182
---
src/shared/tpm2-util.c | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/src/shared/tpm2-util.c b/src/shared/tpm2-util.c
index dd22f94dc0..7387dcc48a 100644
--- a/src/shared/tpm2-util.c
+++ b/src/shared/tpm2-util.c
@@ -4183,6 +4183,7 @@ const char *tpm2_hash_alg_to_string(uint16_t alg) {
return "sha384";
if (alg == TPM2_ALG_SHA512)
return "sha512";
+ log_debug("Unknown hash algorithm id 0x%" PRIx16, alg);
return NULL;
}
@@ -4195,7 +4196,7 @@ int tpm2_hash_alg_from_string(const char *alg) {
return TPM2_ALG_SHA384;
if (strcaseeq_ptr(alg, "sha512"))
return TPM2_ALG_SHA512;
- return -EINVAL;
+ return log_debug_errno(SYNTHETIC_ERRNO(EINVAL), "Unknown hash algorithm name '%s'", alg);
}
const char *tpm2_asym_alg_to_string(uint16_t alg) {
@@ -4203,6 +4204,7 @@ const char *tpm2_asym_alg_to_string(uint16_t alg) {
return "ecc";
if (alg == TPM2_ALG_RSA)
return "rsa";
+ log_debug("Unknown asymmetric algorithm id 0x%" PRIx16, alg);
return NULL;
}
@@ -4211,7 +4213,7 @@ int tpm2_asym_alg_from_string(const char *alg) {
return TPM2_ALG_ECC;
if (strcaseeq_ptr(alg, "rsa"))
return TPM2_ALG_RSA;
- return -EINVAL;
+ return log_debug_errno(SYNTHETIC_ERRNO(EINVAL), "Unknown asymmetric algorithm name '%s'", alg);
}
Tpm2Support tpm2_support(void) {