blob: 10c784140f5752ab4068b0abf8f18c4257752752 [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 Wang3a4f58b2024-11-18 10:56:58 +000036 ":trusty_security_vm_signed",
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",
Alice Wangab0d0202023-05-17 08:07:41 +000040 ":test_image_with_service_vm_prop",
41 ":test_image_with_unknown_vm_type_prop",
Alice Wangab0d0202023-05-17 08:07:41 +000042 ":test_image_with_duplicated_capability",
Shikha Panwara26f16a2023-09-27 09:39:00 +000043 ":test_image_with_rollback_index_5",
Shikha Panwar4a0651d2023-09-28 13:06:13 +000044 ":test_image_with_multiple_capabilities",
Nikolina Ilic57ba9c42024-10-01 09:50:48 +000045 ":test_image_with_all_capabilities",
Alice Wanga78279c2022-12-16 12:41:19 +000046 ":unsigned_test_image",
47 ],
Alice Wangbf7fadd2023-01-13 12:18:24 +000048 prefer_rlib: true,
Alice Wanga78279c2022-12-16 12:41:19 +000049 rustlibs: [
50 "libanyhow",
Alice Wangbf7fadd2023-01-13 12:18:24 +000051 "libavb_bindgen",
David Pursella7c727b2023-08-14 16:24:40 -070052 "libavb_rs_nostd",
Alice Wang1f0add02023-01-23 16:22:53 +000053 "libhex",
Alice Wangbf7fadd2023-01-13 12:18:24 +000054 "libpvmfw_avb_nostd",
Alice Wang1f0add02023-01-23 16:22:53 +000055 "libopenssl",
Alice Wanga78279c2022-12-16 12:41:19 +000056 ],
57 enabled: false,
58 arch: {
59 // Microdroid kernel is only available in these architectures.
60 arm64: {
61 enabled: true,
62 },
63 x86_64: {
64 enabled: true,
65 },
66 },
67}
68
69// Generates a 16KB unsigned image for testing.
70genrule {
71 name: "unsigned_test_image",
72 tools: ["avbtool"],
73 out: ["unsigned_test.img"],
74 cmd: "$(location avbtool) generate_test_image --image_size 16384 --output $(out)",
Alice Wangf3d96b12022-12-15 13:10:47 +000075}
Alice Wang6b486f12023-01-06 13:12:16 +000076
Alice Wang86383df2023-01-11 10:03:56 +000077avb_gen_vbmeta_image {
78 name: "test_non_initrd_hashdesc",
79 src: ":unsigned_test_image",
80 partition_name: "non_initrd11",
81 salt: "2222",
82}
83
84avb_add_hash_footer {
85 name: "test_image_with_non_initrd_hashdesc",
86 src: ":unsigned_test_image",
87 partition_name: "boot",
88 private_key: ":pvmfw_sign_key",
Alice Wangf2752862023-01-18 11:51:25 +000089 salt: "3322",
Alice Wang86383df2023-01-11 10:03:56 +000090 include_descriptors_from_images: [
91 ":test_non_initrd_hashdesc",
92 ],
93}
94
95avb_add_hash_footer {
Alice Wangf2752862023-01-18 11:51:25 +000096 name: "test_image_with_initrd_and_non_initrd_desc",
97 src: ":unsigned_test_image",
98 partition_name: "boot",
99 private_key: ":pvmfw_sign_key",
100 salt: "3241",
101 include_descriptors_from_images: [
102 ":microdroid_initrd_normal_hashdesc",
103 ":test_non_initrd_hashdesc",
104 ],
105 enabled: false,
106 arch: {
107 // microdroid_initrd_normal_hashdesc is only available in these architectures.
108 arm64: {
109 enabled: true,
110 },
111 x86_64: {
112 enabled: true,
113 },
114 },
115}
116
117avb_add_hash_footer {
Alice Wangab0d0202023-05-17 08:07:41 +0000118 name: "test_image_with_service_vm_prop",
119 src: ":unsigned_test_image",
120 partition_name: "boot",
121 private_key: ":pvmfw_sign_key",
122 salt: "2131",
123 props: [
124 {
125 name: "com.android.virt.cap",
126 value: "remote_attest",
127 },
128 ],
129}
130
131avb_add_hash_footer {
132 name: "test_image_with_unknown_vm_type_prop",
133 src: ":unsigned_test_image",
134 partition_name: "boot",
135 private_key: ":pvmfw_sign_key",
136 salt: "2132",
137 props: [
138 {
139 name: "com.android.virt.cap",
140 value: "foo",
141 },
142 ],
143}
144
145avb_add_hash_footer {
Alice Wangab0d0202023-05-17 08:07:41 +0000146 name: "test_image_with_duplicated_capability",
147 src: ":unsigned_test_image",
148 partition_name: "boot",
149 private_key: ":pvmfw_sign_key",
150 salt: "2134",
151 props: [
152 {
153 name: "com.android.virt.cap",
154 value: "remote_attest|remote_attest|remote_attest",
155 },
156 ],
157}
158
159avb_add_hash_footer {
Alice Wang6b486f12023-01-06 13:12:16 +0000160 name: "test_image_with_one_hashdesc",
161 src: ":unsigned_test_image",
Alice Wang8aa3cb12023-01-11 09:04:04 +0000162 partition_name: "boot",
Alice Wang6b486f12023-01-06 13:12:16 +0000163 private_key: ":pvmfw_sign_key",
164 salt: "1111",
165}
Shikha Panwara26f16a2023-09-27 09:39:00 +0000166
167avb_add_hash_footer {
168 name: "test_image_with_rollback_index_5",
169 src: ":unsigned_test_image",
170 partition_name: "boot",
171 private_key: ":pvmfw_sign_key",
172 salt: "1211",
173 rollback_index: 5,
174}
Shikha Panwar4a0651d2023-09-28 13:06:13 +0000175
176avb_add_hash_footer {
177 name: "test_image_with_multiple_capabilities",
178 src: ":unsigned_test_image",
179 partition_name: "boot",
180 private_key: ":pvmfw_sign_key",
181 salt: "2134",
182 props: [
183 {
184 name: "com.android.virt.cap",
185 value: "remote_attest|secretkeeper_protection",
186 },
187 ],
188}
Nikolina Ilic57ba9c42024-10-01 09:50:48 +0000189
190avb_add_hash_footer {
191 name: "test_image_with_all_capabilities",
192 src: ":unsigned_test_image",
193 partition_name: "boot",
194 private_key: ":pvmfw_sign_key",
195 salt: "4231",
196 props: [
197 {
198 name: "com.android.virt.cap",
Alice Wangfe0b9762024-11-21 14:47:54 +0000199 value: "remote_attest|trusty_security_vm|secretkeeper_protection|supports_uefi_boot",
Nikolina Ilic57ba9c42024-10-01 09:50:48 +0000200 },
201 ],
202}