blob: c60260ec59099849d704a77eba94743b4e7e2672 [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 Wang94a06352023-10-16 07:19:10 +000022 whole_static_libs: [
Alice Wang94a06352023-10-16 07:19:10 +000023 "libcrypto_baremetal",
24 ],
25 visibility: [
26 "//packages/modules/Virtualization:__subpackages__",
27 ],
28}
29
30rust_library {
31 name: "libdiced_open_dice",
32 defaults: ["libdiced_open_dice_defaults"],
Hasini Gunasingheb39fc152023-12-14 11:13:51 +000033 host_supported: true,
Alice Wang94a06352023-10-16 07:19:10 +000034 vendor_available: true,
35 rustlibs: [
Alice Wangb1ed0842024-11-05 09:45:37 +000036 "libcoset",
Alice Wang94a06352023-10-16 07:19:10 +000037 "libopen_dice_android_bindgen",
38 "libopen_dice_cbor_bindgen",
Nikita Ioffeab035a52024-03-14 00:33:50 +000039 "libserde",
Alice Wang94a06352023-10-16 07:19:10 +000040 "libzeroize",
41 ],
42 features: [
Nikita Ioffeab035a52024-03-14 00:33:50 +000043 "serde_derive",
Alice Wang94a06352023-10-16 07:19:10 +000044 "std",
45 ],
Nikita Ioffeab035a52024-03-14 00:33:50 +000046 proc_macros: ["libserde_derive"],
Alice Wang94a06352023-10-16 07:19:10 +000047 shared_libs: [
48 "libcrypto",
49 ],
Alice Wang94a06352023-10-16 07:19:10 +000050 visibility: [
Shikha Panwarc8ba73c2024-01-03 18:34:38 +000051 "//hardware/interfaces/security/secretkeeper/aidl/vts",
Alice Wang94a06352023-10-16 07:19:10 +000052 "//packages/modules/Virtualization:__subpackages__",
Hasini Gunasinghe19234c42023-12-13 14:47:47 +000053 "//system/authgraph/tests:__subpackages__",
Shikha Panwar0ebd67e2023-12-22 23:58:31 +000054 "//system/secretkeeper/client:__subpackages__",
Istvan Nador8f2ab792024-09-10 11:08:55 +000055 "//system/software_defined_vehicle:__subpackages__",
Alice Wang94a06352023-10-16 07:19:10 +000056 ],
57 apex_available: [
58 "//apex_available:platform",
59 "com.android.virt",
60 ],
61}
62
63rust_defaults {
64 name: "libdiced_open_dice_test_defaults",
65 crate_name: "diced_open_dice_test",
Alan Stokesd7aea452024-03-14 14:20:04 +000066 srcs: ["tests/api_test.rs"],
Alice Wang94a06352023-10-16 07:19:10 +000067 test_suites: ["general-tests"],
68}
69
70rust_test {
71 name: "libdiced_open_dice.integration_test",
72 defaults: ["libdiced_open_dice_test_defaults"],
73 rustlibs: [
74 "libdiced_open_dice",
75 ],
76}
77
78rust_test {
79 name: "libdiced_open_dice_nostd.integration_test",
80 defaults: ["libdiced_open_dice_test_defaults"],
81 rustlibs: [
82 "libdiced_open_dice_nostd",
83 ],
84}
85
86rust_defaults {
87 name: "libopen_dice_bindgen_nostd.rust_defaults",
88 bindgen_flags: [
89 "--use-core",
90 "--ctypes-prefix=core::ffi",
91 "--raw-line=#![no_std]",
92 ],
Ivan Lozano6561e342024-08-07 14:16:39 +000093 dylib: {
94 enabled: false,
95 },
Alice Wang94a06352023-10-16 07:19:10 +000096 no_stdlibs: true,
97 prefer_rlib: true,
98 stdlibs: [
99 "libcore.rust_sysroot",
100 "libcompiler_builtins.rust_sysroot",
101 ],
102 target: {
103 musl: {
104 enabled: false,
105 },
106 glibc: {
107 enabled: false,
108 },
109 darwin: {
110 enabled: false,
111 },
112 },
113}
114
115rust_defaults {
116 name: "libopen_dice.rust_defaults",
117 host_supported: true,
118 vendor_available: true,
119 apex_available: [
120 "//apex_available:platform",
121 "com.android.compos",
122 "com.android.virt",
123 ],
124}
125
126rust_defaults {
127 name: "libopen_dice_cbor_bindgen.rust_defaults",
128 wrapper_src: "bindgen/dice.h",
129 crate_name: "open_dice_cbor_bindgen",
130 source_stem: "bindings",
131 bindgen_flags: [
132 "--rustified-enum DiceConfigType",
133 "--rustified-enum DiceMode",
134 "--rustified-enum DiceResult",
135
136 // By generating only essential functions, we can make bindings concise and
137 // optimize compilation time.
138 "--allowlist-function=DiceDeriveCdiPrivateKeySeed",
139 "--allowlist-function=DiceDeriveCdiCertificateId",
140 "--allowlist-function=DiceMainFlow",
141 "--allowlist-function=DiceHash",
142 "--allowlist-function=DiceKdf",
143 "--allowlist-function=DiceKeypairFromSeed",
144 "--allowlist-function=DiceSign",
145 "--allowlist-function=DiceVerify",
146 "--allowlist-function=DiceGenerateCertificate",
147
148 // We also need some constants in addition to the functions.
149 "--allowlist-var=DICE_CDI_SIZE",
150 "--allowlist-var=DICE_HASH_SIZE",
151 "--allowlist-var=DICE_HIDDEN_SIZE",
152 "--allowlist-var=DICE_INLINE_CONFIG_SIZE",
153 "--allowlist-var=DICE_PRIVATE_KEY_SEED_SIZE",
154 "--allowlist-var=DICE_ID_SIZE",
Alice Wang94a06352023-10-16 07:19:10 +0000155 "--allowlist-var=DICE_PRIVATE_KEY_SIZE",
Alice Wang94a06352023-10-16 07:19:10 +0000156 ],
157}
158
159rust_bindgen {
160 name: "libopen_dice_cbor_bindgen",
161 defaults: [
162 "libopen_dice.rust_defaults",
163 "libopen_dice_cbor_bindgen.rust_defaults",
164 ],
165 whole_static_libs: ["libopen_dice_cbor"],
166}
167
168rust_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
177rust_defaults {
178 name: "libopen_dice_android_bindgen.rust_defaults",
179 wrapper_src: "bindgen/android.h",
180 crate_name: "open_dice_android_bindgen",
181 source_stem: "bindings",
182 bindgen_flags: [
183 // By generating only essential functions, we can make bindings concise and
184 // optimize compilation time.
185 "--allowlist-function=DiceAndroidFormatConfigDescriptor",
186 "--allowlist-function=DiceAndroidMainFlow",
187 "--allowlist-function=DiceAndroidHandoverMainFlow",
188 "--allowlist-function=DiceAndroidHandoverParse",
189
190 // We also need some constants in addition to the functions.
191 "--allowlist-var=DICE_ANDROID_CONFIG_.*",
192
193 // Prevent DiceInputValues from being generated a second time and
194 // import it instead from open_dice_cbor_bindgen.
195 "--blocklist-type=DiceInputValues_",
196 "--blocklist-type=DiceInputValues",
197 "--raw-line",
198 "pub use open_dice_cbor_bindgen::DiceInputValues;",
199
200 // Prevent DiceResult from being generated a second time and
201 // import it instead from open_dice_cbor_bindgen.
202 "--blocklist-type=DiceResult",
203 "--raw-line",
204 "pub use open_dice_cbor_bindgen::DiceResult;",
205 ],
206
207}
208
209rust_bindgen {
210 name: "libopen_dice_android_bindgen",
211 defaults: [
212 "libopen_dice.rust_defaults",
213 "libopen_dice_android_bindgen.rust_defaults",
214 ],
215 rustlibs: [
216 "libopen_dice_cbor_bindgen",
217 ],
218 whole_static_libs: ["libopen_dice_android"],
219}
220
221rust_bindgen {
222 name: "libopen_dice_android_bindgen_nostd",
223 defaults: [
224 "libopen_dice_android_bindgen.rust_defaults",
225 "libopen_dice_bindgen_nostd.rust_defaults",
226 ],
227 rustlibs: [
228 "libopen_dice_cbor_bindgen_nostd",
229 ],
230 whole_static_libs: ["libopen_dice_android_baremetal"],
231}
232
233rust_test {
234 name: "libopen_dice_cbor_bindgen_test",
235 srcs: [
236 ":libopen_dice_cbor_bindgen",
237 ],
238 crate_name: "open_dice_cbor_bindgen_test",
239 test_suites: ["general-tests"],
240 auto_gen_config: true,
241 clippy_lints: "none",
242 lints: "none",
243}
244
245rust_test {
246 name: "libopen_dice_android_bindgen_test",
247 srcs: [
248 ":libopen_dice_android_bindgen",
249 ],
250 crate_name: "open_dice_android_bindgen_test",
251 rustlibs: [
252 "libopen_dice_cbor_bindgen",
253 ],
254 test_suites: ["general-tests"],
255 auto_gen_config: true,
256 clippy_lints: "none",
257 lints: "none",
258}