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