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