mirror of
https://github.com/systemd/systemd.git
synced 2026-08-05 07:30:30 +00:00
tpm2: change tpm2_unseal() to accept Tpm2Context instead of device string
This matches the change to tpm2_seal(), which now accepts a Tpm2Context instead of a device string. This also allows using the same TPM context for sealing and unsealing, which will be required by (future) test code when sealing/unsealing using a transient key.
This commit is contained in:
@@ -80,7 +80,12 @@ int acquire_luks2_key(
|
||||
return log_error_errno(r, "Failed to load PCR signature: %m");
|
||||
}
|
||||
|
||||
r = tpm2_unseal(device,
|
||||
_cleanup_(tpm2_context_unrefp) Tpm2Context *tpm2_context = NULL;
|
||||
r = tpm2_context_new(device, &tpm2_context);
|
||||
if (r < 0)
|
||||
return log_error_errno(r, "Failed to create TPM2 context: %m");
|
||||
|
||||
r = tpm2_unseal(tpm2_context,
|
||||
hash_pcr_mask,
|
||||
pcr_bank,
|
||||
pubkey, pubkey_size,
|
||||
|
||||
@@ -129,8 +129,13 @@ int acquire_tpm2_key(
|
||||
return log_error_errno(r, "Failed to load pcr signature: %m");
|
||||
}
|
||||
|
||||
_cleanup_(tpm2_context_unrefp) Tpm2Context *tpm2_context = NULL;
|
||||
r = tpm2_context_new(device, &tpm2_context);
|
||||
if (r < 0)
|
||||
return log_error_errno(r, "Failed to create TPM2 context: %m");
|
||||
|
||||
if (!(flags & TPM2_FLAGS_USE_PIN)) {
|
||||
r = tpm2_unseal(device,
|
||||
r = tpm2_unseal(tpm2_context,
|
||||
hash_pcr_mask,
|
||||
pcr_bank,
|
||||
pubkey, pubkey_size,
|
||||
@@ -177,7 +182,7 @@ int acquire_tpm2_key(
|
||||
/* no salting needed, backwards compat with non-salted pins */
|
||||
b64_salted_pin = TAKE_PTR(pin_str);
|
||||
|
||||
r = tpm2_unseal(device,
|
||||
r = tpm2_unseal(tpm2_context,
|
||||
hash_pcr_mask,
|
||||
pcr_bank,
|
||||
pubkey, pubkey_size,
|
||||
|
||||
Reference in New Issue
Block a user