1package { 2 default_visibility: [":__subpackages__"], 3 default_applicable_licenses: ["Android-Apache-2.0"], 4} 5 6rust_defaults { 7 name: "libdiced_open_dice_defaults", 8 crate_name: "diced_open_dice", 9 defaults: ["avf_build_flags_rust"], 10 srcs: ["src/lib.rs"], 11} 12 13rust_library_rlib { 14 name: "libdiced_open_dice_nostd", 15 defaults: ["libdiced_open_dice_defaults"], 16 rustlibs: [ 17 "libopen_dice_android_bindgen_nostd", 18 "libopen_dice_cbor_bindgen_nostd", 19 "libzeroize_nostd", 20 ], 21 features: [ 22 "alloc", 23 ], 24 whole_static_libs: [ 25 "libopen_dice_cbor", 26 "libcrypto_baremetal", 27 ], 28 visibility: [ 29 "//packages/modules/Virtualization:__subpackages__", 30 "//system/authgraph/tests:__subpackages__", 31 ], 32} 33 34rust_library { 35 name: "libdiced_open_dice", 36 defaults: ["libdiced_open_dice_defaults"], 37 host_supported: true, 38 vendor_available: true, 39 rustlibs: [ 40 "libopen_dice_android_bindgen", 41 "libopen_dice_cbor_bindgen", 42 "libserde", 43 "libzeroize", 44 ], 45 features: [ 46 "alloc", 47 "serde_derive", 48 "std", 49 ], 50 proc_macros: ["libserde_derive"], 51 shared_libs: [ 52 "libcrypto", 53 ], 54 static_libs: [ 55 "libopen_dice_cbor", 56 ], 57 whole_static_libs: [ 58 "libopen_dice_android", 59 ], 60 visibility: [ 61 "//hardware/interfaces/security/secretkeeper/aidl/vts", 62 "//packages/modules/Virtualization:__subpackages__", 63 "//system/authgraph/tests:__subpackages__", 64 "//system/secretkeeper/client:__subpackages__", 65 ], 66 apex_available: [ 67 "//apex_available:platform", 68 "com.android.virt", 69 ], 70} 71 72rust_defaults { 73 name: "libdiced_open_dice_test_defaults", 74 crate_name: "diced_open_dice_test", 75 srcs: ["tests/api_test.rs"], 76 test_suites: ["general-tests"], 77} 78 79rust_test { 80 name: "libdiced_open_dice.integration_test", 81 defaults: ["libdiced_open_dice_test_defaults"], 82 rustlibs: [ 83 "libdiced_open_dice", 84 ], 85} 86 87rust_test { 88 name: "libdiced_open_dice_nostd.integration_test", 89 defaults: ["libdiced_open_dice_test_defaults"], 90 rustlibs: [ 91 "libdiced_open_dice_nostd", 92 ], 93} 94 95rust_defaults { 96 name: "libopen_dice_bindgen_nostd.rust_defaults", 97 bindgen_flags: [ 98 "--use-core", 99 "--ctypes-prefix=core::ffi", 100 "--raw-line=#![no_std]", 101 ], 102 no_stdlibs: true, 103 prefer_rlib: true, 104 stdlibs: [ 105 "libcore.rust_sysroot", 106 "libcompiler_builtins.rust_sysroot", 107 ], 108 target: { 109 musl: { 110 enabled: false, 111 }, 112 glibc: { 113 enabled: false, 114 }, 115 darwin: { 116 enabled: false, 117 }, 118 }, 119} 120 121rust_defaults { 122 name: "libopen_dice.rust_defaults", 123 host_supported: true, 124 vendor_available: true, 125 apex_available: [ 126 "//apex_available:platform", 127 "com.android.compos", 128 "com.android.virt", 129 ], 130} 131 132rust_defaults { 133 name: "libopen_dice_cbor_bindgen.rust_defaults", 134 wrapper_src: "bindgen/dice.h", 135 crate_name: "open_dice_cbor_bindgen", 136 source_stem: "bindings", 137 bindgen_flags: [ 138 "--rustified-enum DiceConfigType", 139 "--rustified-enum DiceMode", 140 "--rustified-enum DiceResult", 141 142 // By generating only essential functions, we can make bindings concise and 143 // optimize compilation time. 144 "--allowlist-function=DiceDeriveCdiPrivateKeySeed", 145 "--allowlist-function=DiceDeriveCdiCertificateId", 146 "--allowlist-function=DiceMainFlow", 147 "--allowlist-function=DiceHash", 148 "--allowlist-function=DiceKdf", 149 "--allowlist-function=DiceKeypairFromSeed", 150 "--allowlist-function=DiceSign", 151 "--allowlist-function=DiceVerify", 152 "--allowlist-function=DiceGenerateCertificate", 153 154 // We also need some constants in addition to the functions. 155 "--allowlist-var=DICE_CDI_SIZE", 156 "--allowlist-var=DICE_HASH_SIZE", 157 "--allowlist-var=DICE_HIDDEN_SIZE", 158 "--allowlist-var=DICE_INLINE_CONFIG_SIZE", 159 "--allowlist-var=DICE_PRIVATE_KEY_SEED_SIZE", 160 "--allowlist-var=DICE_ID_SIZE", 161 "--allowlist-var=DICE_PUBLIC_KEY_SIZE", 162 "--allowlist-var=DICE_PRIVATE_KEY_SIZE", 163 "--allowlist-var=DICE_SIGNATURE_SIZE", 164 "--allowlist-var=DICE_COSE_KEY_ALG_VALUE", 165 ], 166} 167 168rust_bindgen { 169 name: "libopen_dice_cbor_bindgen", 170 defaults: [ 171 "libopen_dice.rust_defaults", 172 "libopen_dice_cbor_bindgen.rust_defaults", 173 ], 174 whole_static_libs: ["libopen_dice_cbor"], 175} 176 177rust_bindgen { 178 name: "libopen_dice_cbor_bindgen_nostd", 179 defaults: [ 180 "libopen_dice_cbor_bindgen.rust_defaults", 181 "libopen_dice_bindgen_nostd.rust_defaults", 182 ], 183 whole_static_libs: ["libopen_dice_cbor_baremetal"], 184} 185 186rust_defaults { 187 name: "libopen_dice_android_bindgen.rust_defaults", 188 wrapper_src: "bindgen/android.h", 189 crate_name: "open_dice_android_bindgen", 190 source_stem: "bindings", 191 bindgen_flags: [ 192 // By generating only essential functions, we can make bindings concise and 193 // optimize compilation time. 194 "--allowlist-function=DiceAndroidFormatConfigDescriptor", 195 "--allowlist-function=DiceAndroidMainFlow", 196 "--allowlist-function=DiceAndroidHandoverMainFlow", 197 "--allowlist-function=DiceAndroidHandoverParse", 198 199 // We also need some constants in addition to the functions. 200 "--allowlist-var=DICE_ANDROID_CONFIG_.*", 201 202 // Prevent DiceInputValues from being generated a second time and 203 // import it instead from open_dice_cbor_bindgen. 204 "--blocklist-type=DiceInputValues_", 205 "--blocklist-type=DiceInputValues", 206 "--raw-line", 207 "pub use open_dice_cbor_bindgen::DiceInputValues;", 208 209 // Prevent DiceResult from being generated a second time and 210 // import it instead from open_dice_cbor_bindgen. 211 "--blocklist-type=DiceResult", 212 "--raw-line", 213 "pub use open_dice_cbor_bindgen::DiceResult;", 214 ], 215 216} 217 218rust_bindgen { 219 name: "libopen_dice_android_bindgen", 220 defaults: [ 221 "libopen_dice.rust_defaults", 222 "libopen_dice_android_bindgen.rust_defaults", 223 ], 224 rustlibs: [ 225 "libopen_dice_cbor_bindgen", 226 ], 227 whole_static_libs: ["libopen_dice_android"], 228} 229 230rust_bindgen { 231 name: "libopen_dice_android_bindgen_nostd", 232 defaults: [ 233 "libopen_dice_android_bindgen.rust_defaults", 234 "libopen_dice_bindgen_nostd.rust_defaults", 235 ], 236 rustlibs: [ 237 "libopen_dice_cbor_bindgen_nostd", 238 ], 239 whole_static_libs: ["libopen_dice_android_baremetal"], 240} 241 242rust_test { 243 name: "libopen_dice_cbor_bindgen_test", 244 srcs: [ 245 ":libopen_dice_cbor_bindgen", 246 ], 247 crate_name: "open_dice_cbor_bindgen_test", 248 test_suites: ["general-tests"], 249 auto_gen_config: true, 250 clippy_lints: "none", 251 lints: "none", 252} 253 254rust_test { 255 name: "libopen_dice_android_bindgen_test", 256 srcs: [ 257 ":libopen_dice_android_bindgen", 258 ], 259 crate_name: "open_dice_android_bindgen_test", 260 rustlibs: [ 261 "libopen_dice_cbor_bindgen", 262 ], 263 test_suites: ["general-tests"], 264 auto_gen_config: true, 265 clippy_lints: "none", 266 lints: "none", 267} 268