blob: 75f70c3c3bf3c72f60a53782389a31985b4ae18c [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
66rust_defaults {
67 name: "libdiced_open_dice_test_defaults",
68 crate_name: "diced_open_dice_test",
Alan Stokesd7aea452024-03-14 14:20:04 +000069 srcs: ["tests/api_test.rs"],
Alice Wang94a06352023-10-16 07:19:10 +000070 test_suites: ["general-tests"],
71}
72
73rust_test {
74 name: "libdiced_open_dice.integration_test",
75 defaults: ["libdiced_open_dice_test_defaults"],
76 rustlibs: [
77 "libdiced_open_dice",
Gil Cukiermane431d962025-01-22 13:25:52 -080078 "libcoset",
Alice Wang94a06352023-10-16 07:19:10 +000079 ],
80}
81
82rust_test {
83 name: "libdiced_open_dice_nostd.integration_test",
84 defaults: ["libdiced_open_dice_test_defaults"],
85 rustlibs: [
86 "libdiced_open_dice_nostd",
Gil Cukiermane431d962025-01-22 13:25:52 -080087 "libcoset_nostd",
Alice Wang94a06352023-10-16 07:19:10 +000088 ],
89}
90
91rust_defaults {
92 name: "libopen_dice_bindgen_nostd.rust_defaults",
93 bindgen_flags: [
94 "--use-core",
95 "--ctypes-prefix=core::ffi",
96 "--raw-line=#![no_std]",
97 ],
Ivan Lozano6561e342024-08-07 14:16:39 +000098 dylib: {
99 enabled: false,
100 },
Alice Wang94a06352023-10-16 07:19:10 +0000101 no_stdlibs: true,
102 prefer_rlib: true,
103 stdlibs: [
104 "libcore.rust_sysroot",
105 "libcompiler_builtins.rust_sysroot",
106 ],
107 target: {
108 musl: {
109 enabled: false,
110 },
111 glibc: {
112 enabled: false,
113 },
114 darwin: {
115 enabled: false,
116 },
117 },
118}
119
120rust_defaults {
121 name: "libopen_dice.rust_defaults",
122 host_supported: true,
123 vendor_available: true,
124 apex_available: [
125 "//apex_available:platform",
126 "com.android.compos",
127 "com.android.virt",
128 ],
129}
130
131rust_defaults {
132 name: "libopen_dice_cbor_bindgen.rust_defaults",
Gil Cukiermanf96915b2024-12-13 16:32:12 -0500133 wrapper_src: "bindgen/dice/dice.h",
Alice Wang94a06352023-10-16 07:19:10 +0000134 crate_name: "open_dice_cbor_bindgen",
135 source_stem: "bindings",
136 bindgen_flags: [
137 "--rustified-enum DiceConfigType",
138 "--rustified-enum DiceMode",
139 "--rustified-enum DiceResult",
Alice Wang14ca76a2024-11-05 12:41:57 +0000140 "--rustified-enum DicePrincipal",
Alice Wang94a06352023-10-16 07:19:10 +0000141
142 // By generating only essential functions, we can make bindings concise and
143 // optimize compilation time.
144 "--allowlist-function=DiceDeriveCdiPrivateKeySeed",
145 "--allowlist-function=DiceDeriveCdiCertificateId",
146 "--allowlist-function=DiceMainFlow",
147 "--allowlist-function=DiceHash",
148 "--allowlist-function=DiceKdf",
149 "--allowlist-function=DiceKeypairFromSeed",
150 "--allowlist-function=DiceSign",
Gil Cukiermane431d962025-01-22 13:25:52 -0800151 "--allowlist-function=DiceCoseSignAndEncodeSign1",
Alice Wang94a06352023-10-16 07:19:10 +0000152 "--allowlist-function=DiceVerify",
153 "--allowlist-function=DiceGenerateCertificate",
154
155 // We also need some constants in addition to the functions.
156 "--allowlist-var=DICE_CDI_SIZE",
157 "--allowlist-var=DICE_HASH_SIZE",
158 "--allowlist-var=DICE_HIDDEN_SIZE",
159 "--allowlist-var=DICE_INLINE_CONFIG_SIZE",
160 "--allowlist-var=DICE_PRIVATE_KEY_SEED_SIZE",
161 "--allowlist-var=DICE_ID_SIZE",
Alice Wangce6cbd72024-11-22 11:19:05 +0000162 "--allowlist-var=DICE_PRIVATE_KEY_BUFFER_SIZE",
Alice Wang94a06352023-10-16 07:19:10 +0000163 ],
164}
165
166rust_bindgen {
167 name: "libopen_dice_cbor_bindgen",
168 defaults: [
169 "libopen_dice.rust_defaults",
170 "libopen_dice_cbor_bindgen.rust_defaults",
171 ],
172 whole_static_libs: ["libopen_dice_cbor"],
173}
174
175rust_bindgen {
176 name: "libopen_dice_cbor_bindgen_nostd",
177 defaults: [
178 "libopen_dice_cbor_bindgen.rust_defaults",
179 "libopen_dice_bindgen_nostd.rust_defaults",
180 ],
Alice Wang87fbc4b2024-11-05 13:09:58 +0000181 bindgen_flags: [
182 "--rustified-enum DiceKeyAlgorithm",
183 "--allowlist-type=DiceContext",
184 ],
185 whole_static_libs: ["libopen_dice_cbor_baremetal_multialg"],
Alice Wang94a06352023-10-16 07:19:10 +0000186}
187
188rust_defaults {
189 name: "libopen_dice_android_bindgen.rust_defaults",
Gil Cukiermanf96915b2024-12-13 16:32:12 -0500190 wrapper_src: "bindgen/android/android.h",
Alice Wang94a06352023-10-16 07:19:10 +0000191 crate_name: "open_dice_android_bindgen",
192 source_stem: "bindings",
193 bindgen_flags: [
194 // By generating only essential functions, we can make bindings concise and
195 // optimize compilation time.
196 "--allowlist-function=DiceAndroidFormatConfigDescriptor",
197 "--allowlist-function=DiceAndroidMainFlow",
198 "--allowlist-function=DiceAndroidHandoverMainFlow",
199 "--allowlist-function=DiceAndroidHandoverParse",
200
201 // We also need some constants in addition to the functions.
202 "--allowlist-var=DICE_ANDROID_CONFIG_.*",
203
204 // Prevent DiceInputValues from being generated a second time and
205 // import it instead from open_dice_cbor_bindgen.
206 "--blocklist-type=DiceInputValues_",
207 "--blocklist-type=DiceInputValues",
208 "--raw-line",
209 "pub use open_dice_cbor_bindgen::DiceInputValues;",
210
211 // Prevent DiceResult from being generated a second time and
212 // import it instead from open_dice_cbor_bindgen.
213 "--blocklist-type=DiceResult",
214 "--raw-line",
215 "pub use open_dice_cbor_bindgen::DiceResult;",
216 ],
217
218}
219
220rust_bindgen {
221 name: "libopen_dice_android_bindgen",
222 defaults: [
223 "libopen_dice.rust_defaults",
224 "libopen_dice_android_bindgen.rust_defaults",
225 ],
226 rustlibs: [
227 "libopen_dice_cbor_bindgen",
228 ],
229 whole_static_libs: ["libopen_dice_android"],
230}
231
232rust_bindgen {
233 name: "libopen_dice_android_bindgen_nostd",
234 defaults: [
235 "libopen_dice_android_bindgen.rust_defaults",
236 "libopen_dice_bindgen_nostd.rust_defaults",
237 ],
238 rustlibs: [
239 "libopen_dice_cbor_bindgen_nostd",
240 ],
Alice Wang87fbc4b2024-11-05 13:09:58 +0000241 whole_static_libs: ["libopen_dice_android_baremetal_multialg"],
Alice Wang94a06352023-10-16 07:19:10 +0000242}
243
244rust_test {
245 name: "libopen_dice_cbor_bindgen_test",
246 srcs: [
247 ":libopen_dice_cbor_bindgen",
248 ],
249 crate_name: "open_dice_cbor_bindgen_test",
250 test_suites: ["general-tests"],
251 auto_gen_config: true,
252 clippy_lints: "none",
253 lints: "none",
254}
255
256rust_test {
257 name: "libopen_dice_android_bindgen_test",
258 srcs: [
259 ":libopen_dice_android_bindgen",
260 ],
261 crate_name: "open_dice_android_bindgen_test",
262 rustlibs: [
263 "libopen_dice_cbor_bindgen",
264 ],
265 test_suites: ["general-tests"],
266 auto_gen_config: true,
267 clippy_lints: "none",
268 lints: "none",
269}
Gil Cukiermanf96915b2024-12-13 16:32:12 -0500270
271dirgroup {
272 name: "trusty_dirgroup_packages_modules_virtualization_libs_open_dice",
273 visibility: ["//trusty/vendor/google/aosp/scripts"],
274 dirs: ["."],
275}