blob: f97a713318ff9dccc6b96ab66b8b940566aed193 [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",
Alice Wang6b486f12023-01-06 13:12:16 +000036 ":test_image_with_one_hashdesc",
Alice Wang86383df2023-01-11 10:03:56 +000037 ":test_image_with_non_initrd_hashdesc",
Alice Wangf2752862023-01-18 11:51:25 +000038 ":test_image_with_initrd_and_non_initrd_desc",
Alice Wang86383df2023-01-11 10:03:56 +000039 ":test_image_with_prop_desc",
Alice Wangab0d0202023-05-17 08:07:41 +000040 ":test_image_with_service_vm_prop",
41 ":test_image_with_unknown_vm_type_prop",
42 ":test_image_with_multiple_props",
43 ":test_image_with_duplicated_capability",
Shikha Panwara26f16a2023-09-27 09:39:00 +000044 ":test_image_with_rollback_index_5",
Shikha Panwar4a0651d2023-09-28 13:06:13 +000045 ":test_image_with_multiple_capabilities",
Nikolina Ilic57ba9c42024-10-01 09:50:48 +000046 ":test_image_with_all_capabilities",
Alice Wanga78279c2022-12-16 12:41:19 +000047 ":unsigned_test_image",
48 ],
Alice Wangbf7fadd2023-01-13 12:18:24 +000049 prefer_rlib: true,
Alice Wanga78279c2022-12-16 12:41:19 +000050 rustlibs: [
51 "libanyhow",
Alice Wangbf7fadd2023-01-13 12:18:24 +000052 "libavb_bindgen",
David Pursella7c727b2023-08-14 16:24:40 -070053 "libavb_rs_nostd",
Alice Wang1f0add02023-01-23 16:22:53 +000054 "libhex",
Alice Wangbf7fadd2023-01-13 12:18:24 +000055 "libpvmfw_avb_nostd",
Alice Wang1f0add02023-01-23 16:22:53 +000056 "libopenssl",
Alice Wanga78279c2022-12-16 12:41:19 +000057 ],
58 enabled: false,
59 arch: {
60 // Microdroid kernel is only available in these architectures.
61 arm64: {
62 enabled: true,
63 },
64 x86_64: {
65 enabled: true,
66 },
67 },
68}
69
70// Generates a 16KB unsigned image for testing.
71genrule {
72 name: "unsigned_test_image",
73 tools: ["avbtool"],
74 out: ["unsigned_test.img"],
75 cmd: "$(location avbtool) generate_test_image --image_size 16384 --output $(out)",
Alice Wangf3d96b12022-12-15 13:10:47 +000076}
Alice Wang6b486f12023-01-06 13:12:16 +000077
Alice Wang86383df2023-01-11 10:03:56 +000078avb_gen_vbmeta_image {
79 name: "test_non_initrd_hashdesc",
80 src: ":unsigned_test_image",
81 partition_name: "non_initrd11",
82 salt: "2222",
83}
84
85avb_add_hash_footer {
86 name: "test_image_with_non_initrd_hashdesc",
87 src: ":unsigned_test_image",
88 partition_name: "boot",
89 private_key: ":pvmfw_sign_key",
Alice Wangf2752862023-01-18 11:51:25 +000090 salt: "3322",
Alice Wang86383df2023-01-11 10:03:56 +000091 include_descriptors_from_images: [
92 ":test_non_initrd_hashdesc",
93 ],
94}
95
96avb_add_hash_footer {
Alice Wangf2752862023-01-18 11:51:25 +000097 name: "test_image_with_initrd_and_non_initrd_desc",
98 src: ":unsigned_test_image",
99 partition_name: "boot",
100 private_key: ":pvmfw_sign_key",
101 salt: "3241",
102 include_descriptors_from_images: [
103 ":microdroid_initrd_normal_hashdesc",
104 ":test_non_initrd_hashdesc",
105 ],
106 enabled: false,
107 arch: {
108 // microdroid_initrd_normal_hashdesc is only available in these architectures.
109 arm64: {
110 enabled: true,
111 },
112 x86_64: {
113 enabled: true,
114 },
115 },
116}
117
118avb_add_hash_footer {
Alice Wang86383df2023-01-11 10:03:56 +0000119 name: "test_image_with_prop_desc",
120 src: ":unsigned_test_image",
121 partition_name: "boot",
122 private_key: ":pvmfw_sign_key",
Alice Wangf2752862023-01-18 11:51:25 +0000123 salt: "2134",
Alice Wang86383df2023-01-11 10:03:56 +0000124 props: [
125 {
126 name: "mock_prop",
127 value: "3333",
128 },
129 ],
130}
131
Alice Wang6b486f12023-01-06 13:12:16 +0000132avb_add_hash_footer {
Alice Wangab0d0202023-05-17 08:07:41 +0000133 name: "test_image_with_service_vm_prop",
134 src: ":unsigned_test_image",
135 partition_name: "boot",
136 private_key: ":pvmfw_sign_key",
137 salt: "2131",
138 props: [
139 {
140 name: "com.android.virt.cap",
141 value: "remote_attest",
142 },
143 ],
144}
145
146avb_add_hash_footer {
147 name: "test_image_with_unknown_vm_type_prop",
148 src: ":unsigned_test_image",
149 partition_name: "boot",
150 private_key: ":pvmfw_sign_key",
151 salt: "2132",
152 props: [
153 {
154 name: "com.android.virt.cap",
155 value: "foo",
156 },
157 ],
158}
159
160avb_add_hash_footer {
161 name: "test_image_with_multiple_props",
162 src: ":unsigned_test_image",
163 partition_name: "boot",
164 private_key: ":pvmfw_sign_key",
165 salt: "2133",
166 props: [
167 {
168 name: "com.android.virt.cap",
169 value: "remote_attest",
170 },
171 {
172 name: "another_vm_type",
173 value: "foo_vm",
174 },
175 ],
176}
177
178avb_add_hash_footer {
179 name: "test_image_with_duplicated_capability",
180 src: ":unsigned_test_image",
181 partition_name: "boot",
182 private_key: ":pvmfw_sign_key",
183 salt: "2134",
184 props: [
185 {
186 name: "com.android.virt.cap",
187 value: "remote_attest|remote_attest|remote_attest",
188 },
189 ],
190}
191
192avb_add_hash_footer {
Alice Wang6b486f12023-01-06 13:12:16 +0000193 name: "test_image_with_one_hashdesc",
194 src: ":unsigned_test_image",
Alice Wang8aa3cb12023-01-11 09:04:04 +0000195 partition_name: "boot",
Alice Wang6b486f12023-01-06 13:12:16 +0000196 private_key: ":pvmfw_sign_key",
197 salt: "1111",
198}
Shikha Panwara26f16a2023-09-27 09:39:00 +0000199
200avb_add_hash_footer {
201 name: "test_image_with_rollback_index_5",
202 src: ":unsigned_test_image",
203 partition_name: "boot",
204 private_key: ":pvmfw_sign_key",
205 salt: "1211",
206 rollback_index: 5,
207}
Shikha Panwar4a0651d2023-09-28 13:06:13 +0000208
209avb_add_hash_footer {
210 name: "test_image_with_multiple_capabilities",
211 src: ":unsigned_test_image",
212 partition_name: "boot",
213 private_key: ":pvmfw_sign_key",
214 salt: "2134",
215 props: [
216 {
217 name: "com.android.virt.cap",
218 value: "remote_attest|secretkeeper_protection",
219 },
220 ],
221}
Nikolina Ilic57ba9c42024-10-01 09:50:48 +0000222
223avb_add_hash_footer {
224 name: "test_image_with_all_capabilities",
225 src: ":unsigned_test_image",
226 partition_name: "boot",
227 private_key: ":pvmfw_sign_key",
228 salt: "4231",
229 props: [
230 {
231 name: "com.android.virt.cap",
232 value: "remote_attest|secretkeeper_protection|supports_uefi_boot",
233 },
234 ],
235}