1package { 2 default_applicable_licenses: ["Android-Apache-2.0"], 3} 4 5rust_library_rlib { 6 name: "libpvmfw_avb_nostd", 7 crate_name: "pvmfw_avb", 8 defaults: ["avf_build_flags_rust"], 9 srcs: ["src/lib.rs"], 10 prefer_rlib: true, 11 rustlibs: [ 12 "libavb_rs_nostd", 13 "libtinyvec_nostd", 14 ], 15 whole_static_libs: [ 16 "libavb_baremetal", 17 ], 18 no_stdlibs: true, 19 stdlibs: [ 20 "libcore.rust_sysroot", 21 ], 22} 23 24rust_test { 25 name: "libpvmfw_avb.integration_test", 26 crate_name: "pvmfw_avb_test", 27 defaults: ["avf_build_flags_rust"], 28 srcs: ["tests/api_test.rs"], 29 test_suites: ["general-tests"], 30 data: [ 31 ":avb_testkey_rsa2048_pub_bin", 32 ":avb_testkey_rsa4096_pub_bin", 33 ":microdroid_kernel_signed", 34 ":microdroid_initrd_normal", 35 ":microdroid_initrd_debuggable", 36 ":test_image_with_one_hashdesc", 37 ":test_image_with_non_initrd_hashdesc", 38 ":test_image_with_initrd_and_non_initrd_desc", 39 ":test_image_with_prop_desc", 40 ":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", 44 ":test_image_with_rollback_index_5", 45 ":test_image_with_multiple_capabilities", 46 ":unsigned_test_image", 47 ], 48 prefer_rlib: true, 49 rustlibs: [ 50 "libanyhow", 51 "libavb_bindgen", 52 "libavb_rs_nostd", 53 "libhex", 54 "libpvmfw_avb_nostd", 55 "libopenssl", 56 ], 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)", 75} 76 77avb_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", 89 salt: "3322", 90 include_descriptors_from_images: [ 91 ":test_non_initrd_hashdesc", 92 ], 93} 94 95avb_add_hash_footer { 96 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 { 118 name: "test_image_with_prop_desc", 119 src: ":unsigned_test_image", 120 partition_name: "boot", 121 private_key: ":pvmfw_sign_key", 122 salt: "2134", 123 props: [ 124 { 125 name: "mock_prop", 126 value: "3333", 127 }, 128 ], 129} 130 131avb_add_hash_footer { 132 name: "test_image_with_service_vm_prop", 133 src: ":unsigned_test_image", 134 partition_name: "boot", 135 private_key: ":pvmfw_sign_key", 136 salt: "2131", 137 props: [ 138 { 139 name: "com.android.virt.cap", 140 value: "remote_attest", 141 }, 142 ], 143} 144 145avb_add_hash_footer { 146 name: "test_image_with_unknown_vm_type_prop", 147 src: ":unsigned_test_image", 148 partition_name: "boot", 149 private_key: ":pvmfw_sign_key", 150 salt: "2132", 151 props: [ 152 { 153 name: "com.android.virt.cap", 154 value: "foo", 155 }, 156 ], 157} 158 159avb_add_hash_footer { 160 name: "test_image_with_multiple_props", 161 src: ":unsigned_test_image", 162 partition_name: "boot", 163 private_key: ":pvmfw_sign_key", 164 salt: "2133", 165 props: [ 166 { 167 name: "com.android.virt.cap", 168 value: "remote_attest", 169 }, 170 { 171 name: "another_vm_type", 172 value: "foo_vm", 173 }, 174 ], 175} 176 177avb_add_hash_footer { 178 name: "test_image_with_duplicated_capability", 179 src: ":unsigned_test_image", 180 partition_name: "boot", 181 private_key: ":pvmfw_sign_key", 182 salt: "2134", 183 props: [ 184 { 185 name: "com.android.virt.cap", 186 value: "remote_attest|remote_attest|remote_attest", 187 }, 188 ], 189} 190 191avb_add_hash_footer { 192 name: "test_image_with_one_hashdesc", 193 src: ":unsigned_test_image", 194 partition_name: "boot", 195 private_key: ":pvmfw_sign_key", 196 salt: "1111", 197} 198 199avb_add_hash_footer { 200 name: "test_image_with_rollback_index_5", 201 src: ":unsigned_test_image", 202 partition_name: "boot", 203 private_key: ":pvmfw_sign_key", 204 salt: "1211", 205 rollback_index: 5, 206} 207 208avb_add_hash_footer { 209 name: "test_image_with_multiple_capabilities", 210 src: ":unsigned_test_image", 211 partition_name: "boot", 212 private_key: ":pvmfw_sign_key", 213 salt: "2134", 214 props: [ 215 { 216 name: "com.android.virt.cap", 217 value: "remote_attest|secretkeeper_protection", 218 }, 219 ], 220} 221