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