From: Lennart Poettering Date: Wed, 28 Aug 2024 14:52:43 +0000 (+0200) Subject: crypenroll: make slot wiping on pin change a bit more explicit X-Git-Tag: v257-rc1~586^2~1 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=43b93a8a264769acbd7be3046c2726d3b5db141c;p=thirdparty%2Fsystemd.git crypenroll: make slot wiping on pin change a bit more explicit --- diff --git a/src/cryptenroll/cryptenroll-tpm2.c b/src/cryptenroll/cryptenroll-tpm2.c index b3d851953bf..db83ddc6e55 100644 --- a/src/cryptenroll/cryptenroll-tpm2.c +++ b/src/cryptenroll/cryptenroll-tpm2.c @@ -443,7 +443,7 @@ int enroll_tpm2(struct crypt_device *cd, slot_to_wipe = r; } else { log_info("This PCR set is already enrolled, executing no operation."); - *ret_slot_to_wipe = slot_to_wipe; + *ret_slot_to_wipe = -1; return r; /* return existing keyslot, so that wiping won't kill it */ } diff --git a/src/cryptenroll/cryptenroll.c b/src/cryptenroll/cryptenroll.c index df67a5636c5..ad98acb7624 100644 --- a/src/cryptenroll/cryptenroll.c +++ b/src/cryptenroll/cryptenroll.c @@ -885,6 +885,8 @@ static int run(int argc, char *argv[]) { slot = enroll_tpm2(cd, &vk, arg_tpm2_device, arg_tpm2_seal_key_handle, arg_tpm2_device_key, arg_tpm2_hash_pcr_values, arg_tpm2_n_hash_pcr_values, arg_tpm2_public_key, arg_tpm2_load_public_key, arg_tpm2_public_key_pcr_mask, arg_tpm2_signature, arg_tpm2_pin, arg_tpm2_pcrlock, &slot_to_wipe); if (slot >= 0 && slot_to_wipe >= 0) { + assert(slot != slot_to_wipe); + /* Updating PIN on an existing enrollment */ r = wipe_slots( cd,