blob: 739f245bc61de203a06abd49e8237c0c5bd434f3 [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 ],
64}
65
Vanand Gasparyan88cd3932025-03-03 14:07:54 +000066rust_library {
67 name: "libdiced_open_dice_multialg",
68 defaults: ["libdiced_open_dice_defaults"],
69 host_supported: true,
70 vendor_available: true,
71 rustlibs: [
72 "libcoset",
73 "libopen_dice_android_bindgen_multialg",
74 "libopen_dice_cbor_bindgen_multialg",
75 "libzeroize",
76 ],
77 features: [
78 "std",
79 "multialg",
80 ],
81 shared_libs: [
82 "libcrypto",
83 ],
84 visibility: [
85 "//system/software_defined_vehicle:__subpackages__",
86 ],
87 apex_available: [
88 "//apex_available:platform",
89 "com.android.virt",
90 ],
91}
92
Alice Wang94a06352023-10-16 07:19:10 +000093rust_defaults {
94 name: "libdiced_open_dice_test_defaults",
95 crate_name: "diced_open_dice_test",
Alan Stokesd7aea452024-03-14 14:20:04 +000096 srcs: ["tests/api_test.rs"],
Alice Wang94a06352023-10-16 07:19:10 +000097 test_suites: ["general-tests"],
98}
99
100rust_test {
101 name: "libdiced_open_dice.integration_test",
102 defaults: ["libdiced_open_dice_test_defaults"],
103 rustlibs: [
104 "libdiced_open_dice",
Gil Cukiermane431d962025-01-22 13:25:52 -0800105 "libcoset",
Alice Wang94a06352023-10-16 07:19:10 +0000106 ],
107}
108
109rust_test {
Vanand Gasparyan88cd3932025-03-03 14:07:54 +0000110 name: "libdiced_open_dice_multialg.integration_test",
111 defaults: ["libdiced_open_dice_test_defaults"],
112 rustlibs: [
113 "libdiced_open_dice_multialg",
114 "libcoset",
115 ],
116 features: [
117 "multialg",
118 ],
119}
120
121rust_test {
Alice Wang94a06352023-10-16 07:19:10 +0000122 name: "libdiced_open_dice_nostd.integration_test",
123 defaults: ["libdiced_open_dice_test_defaults"],
124 rustlibs: [
125 "libdiced_open_dice_nostd",
Gil Cukiermane431d962025-01-22 13:25:52 -0800126 "libcoset_nostd",
Alice Wang94a06352023-10-16 07:19:10 +0000127 ],
128}
129
130rust_defaults {
131 name: "libopen_dice_bindgen_nostd.rust_defaults",
132 bindgen_flags: [
133 "--use-core",
134 "--ctypes-prefix=core::ffi",
135 "--raw-line=#![no_std]",
136 ],
Ivan Lozano6561e342024-08-07 14:16:39 +0000137 dylib: {
138 enabled: false,
139 },
Alice Wang94a06352023-10-16 07:19:10 +0000140 no_stdlibs: true,
141 prefer_rlib: true,
142 stdlibs: [
143 "libcore.rust_sysroot",
144 "libcompiler_builtins.rust_sysroot",
145 ],
146 target: {
147 musl: {
148 enabled: false,
149 },
150 glibc: {
151 enabled: false,
152 },
153 darwin: {
154 enabled: false,
155 },
156 },
157}
158
159rust_defaults {
160 name: "libopen_dice.rust_defaults",
161 host_supported: true,
162 vendor_available: true,
163 apex_available: [
164 "//apex_available:platform",
165 "com.android.compos",
166 "com.android.virt",
167 ],
168}
169
170rust_defaults {
171 name: "libopen_dice_cbor_bindgen.rust_defaults",
Gil Cukiermanf96915b2024-12-13 16:32:12 -0500172 wrapper_src: "bindgen/dice/dice.h",
Alice Wang94a06352023-10-16 07:19:10 +0000173 crate_name: "open_dice_cbor_bindgen",
174 source_stem: "bindings",
175 bindgen_flags: [
176 "--rustified-enum DiceConfigType",
177 "--rustified-enum DiceMode",
178 "--rustified-enum DiceResult",
Alice Wang14ca76a2024-11-05 12:41:57 +0000179 "--rustified-enum DicePrincipal",
Alice Wang94a06352023-10-16 07:19:10 +0000180
181 // By generating only essential functions, we can make bindings concise and
182 // optimize compilation time.
183 "--allowlist-function=DiceDeriveCdiPrivateKeySeed",
184 "--allowlist-function=DiceDeriveCdiCertificateId",
185 "--allowlist-function=DiceMainFlow",
186 "--allowlist-function=DiceHash",
187 "--allowlist-function=DiceKdf",
188 "--allowlist-function=DiceKeypairFromSeed",
189 "--allowlist-function=DiceSign",
Gil Cukiermane431d962025-01-22 13:25:52 -0800190 "--allowlist-function=DiceCoseSignAndEncodeSign1",
Alice Wang94a06352023-10-16 07:19:10 +0000191 "--allowlist-function=DiceVerify",
192 "--allowlist-function=DiceGenerateCertificate",
193
194 // We also need some constants in addition to the functions.
195 "--allowlist-var=DICE_CDI_SIZE",
196 "--allowlist-var=DICE_HASH_SIZE",
197 "--allowlist-var=DICE_HIDDEN_SIZE",
198 "--allowlist-var=DICE_INLINE_CONFIG_SIZE",
199 "--allowlist-var=DICE_PRIVATE_KEY_SEED_SIZE",
200 "--allowlist-var=DICE_ID_SIZE",
Alice Wangce6cbd72024-11-22 11:19:05 +0000201 "--allowlist-var=DICE_PRIVATE_KEY_BUFFER_SIZE",
Alice Wang94a06352023-10-16 07:19:10 +0000202 ],
203}
204
205rust_bindgen {
206 name: "libopen_dice_cbor_bindgen",
207 defaults: [
208 "libopen_dice.rust_defaults",
209 "libopen_dice_cbor_bindgen.rust_defaults",
210 ],
211 whole_static_libs: ["libopen_dice_cbor"],
Ivan Lozano36f783f2025-01-28 21:41:57 +0000212 shared_libs: ["libcrypto"],
Alice Wang94a06352023-10-16 07:19:10 +0000213}
214
215rust_bindgen {
Vanand Gasparyan88cd3932025-03-03 14:07:54 +0000216 name: "libopen_dice_cbor_bindgen_multialg",
217 defaults: [
218 "libopen_dice.rust_defaults",
219 "libopen_dice_cbor_bindgen.rust_defaults",
220 ],
221 bindgen_flags: [
222 "--rustified-enum DiceKeyAlgorithm",
223 "--allowlist-type=DiceContext",
224 ],
225 whole_static_libs: ["libopen_dice_cbor_multialg"],
226 shared_libs: ["libcrypto"],
227}
228
229rust_bindgen {
Alice Wang94a06352023-10-16 07:19:10 +0000230 name: "libopen_dice_cbor_bindgen_nostd",
231 defaults: [
232 "libopen_dice_cbor_bindgen.rust_defaults",
233 "libopen_dice_bindgen_nostd.rust_defaults",
234 ],
Alice Wang87fbc4b2024-11-05 13:09:58 +0000235 bindgen_flags: [
236 "--rustified-enum DiceKeyAlgorithm",
237 "--allowlist-type=DiceContext",
238 ],
239 whole_static_libs: ["libopen_dice_cbor_baremetal_multialg"],
Alice Wang94a06352023-10-16 07:19:10 +0000240}
241
242rust_defaults {
243 name: "libopen_dice_android_bindgen.rust_defaults",
Gil Cukiermanf96915b2024-12-13 16:32:12 -0500244 wrapper_src: "bindgen/android/android.h",
Alice Wang94a06352023-10-16 07:19:10 +0000245 crate_name: "open_dice_android_bindgen",
246 source_stem: "bindings",
247 bindgen_flags: [
248 // By generating only essential functions, we can make bindings concise and
249 // optimize compilation time.
250 "--allowlist-function=DiceAndroidFormatConfigDescriptor",
251 "--allowlist-function=DiceAndroidMainFlow",
252 "--allowlist-function=DiceAndroidHandoverMainFlow",
253 "--allowlist-function=DiceAndroidHandoverParse",
254
255 // We also need some constants in addition to the functions.
256 "--allowlist-var=DICE_ANDROID_CONFIG_.*",
257
258 // Prevent DiceInputValues from being generated a second time and
259 // import it instead from open_dice_cbor_bindgen.
260 "--blocklist-type=DiceInputValues_",
261 "--blocklist-type=DiceInputValues",
262 "--raw-line",
263 "pub use open_dice_cbor_bindgen::DiceInputValues;",
264
265 // Prevent DiceResult from being generated a second time and
266 // import it instead from open_dice_cbor_bindgen.
267 "--blocklist-type=DiceResult",
268 "--raw-line",
269 "pub use open_dice_cbor_bindgen::DiceResult;",
270 ],
271
272}
273
274rust_bindgen {
275 name: "libopen_dice_android_bindgen",
276 defaults: [
277 "libopen_dice.rust_defaults",
278 "libopen_dice_android_bindgen.rust_defaults",
279 ],
280 rustlibs: [
281 "libopen_dice_cbor_bindgen",
282 ],
283 whole_static_libs: ["libopen_dice_android"],
284}
285
286rust_bindgen {
Vanand Gasparyan88cd3932025-03-03 14:07:54 +0000287 name: "libopen_dice_android_bindgen_multialg",
288 defaults: [
289 "libopen_dice.rust_defaults",
290 "libopen_dice_android_bindgen.rust_defaults",
291 ],
292 rustlibs: [
293 "libopen_dice_cbor_bindgen_multialg",
294 ],
295 whole_static_libs: ["libopen_dice_android_multialg"],
296}
297
298rust_bindgen {
Alice Wang94a06352023-10-16 07:19:10 +0000299 name: "libopen_dice_android_bindgen_nostd",
300 defaults: [
301 "libopen_dice_android_bindgen.rust_defaults",
302 "libopen_dice_bindgen_nostd.rust_defaults",
303 ],
304 rustlibs: [
305 "libopen_dice_cbor_bindgen_nostd",
306 ],
Alice Wang87fbc4b2024-11-05 13:09:58 +0000307 whole_static_libs: ["libopen_dice_android_baremetal_multialg"],
Alice Wang94a06352023-10-16 07:19:10 +0000308}
309
310rust_test {
311 name: "libopen_dice_cbor_bindgen_test",
312 srcs: [
313 ":libopen_dice_cbor_bindgen",
314 ],
315 crate_name: "open_dice_cbor_bindgen_test",
316 test_suites: ["general-tests"],
317 auto_gen_config: true,
318 clippy_lints: "none",
319 lints: "none",
320}
321
322rust_test {
323 name: "libopen_dice_android_bindgen_test",
324 srcs: [
325 ":libopen_dice_android_bindgen",
326 ],
327 crate_name: "open_dice_android_bindgen_test",
328 rustlibs: [
329 "libopen_dice_cbor_bindgen",
330 ],
331 test_suites: ["general-tests"],
332 auto_gen_config: true,
333 clippy_lints: "none",
334 lints: "none",
335}
Gil Cukiermanf96915b2024-12-13 16:32:12 -0500336
337dirgroup {
338 name: "trusty_dirgroup_packages_modules_virtualization_libs_open_dice",
339 visibility: ["//trusty/vendor/google/aosp/scripts"],
340 dirs: ["."],
341}