tpm2-util: add common parser for the LUKS2 TPM2 JSON structure

This splits out the JSON parser used by the systemd-cryptsetup code.

This is preparation for later work to reuse it in the tpm2 cryptsetup
token module, which currently uses a separate but very similar parser
for the same data.

No change in behaviour.
This commit is contained in:
Lennart Poettering
2022-09-08 16:34:27 +02:00
parent dc63b2c909
commit fdf6c27cba
7 changed files with 226 additions and 173 deletions
+2 -1
View File
@@ -74,7 +74,6 @@ void cryptsetup_enable_logging(struct crypt_device *cd);
int cryptsetup_set_minimal_pbkdf(struct crypt_device *cd);
int cryptsetup_get_token_as_json(struct crypt_device *cd, int idx, const char *verify_type, JsonVariant **ret);
int cryptsetup_get_keyslot_from_token(JsonVariant *v);
int cryptsetup_add_token_json(struct crypt_device *cd, JsonVariant *v);
#else
@@ -87,6 +86,8 @@ static inline void sym_crypt_freep(struct crypt_device** cd) {}
#endif
int cryptsetup_get_keyslot_from_token(JsonVariant *v);
static inline const char *mangle_none(const char *s) {
/* A helper that turns cryptsetup/integritysetup/veritysetup "options" strings into NULL if they are effectively empty */
return isempty(s) || STR_IN_SET(s, "-", "none") ? NULL : s;