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