1# fsverity-utils
2
3## 简介
4fsverity-utils是与内核特性fs-verity配套的一组用户态工具。fs-verity是Linux Kernel提供的保护文件完整性的机制,可以实现以文件为粒度的按需保护可写分区的只读文件。可选地,fs-verity提供对文件签名的验证,以保证文件的真实性。
5
6**1.  组件引入背景**
7为了OpenHarmony上使用内核特性fs-verity而提供的三方库接口。
8
9**2. 使用场景**
10可以通过动态库或者静态库的方式依赖此组件,调用接口计算fs-verity的摘要、签名。
11
12**3. 为OpenHarmony带来的价值**
13满足在OpenHarmony上使能内核特性fs-verity的诉求。
14
15## OpenHaromny中如何使用fsverity-utils
16
171. 在BUILD.gn中增加编译依赖
18```
19include_dirs = [
20  "//third_party/fsverity_utils/include",
21  "//third_party/fsverity_utils/common"
22]
23
24deps = [
25  # 动态库依赖(可选)
26  "//third_party/fsverity_utils:libfsverity_utils",
27  # 静态库依赖(可选)
28  "//third_party/fsverity_utils:libfsverity_utils_static" 
29]
30```
31
322. libfsverity_utils(_static)提供的主要接口
33
34| 接口名称 |  功能  |
35| --------------------- | ------------------ |
36| libfsverity_enable | 对文件使能fs-verity保护 |
37| libfsverity_enable_with_sig | 对文件使能带fs-verity签名 |
38| libfsverity_compute_digest | 计算文件的fsverity摘要 |
39| libfsverity_sign_digest | 对fsverity摘要进行签名 |
40
41具体使用方法和其他接口见`include/libfsverity.h`。
42
43
44## fsverity-utils使用文档
45
46代码仓库:https://git.kernel.org/pub/scm/fs/fsverity/fsverity-utils.git
47
48fs-verity介绍:https://www.kernel.org/doc/html/latest/filesystems/fsverity.html