blob: 5353a21db48470aed8a481a922d4b03943e1d39d [file] [log] [blame]
Alice Wangf3d96b12022-12-15 13:10:47 +00001package {
2 default_applicable_licenses: ["Android-Apache-2.0"],
3}
4
5rust_defaults {
6 name: "libpvmfw_avb_nostd_defaults",
7 crate_name: "pvmfw_avb",
8 srcs: ["src/lib.rs"],
9 prefer_rlib: true,
Alan Stokesa0e42962023-04-14 17:59:50 +010010 // Require unsafe blocks for inside unsafe functions.
11 flags: ["-Dunsafe_op_in_unsafe_fn"],
Alice Wangf3d96b12022-12-15 13:10:47 +000012 rustlibs: [
Pierre-Clément Tosi69467e02023-02-01 13:35:15 +000013 "libavb_bindgen_nostd",
Alice Wangf2752862023-01-18 11:51:25 +000014 "libtinyvec_nostd",
Alice Wangf3d96b12022-12-15 13:10:47 +000015 ],
Alice Wanga78279c2022-12-16 12:41:19 +000016 whole_static_libs: [
Pierre-Clément Tosi69467e02023-02-01 13:35:15 +000017 "libavb_baremetal",
Alice Wanga78279c2022-12-16 12:41:19 +000018 ],
Alice Wangf3d96b12022-12-15 13:10:47 +000019}
20
21rust_library_rlib {
22 name: "libpvmfw_avb_nostd",
23 defaults: ["libpvmfw_avb_nostd_defaults"],
24 no_stdlibs: true,
25 stdlibs: [
26 "libcore.rust_sysroot",
27 ],
28}
29
30rust_test {
Alice Wangbf7fadd2023-01-13 12:18:24 +000031 name: "libpvmfw_avb.integration_test",
32 crate_name: "pvmfw_avb_test",
Alice Wang2925b0a2023-01-19 10:44:24 +000033 srcs: ["tests/*.rs"],
Alice Wangf3d96b12022-12-15 13:10:47 +000034 test_suites: ["general-tests"],
Alice Wanga78279c2022-12-16 12:41:19 +000035 data: [
36 ":avb_testkey_rsa2048_pub_bin",
37 ":avb_testkey_rsa4096_pub_bin",
38 ":microdroid_kernel_signed",
Alice Wang6b486f12023-01-06 13:12:16 +000039 ":microdroid_initrd_normal",
Alice Wang4e55dd92023-01-11 10:17:01 +000040 ":microdroid_initrd_debuggable",
Alice Wang6b486f12023-01-06 13:12:16 +000041 ":test_image_with_one_hashdesc",
Alice Wang86383df2023-01-11 10:03:56 +000042 ":test_image_with_non_initrd_hashdesc",
Alice Wangf2752862023-01-18 11:51:25 +000043 ":test_image_with_initrd_and_non_initrd_desc",
Alice Wang86383df2023-01-11 10:03:56 +000044 ":test_image_with_prop_desc",
Alice Wangab0d0202023-05-17 08:07:41 +000045 ":test_image_with_service_vm_prop",
46 ":test_image_with_unknown_vm_type_prop",
47 ":test_image_with_multiple_props",
48 ":test_image_with_duplicated_capability",
Alice Wanga78279c2022-12-16 12:41:19 +000049 ":unsigned_test_image",
50 ],
Alice Wangbf7fadd2023-01-13 12:18:24 +000051 prefer_rlib: true,
Alice Wanga78279c2022-12-16 12:41:19 +000052 rustlibs: [
53 "libanyhow",
Alice Wangbf7fadd2023-01-13 12:18:24 +000054 "libavb_bindgen",
Alice Wang1f0add02023-01-23 16:22:53 +000055 "libhex",
Alice Wangbf7fadd2023-01-13 12:18:24 +000056 "libpvmfw_avb_nostd",
Alice Wang1f0add02023-01-23 16:22:53 +000057 "libopenssl",
Alice Wanga78279c2022-12-16 12:41:19 +000058 ],
59 enabled: false,
60 arch: {
61 // Microdroid kernel is only available in these architectures.
62 arm64: {
63 enabled: true,
64 },
65 x86_64: {
66 enabled: true,
67 },
68 },
69}
70
71// Generates a 16KB unsigned image for testing.
72genrule {
73 name: "unsigned_test_image",
74 tools: ["avbtool"],
75 out: ["unsigned_test.img"],
76 cmd: "$(location avbtool) generate_test_image --image_size 16384 --output $(out)",
Alice Wangf3d96b12022-12-15 13:10:47 +000077}
Alice Wang6b486f12023-01-06 13:12:16 +000078
Alice Wang86383df2023-01-11 10:03:56 +000079avb_gen_vbmeta_image {
80 name: "test_non_initrd_hashdesc",
81 src: ":unsigned_test_image",
82 partition_name: "non_initrd11",
83 salt: "2222",
84}
85
86avb_add_hash_footer {
87 name: "test_image_with_non_initrd_hashdesc",
88 src: ":unsigned_test_image",
89 partition_name: "boot",
90 private_key: ":pvmfw_sign_key",
Alice Wangf2752862023-01-18 11:51:25 +000091 salt: "3322",
Alice Wang86383df2023-01-11 10:03:56 +000092 include_descriptors_from_images: [
93 ":test_non_initrd_hashdesc",
94 ],
95}
96
97avb_add_hash_footer {
Alice Wangf2752862023-01-18 11:51:25 +000098 name: "test_image_with_initrd_and_non_initrd_desc",
99 src: ":unsigned_test_image",
100 partition_name: "boot",
101 private_key: ":pvmfw_sign_key",
102 salt: "3241",
103 include_descriptors_from_images: [
104 ":microdroid_initrd_normal_hashdesc",
105 ":test_non_initrd_hashdesc",
106 ],
107 enabled: false,
108 arch: {
109 // microdroid_initrd_normal_hashdesc is only available in these architectures.
110 arm64: {
111 enabled: true,
112 },
113 x86_64: {
114 enabled: true,
115 },
116 },
117}
118
119avb_add_hash_footer {
Alice Wang86383df2023-01-11 10:03:56 +0000120 name: "test_image_with_prop_desc",
121 src: ":unsigned_test_image",
122 partition_name: "boot",
123 private_key: ":pvmfw_sign_key",
Alice Wangf2752862023-01-18 11:51:25 +0000124 salt: "2134",
Alice Wang86383df2023-01-11 10:03:56 +0000125 props: [
126 {
127 name: "mock_prop",
128 value: "3333",
129 },
130 ],
131}
132
Alice Wang6b486f12023-01-06 13:12:16 +0000133avb_add_hash_footer {
Alice Wangab0d0202023-05-17 08:07:41 +0000134 name: "test_image_with_service_vm_prop",
135 src: ":unsigned_test_image",
136 partition_name: "boot",
137 private_key: ":pvmfw_sign_key",
138 salt: "2131",
139 props: [
140 {
141 name: "com.android.virt.cap",
142 value: "remote_attest",
143 },
144 ],
145}
146
147avb_add_hash_footer {
148 name: "test_image_with_unknown_vm_type_prop",
149 src: ":unsigned_test_image",
150 partition_name: "boot",
151 private_key: ":pvmfw_sign_key",
152 salt: "2132",
153 props: [
154 {
155 name: "com.android.virt.cap",
156 value: "foo",
157 },
158 ],
159}
160
161avb_add_hash_footer {
162 name: "test_image_with_multiple_props",
163 src: ":unsigned_test_image",
164 partition_name: "boot",
165 private_key: ":pvmfw_sign_key",
166 salt: "2133",
167 props: [
168 {
169 name: "com.android.virt.cap",
170 value: "remote_attest",
171 },
172 {
173 name: "another_vm_type",
174 value: "foo_vm",
175 },
176 ],
177}
178
179avb_add_hash_footer {
180 name: "test_image_with_duplicated_capability",
181 src: ":unsigned_test_image",
182 partition_name: "boot",
183 private_key: ":pvmfw_sign_key",
184 salt: "2134",
185 props: [
186 {
187 name: "com.android.virt.cap",
188 value: "remote_attest|remote_attest|remote_attest",
189 },
190 ],
191}
192
193avb_add_hash_footer {
Alice Wang6b486f12023-01-06 13:12:16 +0000194 name: "test_image_with_one_hashdesc",
195 src: ":unsigned_test_image",
Alice Wang8aa3cb12023-01-11 09:04:04 +0000196 partition_name: "boot",
Alice Wang6b486f12023-01-06 13:12:16 +0000197 private_key: ":pvmfw_sign_key",
198 salt: "1111",
199}