blob: 49c4717b82fb1c2540993e6b769564ebde000801 [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",
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 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",
Alice Wang2925b0a2023-01-19 10:44:24 +000028 srcs: ["tests/*.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",
Alice Wanga78279c2022-12-16 12:41:19 +000044 ":unsigned_test_image",
45 ],
Alice Wangbf7fadd2023-01-13 12:18:24 +000046 prefer_rlib: true,
Alice Wanga78279c2022-12-16 12:41:19 +000047 rustlibs: [
48 "libanyhow",
Alice Wangbf7fadd2023-01-13 12:18:24 +000049 "libavb_bindgen",
Alice Wang1f0add02023-01-23 16:22:53 +000050 "libhex",
Alice Wangbf7fadd2023-01-13 12:18:24 +000051 "libpvmfw_avb_nostd",
Alice Wang1f0add02023-01-23 16:22:53 +000052 "libopenssl",
Alice Wanga78279c2022-12-16 12:41:19 +000053 ],
54 enabled: false,
55 arch: {
56 // Microdroid kernel is only available in these architectures.
57 arm64: {
58 enabled: true,
59 },
60 x86_64: {
61 enabled: true,
62 },
63 },
64}
65
66// Generates a 16KB unsigned image for testing.
67genrule {
68 name: "unsigned_test_image",
69 tools: ["avbtool"],
70 out: ["unsigned_test.img"],
71 cmd: "$(location avbtool) generate_test_image --image_size 16384 --output $(out)",
Alice Wangf3d96b12022-12-15 13:10:47 +000072}
Alice Wang6b486f12023-01-06 13:12:16 +000073
Alice Wang86383df2023-01-11 10:03:56 +000074avb_gen_vbmeta_image {
75 name: "test_non_initrd_hashdesc",
76 src: ":unsigned_test_image",
77 partition_name: "non_initrd11",
78 salt: "2222",
79}
80
81avb_add_hash_footer {
82 name: "test_image_with_non_initrd_hashdesc",
83 src: ":unsigned_test_image",
84 partition_name: "boot",
85 private_key: ":pvmfw_sign_key",
Alice Wangf2752862023-01-18 11:51:25 +000086 salt: "3322",
Alice Wang86383df2023-01-11 10:03:56 +000087 include_descriptors_from_images: [
88 ":test_non_initrd_hashdesc",
89 ],
90}
91
92avb_add_hash_footer {
Alice Wangf2752862023-01-18 11:51:25 +000093 name: "test_image_with_initrd_and_non_initrd_desc",
94 src: ":unsigned_test_image",
95 partition_name: "boot",
96 private_key: ":pvmfw_sign_key",
97 salt: "3241",
98 include_descriptors_from_images: [
99 ":microdroid_initrd_normal_hashdesc",
100 ":test_non_initrd_hashdesc",
101 ],
102 enabled: false,
103 arch: {
104 // microdroid_initrd_normal_hashdesc is only available in these architectures.
105 arm64: {
106 enabled: true,
107 },
108 x86_64: {
109 enabled: true,
110 },
111 },
112}
113
114avb_add_hash_footer {
Alice Wang86383df2023-01-11 10:03:56 +0000115 name: "test_image_with_prop_desc",
116 src: ":unsigned_test_image",
117 partition_name: "boot",
118 private_key: ":pvmfw_sign_key",
Alice Wangf2752862023-01-18 11:51:25 +0000119 salt: "2134",
Alice Wang86383df2023-01-11 10:03:56 +0000120 props: [
121 {
122 name: "mock_prop",
123 value: "3333",
124 },
125 ],
126}
127
Alice Wang6b486f12023-01-06 13:12:16 +0000128avb_add_hash_footer {
Alice Wangab0d0202023-05-17 08:07:41 +0000129 name: "test_image_with_service_vm_prop",
130 src: ":unsigned_test_image",
131 partition_name: "boot",
132 private_key: ":pvmfw_sign_key",
133 salt: "2131",
134 props: [
135 {
136 name: "com.android.virt.cap",
137 value: "remote_attest",
138 },
139 ],
140}
141
142avb_add_hash_footer {
143 name: "test_image_with_unknown_vm_type_prop",
144 src: ":unsigned_test_image",
145 partition_name: "boot",
146 private_key: ":pvmfw_sign_key",
147 salt: "2132",
148 props: [
149 {
150 name: "com.android.virt.cap",
151 value: "foo",
152 },
153 ],
154}
155
156avb_add_hash_footer {
157 name: "test_image_with_multiple_props",
158 src: ":unsigned_test_image",
159 partition_name: "boot",
160 private_key: ":pvmfw_sign_key",
161 salt: "2133",
162 props: [
163 {
164 name: "com.android.virt.cap",
165 value: "remote_attest",
166 },
167 {
168 name: "another_vm_type",
169 value: "foo_vm",
170 },
171 ],
172}
173
174avb_add_hash_footer {
175 name: "test_image_with_duplicated_capability",
176 src: ":unsigned_test_image",
177 partition_name: "boot",
178 private_key: ":pvmfw_sign_key",
179 salt: "2134",
180 props: [
181 {
182 name: "com.android.virt.cap",
183 value: "remote_attest|remote_attest|remote_attest",
184 },
185 ],
186}
187
188avb_add_hash_footer {
Alice Wang6b486f12023-01-06 13:12:16 +0000189 name: "test_image_with_one_hashdesc",
190 src: ":unsigned_test_image",
Alice Wang8aa3cb12023-01-11 09:04:04 +0000191 partition_name: "boot",
Alice Wang6b486f12023-01-06 13:12:16 +0000192 private_key: ":pvmfw_sign_key",
193 salt: "1111",
194}