Alice Wang | 94a0635 | 2023-10-16 07:19:10 +0000 | [diff] [blame] | 1 | package { |
| 2 | default_visibility: [":__subpackages__"], |
| 3 | default_applicable_licenses: ["Android-Apache-2.0"], |
| 4 | } |
| 5 | |
| 6 | rust_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 | |
| 13 | rust_library_rlib { |
| 14 | name: "libdiced_open_dice_nostd", |
| 15 | defaults: ["libdiced_open_dice_defaults"], |
| 16 | rustlibs: [ |
Alice Wang | b1ed084 | 2024-11-05 09:45:37 +0000 | [diff] [blame] | 17 | "libcoset_nostd", |
Alice Wang | 94a0635 | 2023-10-16 07:19:10 +0000 | [diff] [blame] | 18 | "libopen_dice_android_bindgen_nostd", |
| 19 | "libopen_dice_cbor_bindgen_nostd", |
| 20 | "libzeroize_nostd", |
| 21 | ], |
Alice Wang | 87fbc4b | 2024-11-05 13:09:58 +0000 | [diff] [blame] | 22 | features: [ |
| 23 | "multialg", |
| 24 | ], |
Alice Wang | 94a0635 | 2023-10-16 07:19:10 +0000 | [diff] [blame] | 25 | whole_static_libs: [ |
Alice Wang | 94a0635 | 2023-10-16 07:19:10 +0000 | [diff] [blame] | 26 | "libcrypto_baremetal", |
| 27 | ], |
| 28 | visibility: [ |
| 29 | "//packages/modules/Virtualization:__subpackages__", |
| 30 | ], |
| 31 | } |
| 32 | |
| 33 | rust_library { |
| 34 | name: "libdiced_open_dice", |
| 35 | defaults: ["libdiced_open_dice_defaults"], |
Hasini Gunasinghe | b39fc15 | 2023-12-14 11:13:51 +0000 | [diff] [blame] | 36 | host_supported: true, |
Alice Wang | 94a0635 | 2023-10-16 07:19:10 +0000 | [diff] [blame] | 37 | vendor_available: true, |
| 38 | rustlibs: [ |
Alice Wang | b1ed084 | 2024-11-05 09:45:37 +0000 | [diff] [blame] | 39 | "libcoset", |
Alice Wang | 94a0635 | 2023-10-16 07:19:10 +0000 | [diff] [blame] | 40 | "libopen_dice_android_bindgen", |
| 41 | "libopen_dice_cbor_bindgen", |
Nikita Ioffe | ab035a5 | 2024-03-14 00:33:50 +0000 | [diff] [blame] | 42 | "libserde", |
Alice Wang | 94a0635 | 2023-10-16 07:19:10 +0000 | [diff] [blame] | 43 | "libzeroize", |
| 44 | ], |
| 45 | features: [ |
Nikita Ioffe | ab035a5 | 2024-03-14 00:33:50 +0000 | [diff] [blame] | 46 | "serde_derive", |
Alice Wang | 94a0635 | 2023-10-16 07:19:10 +0000 | [diff] [blame] | 47 | "std", |
| 48 | ], |
Nikita Ioffe | ab035a5 | 2024-03-14 00:33:50 +0000 | [diff] [blame] | 49 | proc_macros: ["libserde_derive"], |
Alice Wang | 94a0635 | 2023-10-16 07:19:10 +0000 | [diff] [blame] | 50 | shared_libs: [ |
| 51 | "libcrypto", |
| 52 | ], |
Alice Wang | 94a0635 | 2023-10-16 07:19:10 +0000 | [diff] [blame] | 53 | visibility: [ |
Shikha Panwar | c8ba73c | 2024-01-03 18:34:38 +0000 | [diff] [blame] | 54 | "//hardware/interfaces/security/secretkeeper/aidl/vts", |
Alice Wang | 94a0635 | 2023-10-16 07:19:10 +0000 | [diff] [blame] | 55 | "//packages/modules/Virtualization:__subpackages__", |
Hasini Gunasinghe | 19234c4 | 2023-12-13 14:47:47 +0000 | [diff] [blame] | 56 | "//system/authgraph/tests:__subpackages__", |
Shikha Panwar | 0ebd67e | 2023-12-22 23:58:31 +0000 | [diff] [blame] | 57 | "//system/secretkeeper/client:__subpackages__", |
Istvan Nador | 8f2ab79 | 2024-09-10 11:08:55 +0000 | [diff] [blame] | 58 | "//system/software_defined_vehicle:__subpackages__", |
Alice Wang | 94a0635 | 2023-10-16 07:19:10 +0000 | [diff] [blame] | 59 | ], |
| 60 | apex_available: [ |
| 61 | "//apex_available:platform", |
| 62 | "com.android.virt", |
| 63 | ], |
| 64 | } |
| 65 | |
Vanand Gasparyan | 88cd393 | 2025-03-03 14:07:54 +0000 | [diff] [blame] | 66 | rust_library { |
| 67 | name: "libdiced_open_dice_multialg", |
| 68 | defaults: ["libdiced_open_dice_defaults"], |
| 69 | host_supported: true, |
| 70 | vendor_available: true, |
| 71 | rustlibs: [ |
| 72 | "libcoset", |
| 73 | "libopen_dice_android_bindgen_multialg", |
| 74 | "libopen_dice_cbor_bindgen_multialg", |
| 75 | "libzeroize", |
| 76 | ], |
| 77 | features: [ |
| 78 | "std", |
| 79 | "multialg", |
| 80 | ], |
| 81 | shared_libs: [ |
| 82 | "libcrypto", |
| 83 | ], |
| 84 | visibility: [ |
| 85 | "//system/software_defined_vehicle:__subpackages__", |
| 86 | ], |
| 87 | apex_available: [ |
| 88 | "//apex_available:platform", |
| 89 | "com.android.virt", |
| 90 | ], |
| 91 | } |
| 92 | |
Alice Wang | 94a0635 | 2023-10-16 07:19:10 +0000 | [diff] [blame] | 93 | rust_defaults { |
| 94 | name: "libdiced_open_dice_test_defaults", |
| 95 | crate_name: "diced_open_dice_test", |
Alan Stokes | d7aea45 | 2024-03-14 14:20:04 +0000 | [diff] [blame] | 96 | srcs: ["tests/api_test.rs"], |
Alice Wang | 94a0635 | 2023-10-16 07:19:10 +0000 | [diff] [blame] | 97 | test_suites: ["general-tests"], |
| 98 | } |
| 99 | |
| 100 | rust_test { |
| 101 | name: "libdiced_open_dice.integration_test", |
| 102 | defaults: ["libdiced_open_dice_test_defaults"], |
| 103 | rustlibs: [ |
| 104 | "libdiced_open_dice", |
Gil Cukierman | e431d96 | 2025-01-22 13:25:52 -0800 | [diff] [blame] | 105 | "libcoset", |
Alice Wang | 94a0635 | 2023-10-16 07:19:10 +0000 | [diff] [blame] | 106 | ], |
| 107 | } |
| 108 | |
| 109 | rust_test { |
Vanand Gasparyan | 88cd393 | 2025-03-03 14:07:54 +0000 | [diff] [blame] | 110 | name: "libdiced_open_dice_multialg.integration_test", |
| 111 | defaults: ["libdiced_open_dice_test_defaults"], |
| 112 | rustlibs: [ |
| 113 | "libdiced_open_dice_multialg", |
| 114 | "libcoset", |
| 115 | ], |
| 116 | features: [ |
| 117 | "multialg", |
| 118 | ], |
| 119 | } |
| 120 | |
| 121 | rust_test { |
Alice Wang | 94a0635 | 2023-10-16 07:19:10 +0000 | [diff] [blame] | 122 | name: "libdiced_open_dice_nostd.integration_test", |
| 123 | defaults: ["libdiced_open_dice_test_defaults"], |
| 124 | rustlibs: [ |
| 125 | "libdiced_open_dice_nostd", |
Gil Cukierman | e431d96 | 2025-01-22 13:25:52 -0800 | [diff] [blame] | 126 | "libcoset_nostd", |
Alice Wang | 94a0635 | 2023-10-16 07:19:10 +0000 | [diff] [blame] | 127 | ], |
| 128 | } |
| 129 | |
| 130 | rust_defaults { |
| 131 | name: "libopen_dice_bindgen_nostd.rust_defaults", |
| 132 | bindgen_flags: [ |
| 133 | "--use-core", |
| 134 | "--ctypes-prefix=core::ffi", |
| 135 | "--raw-line=#![no_std]", |
| 136 | ], |
Ivan Lozano | 6561e34 | 2024-08-07 14:16:39 +0000 | [diff] [blame] | 137 | dylib: { |
| 138 | enabled: false, |
| 139 | }, |
Alice Wang | 94a0635 | 2023-10-16 07:19:10 +0000 | [diff] [blame] | 140 | no_stdlibs: true, |
| 141 | prefer_rlib: true, |
| 142 | stdlibs: [ |
| 143 | "libcore.rust_sysroot", |
| 144 | "libcompiler_builtins.rust_sysroot", |
| 145 | ], |
| 146 | target: { |
| 147 | musl: { |
| 148 | enabled: false, |
| 149 | }, |
| 150 | glibc: { |
| 151 | enabled: false, |
| 152 | }, |
| 153 | darwin: { |
| 154 | enabled: false, |
| 155 | }, |
| 156 | }, |
| 157 | } |
| 158 | |
| 159 | rust_defaults { |
| 160 | name: "libopen_dice.rust_defaults", |
| 161 | host_supported: true, |
| 162 | vendor_available: true, |
| 163 | apex_available: [ |
| 164 | "//apex_available:platform", |
| 165 | "com.android.compos", |
| 166 | "com.android.virt", |
| 167 | ], |
| 168 | } |
| 169 | |
| 170 | rust_defaults { |
| 171 | name: "libopen_dice_cbor_bindgen.rust_defaults", |
Gil Cukierman | f96915b | 2024-12-13 16:32:12 -0500 | [diff] [blame] | 172 | wrapper_src: "bindgen/dice/dice.h", |
Alice Wang | 94a0635 | 2023-10-16 07:19:10 +0000 | [diff] [blame] | 173 | crate_name: "open_dice_cbor_bindgen", |
| 174 | source_stem: "bindings", |
| 175 | bindgen_flags: [ |
| 176 | "--rustified-enum DiceConfigType", |
| 177 | "--rustified-enum DiceMode", |
| 178 | "--rustified-enum DiceResult", |
Alice Wang | 14ca76a | 2024-11-05 12:41:57 +0000 | [diff] [blame] | 179 | "--rustified-enum DicePrincipal", |
Alice Wang | 94a0635 | 2023-10-16 07:19:10 +0000 | [diff] [blame] | 180 | |
| 181 | // By generating only essential functions, we can make bindings concise and |
| 182 | // optimize compilation time. |
| 183 | "--allowlist-function=DiceDeriveCdiPrivateKeySeed", |
| 184 | "--allowlist-function=DiceDeriveCdiCertificateId", |
| 185 | "--allowlist-function=DiceMainFlow", |
| 186 | "--allowlist-function=DiceHash", |
| 187 | "--allowlist-function=DiceKdf", |
| 188 | "--allowlist-function=DiceKeypairFromSeed", |
| 189 | "--allowlist-function=DiceSign", |
Gil Cukierman | e431d96 | 2025-01-22 13:25:52 -0800 | [diff] [blame] | 190 | "--allowlist-function=DiceCoseSignAndEncodeSign1", |
Alice Wang | 94a0635 | 2023-10-16 07:19:10 +0000 | [diff] [blame] | 191 | "--allowlist-function=DiceVerify", |
| 192 | "--allowlist-function=DiceGenerateCertificate", |
| 193 | |
| 194 | // We also need some constants in addition to the functions. |
| 195 | "--allowlist-var=DICE_CDI_SIZE", |
| 196 | "--allowlist-var=DICE_HASH_SIZE", |
| 197 | "--allowlist-var=DICE_HIDDEN_SIZE", |
| 198 | "--allowlist-var=DICE_INLINE_CONFIG_SIZE", |
| 199 | "--allowlist-var=DICE_PRIVATE_KEY_SEED_SIZE", |
| 200 | "--allowlist-var=DICE_ID_SIZE", |
Alice Wang | ce6cbd7 | 2024-11-22 11:19:05 +0000 | [diff] [blame] | 201 | "--allowlist-var=DICE_PRIVATE_KEY_BUFFER_SIZE", |
Alice Wang | 94a0635 | 2023-10-16 07:19:10 +0000 | [diff] [blame] | 202 | ], |
| 203 | } |
| 204 | |
| 205 | rust_bindgen { |
| 206 | name: "libopen_dice_cbor_bindgen", |
| 207 | defaults: [ |
| 208 | "libopen_dice.rust_defaults", |
| 209 | "libopen_dice_cbor_bindgen.rust_defaults", |
| 210 | ], |
| 211 | whole_static_libs: ["libopen_dice_cbor"], |
Ivan Lozano | 36f783f | 2025-01-28 21:41:57 +0000 | [diff] [blame] | 212 | shared_libs: ["libcrypto"], |
Alice Wang | 94a0635 | 2023-10-16 07:19:10 +0000 | [diff] [blame] | 213 | } |
| 214 | |
| 215 | rust_bindgen { |
Vanand Gasparyan | 88cd393 | 2025-03-03 14:07:54 +0000 | [diff] [blame] | 216 | name: "libopen_dice_cbor_bindgen_multialg", |
| 217 | defaults: [ |
| 218 | "libopen_dice.rust_defaults", |
| 219 | "libopen_dice_cbor_bindgen.rust_defaults", |
| 220 | ], |
| 221 | bindgen_flags: [ |
| 222 | "--rustified-enum DiceKeyAlgorithm", |
| 223 | "--allowlist-type=DiceContext", |
| 224 | ], |
| 225 | whole_static_libs: ["libopen_dice_cbor_multialg"], |
| 226 | shared_libs: ["libcrypto"], |
| 227 | } |
| 228 | |
| 229 | rust_bindgen { |
Alice Wang | 94a0635 | 2023-10-16 07:19:10 +0000 | [diff] [blame] | 230 | name: "libopen_dice_cbor_bindgen_nostd", |
| 231 | defaults: [ |
| 232 | "libopen_dice_cbor_bindgen.rust_defaults", |
| 233 | "libopen_dice_bindgen_nostd.rust_defaults", |
| 234 | ], |
Alice Wang | 87fbc4b | 2024-11-05 13:09:58 +0000 | [diff] [blame] | 235 | bindgen_flags: [ |
| 236 | "--rustified-enum DiceKeyAlgorithm", |
| 237 | "--allowlist-type=DiceContext", |
| 238 | ], |
| 239 | whole_static_libs: ["libopen_dice_cbor_baremetal_multialg"], |
Alice Wang | 94a0635 | 2023-10-16 07:19:10 +0000 | [diff] [blame] | 240 | } |
| 241 | |
| 242 | rust_defaults { |
| 243 | name: "libopen_dice_android_bindgen.rust_defaults", |
Gil Cukierman | f96915b | 2024-12-13 16:32:12 -0500 | [diff] [blame] | 244 | wrapper_src: "bindgen/android/android.h", |
Alice Wang | 94a0635 | 2023-10-16 07:19:10 +0000 | [diff] [blame] | 245 | crate_name: "open_dice_android_bindgen", |
| 246 | source_stem: "bindings", |
| 247 | bindgen_flags: [ |
| 248 | // By generating only essential functions, we can make bindings concise and |
| 249 | // optimize compilation time. |
| 250 | "--allowlist-function=DiceAndroidFormatConfigDescriptor", |
| 251 | "--allowlist-function=DiceAndroidMainFlow", |
| 252 | "--allowlist-function=DiceAndroidHandoverMainFlow", |
| 253 | "--allowlist-function=DiceAndroidHandoverParse", |
| 254 | |
| 255 | // We also need some constants in addition to the functions. |
| 256 | "--allowlist-var=DICE_ANDROID_CONFIG_.*", |
| 257 | |
| 258 | // Prevent DiceInputValues from being generated a second time and |
| 259 | // import it instead from open_dice_cbor_bindgen. |
| 260 | "--blocklist-type=DiceInputValues_", |
| 261 | "--blocklist-type=DiceInputValues", |
| 262 | "--raw-line", |
| 263 | "pub use open_dice_cbor_bindgen::DiceInputValues;", |
| 264 | |
| 265 | // Prevent DiceResult from being generated a second time and |
| 266 | // import it instead from open_dice_cbor_bindgen. |
| 267 | "--blocklist-type=DiceResult", |
| 268 | "--raw-line", |
| 269 | "pub use open_dice_cbor_bindgen::DiceResult;", |
| 270 | ], |
| 271 | |
| 272 | } |
| 273 | |
| 274 | rust_bindgen { |
| 275 | name: "libopen_dice_android_bindgen", |
| 276 | defaults: [ |
| 277 | "libopen_dice.rust_defaults", |
| 278 | "libopen_dice_android_bindgen.rust_defaults", |
| 279 | ], |
| 280 | rustlibs: [ |
| 281 | "libopen_dice_cbor_bindgen", |
| 282 | ], |
| 283 | whole_static_libs: ["libopen_dice_android"], |
| 284 | } |
| 285 | |
| 286 | rust_bindgen { |
Vanand Gasparyan | 88cd393 | 2025-03-03 14:07:54 +0000 | [diff] [blame] | 287 | name: "libopen_dice_android_bindgen_multialg", |
| 288 | defaults: [ |
| 289 | "libopen_dice.rust_defaults", |
| 290 | "libopen_dice_android_bindgen.rust_defaults", |
| 291 | ], |
| 292 | rustlibs: [ |
| 293 | "libopen_dice_cbor_bindgen_multialg", |
| 294 | ], |
| 295 | whole_static_libs: ["libopen_dice_android_multialg"], |
| 296 | } |
| 297 | |
| 298 | rust_bindgen { |
Alice Wang | 94a0635 | 2023-10-16 07:19:10 +0000 | [diff] [blame] | 299 | name: "libopen_dice_android_bindgen_nostd", |
| 300 | defaults: [ |
| 301 | "libopen_dice_android_bindgen.rust_defaults", |
| 302 | "libopen_dice_bindgen_nostd.rust_defaults", |
| 303 | ], |
| 304 | rustlibs: [ |
| 305 | "libopen_dice_cbor_bindgen_nostd", |
| 306 | ], |
Alice Wang | 87fbc4b | 2024-11-05 13:09:58 +0000 | [diff] [blame] | 307 | whole_static_libs: ["libopen_dice_android_baremetal_multialg"], |
Alice Wang | 94a0635 | 2023-10-16 07:19:10 +0000 | [diff] [blame] | 308 | } |
| 309 | |
| 310 | rust_test { |
| 311 | name: "libopen_dice_cbor_bindgen_test", |
| 312 | srcs: [ |
| 313 | ":libopen_dice_cbor_bindgen", |
| 314 | ], |
| 315 | crate_name: "open_dice_cbor_bindgen_test", |
| 316 | test_suites: ["general-tests"], |
| 317 | auto_gen_config: true, |
| 318 | clippy_lints: "none", |
| 319 | lints: "none", |
| 320 | } |
| 321 | |
| 322 | rust_test { |
| 323 | name: "libopen_dice_android_bindgen_test", |
| 324 | srcs: [ |
| 325 | ":libopen_dice_android_bindgen", |
| 326 | ], |
| 327 | crate_name: "open_dice_android_bindgen_test", |
| 328 | rustlibs: [ |
| 329 | "libopen_dice_cbor_bindgen", |
| 330 | ], |
| 331 | test_suites: ["general-tests"], |
| 332 | auto_gen_config: true, |
| 333 | clippy_lints: "none", |
| 334 | lints: "none", |
| 335 | } |
Gil Cukierman | f96915b | 2024-12-13 16:32:12 -0500 | [diff] [blame] | 336 | |
| 337 | dirgroup { |
| 338 | name: "trusty_dirgroup_packages_modules_virtualization_libs_open_dice", |
| 339 | visibility: ["//trusty/vendor/google/aosp/scripts"], |
| 340 | dirs: ["."], |
| 341 | } |