blob: 0d55d7c48ffda774b4d27e2933ab44bbd5390160 [file] [log] [blame]
Alice Wangf3d96b12022-12-15 13:10:47 +00001package {
2 default_applicable_licenses: ["Android-Apache-2.0"],
3}
4
Pierre-Clément Tosi44e9f942023-06-27 14:33:56 +00005rust_library_rlib {
6 name: "libpvmfw_avb_nostd",
Alice Wangf3d96b12022-12-15 13:10:47 +00007 crate_name: "pvmfw_avb",
Nikita Ioffeda1b2732023-09-04 13:46:56 +01008 defaults: ["avf_build_flags_rust"],
Alice Wangf3d96b12022-12-15 13:10:47 +00009 srcs: ["src/lib.rs"],
10 prefer_rlib: true,
11 rustlibs: [
David Pursella7c727b2023-08-14 16:24:40 -070012 "libavb_rs_nostd",
Alice Wangf2752862023-01-18 11:51:25 +000013 "libtinyvec_nostd",
Alice Wangf3d96b12022-12-15 13:10:47 +000014 ],
Alice Wanga78279c2022-12-16 12:41:19 +000015 whole_static_libs: [
Pierre-Clément Tosi69467e02023-02-01 13:35:15 +000016 "libavb_baremetal",
Alice Wanga78279c2022-12-16 12:41:19 +000017 ],
Alice Wangf3d96b12022-12-15 13:10:47 +000018 no_stdlibs: true,
19 stdlibs: [
20 "libcore.rust_sysroot",
21 ],
22}
23
24rust_test {
Alice Wangbf7fadd2023-01-13 12:18:24 +000025 name: "libpvmfw_avb.integration_test",
26 crate_name: "pvmfw_avb_test",
Nikita Ioffeda1b2732023-09-04 13:46:56 +010027 defaults: ["avf_build_flags_rust"],
Alan Stokesd7aea452024-03-14 14:20:04 +000028 srcs: ["tests/api_test.rs"],
Alice Wangf3d96b12022-12-15 13:10:47 +000029 test_suites: ["general-tests"],
Alice Wanga78279c2022-12-16 12:41:19 +000030 data: [
31 ":avb_testkey_rsa2048_pub_bin",
32 ":avb_testkey_rsa4096_pub_bin",
33 ":microdroid_kernel_signed",
Alice Wang6b486f12023-01-06 13:12:16 +000034 ":microdroid_initrd_normal",
Alice Wang4e55dd92023-01-11 10:17:01 +000035 ":microdroid_initrd_debuggable",
Armelle Lainef50811b2025-01-23 00:40:04 +000036 ":trusty_test_vm_signed_bin",
Alice Wang6b486f12023-01-06 13:12:16 +000037 ":test_image_with_one_hashdesc",
Alice Wang86383df2023-01-11 10:03:56 +000038 ":test_image_with_non_initrd_hashdesc",
Alice Wangf2752862023-01-18 11:51:25 +000039 ":test_image_with_initrd_and_non_initrd_desc",
Pierre-Clément Tosif1369352024-12-02 18:55:08 +000040 ":test_image_with_name",
Pierre-Clément Tosi9fbbaf32024-11-26 14:00:01 +000041 ":test_image_with_invalid_page_size",
42 ":test_image_with_negative_page_size",
43 ":test_image_with_overflow_page_size",
44 ":test_image_with_0k_page_size",
45 ":test_image_with_1k_page_size",
46 ":test_image_with_4k_page_size",
47 ":test_image_with_9k_page_size",
48 ":test_image_with_16k_page_size",
Alice Wangab0d0202023-05-17 08:07:41 +000049 ":test_image_with_service_vm_prop",
50 ":test_image_with_unknown_vm_type_prop",
Alice Wangab0d0202023-05-17 08:07:41 +000051 ":test_image_with_duplicated_capability",
Shikha Panwara26f16a2023-09-27 09:39:00 +000052 ":test_image_with_rollback_index_5",
Shikha Panwar4a0651d2023-09-28 13:06:13 +000053 ":test_image_with_multiple_capabilities",
Nikolina Ilic57ba9c42024-10-01 09:50:48 +000054 ":test_image_with_all_capabilities",
Alice Wanga78279c2022-12-16 12:41:19 +000055 ":unsigned_test_image",
56 ],
Alice Wangbf7fadd2023-01-13 12:18:24 +000057 prefer_rlib: true,
Alice Wanga78279c2022-12-16 12:41:19 +000058 rustlibs: [
59 "libanyhow",
Alice Wangbf7fadd2023-01-13 12:18:24 +000060 "libavb_bindgen",
David Pursella7c727b2023-08-14 16:24:40 -070061 "libavb_rs_nostd",
Alice Wang1f0add02023-01-23 16:22:53 +000062 "libhex",
Alice Wangbf7fadd2023-01-13 12:18:24 +000063 "libpvmfw_avb_nostd",
Alice Wang1f0add02023-01-23 16:22:53 +000064 "libopenssl",
Alice Wanga78279c2022-12-16 12:41:19 +000065 ],
66 enabled: false,
67 arch: {
68 // Microdroid kernel is only available in these architectures.
69 arm64: {
70 enabled: true,
71 },
72 x86_64: {
73 enabled: true,
74 },
75 },
76}
77
78// Generates a 16KB unsigned image for testing.
79genrule {
80 name: "unsigned_test_image",
81 tools: ["avbtool"],
82 out: ["unsigned_test.img"],
83 cmd: "$(location avbtool) generate_test_image --image_size 16384 --output $(out)",
Alice Wangf3d96b12022-12-15 13:10:47 +000084}
Alice Wang6b486f12023-01-06 13:12:16 +000085
Alice Wang86383df2023-01-11 10:03:56 +000086avb_gen_vbmeta_image {
87 name: "test_non_initrd_hashdesc",
88 src: ":unsigned_test_image",
89 partition_name: "non_initrd11",
90 salt: "2222",
91}
92
93avb_add_hash_footer {
94 name: "test_image_with_non_initrd_hashdesc",
95 src: ":unsigned_test_image",
96 partition_name: "boot",
97 private_key: ":pvmfw_sign_key",
Alice Wangf2752862023-01-18 11:51:25 +000098 salt: "3322",
Alice Wang86383df2023-01-11 10:03:56 +000099 include_descriptors_from_images: [
100 ":test_non_initrd_hashdesc",
101 ],
102}
103
104avb_add_hash_footer {
Alice Wangf2752862023-01-18 11:51:25 +0000105 name: "test_image_with_initrd_and_non_initrd_desc",
106 src: ":unsigned_test_image",
107 partition_name: "boot",
108 private_key: ":pvmfw_sign_key",
109 salt: "3241",
110 include_descriptors_from_images: [
111 ":microdroid_initrd_normal_hashdesc",
112 ":test_non_initrd_hashdesc",
113 ],
114 enabled: false,
115 arch: {
116 // microdroid_initrd_normal_hashdesc is only available in these architectures.
117 arm64: {
118 enabled: true,
119 },
120 x86_64: {
121 enabled: true,
122 },
123 },
124}
125
126avb_add_hash_footer {
Pierre-Clément Tosif1369352024-12-02 18:55:08 +0000127 name: "test_image_with_name",
128 src: ":unsigned_test_image",
129 partition_name: "boot",
130 private_key: ":pvmfw_sign_key",
131 salt: "2134",
132 props: [
133 {
134 name: "com.android.virt.name",
135 value: "test_vm_name",
136 },
137 ],
138}
139
140avb_add_hash_footer {
Pierre-Clément Tosi9fbbaf32024-11-26 14:00:01 +0000141 name: "test_image_with_invalid_page_size",
142 src: ":unsigned_test_image",
143 partition_name: "boot",
144 private_key: ":pvmfw_sign_key",
145 salt: "2134",
146 props: [
147 {
148 name: "com.android.virt.page_size",
149 value: "invalid",
150 },
151 ],
152}
153
154avb_add_hash_footer {
155 name: "test_image_with_negative_page_size",
156 src: ":unsigned_test_image",
157 partition_name: "boot",
158 private_key: ":pvmfw_sign_key",
159 salt: "2134",
160 props: [
161 {
162 name: "com.android.virt.page_size",
163 value: "-16",
164 },
165 ],
166}
167
168avb_add_hash_footer {
169 name: "test_image_with_overflow_page_size",
170 src: ":unsigned_test_image",
171 partition_name: "boot",
172 private_key: ":pvmfw_sign_key",
173 salt: "2134",
174 props: [
175 {
176 name: "com.android.virt.page_size",
177 value: "18014398509481983",
178 },
179 ],
180}
181
182avb_add_hash_footer {
183 name: "test_image_with_0k_page_size",
184 src: ":unsigned_test_image",
185 partition_name: "boot",
186 private_key: ":pvmfw_sign_key",
187 salt: "2134",
188 props: [
189 {
190 name: "com.android.virt.page_size",
191 value: "0",
192 },
193 ],
194}
195
196avb_add_hash_footer {
197 name: "test_image_with_1k_page_size",
198 src: ":unsigned_test_image",
199 partition_name: "boot",
200 private_key: ":pvmfw_sign_key",
201 salt: "2134",
202 props: [
203 {
204 name: "com.android.virt.page_size",
205 value: "1",
206 },
207 ],
208}
209
210avb_add_hash_footer {
211 name: "test_image_with_4k_page_size",
212 src: ":unsigned_test_image",
213 partition_name: "boot",
214 private_key: ":pvmfw_sign_key",
215 salt: "2134",
216 props: [
217 {
218 name: "com.android.virt.page_size",
219 value: "4",
220 },
221 ],
222}
223
224avb_add_hash_footer {
225 name: "test_image_with_9k_page_size",
226 src: ":unsigned_test_image",
227 partition_name: "boot",
228 private_key: ":pvmfw_sign_key",
229 salt: "2134",
230 props: [
231 {
232 name: "com.android.virt.page_size",
233 value: "9",
234 },
235 ],
236}
237
238avb_add_hash_footer {
239 name: "test_image_with_16k_page_size",
240 src: ":unsigned_test_image",
241 partition_name: "boot",
242 private_key: ":pvmfw_sign_key",
243 salt: "2134",
244 props: [
245 {
246 name: "com.android.virt.page_size",
247 value: "16",
248 },
249 ],
250}
251
252avb_add_hash_footer {
Alice Wangab0d0202023-05-17 08:07:41 +0000253 name: "test_image_with_service_vm_prop",
254 src: ":unsigned_test_image",
255 partition_name: "boot",
256 private_key: ":pvmfw_sign_key",
257 salt: "2131",
258 props: [
259 {
260 name: "com.android.virt.cap",
261 value: "remote_attest",
262 },
263 ],
264}
265
266avb_add_hash_footer {
267 name: "test_image_with_unknown_vm_type_prop",
268 src: ":unsigned_test_image",
269 partition_name: "boot",
270 private_key: ":pvmfw_sign_key",
271 salt: "2132",
272 props: [
273 {
274 name: "com.android.virt.cap",
275 value: "foo",
276 },
277 ],
278}
279
280avb_add_hash_footer {
Alice Wangab0d0202023-05-17 08:07:41 +0000281 name: "test_image_with_duplicated_capability",
282 src: ":unsigned_test_image",
283 partition_name: "boot",
284 private_key: ":pvmfw_sign_key",
285 salt: "2134",
286 props: [
287 {
288 name: "com.android.virt.cap",
289 value: "remote_attest|remote_attest|remote_attest",
290 },
291 ],
292}
293
294avb_add_hash_footer {
Alice Wang6b486f12023-01-06 13:12:16 +0000295 name: "test_image_with_one_hashdesc",
296 src: ":unsigned_test_image",
Alice Wang8aa3cb12023-01-11 09:04:04 +0000297 partition_name: "boot",
Alice Wang6b486f12023-01-06 13:12:16 +0000298 private_key: ":pvmfw_sign_key",
299 salt: "1111",
300}
Shikha Panwara26f16a2023-09-27 09:39:00 +0000301
302avb_add_hash_footer {
303 name: "test_image_with_rollback_index_5",
304 src: ":unsigned_test_image",
305 partition_name: "boot",
306 private_key: ":pvmfw_sign_key",
307 salt: "1211",
308 rollback_index: 5,
309}
Shikha Panwar4a0651d2023-09-28 13:06:13 +0000310
311avb_add_hash_footer {
312 name: "test_image_with_multiple_capabilities",
313 src: ":unsigned_test_image",
314 partition_name: "boot",
315 private_key: ":pvmfw_sign_key",
316 salt: "2134",
317 props: [
318 {
319 name: "com.android.virt.cap",
320 value: "remote_attest|secretkeeper_protection",
321 },
322 ],
323}
Nikolina Ilic57ba9c42024-10-01 09:50:48 +0000324
325avb_add_hash_footer {
326 name: "test_image_with_all_capabilities",
327 src: ":unsigned_test_image",
328 partition_name: "boot",
329 private_key: ":pvmfw_sign_key",
330 salt: "4231",
331 props: [
332 {
333 name: "com.android.virt.cap",
Alice Wangfe0b9762024-11-21 14:47:54 +0000334 value: "remote_attest|trusty_security_vm|secretkeeper_protection|supports_uefi_boot",
Nikolina Ilic57ba9c42024-10-01 09:50:48 +0000335 },
336 ],
337}