]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
tpm2: add debug logging to functions converting hash or asym algs to/from strings...
authorDan Streetman <ddstreet@ieee.org>
Tue, 1 Aug 2023 18:09:04 +0000 (14:09 -0400)
committerDan Streetman <ddstreet@ieee.org>
Fri, 4 Aug 2023 14:55:53 +0000 (10:55 -0400)
Add debug log message if the algorithm name or id is not known.

src/shared/tpm2-util.c

index bc4f7f3c90d086036c5b6f68b34842211c984b3c..a26bf35c70cbed6199c932d63689519e45018430 100644 (file)
@@ -4248,6 +4248,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;
 }
 
@@ -4260,7 +4261,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) {
@@ -4268,6 +4269,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;
 }
 
@@ -4276,7 +4278,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) {