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