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.
This commit is contained in:
Lennart Poettering
2022-08-19 21:26:26 +02:00
parent 466266c172
commit 222a951fa4
6 changed files with 36 additions and 59 deletions
+3 -14
View File
@@ -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="))) {