summaryrefslogtreecommitdiff
path: root/src/partition
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2021-09-13 10:52:43 +0200
committerLennart Poettering <lennart@poettering.net>2021-09-13 14:48:23 +0200
commit2b92a67261934d5788613385279157eb1c9fd110 (patch)
tree95bb5d819d43ec9beac1a6bee6fab5c8fcc6fbd2 /src/partition
parent3f9992d82e0bc601bb33ad7b19a1722c4478c542 (diff)
downloadsystemd-2b92a67261934d5788613385279157eb1c9fd110.tar.gz
tpm2: support RSA primary keys as fallback if TPM2 devices don't support ECC
Previously, we hardcoded use of ECC as primary keys, since they are much faster (i.e. saving multiple seconds) to do TPM2 operations with. Alas, not all TPM2 chips appear to support ECC. Bummer. Let's hence add a fallback logic: if we can't create an ECC primary key, use an RSA key, and store that fact away. AFIU the security guarantees should be roughly the same, it's just that RSA primary keys is so much slower to work with than ECC. The primary key algorithm is used is stored in the JSON header of LUKS disks, in a new field. If the field is absent we assume to use ECC, to provide full compatibility with old systemd versions. The primary key algorithm is stored in a new field in the credentials file format (in fact, a previously unused zero space is used), too. Hopefully, this should ensure that TPM2 support will "just work" on more systems. Fixes: #20361
Diffstat (limited to 'src/partition')
-rw-r--r--src/partition/repart.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/src/partition/repart.c b/src/partition/repart.c
index 926dbb2ae4..bf6bac07c5 100644
--- a/src/partition/repart.c
+++ b/src/partition/repart.c
@@ -2618,10 +2618,10 @@ static int partition_encrypt(
_cleanup_(erase_and_freep) void *secret = NULL;
_cleanup_free_ void *blob = NULL, *hash = NULL;
size_t secret_size, blob_size, hash_size;
- uint16_t pcr_bank;
+ uint16_t pcr_bank, primary_alg;
int keyslot;
- r = tpm2_seal(arg_tpm2_device, arg_tpm2_pcr_mask, &secret, &secret_size, &blob, &blob_size, &hash, &hash_size, &pcr_bank);
+ r = tpm2_seal(arg_tpm2_device, arg_tpm2_pcr_mask, &secret, &secret_size, &blob, &blob_size, &hash, &hash_size, &pcr_bank, &primary_alg);
if (r < 0)
return log_error_errno(r, "Failed to seal to TPM2: %m");
@@ -2643,7 +2643,7 @@ static int partition_encrypt(
if (keyslot < 0)
return log_error_errno(keyslot, "Failed to add new TPM2 key to %s: %m", node);
- r = tpm2_make_luks2_json(keyslot, arg_tpm2_pcr_mask, pcr_bank, blob, blob_size, hash, hash_size, &v);
+ r = tpm2_make_luks2_json(keyslot, arg_tpm2_pcr_mask, pcr_bank, primary_alg, blob, blob_size, hash, hash_size, &v);
if (r < 0)
return log_error_errno(r, "Failed to prepare TPM2 JSON token object: %m");