summaryrefslogtreecommitdiff
path: root/src/cryptsetup
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2022-08-17 17:00:27 +0200
committerLennart Poettering <lennart@poettering.net>2022-08-19 21:26:26 +0200
commit222a951fa4a625e2d7d9c2799d9873377029d1bf (patch)
treec9dab5810fa7f5f25b9b9a7a27fbc0cb384ef877 /src/cryptsetup
parent466266c1728e3b53b7020e4c0165c3e88576b805 (diff)
downloadsystemd-222a951fa4a625e2d7d9c2799d9873377029d1bf.tar.gz
tpm2-util: introduce tpm2_parse_pcr_argument() helper
Add a new tpm2_parse_pcr_argument() helper that unifies how we merge PCR masks in a single function, we can use all over the place. Previously we had basically the same code for this at 4 places.
Diffstat (limited to 'src/cryptsetup')
-rw-r--r--src/cryptsetup/cryptsetup.c17
1 files changed, 3 insertions, 14 deletions
diff --git a/src/cryptsetup/cryptsetup.c b/src/cryptsetup/cryptsetup.c
index f0130eb238..c9a55a314b 100644
--- a/src/cryptsetup/cryptsetup.c
+++ b/src/cryptsetup/cryptsetup.c
@@ -394,20 +394,9 @@ static int parse_one_option(const char *option) {
} else if ((val = startswith(option, "tpm2-pcrs="))) {
- if (isempty(val))
- arg_tpm2_pcr_mask = 0;
- else {
- uint32_t mask;
-
- r = tpm2_parse_pcrs(val, &mask);
- if (r < 0)
- return r;
-
- if (arg_tpm2_pcr_mask == UINT32_MAX)
- arg_tpm2_pcr_mask = mask;
- else
- arg_tpm2_pcr_mask |= mask;
- }
+ r = tpm2_parse_pcr_argument(val, &arg_tpm2_pcr_mask);
+ if (r < 0)
+ return r;
} else if ((val = startswith(option, "tpm2-pin="))) {