1 /* SPDX-License-Identifier: GPL-2.0+ */ 2 #ifndef FSVERITYSETUP_H 3 #define FSVERITYSETUP_H 4 5 #include "util.h" 6 7 struct fsveritysetup_params { 8 const struct fsverity_hash_alg *hash_alg; 9 u8 *salt; 10 size_t saltlen; 11 int blocksize; 12 int blockbits; /* ilog2(blocksize) */ 13 unsigned int hashes_per_block; /* blocksize / digest_size */ 14 const char *signing_key_file; 15 const char *signing_cert_file; 16 const char *signature_file; 17 struct fsverity_elide_patch **elisions_and_patches; 18 size_t num_elisions_and_patches; 19 }; 20 21 void fsverity_append_extension(void **buf_p, int type, 22 const void *ext, size_t extlen); 23 24 #define FSVERITY_EXTLEN(inner_len) \ 25 ALIGN(sizeof(struct fsverity_extension) + (inner_len), 8) 26 27 /* elide_patch.c */ 28 bool load_elisions_and_patches(const struct string_list *elide_opts, 29 const struct string_list *patch_opts, 30 struct fsveritysetup_params *params); 31 void free_elisions_and_patches(struct fsveritysetup_params *params); 32 bool apply_elisions_and_patches(const struct fsveritysetup_params *params, 33 struct filedes *in, u64 in_length, 34 struct filedes *out_ret, u64 *out_length_ret); 35 size_t total_elide_patch_ext_length(const struct fsveritysetup_params *params); 36 void append_elide_patch_exts(void **buf_p, 37 const struct fsveritysetup_params *params); 38 /* sign.c */ 39 int append_signed_measurement(struct filedes *out, 40 const struct fsveritysetup_params *params, 41 const u8 *measurement); 42 43 #endif /* FSVERITYSETUP_H */ 44