Alice Wang | 0b9e110 | 2023-02-02 09:57:06 +0000 | [diff] [blame] | 1 | package { |
Alice Wang | 988df59 | 2023-02-16 12:05:42 +0000 | [diff] [blame] | 2 | default_visibility: [":__subpackages__"], |
Alice Wang | 0b9e110 | 2023-02-02 09:57:06 +0000 | [diff] [blame] | 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 | srcs: ["src/lib.rs"], |
| 10 | static_libs: [ |
| 11 | "libopen_dice_cbor", |
| 12 | ], |
| 13 | vendor_available: true, |
| 14 | apex_available: [ |
| 15 | "//apex_available:platform", |
| 16 | "com.android.virt", |
| 17 | ], |
| 18 | } |
| 19 | |
| 20 | rust_library_rlib { |
| 21 | name: "libdiced_open_dice_nostd", |
| 22 | defaults: ["libdiced_open_dice_defaults"], |
| 23 | rustlibs: [ |
Alice Wang | 9c40eca | 2023-02-03 13:10:24 +0000 | [diff] [blame] | 24 | "libopen_dice_bcc_bindgen_nostd", |
Alice Wang | 0b9e110 | 2023-02-02 09:57:06 +0000 | [diff] [blame] | 25 | "libopen_dice_cbor_bindgen_nostd", |
Alice Wang | f4bd1c6 | 2023-02-08 08:38:44 +0000 | [diff] [blame] | 26 | "libzeroize_nostd", |
Alice Wang | 0b9e110 | 2023-02-02 09:57:06 +0000 | [diff] [blame] | 27 | ], |
Alice Wang | 988df59 | 2023-02-16 12:05:42 +0000 | [diff] [blame] | 28 | whole_static_libs: [ |
Alice Wang | 24954b4 | 2023-02-06 10:03:45 +0000 | [diff] [blame] | 29 | "libopen_dice_cbor", |
| 30 | "libcrypto_baremetal", |
| 31 | ], |
Alice Wang | 988df59 | 2023-02-16 12:05:42 +0000 | [diff] [blame] | 32 | visibility: [ |
| 33 | "//packages/modules/Virtualization:__subpackages__", |
| 34 | ], |
Alice Wang | 0b9e110 | 2023-02-02 09:57:06 +0000 | [diff] [blame] | 35 | } |
| 36 | |
Alice Wang | 856d656 | 2023-02-03 13:51:08 +0000 | [diff] [blame] | 37 | rust_library { |
Alice Wang | 0b9e110 | 2023-02-02 09:57:06 +0000 | [diff] [blame] | 38 | name: "libdiced_open_dice", |
| 39 | defaults: ["libdiced_open_dice_defaults"], |
| 40 | rustlibs: [ |
Alice Wang | 9c40eca | 2023-02-03 13:10:24 +0000 | [diff] [blame] | 41 | "libopen_dice_bcc_bindgen", |
Alice Wang | 0b9e110 | 2023-02-02 09:57:06 +0000 | [diff] [blame] | 42 | "libopen_dice_cbor_bindgen", |
Alice Wang | 856d656 | 2023-02-03 13:51:08 +0000 | [diff] [blame] | 43 | // For ZVec |
| 44 | "libkeystore2_crypto_rust", |
Alice Wang | f4bd1c6 | 2023-02-08 08:38:44 +0000 | [diff] [blame] | 45 | "libzeroize", |
Alice Wang | 0b9e110 | 2023-02-02 09:57:06 +0000 | [diff] [blame] | 46 | ], |
| 47 | features: [ |
| 48 | "std", |
| 49 | ], |
Alice Wang | 9c40eca | 2023-02-03 13:10:24 +0000 | [diff] [blame] | 50 | whole_static_libs: [ |
| 51 | "libopen_dice_bcc", |
| 52 | ], |
Alice Wang | 988df59 | 2023-02-16 12:05:42 +0000 | [diff] [blame] | 53 | visibility: [ |
| 54 | "//system/security/diced:__subpackages__", |
| 55 | "//packages/modules/Virtualization:__subpackages__", |
Alice Wang | 5e8db6a | 2023-02-17 17:13:18 +0000 | [diff] [blame] | 56 | "//hardware/interfaces/security/dice/aidl:__subpackages__", |
Alice Wang | 988df59 | 2023-02-16 12:05:42 +0000 | [diff] [blame] | 57 | ], |
Alice Wang | 24954b4 | 2023-02-06 10:03:45 +0000 | [diff] [blame] | 58 | } |
| 59 | |
Alice Wang | ceb6642 | 2023-02-07 13:55:33 +0000 | [diff] [blame] | 60 | rust_defaults { |
| 61 | name: "libdiced_open_dice_test_defaults", |
| 62 | crate_name: "diced_open_dice_test", |
| 63 | srcs: ["tests/*.rs"], |
| 64 | test_suites: ["general-tests"], |
| 65 | } |
| 66 | |
| 67 | rust_test { |
| 68 | name: "libdiced_open_dice.integration_test", |
| 69 | defaults: ["libdiced_open_dice_test_defaults"], |
| 70 | rustlibs: [ |
| 71 | "libdiced_open_dice", |
| 72 | ], |
| 73 | } |
| 74 | |
| 75 | rust_test { |
| 76 | name: "libdiced_open_dice_nostd.integration_test", |
| 77 | defaults: ["libdiced_open_dice_test_defaults"], |
| 78 | rustlibs: [ |
| 79 | "libdiced_open_dice_nostd", |
| 80 | ], |
| 81 | } |
Alice Wang | 988df59 | 2023-02-16 12:05:42 +0000 | [diff] [blame] | 82 | |
| 83 | rust_defaults { |
| 84 | name: "libopen_dice_bindgen_nostd.rust_defaults", |
| 85 | bindgen_flags: [ |
| 86 | "--use-core", |
| 87 | "--ctypes-prefix=core::ffi", |
| 88 | "--raw-line=#![no_std]", |
| 89 | ], |
| 90 | no_stdlibs: true, |
| 91 | prefer_rlib: true, |
| 92 | stdlibs: [ |
| 93 | "libcore.rust_sysroot", |
| 94 | "libcompiler_builtins.rust_sysroot", |
| 95 | ], |
| 96 | target: { |
| 97 | musl: { |
| 98 | enabled: false, |
| 99 | }, |
| 100 | glibc: { |
| 101 | enabled: false, |
| 102 | }, |
| 103 | darwin: { |
| 104 | enabled: false, |
| 105 | }, |
| 106 | }, |
| 107 | } |
| 108 | |
| 109 | rust_defaults { |
| 110 | name: "libopen_dice.rust_defaults", |
| 111 | host_supported: true, |
| 112 | vendor_available: true, |
| 113 | apex_available: [ |
| 114 | "//apex_available:platform", |
| 115 | "com.android.compos", |
| 116 | "com.android.virt", |
| 117 | ], |
| 118 | } |
| 119 | |
| 120 | rust_defaults { |
| 121 | name: "libopen_dice_cbor_bindgen.rust_defaults", |
| 122 | defaults: ["libopen_dice.rust_defaults"], |
| 123 | wrapper_src: "bindgen/dice.h", |
| 124 | crate_name: "open_dice_cbor_bindgen", |
| 125 | source_stem: "bindings", |
| 126 | bindgen_flags: [ |
| 127 | "--size_t-is-usize", |
| 128 | "--rustified-enum DiceConfigType", |
| 129 | "--rustified-enum DiceMode", |
| 130 | "--rustified-enum DiceResult", |
| 131 | |
| 132 | // By generating only essential functions, we can make bindings concise and |
| 133 | // optimize compilation time. |
| 134 | "--allowlist-function=DiceDeriveCdiPrivateKeySeed", |
| 135 | "--allowlist-function=DiceDeriveCdiCertificateId", |
| 136 | "--allowlist-function=DiceMainFlow", |
| 137 | "--allowlist-function=DiceHash", |
| 138 | "--allowlist-function=DiceKdf", |
| 139 | "--allowlist-function=DiceKeypairFromSeed", |
| 140 | "--allowlist-function=DiceSign", |
| 141 | "--allowlist-function=DiceVerify", |
| 142 | "--allowlist-function=DiceGenerateCertificate", |
| 143 | |
| 144 | // We also need some constants in addition to the functions. |
| 145 | "--allowlist-var=DICE_CDI_SIZE", |
| 146 | "--allowlist-var=DICE_HASH_SIZE", |
| 147 | "--allowlist-var=DICE_HIDDEN_SIZE", |
| 148 | "--allowlist-var=DICE_INLINE_CONFIG_SIZE", |
| 149 | "--allowlist-var=DICE_PRIVATE_KEY_SEED_SIZE", |
| 150 | "--allowlist-var=DICE_ID_SIZE", |
| 151 | "--allowlist-var=DICE_PUBLIC_KEY_SIZE", |
| 152 | "--allowlist-var=DICE_PRIVATE_KEY_SIZE", |
| 153 | "--allowlist-var=DICE_SIGNATURE_SIZE", |
| 154 | ], |
| 155 | } |
| 156 | |
| 157 | rust_bindgen { |
| 158 | name: "libopen_dice_cbor_bindgen", |
| 159 | defaults: ["libopen_dice_cbor_bindgen.rust_defaults"], |
| 160 | whole_static_libs: ["libopen_dice_cbor"], |
| 161 | // TODO(b/267575445): Remove the visibility to open_dice_cbor once everything |
| 162 | // in open_dice_cbor is moved to open_dice |
| 163 | visibility: [ |
| 164 | "//system/security/diced/open_dice_cbor", |
| 165 | ], |
| 166 | } |
| 167 | |
| 168 | rust_bindgen { |
| 169 | name: "libopen_dice_cbor_bindgen_nostd", |
| 170 | defaults: [ |
| 171 | "libopen_dice_cbor_bindgen.rust_defaults", |
| 172 | "libopen_dice_bindgen_nostd.rust_defaults", |
| 173 | ], |
| 174 | whole_static_libs: ["libopen_dice_cbor_baremetal"], |
| 175 | } |
| 176 | |
| 177 | rust_defaults { |
| 178 | name: "libopen_dice_bcc_bindgen.rust_defaults", |
| 179 | defaults: ["libopen_dice.rust_defaults"], |
| 180 | wrapper_src: "bindgen/android/bcc.h", |
| 181 | crate_name: "open_dice_bcc_bindgen", |
| 182 | source_stem: "bindings", |
| 183 | bindgen_flags: [ |
| 184 | "--size_t-is-usize", |
| 185 | |
| 186 | // By generating only essential functions, we can make bindings concise and |
| 187 | // optimize compilation time. |
| 188 | "--allowlist-function=BccFormatConfigDescriptor", |
| 189 | "--allowlist-function=BccMainFlow", |
| 190 | "--allowlist-function=BccHandoverMainFlow", |
| 191 | "--allowlist-function=BccHandoverParse", |
| 192 | |
| 193 | // We also need some constants in addition to the functions. |
| 194 | "--allowlist-var=BCC_INPUT_COMPONENT_NAME", |
| 195 | "--allowlist-var=BCC_INPUT_COMPONENT_VERSION", |
| 196 | "--allowlist-var=BCC_INPUT_RESETTABLE", |
| 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_bcc_bindgen", |
| 216 | defaults: ["libopen_dice_bcc_bindgen.rust_defaults"], |
| 217 | rustlibs: [ |
| 218 | "libopen_dice_cbor_bindgen", |
| 219 | ], |
| 220 | whole_static_libs: ["libopen_dice_bcc"], |
| 221 | } |
| 222 | |
| 223 | rust_bindgen { |
| 224 | name: "libopen_dice_bcc_bindgen_nostd", |
| 225 | defaults: [ |
| 226 | "libopen_dice_bcc_bindgen.rust_defaults", |
| 227 | "libopen_dice_bindgen_nostd.rust_defaults", |
| 228 | ], |
| 229 | rustlibs: [ |
| 230 | "libopen_dice_cbor_bindgen_nostd", |
| 231 | ], |
| 232 | whole_static_libs: ["libopen_dice_bcc_baremetal"], |
| 233 | } |
| 234 | |
| 235 | rust_test { |
| 236 | name: "libopen_dice_cbor_bindgen_test", |
| 237 | srcs: [ |
| 238 | ":libopen_dice_cbor_bindgen", |
| 239 | ], |
| 240 | crate_name: "open_dice_cbor_bindgen_test", |
| 241 | test_suites: ["general-tests"], |
| 242 | auto_gen_config: true, |
| 243 | clippy_lints: "none", |
| 244 | lints: "none", |
| 245 | } |
| 246 | |
| 247 | rust_test { |
| 248 | name: "libopen_dice_bcc_bindgen_test", |
| 249 | srcs: [ |
| 250 | ":libopen_dice_bcc_bindgen", |
| 251 | ], |
| 252 | crate_name: "open_dice_bcc_bindgen_test", |
| 253 | rustlibs: [ |
| 254 | "libopen_dice_cbor_bindgen", |
| 255 | ], |
| 256 | test_suites: ["general-tests"], |
| 257 | auto_gen_config: true, |
| 258 | clippy_lints: "none", |
| 259 | lints: "none", |
| 260 | } |