blob: 9e4544d9a0840cc9e71c21c4d0a873f6a6300411 [file] [log] [blame]
Alice Wang94a06352023-10-16 07:19:10 +00001package {
2 default_visibility: [":__subpackages__"],
3 default_applicable_licenses: ["Android-Apache-2.0"],
4}
5
6rust_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
13rust_library_rlib {
14 name: "libdiced_open_dice_nostd",
15 defaults: ["libdiced_open_dice_defaults"],
16 rustlibs: [
Alice Wangb1ed0842024-11-05 09:45:37 +000017 "libcoset_nostd",
Alice Wang94a06352023-10-16 07:19:10 +000018 "libopen_dice_android_bindgen_nostd",
19 "libopen_dice_cbor_bindgen_nostd",
20 "libzeroize_nostd",
21 ],
Alice Wang87fbc4b2024-11-05 13:09:58 +000022 features: [
23 "multialg",
24 ],
Alice Wang94a06352023-10-16 07:19:10 +000025 whole_static_libs: [
Alice Wang94a06352023-10-16 07:19:10 +000026 "libcrypto_baremetal",
27 ],
28 visibility: [
29 "//packages/modules/Virtualization:__subpackages__",
30 ],
31}
32
33rust_library {
34 name: "libdiced_open_dice",
35 defaults: ["libdiced_open_dice_defaults"],
Hasini Gunasingheb39fc152023-12-14 11:13:51 +000036 host_supported: true,
Alice Wang94a06352023-10-16 07:19:10 +000037 vendor_available: true,
38 rustlibs: [
Alice Wangb1ed0842024-11-05 09:45:37 +000039 "libcoset",
Alice Wang94a06352023-10-16 07:19:10 +000040 "libopen_dice_android_bindgen",
41 "libopen_dice_cbor_bindgen",
Nikita Ioffeab035a52024-03-14 00:33:50 +000042 "libserde",
Alice Wang94a06352023-10-16 07:19:10 +000043 "libzeroize",
44 ],
45 features: [
Nikita Ioffeab035a52024-03-14 00:33:50 +000046 "serde_derive",
Alice Wang94a06352023-10-16 07:19:10 +000047 "std",
48 ],
Nikita Ioffeab035a52024-03-14 00:33:50 +000049 proc_macros: ["libserde_derive"],
Alice Wang94a06352023-10-16 07:19:10 +000050 shared_libs: [
51 "libcrypto",
52 ],
Alice Wang94a06352023-10-16 07:19:10 +000053 visibility: [
Shikha Panwarc8ba73c2024-01-03 18:34:38 +000054 "//hardware/interfaces/security/secretkeeper/aidl/vts",
Alice Wang94a06352023-10-16 07:19:10 +000055 "//packages/modules/Virtualization:__subpackages__",
Hasini Gunasinghe19234c42023-12-13 14:47:47 +000056 "//system/authgraph/tests:__subpackages__",
Shikha Panwar0ebd67e2023-12-22 23:58:31 +000057 "//system/secretkeeper/client:__subpackages__",
Istvan Nador8f2ab792024-09-10 11:08:55 +000058 "//system/software_defined_vehicle:__subpackages__",
Alice Wang94a06352023-10-16 07:19:10 +000059 ],
60 apex_available: [
61 "//apex_available:platform",
62 "com.android.virt",
63 ],
Rafael Perez Torres1d0cc772025-03-17 14:22:27 +000064 min_sdk_version: "35",
Alice Wang94a06352023-10-16 07:19:10 +000065}
66
Vanand Gasparyan88cd3932025-03-03 14:07:54 +000067rust_library {
68 name: "libdiced_open_dice_multialg",
69 defaults: ["libdiced_open_dice_defaults"],
70 host_supported: true,
71 vendor_available: true,
72 rustlibs: [
73 "libcoset",
74 "libopen_dice_android_bindgen_multialg",
75 "libopen_dice_cbor_bindgen_multialg",
76 "libzeroize",
77 ],
78 features: [
79 "std",
80 "multialg",
81 ],
82 shared_libs: [
83 "libcrypto",
84 ],
85 visibility: [
86 "//system/software_defined_vehicle:__subpackages__",
87 ],
88 apex_available: [
89 "//apex_available:platform",
90 "com.android.virt",
91 ],
Rafael Perez Torres1d0cc772025-03-17 14:22:27 +000092 min_sdk_version: "35",
Vanand Gasparyan88cd3932025-03-03 14:07:54 +000093}
94
Alice Wang94a06352023-10-16 07:19:10 +000095rust_defaults {
96 name: "libdiced_open_dice_test_defaults",
97 crate_name: "diced_open_dice_test",
Alan Stokesd7aea452024-03-14 14:20:04 +000098 srcs: ["tests/api_test.rs"],
Alice Wang94a06352023-10-16 07:19:10 +000099 test_suites: ["general-tests"],
100}
101
102rust_test {
103 name: "libdiced_open_dice.integration_test",
104 defaults: ["libdiced_open_dice_test_defaults"],
105 rustlibs: [
106 "libdiced_open_dice",
Gil Cukiermane431d962025-01-22 13:25:52 -0800107 "libcoset",
Alice Wang94a06352023-10-16 07:19:10 +0000108 ],
109}
110
111rust_test {
Vanand Gasparyan88cd3932025-03-03 14:07:54 +0000112 name: "libdiced_open_dice_multialg.integration_test",
113 defaults: ["libdiced_open_dice_test_defaults"],
114 rustlibs: [
115 "libdiced_open_dice_multialg",
116 "libcoset",
117 ],
118 features: [
119 "multialg",
120 ],
121}
122
123rust_test {
Alice Wang94a06352023-10-16 07:19:10 +0000124 name: "libdiced_open_dice_nostd.integration_test",
125 defaults: ["libdiced_open_dice_test_defaults"],
126 rustlibs: [
127 "libdiced_open_dice_nostd",
Gil Cukiermane431d962025-01-22 13:25:52 -0800128 "libcoset_nostd",
Alice Wang94a06352023-10-16 07:19:10 +0000129 ],
130}
131
132rust_defaults {
133 name: "libopen_dice_bindgen_nostd.rust_defaults",
134 bindgen_flags: [
135 "--use-core",
136 "--ctypes-prefix=core::ffi",
137 "--raw-line=#![no_std]",
138 ],
Ivan Lozano6561e342024-08-07 14:16:39 +0000139 dylib: {
140 enabled: false,
141 },
Alice Wang94a06352023-10-16 07:19:10 +0000142 no_stdlibs: true,
143 prefer_rlib: true,
144 stdlibs: [
145 "libcore.rust_sysroot",
146 "libcompiler_builtins.rust_sysroot",
147 ],
148 target: {
149 musl: {
150 enabled: false,
151 },
152 glibc: {
153 enabled: false,
154 },
155 darwin: {
156 enabled: false,
157 },
158 },
159}
160
161rust_defaults {
162 name: "libopen_dice.rust_defaults",
163 host_supported: true,
164 vendor_available: true,
165 apex_available: [
166 "//apex_available:platform",
167 "com.android.compos",
168 "com.android.virt",
169 ],
170}
171
172rust_defaults {
173 name: "libopen_dice_cbor_bindgen.rust_defaults",
Gil Cukiermanf96915b2024-12-13 16:32:12 -0500174 wrapper_src: "bindgen/dice/dice.h",
Alice Wang94a06352023-10-16 07:19:10 +0000175 crate_name: "open_dice_cbor_bindgen",
176 source_stem: "bindings",
177 bindgen_flags: [
178 "--rustified-enum DiceConfigType",
179 "--rustified-enum DiceMode",
180 "--rustified-enum DiceResult",
Alice Wang14ca76a2024-11-05 12:41:57 +0000181 "--rustified-enum DicePrincipal",
Alice Wang94a06352023-10-16 07:19:10 +0000182
183 // By generating only essential functions, we can make bindings concise and
184 // optimize compilation time.
185 "--allowlist-function=DiceDeriveCdiPrivateKeySeed",
186 "--allowlist-function=DiceDeriveCdiCertificateId",
187 "--allowlist-function=DiceMainFlow",
188 "--allowlist-function=DiceHash",
189 "--allowlist-function=DiceKdf",
190 "--allowlist-function=DiceKeypairFromSeed",
191 "--allowlist-function=DiceSign",
Gil Cukiermane431d962025-01-22 13:25:52 -0800192 "--allowlist-function=DiceCoseSignAndEncodeSign1",
Alice Wang94a06352023-10-16 07:19:10 +0000193 "--allowlist-function=DiceVerify",
194 "--allowlist-function=DiceGenerateCertificate",
195
196 // We also need some constants in addition to the functions.
197 "--allowlist-var=DICE_CDI_SIZE",
198 "--allowlist-var=DICE_HASH_SIZE",
199 "--allowlist-var=DICE_HIDDEN_SIZE",
200 "--allowlist-var=DICE_INLINE_CONFIG_SIZE",
201 "--allowlist-var=DICE_PRIVATE_KEY_SEED_SIZE",
202 "--allowlist-var=DICE_ID_SIZE",
Alice Wangce6cbd72024-11-22 11:19:05 +0000203 "--allowlist-var=DICE_PRIVATE_KEY_BUFFER_SIZE",
Alice Wang94a06352023-10-16 07:19:10 +0000204 ],
205}
206
207rust_bindgen {
208 name: "libopen_dice_cbor_bindgen",
209 defaults: [
210 "libopen_dice.rust_defaults",
211 "libopen_dice_cbor_bindgen.rust_defaults",
212 ],
213 whole_static_libs: ["libopen_dice_cbor"],
Ivan Lozano36f783f2025-01-28 21:41:57 +0000214 shared_libs: ["libcrypto"],
Rafael Perez Torres1d0cc772025-03-17 14:22:27 +0000215 min_sdk_version: "35",
Alice Wang94a06352023-10-16 07:19:10 +0000216}
217
218rust_bindgen {
Vanand Gasparyan88cd3932025-03-03 14:07:54 +0000219 name: "libopen_dice_cbor_bindgen_multialg",
220 defaults: [
221 "libopen_dice.rust_defaults",
222 "libopen_dice_cbor_bindgen.rust_defaults",
223 ],
224 bindgen_flags: [
225 "--rustified-enum DiceKeyAlgorithm",
226 "--allowlist-type=DiceContext",
227 ],
228 whole_static_libs: ["libopen_dice_cbor_multialg"],
229 shared_libs: ["libcrypto"],
Rafael Perez Torres1d0cc772025-03-17 14:22:27 +0000230 min_sdk_version: "35",
Vanand Gasparyan88cd3932025-03-03 14:07:54 +0000231}
232
233rust_bindgen {
Alice Wang94a06352023-10-16 07:19:10 +0000234 name: "libopen_dice_cbor_bindgen_nostd",
235 defaults: [
236 "libopen_dice_cbor_bindgen.rust_defaults",
237 "libopen_dice_bindgen_nostd.rust_defaults",
238 ],
Alice Wang87fbc4b2024-11-05 13:09:58 +0000239 bindgen_flags: [
240 "--rustified-enum DiceKeyAlgorithm",
241 "--allowlist-type=DiceContext",
242 ],
243 whole_static_libs: ["libopen_dice_cbor_baremetal_multialg"],
Alice Wang94a06352023-10-16 07:19:10 +0000244}
245
246rust_defaults {
247 name: "libopen_dice_android_bindgen.rust_defaults",
Gil Cukiermanf96915b2024-12-13 16:32:12 -0500248 wrapper_src: "bindgen/android/android.h",
Alice Wang94a06352023-10-16 07:19:10 +0000249 crate_name: "open_dice_android_bindgen",
250 source_stem: "bindings",
251 bindgen_flags: [
252 // By generating only essential functions, we can make bindings concise and
253 // optimize compilation time.
254 "--allowlist-function=DiceAndroidFormatConfigDescriptor",
255 "--allowlist-function=DiceAndroidMainFlow",
256 "--allowlist-function=DiceAndroidHandoverMainFlow",
257 "--allowlist-function=DiceAndroidHandoverParse",
258
259 // We also need some constants in addition to the functions.
260 "--allowlist-var=DICE_ANDROID_CONFIG_.*",
261
262 // Prevent DiceInputValues from being generated a second time and
263 // import it instead from open_dice_cbor_bindgen.
264 "--blocklist-type=DiceInputValues_",
265 "--blocklist-type=DiceInputValues",
266 "--raw-line",
267 "pub use open_dice_cbor_bindgen::DiceInputValues;",
268
269 // Prevent DiceResult from being generated a second time and
270 // import it instead from open_dice_cbor_bindgen.
271 "--blocklist-type=DiceResult",
272 "--raw-line",
273 "pub use open_dice_cbor_bindgen::DiceResult;",
274 ],
275
276}
277
278rust_bindgen {
279 name: "libopen_dice_android_bindgen",
280 defaults: [
281 "libopen_dice.rust_defaults",
282 "libopen_dice_android_bindgen.rust_defaults",
283 ],
284 rustlibs: [
285 "libopen_dice_cbor_bindgen",
286 ],
287 whole_static_libs: ["libopen_dice_android"],
Rafael Perez Torres1d0cc772025-03-17 14:22:27 +0000288 min_sdk_version: "35",
Alice Wang94a06352023-10-16 07:19:10 +0000289}
290
291rust_bindgen {
Vanand Gasparyan88cd3932025-03-03 14:07:54 +0000292 name: "libopen_dice_android_bindgen_multialg",
293 defaults: [
294 "libopen_dice.rust_defaults",
295 "libopen_dice_android_bindgen.rust_defaults",
296 ],
297 rustlibs: [
298 "libopen_dice_cbor_bindgen_multialg",
299 ],
300 whole_static_libs: ["libopen_dice_android_multialg"],
Rafael Perez Torres1d0cc772025-03-17 14:22:27 +0000301 min_sdk_version: "35",
Vanand Gasparyan88cd3932025-03-03 14:07:54 +0000302}
303
304rust_bindgen {
Alice Wang94a06352023-10-16 07:19:10 +0000305 name: "libopen_dice_android_bindgen_nostd",
306 defaults: [
307 "libopen_dice_android_bindgen.rust_defaults",
308 "libopen_dice_bindgen_nostd.rust_defaults",
309 ],
310 rustlibs: [
311 "libopen_dice_cbor_bindgen_nostd",
312 ],
Alice Wang87fbc4b2024-11-05 13:09:58 +0000313 whole_static_libs: ["libopen_dice_android_baremetal_multialg"],
Alice Wang94a06352023-10-16 07:19:10 +0000314}
315
316rust_test {
317 name: "libopen_dice_cbor_bindgen_test",
318 srcs: [
319 ":libopen_dice_cbor_bindgen",
320 ],
321 crate_name: "open_dice_cbor_bindgen_test",
322 test_suites: ["general-tests"],
323 auto_gen_config: true,
324 clippy_lints: "none",
325 lints: "none",
326}
327
328rust_test {
329 name: "libopen_dice_android_bindgen_test",
330 srcs: [
331 ":libopen_dice_android_bindgen",
332 ],
333 crate_name: "open_dice_android_bindgen_test",
334 rustlibs: [
335 "libopen_dice_cbor_bindgen",
336 ],
337 test_suites: ["general-tests"],
338 auto_gen_config: true,
339 clippy_lints: "none",
340 lints: "none",
341}
Gil Cukiermanf96915b2024-12-13 16:32:12 -0500342
343dirgroup {
344 name: "trusty_dirgroup_packages_modules_virtualization_libs_open_dice",
345 visibility: ["//trusty/vendor/google/aosp/scripts"],
346 dirs: ["."],
347}