summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2023-10-21 16:17:39 +0200
committerLuca Boccassi <luca.boccassi@gmail.com>2023-10-21 20:34:55 +0200
commitb98c4f1d48124f7152a28cda4bfc9a9dd3136a65 (patch)
treed8df854535df52c9786f32b1f9482bd4e3f41a81
parentMerge pull request #29382 from YHNdnzj/sleep-round-two (diff)
downloadsystemd-b98c4f1d48124f7152a28cda4bfc9a9dd3136a65.tar.xz
systemd-b98c4f1d48124f7152a28cda4bfc9a9dd3136a65.zip
tpm2-util: rename tpm2_calculate_name() → tpm2_calculate_pubkey_name()
We'll soon have a function for determining the name of an NV index, hence let's rename the existing function for the same of a public key to make clear it's about public keys only.
-rw-r--r--src/shared/tpm2-util.c4
-rw-r--r--src/shared/tpm2-util.h2
-rw-r--r--src/test/test-tpm2.c6
3 files changed, 6 insertions, 6 deletions
diff --git a/src/shared/tpm2-util.c b/src/shared/tpm2-util.c
index ce79c5b5f8..22e2e2cab8 100644
--- a/src/shared/tpm2-util.c
+++ b/src/shared/tpm2-util.c
@@ -3090,7 +3090,7 @@ static int find_signature(
*
* Since we (currently) hardcode to always using SHA256 for hashing, this returns an error if the public key
* nameAlg is not TPM2_ALG_SHA256. */
-int tpm2_calculate_name(const TPMT_PUBLIC *public, TPM2B_NAME *ret_name) {
+int tpm2_calculate_pubkey_name(const TPMT_PUBLIC *public, TPM2B_NAME *ret_name) {
TSS2_RC rc;
int r;
@@ -3354,7 +3354,7 @@ int tpm2_calculate_policy_authorize(
"Offset 0x%zx wrong after marshalling PolicyAuthorize command", offset);
TPM2B_NAME name = {};
- r = tpm2_calculate_name(&public->publicArea, &name);
+ r = tpm2_calculate_pubkey_name(&public->publicArea, &name);
if (r < 0)
return r;
diff --git a/src/shared/tpm2-util.h b/src/shared/tpm2-util.h
index f593915449..c57af8858d 100644
--- a/src/shared/tpm2-util.h
+++ b/src/shared/tpm2-util.h
@@ -192,7 +192,7 @@ int tpm2_read_public(Tpm2Context *c, const Tpm2Handle *session, const Tpm2Handle
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);
-int tpm2_calculate_name(const TPMT_PUBLIC *public, TPM2B_NAME *ret_name);
+int tpm2_calculate_pubkey_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);
int tpm2_calculate_policy_pcr(const Tpm2PCRValue *pcr_values, size_t n_pcr_values, TPM2B_DIGEST *digest);
diff --git a/src/test/test-tpm2.c b/src/test/test-tpm2.c
index bbf2790a47..80e20db360 100644
--- a/src/test/test-tpm2.c
+++ b/src/test/test-tpm2.c
@@ -859,18 +859,18 @@ static void check_name(const TPM2B_NAME *name, const char *expect) {
assert_se(memcmp(name->name, e, e_len) == 0);
}
-TEST(calculate_name) {
+TEST(calculate_pubkey_name) {
TPM2B_PUBLIC public;
TPM2B_NAME name;
/* RSA */
tpm2b_public_rsa_init(&public, "9ec7341c52093ac40a1965a5df10432513c539adcf905e30577ab6ebc88ffe53cd08cef12ed9bec6125432f4fada3629b8b96d31b8f507aa35029188fe396da823fcb236027f7fbb01b0da3d87be7f999390449ced604bdf7e26c48657cc0671000f1147da195c3861c96642e54427cb7a11572e07567ec3fd6316978abc4bd92b27bb0a0e4958e599804eeb41d682b3b7fc1f960209f80a4fb8a1b64abfd96bf5d554e73cdd6ad1c8becb4fcf5e8f0c3e621d210e5e2f308f6520ad9a966779231b99f06c5989e5a23a9415c8808ab89ce81117632e2f8461cd4428bded40979236aeadafe8de3f51660a45e1dbc87694e6a36360201cca3ff9e7263e712727");
- assert_se(tpm2_calculate_name(&public.publicArea, &name) >= 0);
+ assert_se(tpm2_calculate_pubkey_name(&public.publicArea, &name) >= 0);
check_name(&name, "000be78f74a470dd92e979ca067cdb2293a35f075e8560b436bd2ccea5da21486a07");
/* ECC */
tpm2b_public_ecc_init(&public, TPM2_ECC_NIST_P256, "238e02ee4fd5598add6b502429f1815418515e4b0d6551c8e816b38cb15451d1", "70c2d491769775ec43ccd5a571c429233e9d30cf0f486c2e01acd6cb32ba93b6");
- assert_se(tpm2_calculate_name(&public.publicArea, &name) >= 0);
+ assert_se(tpm2_calculate_pubkey_name(&public.publicArea, &name) >= 0);
check_name(&name, "000b302787187ba19c82011c987bd2dcdbb652b3a543ccc5cb0b49c33d4caae604a6");
}