blob: 73d188bd9c51fb93d32e5b81d002dd58b0293a3a [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: [
Pierre-Clément Tosi69467e02023-02-01 13:35:15 +000012 "libavb_bindgen_nostd",
David Pursella7c727b2023-08-14 16:24:40 -070013 "libavb_rs_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 no_stdlibs: true,
20 stdlibs: [
21 "libcore.rust_sysroot",
22 ],
23}
24
25rust_test {
Alice Wangbf7fadd2023-01-13 12:18:24 +000026 name: "libpvmfw_avb.integration_test",
27 crate_name: "pvmfw_avb_test",
Nikita Ioffeda1b2732023-09-04 13:46:56 +010028 defaults: ["avf_build_flags_rust"],
Alice Wang2925b0a2023-01-19 10:44:24 +000029 srcs: ["tests/*.rs"],
Alice Wangf3d96b12022-12-15 13:10:47 +000030 test_suites: ["general-tests"],
Alice Wanga78279c2022-12-16 12:41:19 +000031 data: [
32 ":avb_testkey_rsa2048_pub_bin",
33 ":avb_testkey_rsa4096_pub_bin",
34 ":microdroid_kernel_signed",
Alice Wang6b486f12023-01-06 13:12:16 +000035 ":microdroid_initrd_normal",
Alice Wang4e55dd92023-01-11 10:17:01 +000036 ":microdroid_initrd_debuggable",
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 Wang86383df2023-01-11 10:03:56 +000040 ":test_image_with_prop_desc",
Alice Wangab0d0202023-05-17 08:07:41 +000041 ":test_image_with_service_vm_prop",
42 ":test_image_with_unknown_vm_type_prop",
43 ":test_image_with_multiple_props",
44 ":test_image_with_duplicated_capability",
Alice Wanga78279c2022-12-16 12:41:19 +000045 ":unsigned_test_image",
46 ],
Alice Wangbf7fadd2023-01-13 12:18:24 +000047 prefer_rlib: true,
Alice Wanga78279c2022-12-16 12:41:19 +000048 rustlibs: [
49 "libanyhow",
Alice Wangbf7fadd2023-01-13 12:18:24 +000050 "libavb_bindgen",
David Pursella7c727b2023-08-14 16:24:40 -070051 "libavb_rs_nostd",
Alice Wang1f0add02023-01-23 16:22:53 +000052 "libhex",
Alice Wangbf7fadd2023-01-13 12:18:24 +000053 "libpvmfw_avb_nostd",
Alice Wang1f0add02023-01-23 16:22:53 +000054 "libopenssl",
Alice Wanga78279c2022-12-16 12:41:19 +000055 ],
56 enabled: false,
57 arch: {
58 // Microdroid kernel is only available in these architectures.
59 arm64: {
60 enabled: true,
61 },
62 x86_64: {
63 enabled: true,
64 },
65 },
66}
67
68// Generates a 16KB unsigned image for testing.
69genrule {
70 name: "unsigned_test_image",
71 tools: ["avbtool"],
72 out: ["unsigned_test.img"],
73 cmd: "$(location avbtool) generate_test_image --image_size 16384 --output $(out)",
Alice Wangf3d96b12022-12-15 13:10:47 +000074}
Alice Wang6b486f12023-01-06 13:12:16 +000075
Alice Wang86383df2023-01-11 10:03:56 +000076avb_gen_vbmeta_image {
77 name: "test_non_initrd_hashdesc",
78 src: ":unsigned_test_image",
79 partition_name: "non_initrd11",
80 salt: "2222",
81}
82
83avb_add_hash_footer {
84 name: "test_image_with_non_initrd_hashdesc",
85 src: ":unsigned_test_image",
86 partition_name: "boot",
87 private_key: ":pvmfw_sign_key",
Alice Wangf2752862023-01-18 11:51:25 +000088 salt: "3322",
Alice Wang86383df2023-01-11 10:03:56 +000089 include_descriptors_from_images: [
90 ":test_non_initrd_hashdesc",
91 ],
92}
93
94avb_add_hash_footer {
Alice Wangf2752862023-01-18 11:51:25 +000095 name: "test_image_with_initrd_and_non_initrd_desc",
96 src: ":unsigned_test_image",
97 partition_name: "boot",
98 private_key: ":pvmfw_sign_key",
99 salt: "3241",
100 include_descriptors_from_images: [
101 ":microdroid_initrd_normal_hashdesc",
102 ":test_non_initrd_hashdesc",
103 ],
104 enabled: false,
105 arch: {
106 // microdroid_initrd_normal_hashdesc is only available in these architectures.
107 arm64: {
108 enabled: true,
109 },
110 x86_64: {
111 enabled: true,
112 },
113 },
114}
115
116avb_add_hash_footer {
Alice Wang86383df2023-01-11 10:03:56 +0000117 name: "test_image_with_prop_desc",
118 src: ":unsigned_test_image",
119 partition_name: "boot",
120 private_key: ":pvmfw_sign_key",
Alice Wangf2752862023-01-18 11:51:25 +0000121 salt: "2134",
Alice Wang86383df2023-01-11 10:03:56 +0000122 props: [
123 {
124 name: "mock_prop",
125 value: "3333",
126 },
127 ],
128}
129
Alice Wang6b486f12023-01-06 13:12:16 +0000130avb_add_hash_footer {
Alice Wangab0d0202023-05-17 08:07:41 +0000131 name: "test_image_with_service_vm_prop",
132 src: ":unsigned_test_image",
133 partition_name: "boot",
134 private_key: ":pvmfw_sign_key",
135 salt: "2131",
136 props: [
137 {
138 name: "com.android.virt.cap",
139 value: "remote_attest",
140 },
141 ],
142}
143
144avb_add_hash_footer {
145 name: "test_image_with_unknown_vm_type_prop",
146 src: ":unsigned_test_image",
147 partition_name: "boot",
148 private_key: ":pvmfw_sign_key",
149 salt: "2132",
150 props: [
151 {
152 name: "com.android.virt.cap",
153 value: "foo",
154 },
155 ],
156}
157
158avb_add_hash_footer {
159 name: "test_image_with_multiple_props",
160 src: ":unsigned_test_image",
161 partition_name: "boot",
162 private_key: ":pvmfw_sign_key",
163 salt: "2133",
164 props: [
165 {
166 name: "com.android.virt.cap",
167 value: "remote_attest",
168 },
169 {
170 name: "another_vm_type",
171 value: "foo_vm",
172 },
173 ],
174}
175
176avb_add_hash_footer {
177 name: "test_image_with_duplicated_capability",
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|remote_attest|remote_attest",
186 },
187 ],
188}
189
190avb_add_hash_footer {
Alice Wang6b486f12023-01-06 13:12:16 +0000191 name: "test_image_with_one_hashdesc",
192 src: ":unsigned_test_image",
Alice Wang8aa3cb12023-01-11 09:04:04 +0000193 partition_name: "boot",
Alice Wang6b486f12023-01-06 13:12:16 +0000194 private_key: ":pvmfw_sign_key",
195 salt: "1111",
196}