blob: 3c5b6eaea7374c56ba743aeb78dc5e80a01d9304 [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",
Alice Wang14ca76a2024-11-05 12:41:57 +0000135 "--rustified-enum DicePrincipal",
Alice Wang94a06352023-10-16 07:19:10 +0000136
137 // By generating only essential functions, we can make bindings concise and
138 // optimize compilation time.
139 "--allowlist-function=DiceDeriveCdiPrivateKeySeed",
140 "--allowlist-function=DiceDeriveCdiCertificateId",
141 "--allowlist-function=DiceMainFlow",
142 "--allowlist-function=DiceHash",
143 "--allowlist-function=DiceKdf",
144 "--allowlist-function=DiceKeypairFromSeed",
145 "--allowlist-function=DiceSign",
146 "--allowlist-function=DiceVerify",
147 "--allowlist-function=DiceGenerateCertificate",
148
149 // We also need some constants in addition to the functions.
150 "--allowlist-var=DICE_CDI_SIZE",
151 "--allowlist-var=DICE_HASH_SIZE",
152 "--allowlist-var=DICE_HIDDEN_SIZE",
153 "--allowlist-var=DICE_INLINE_CONFIG_SIZE",
154 "--allowlist-var=DICE_PRIVATE_KEY_SEED_SIZE",
155 "--allowlist-var=DICE_ID_SIZE",
Alice Wang94a06352023-10-16 07:19:10 +0000156 "--allowlist-var=DICE_PRIVATE_KEY_SIZE",
Alice Wang94a06352023-10-16 07:19:10 +0000157 ],
158}
159
160rust_bindgen {
161 name: "libopen_dice_cbor_bindgen",
162 defaults: [
163 "libopen_dice.rust_defaults",
164 "libopen_dice_cbor_bindgen.rust_defaults",
165 ],
166 whole_static_libs: ["libopen_dice_cbor"],
167}
168
169rust_bindgen {
170 name: "libopen_dice_cbor_bindgen_nostd",
171 defaults: [
172 "libopen_dice_cbor_bindgen.rust_defaults",
173 "libopen_dice_bindgen_nostd.rust_defaults",
174 ],
175 whole_static_libs: ["libopen_dice_cbor_baremetal"],
176}
177
178rust_defaults {
179 name: "libopen_dice_android_bindgen.rust_defaults",
180 wrapper_src: "bindgen/android.h",
181 crate_name: "open_dice_android_bindgen",
182 source_stem: "bindings",
183 bindgen_flags: [
184 // By generating only essential functions, we can make bindings concise and
185 // optimize compilation time.
186 "--allowlist-function=DiceAndroidFormatConfigDescriptor",
187 "--allowlist-function=DiceAndroidMainFlow",
188 "--allowlist-function=DiceAndroidHandoverMainFlow",
189 "--allowlist-function=DiceAndroidHandoverParse",
190
191 // We also need some constants in addition to the functions.
192 "--allowlist-var=DICE_ANDROID_CONFIG_.*",
193
194 // Prevent DiceInputValues from being generated a second time and
195 // import it instead from open_dice_cbor_bindgen.
196 "--blocklist-type=DiceInputValues_",
197 "--blocklist-type=DiceInputValues",
198 "--raw-line",
199 "pub use open_dice_cbor_bindgen::DiceInputValues;",
200
201 // Prevent DiceResult from being generated a second time and
202 // import it instead from open_dice_cbor_bindgen.
203 "--blocklist-type=DiceResult",
204 "--raw-line",
205 "pub use open_dice_cbor_bindgen::DiceResult;",
206 ],
207
208}
209
210rust_bindgen {
211 name: "libopen_dice_android_bindgen",
212 defaults: [
213 "libopen_dice.rust_defaults",
214 "libopen_dice_android_bindgen.rust_defaults",
215 ],
216 rustlibs: [
217 "libopen_dice_cbor_bindgen",
218 ],
219 whole_static_libs: ["libopen_dice_android"],
220}
221
222rust_bindgen {
223 name: "libopen_dice_android_bindgen_nostd",
224 defaults: [
225 "libopen_dice_android_bindgen.rust_defaults",
226 "libopen_dice_bindgen_nostd.rust_defaults",
227 ],
228 rustlibs: [
229 "libopen_dice_cbor_bindgen_nostd",
230 ],
231 whole_static_libs: ["libopen_dice_android_baremetal"],
232}
233
234rust_test {
235 name: "libopen_dice_cbor_bindgen_test",
236 srcs: [
237 ":libopen_dice_cbor_bindgen",
238 ],
239 crate_name: "open_dice_cbor_bindgen_test",
240 test_suites: ["general-tests"],
241 auto_gen_config: true,
242 clippy_lints: "none",
243 lints: "none",
244}
245
246rust_test {
247 name: "libopen_dice_android_bindgen_test",
248 srcs: [
249 ":libopen_dice_android_bindgen",
250 ],
251 crate_name: "open_dice_android_bindgen_test",
252 rustlibs: [
253 "libopen_dice_cbor_bindgen",
254 ],
255 test_suites: ["general-tests"],
256 auto_gen_config: true,
257 clippy_lints: "none",
258 lints: "none",
259}