Alice Wang | f3d96b1 | 2022-12-15 13:10:47 +0000 | [diff] [blame] | 1 | package { |
| 2 | default_applicable_licenses: ["Android-Apache-2.0"], |
| 3 | } |
| 4 | |
Pierre-Clément Tosi | 44e9f94 | 2023-06-27 14:33:56 +0000 | [diff] [blame] | 5 | rust_library_rlib { |
| 6 | name: "libpvmfw_avb_nostd", |
Alice Wang | f3d96b1 | 2022-12-15 13:10:47 +0000 | [diff] [blame] | 7 | crate_name: "pvmfw_avb", |
Nikita Ioffe | da1b273 | 2023-09-04 13:46:56 +0100 | [diff] [blame] | 8 | defaults: ["avf_build_flags_rust"], |
Alice Wang | f3d96b1 | 2022-12-15 13:10:47 +0000 | [diff] [blame] | 9 | srcs: ["src/lib.rs"], |
| 10 | prefer_rlib: true, |
| 11 | rustlibs: [ |
David Pursell | a7c727b | 2023-08-14 16:24:40 -0700 | [diff] [blame] | 12 | "libavb_rs_nostd", |
Alice Wang | f275286 | 2023-01-18 11:51:25 +0000 | [diff] [blame] | 13 | "libtinyvec_nostd", |
Alice Wang | f3d96b1 | 2022-12-15 13:10:47 +0000 | [diff] [blame] | 14 | ], |
Alice Wang | a78279c | 2022-12-16 12:41:19 +0000 | [diff] [blame] | 15 | whole_static_libs: [ |
Pierre-Clément Tosi | 69467e0 | 2023-02-01 13:35:15 +0000 | [diff] [blame] | 16 | "libavb_baremetal", |
Alice Wang | a78279c | 2022-12-16 12:41:19 +0000 | [diff] [blame] | 17 | ], |
Alice Wang | f3d96b1 | 2022-12-15 13:10:47 +0000 | [diff] [blame] | 18 | no_stdlibs: true, |
| 19 | stdlibs: [ |
| 20 | "libcore.rust_sysroot", |
| 21 | ], |
| 22 | } |
| 23 | |
| 24 | rust_test { |
Alice Wang | bf7fadd | 2023-01-13 12:18:24 +0000 | [diff] [blame] | 25 | name: "libpvmfw_avb.integration_test", |
| 26 | crate_name: "pvmfw_avb_test", |
Nikita Ioffe | da1b273 | 2023-09-04 13:46:56 +0100 | [diff] [blame] | 27 | defaults: ["avf_build_flags_rust"], |
Alan Stokes | d7aea45 | 2024-03-14 14:20:04 +0000 | [diff] [blame] | 28 | srcs: ["tests/api_test.rs"], |
Alice Wang | f3d96b1 | 2022-12-15 13:10:47 +0000 | [diff] [blame] | 29 | test_suites: ["general-tests"], |
Alice Wang | a78279c | 2022-12-16 12:41:19 +0000 | [diff] [blame] | 30 | data: [ |
| 31 | ":avb_testkey_rsa2048_pub_bin", |
| 32 | ":avb_testkey_rsa4096_pub_bin", |
| 33 | ":microdroid_kernel_signed", |
Alice Wang | 6b486f1 | 2023-01-06 13:12:16 +0000 | [diff] [blame] | 34 | ":microdroid_initrd_normal", |
Alice Wang | 4e55dd9 | 2023-01-11 10:17:01 +0000 | [diff] [blame] | 35 | ":microdroid_initrd_debuggable", |
Armelle Laine | f50811b | 2025-01-23 00:40:04 +0000 | [diff] [blame^] | 36 | ":trusty_test_vm_signed_bin", |
Alice Wang | 6b486f1 | 2023-01-06 13:12:16 +0000 | [diff] [blame] | 37 | ":test_image_with_one_hashdesc", |
Alice Wang | 86383df | 2023-01-11 10:03:56 +0000 | [diff] [blame] | 38 | ":test_image_with_non_initrd_hashdesc", |
Alice Wang | f275286 | 2023-01-18 11:51:25 +0000 | [diff] [blame] | 39 | ":test_image_with_initrd_and_non_initrd_desc", |
Pierre-Clément Tosi | 9fbbaf3 | 2024-11-26 14:00:01 +0000 | [diff] [blame] | 40 | ":test_image_with_invalid_page_size", |
| 41 | ":test_image_with_negative_page_size", |
| 42 | ":test_image_with_overflow_page_size", |
| 43 | ":test_image_with_0k_page_size", |
| 44 | ":test_image_with_1k_page_size", |
| 45 | ":test_image_with_4k_page_size", |
| 46 | ":test_image_with_9k_page_size", |
| 47 | ":test_image_with_16k_page_size", |
Alice Wang | ab0d020 | 2023-05-17 08:07:41 +0000 | [diff] [blame] | 48 | ":test_image_with_service_vm_prop", |
| 49 | ":test_image_with_unknown_vm_type_prop", |
Alice Wang | ab0d020 | 2023-05-17 08:07:41 +0000 | [diff] [blame] | 50 | ":test_image_with_duplicated_capability", |
Shikha Panwar | a26f16a | 2023-09-27 09:39:00 +0000 | [diff] [blame] | 51 | ":test_image_with_rollback_index_5", |
Shikha Panwar | 4a0651d | 2023-09-28 13:06:13 +0000 | [diff] [blame] | 52 | ":test_image_with_multiple_capabilities", |
Nikolina Ilic | 57ba9c4 | 2024-10-01 09:50:48 +0000 | [diff] [blame] | 53 | ":test_image_with_all_capabilities", |
Alice Wang | a78279c | 2022-12-16 12:41:19 +0000 | [diff] [blame] | 54 | ":unsigned_test_image", |
| 55 | ], |
Alice Wang | bf7fadd | 2023-01-13 12:18:24 +0000 | [diff] [blame] | 56 | prefer_rlib: true, |
Alice Wang | a78279c | 2022-12-16 12:41:19 +0000 | [diff] [blame] | 57 | rustlibs: [ |
| 58 | "libanyhow", |
Alice Wang | bf7fadd | 2023-01-13 12:18:24 +0000 | [diff] [blame] | 59 | "libavb_bindgen", |
David Pursell | a7c727b | 2023-08-14 16:24:40 -0700 | [diff] [blame] | 60 | "libavb_rs_nostd", |
Alice Wang | 1f0add0 | 2023-01-23 16:22:53 +0000 | [diff] [blame] | 61 | "libhex", |
Alice Wang | bf7fadd | 2023-01-13 12:18:24 +0000 | [diff] [blame] | 62 | "libpvmfw_avb_nostd", |
Alice Wang | 1f0add0 | 2023-01-23 16:22:53 +0000 | [diff] [blame] | 63 | "libopenssl", |
Alice Wang | a78279c | 2022-12-16 12:41:19 +0000 | [diff] [blame] | 64 | ], |
| 65 | enabled: false, |
| 66 | arch: { |
| 67 | // Microdroid kernel is only available in these architectures. |
| 68 | arm64: { |
| 69 | enabled: true, |
| 70 | }, |
| 71 | x86_64: { |
| 72 | enabled: true, |
| 73 | }, |
| 74 | }, |
| 75 | } |
| 76 | |
| 77 | // Generates a 16KB unsigned image for testing. |
| 78 | genrule { |
| 79 | name: "unsigned_test_image", |
| 80 | tools: ["avbtool"], |
| 81 | out: ["unsigned_test.img"], |
| 82 | cmd: "$(location avbtool) generate_test_image --image_size 16384 --output $(out)", |
Alice Wang | f3d96b1 | 2022-12-15 13:10:47 +0000 | [diff] [blame] | 83 | } |
Alice Wang | 6b486f1 | 2023-01-06 13:12:16 +0000 | [diff] [blame] | 84 | |
Alice Wang | 86383df | 2023-01-11 10:03:56 +0000 | [diff] [blame] | 85 | avb_gen_vbmeta_image { |
| 86 | name: "test_non_initrd_hashdesc", |
| 87 | src: ":unsigned_test_image", |
| 88 | partition_name: "non_initrd11", |
| 89 | salt: "2222", |
| 90 | } |
| 91 | |
| 92 | avb_add_hash_footer { |
| 93 | name: "test_image_with_non_initrd_hashdesc", |
| 94 | src: ":unsigned_test_image", |
| 95 | partition_name: "boot", |
| 96 | private_key: ":pvmfw_sign_key", |
Alice Wang | f275286 | 2023-01-18 11:51:25 +0000 | [diff] [blame] | 97 | salt: "3322", |
Alice Wang | 86383df | 2023-01-11 10:03:56 +0000 | [diff] [blame] | 98 | include_descriptors_from_images: [ |
| 99 | ":test_non_initrd_hashdesc", |
| 100 | ], |
| 101 | } |
| 102 | |
| 103 | avb_add_hash_footer { |
Alice Wang | f275286 | 2023-01-18 11:51:25 +0000 | [diff] [blame] | 104 | name: "test_image_with_initrd_and_non_initrd_desc", |
| 105 | src: ":unsigned_test_image", |
| 106 | partition_name: "boot", |
| 107 | private_key: ":pvmfw_sign_key", |
| 108 | salt: "3241", |
| 109 | include_descriptors_from_images: [ |
| 110 | ":microdroid_initrd_normal_hashdesc", |
| 111 | ":test_non_initrd_hashdesc", |
| 112 | ], |
| 113 | enabled: false, |
| 114 | arch: { |
| 115 | // microdroid_initrd_normal_hashdesc is only available in these architectures. |
| 116 | arm64: { |
| 117 | enabled: true, |
| 118 | }, |
| 119 | x86_64: { |
| 120 | enabled: true, |
| 121 | }, |
| 122 | }, |
| 123 | } |
| 124 | |
| 125 | avb_add_hash_footer { |
Pierre-Clément Tosi | 9fbbaf3 | 2024-11-26 14:00:01 +0000 | [diff] [blame] | 126 | name: "test_image_with_invalid_page_size", |
| 127 | src: ":unsigned_test_image", |
| 128 | partition_name: "boot", |
| 129 | private_key: ":pvmfw_sign_key", |
| 130 | salt: "2134", |
| 131 | props: [ |
| 132 | { |
| 133 | name: "com.android.virt.page_size", |
| 134 | value: "invalid", |
| 135 | }, |
| 136 | ], |
| 137 | } |
| 138 | |
| 139 | avb_add_hash_footer { |
| 140 | name: "test_image_with_negative_page_size", |
| 141 | src: ":unsigned_test_image", |
| 142 | partition_name: "boot", |
| 143 | private_key: ":pvmfw_sign_key", |
| 144 | salt: "2134", |
| 145 | props: [ |
| 146 | { |
| 147 | name: "com.android.virt.page_size", |
| 148 | value: "-16", |
| 149 | }, |
| 150 | ], |
| 151 | } |
| 152 | |
| 153 | avb_add_hash_footer { |
| 154 | name: "test_image_with_overflow_page_size", |
| 155 | src: ":unsigned_test_image", |
| 156 | partition_name: "boot", |
| 157 | private_key: ":pvmfw_sign_key", |
| 158 | salt: "2134", |
| 159 | props: [ |
| 160 | { |
| 161 | name: "com.android.virt.page_size", |
| 162 | value: "18014398509481983", |
| 163 | }, |
| 164 | ], |
| 165 | } |
| 166 | |
| 167 | avb_add_hash_footer { |
| 168 | name: "test_image_with_0k_page_size", |
| 169 | src: ":unsigned_test_image", |
| 170 | partition_name: "boot", |
| 171 | private_key: ":pvmfw_sign_key", |
| 172 | salt: "2134", |
| 173 | props: [ |
| 174 | { |
| 175 | name: "com.android.virt.page_size", |
| 176 | value: "0", |
| 177 | }, |
| 178 | ], |
| 179 | } |
| 180 | |
| 181 | avb_add_hash_footer { |
| 182 | name: "test_image_with_1k_page_size", |
| 183 | src: ":unsigned_test_image", |
| 184 | partition_name: "boot", |
| 185 | private_key: ":pvmfw_sign_key", |
| 186 | salt: "2134", |
| 187 | props: [ |
| 188 | { |
| 189 | name: "com.android.virt.page_size", |
| 190 | value: "1", |
| 191 | }, |
| 192 | ], |
| 193 | } |
| 194 | |
| 195 | avb_add_hash_footer { |
| 196 | name: "test_image_with_4k_page_size", |
| 197 | src: ":unsigned_test_image", |
| 198 | partition_name: "boot", |
| 199 | private_key: ":pvmfw_sign_key", |
| 200 | salt: "2134", |
| 201 | props: [ |
| 202 | { |
| 203 | name: "com.android.virt.page_size", |
| 204 | value: "4", |
| 205 | }, |
| 206 | ], |
| 207 | } |
| 208 | |
| 209 | avb_add_hash_footer { |
| 210 | name: "test_image_with_9k_page_size", |
| 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.page_size", |
| 218 | value: "9", |
| 219 | }, |
| 220 | ], |
| 221 | } |
| 222 | |
| 223 | avb_add_hash_footer { |
| 224 | name: "test_image_with_16k_page_size", |
| 225 | src: ":unsigned_test_image", |
| 226 | partition_name: "boot", |
| 227 | private_key: ":pvmfw_sign_key", |
| 228 | salt: "2134", |
| 229 | props: [ |
| 230 | { |
| 231 | name: "com.android.virt.page_size", |
| 232 | value: "16", |
| 233 | }, |
| 234 | ], |
| 235 | } |
| 236 | |
| 237 | avb_add_hash_footer { |
Alice Wang | ab0d020 | 2023-05-17 08:07:41 +0000 | [diff] [blame] | 238 | name: "test_image_with_service_vm_prop", |
| 239 | src: ":unsigned_test_image", |
| 240 | partition_name: "boot", |
| 241 | private_key: ":pvmfw_sign_key", |
| 242 | salt: "2131", |
| 243 | props: [ |
| 244 | { |
| 245 | name: "com.android.virt.cap", |
| 246 | value: "remote_attest", |
| 247 | }, |
| 248 | ], |
| 249 | } |
| 250 | |
| 251 | avb_add_hash_footer { |
| 252 | name: "test_image_with_unknown_vm_type_prop", |
| 253 | src: ":unsigned_test_image", |
| 254 | partition_name: "boot", |
| 255 | private_key: ":pvmfw_sign_key", |
| 256 | salt: "2132", |
| 257 | props: [ |
| 258 | { |
| 259 | name: "com.android.virt.cap", |
| 260 | value: "foo", |
| 261 | }, |
| 262 | ], |
| 263 | } |
| 264 | |
| 265 | avb_add_hash_footer { |
Alice Wang | ab0d020 | 2023-05-17 08:07:41 +0000 | [diff] [blame] | 266 | name: "test_image_with_duplicated_capability", |
| 267 | src: ":unsigned_test_image", |
| 268 | partition_name: "boot", |
| 269 | private_key: ":pvmfw_sign_key", |
| 270 | salt: "2134", |
| 271 | props: [ |
| 272 | { |
| 273 | name: "com.android.virt.cap", |
| 274 | value: "remote_attest|remote_attest|remote_attest", |
| 275 | }, |
| 276 | ], |
| 277 | } |
| 278 | |
| 279 | avb_add_hash_footer { |
Alice Wang | 6b486f1 | 2023-01-06 13:12:16 +0000 | [diff] [blame] | 280 | name: "test_image_with_one_hashdesc", |
| 281 | src: ":unsigned_test_image", |
Alice Wang | 8aa3cb1 | 2023-01-11 09:04:04 +0000 | [diff] [blame] | 282 | partition_name: "boot", |
Alice Wang | 6b486f1 | 2023-01-06 13:12:16 +0000 | [diff] [blame] | 283 | private_key: ":pvmfw_sign_key", |
| 284 | salt: "1111", |
| 285 | } |
Shikha Panwar | a26f16a | 2023-09-27 09:39:00 +0000 | [diff] [blame] | 286 | |
| 287 | avb_add_hash_footer { |
| 288 | name: "test_image_with_rollback_index_5", |
| 289 | src: ":unsigned_test_image", |
| 290 | partition_name: "boot", |
| 291 | private_key: ":pvmfw_sign_key", |
| 292 | salt: "1211", |
| 293 | rollback_index: 5, |
| 294 | } |
Shikha Panwar | 4a0651d | 2023-09-28 13:06:13 +0000 | [diff] [blame] | 295 | |
| 296 | avb_add_hash_footer { |
| 297 | name: "test_image_with_multiple_capabilities", |
| 298 | src: ":unsigned_test_image", |
| 299 | partition_name: "boot", |
| 300 | private_key: ":pvmfw_sign_key", |
| 301 | salt: "2134", |
| 302 | props: [ |
| 303 | { |
| 304 | name: "com.android.virt.cap", |
| 305 | value: "remote_attest|secretkeeper_protection", |
| 306 | }, |
| 307 | ], |
| 308 | } |
Nikolina Ilic | 57ba9c4 | 2024-10-01 09:50:48 +0000 | [diff] [blame] | 309 | |
| 310 | avb_add_hash_footer { |
| 311 | name: "test_image_with_all_capabilities", |
| 312 | src: ":unsigned_test_image", |
| 313 | partition_name: "boot", |
| 314 | private_key: ":pvmfw_sign_key", |
| 315 | salt: "4231", |
| 316 | props: [ |
| 317 | { |
| 318 | name: "com.android.virt.cap", |
Alice Wang | fe0b976 | 2024-11-21 14:47:54 +0000 | [diff] [blame] | 319 | value: "remote_attest|trusty_security_vm|secretkeeper_protection|supports_uefi_boot", |
Nikolina Ilic | 57ba9c4 | 2024-10-01 09:50:48 +0000 | [diff] [blame] | 320 | }, |
| 321 | ], |
| 322 | } |