blob: 4efee6a07e389c5c3ede069602e29e2492c5721a [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,
10 rustlibs: [
Pierre-Clément Tosi69467e02023-02-01 13:35:15 +000011 "libavb_bindgen_nostd",
Alice Wangf2752862023-01-18 11:51:25 +000012 "libtinyvec_nostd",
Alice Wangf3d96b12022-12-15 13:10:47 +000013 ],
Alice Wanga78279c2022-12-16 12:41:19 +000014 whole_static_libs: [
Pierre-Clément Tosi69467e02023-02-01 13:35:15 +000015 "libavb_baremetal",
Alice Wanga78279c2022-12-16 12:41:19 +000016 ],
Alice Wangf3d96b12022-12-15 13:10:47 +000017 no_stdlibs: true,
18 stdlibs: [
19 "libcore.rust_sysroot",
20 ],
21}
22
23rust_test {
Alice Wangbf7fadd2023-01-13 12:18:24 +000024 name: "libpvmfw_avb.integration_test",
25 crate_name: "pvmfw_avb_test",
Alice Wang2925b0a2023-01-19 10:44:24 +000026 srcs: ["tests/*.rs"],
Alice Wangf3d96b12022-12-15 13:10:47 +000027 test_suites: ["general-tests"],
Alice Wanga78279c2022-12-16 12:41:19 +000028 data: [
29 ":avb_testkey_rsa2048_pub_bin",
30 ":avb_testkey_rsa4096_pub_bin",
31 ":microdroid_kernel_signed",
Alice Wang6b486f12023-01-06 13:12:16 +000032 ":microdroid_initrd_normal",
Alice Wang4e55dd92023-01-11 10:17:01 +000033 ":microdroid_initrd_debuggable",
Alice Wang6b486f12023-01-06 13:12:16 +000034 ":test_image_with_one_hashdesc",
Alice Wang86383df2023-01-11 10:03:56 +000035 ":test_image_with_non_initrd_hashdesc",
Alice Wangf2752862023-01-18 11:51:25 +000036 ":test_image_with_initrd_and_non_initrd_desc",
Alice Wang86383df2023-01-11 10:03:56 +000037 ":test_image_with_prop_desc",
Alice Wangab0d0202023-05-17 08:07:41 +000038 ":test_image_with_service_vm_prop",
39 ":test_image_with_unknown_vm_type_prop",
40 ":test_image_with_multiple_props",
41 ":test_image_with_duplicated_capability",
Alice Wanga78279c2022-12-16 12:41:19 +000042 ":unsigned_test_image",
43 ],
Alice Wangbf7fadd2023-01-13 12:18:24 +000044 prefer_rlib: true,
Alice Wanga78279c2022-12-16 12:41:19 +000045 rustlibs: [
46 "libanyhow",
Alice Wangbf7fadd2023-01-13 12:18:24 +000047 "libavb_bindgen",
Alice Wang1f0add02023-01-23 16:22:53 +000048 "libhex",
Alice Wangbf7fadd2023-01-13 12:18:24 +000049 "libpvmfw_avb_nostd",
Alice Wang1f0add02023-01-23 16:22:53 +000050 "libopenssl",
Alice Wanga78279c2022-12-16 12:41:19 +000051 ],
52 enabled: false,
53 arch: {
54 // Microdroid kernel is only available in these architectures.
55 arm64: {
56 enabled: true,
57 },
58 x86_64: {
59 enabled: true,
60 },
61 },
62}
63
64// Generates a 16KB unsigned image for testing.
65genrule {
66 name: "unsigned_test_image",
67 tools: ["avbtool"],
68 out: ["unsigned_test.img"],
69 cmd: "$(location avbtool) generate_test_image --image_size 16384 --output $(out)",
Alice Wangf3d96b12022-12-15 13:10:47 +000070}
Alice Wang6b486f12023-01-06 13:12:16 +000071
Alice Wang86383df2023-01-11 10:03:56 +000072avb_gen_vbmeta_image {
73 name: "test_non_initrd_hashdesc",
74 src: ":unsigned_test_image",
75 partition_name: "non_initrd11",
76 salt: "2222",
77}
78
79avb_add_hash_footer {
80 name: "test_image_with_non_initrd_hashdesc",
81 src: ":unsigned_test_image",
82 partition_name: "boot",
83 private_key: ":pvmfw_sign_key",
Alice Wangf2752862023-01-18 11:51:25 +000084 salt: "3322",
Alice Wang86383df2023-01-11 10:03:56 +000085 include_descriptors_from_images: [
86 ":test_non_initrd_hashdesc",
87 ],
88}
89
90avb_add_hash_footer {
Alice Wangf2752862023-01-18 11:51:25 +000091 name: "test_image_with_initrd_and_non_initrd_desc",
92 src: ":unsigned_test_image",
93 partition_name: "boot",
94 private_key: ":pvmfw_sign_key",
95 salt: "3241",
96 include_descriptors_from_images: [
97 ":microdroid_initrd_normal_hashdesc",
98 ":test_non_initrd_hashdesc",
99 ],
100 enabled: false,
101 arch: {
102 // microdroid_initrd_normal_hashdesc is only available in these architectures.
103 arm64: {
104 enabled: true,
105 },
106 x86_64: {
107 enabled: true,
108 },
109 },
110}
111
112avb_add_hash_footer {
Alice Wang86383df2023-01-11 10:03:56 +0000113 name: "test_image_with_prop_desc",
114 src: ":unsigned_test_image",
115 partition_name: "boot",
116 private_key: ":pvmfw_sign_key",
Alice Wangf2752862023-01-18 11:51:25 +0000117 salt: "2134",
Alice Wang86383df2023-01-11 10:03:56 +0000118 props: [
119 {
120 name: "mock_prop",
121 value: "3333",
122 },
123 ],
124}
125
Alice Wang6b486f12023-01-06 13:12:16 +0000126avb_add_hash_footer {
Alice Wangab0d0202023-05-17 08:07:41 +0000127 name: "test_image_with_service_vm_prop",
128 src: ":unsigned_test_image",
129 partition_name: "boot",
130 private_key: ":pvmfw_sign_key",
131 salt: "2131",
132 props: [
133 {
134 name: "com.android.virt.cap",
135 value: "remote_attest",
136 },
137 ],
138}
139
140avb_add_hash_footer {
141 name: "test_image_with_unknown_vm_type_prop",
142 src: ":unsigned_test_image",
143 partition_name: "boot",
144 private_key: ":pvmfw_sign_key",
145 salt: "2132",
146 props: [
147 {
148 name: "com.android.virt.cap",
149 value: "foo",
150 },
151 ],
152}
153
154avb_add_hash_footer {
155 name: "test_image_with_multiple_props",
156 src: ":unsigned_test_image",
157 partition_name: "boot",
158 private_key: ":pvmfw_sign_key",
159 salt: "2133",
160 props: [
161 {
162 name: "com.android.virt.cap",
163 value: "remote_attest",
164 },
165 {
166 name: "another_vm_type",
167 value: "foo_vm",
168 },
169 ],
170}
171
172avb_add_hash_footer {
173 name: "test_image_with_duplicated_capability",
174 src: ":unsigned_test_image",
175 partition_name: "boot",
176 private_key: ":pvmfw_sign_key",
177 salt: "2134",
178 props: [
179 {
180 name: "com.android.virt.cap",
181 value: "remote_attest|remote_attest|remote_attest",
182 },
183 ],
184}
185
186avb_add_hash_footer {
Alice Wang6b486f12023-01-06 13:12:16 +0000187 name: "test_image_with_one_hashdesc",
188 src: ":unsigned_test_image",
Alice Wang8aa3cb12023-01-11 09:04:04 +0000189 partition_name: "boot",
Alice Wang6b486f12023-01-06 13:12:16 +0000190 private_key: ":pvmfw_sign_key",
191 salt: "1111",
192}