From b060b9a492e161d0f59721b9a22cce528c967a40 Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Wed, 16 Aug 2023 17:25:05 +0200 Subject: [PATCH 1/2] tpm2-util: give PCR 6 a name too The specs call this TCG PC Client Platform Firmware Profile Specification says this PCR is owned by the Host Platform Manufacturer, at various places. Hence let's give it that name. --- src/shared/tpm2-util.c | 1 + src/shared/tpm2-util.h | 1 + 2 files changed, 2 insertions(+) diff --git a/src/shared/tpm2-util.c b/src/shared/tpm2-util.c index 3f517d5919..1a3c162624 100644 --- a/src/shared/tpm2-util.c +++ b/src/shared/tpm2-util.c @@ -5008,6 +5008,7 @@ static const char* const pcr_index_table[_PCR_INDEX_MAX_DEFINED] = { [PCR_EXTERNAL_CONFIG] = "external-config", [PCR_BOOT_LOADER_CODE] = "boot-loader-code", [PCR_BOOT_LOADER_CONFIG] = "boot-loader-config", + [PCR_HOST_PLATFORM] = "host-platform", [PCR_SECURE_BOOT_POLICY] = "secure-boot-policy", [PCR_KERNEL_INITRD] = "kernel-initrd", [PCR_IMA] = "ima", diff --git a/src/shared/tpm2-util.h b/src/shared/tpm2-util.h index 32da247c37..7959a17b81 100644 --- a/src/shared/tpm2-util.h +++ b/src/shared/tpm2-util.h @@ -308,6 +308,7 @@ enum { PCR_EXTERNAL_CONFIG = 3, PCR_BOOT_LOADER_CODE = 4, PCR_BOOT_LOADER_CONFIG = 5, + PCR_HOST_PLATFORM = 6, PCR_SECURE_BOOT_POLICY = 7, /* The following names for PCRs 9…15 are based on the "Linux TPM PCR Registry" (https://uapi-group.org/specifications/specs/linux_tpm_pcr_registry/) */ From f51ed26b3865587cdb3db68fce6f7fa0a61e1485 Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Sun, 16 Jul 2023 11:14:11 +0200 Subject: [PATCH 2/2] tpm2-util: add _const_/_pure_ to a couple of to_string()/from_string() functions --- src/shared/tpm2-util.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/shared/tpm2-util.h b/src/shared/tpm2-util.h index 7959a17b81..23a97f15ff 100644 --- a/src/shared/tpm2-util.h +++ b/src/shared/tpm2-util.h @@ -272,11 +272,11 @@ int tpm2_parse_luks2_json(JsonVariant *v, int *ret_keyslot, uint32_t *ret_hash_p int tpm2_hash_alg_to_size(uint16_t alg); -const char *tpm2_hash_alg_to_string(uint16_t alg); -int tpm2_hash_alg_from_string(const char *alg); +const char *tpm2_hash_alg_to_string(uint16_t alg) _const_; +int tpm2_hash_alg_from_string(const char *alg) _pure_; -const char *tpm2_asym_alg_to_string(uint16_t alg); -int tpm2_asym_alg_from_string(const char *alg); +const char *tpm2_asym_alg_to_string(uint16_t alg) _const_; +int tpm2_asym_alg_from_string(const char *alg) _pure_; char *tpm2_pcr_mask_to_string(uint32_t mask);