blob: ab3220e057a01bd190b8fc5a1c894b2cd15cb64a [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: [
25 "libopen_dice_cbor",
26 "libcrypto_baremetal",
27 ],
28 visibility: [
29 "//packages/modules/Virtualization:__subpackages__",
Hasini Gunasinghe19234c42023-12-13 14:47:47 +000030 "//system/authgraph/tests:__subpackages__",
Alice Wang94a06352023-10-16 07:19:10 +000031 ],
32}
33
34rust_library {
35 name: "libdiced_open_dice",
36 defaults: ["libdiced_open_dice_defaults"],
Hasini Gunasingheb39fc152023-12-14 11:13:51 +000037 host_supported: true,
Alice Wang94a06352023-10-16 07:19:10 +000038 vendor_available: true,
39 rustlibs: [
40 "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: [
46 "alloc",
Nikita Ioffeab035a52024-03-14 00:33:50 +000047 "serde_derive",
Alice Wang94a06352023-10-16 07:19:10 +000048 "std",
49 ],
Nikita Ioffeab035a52024-03-14 00:33:50 +000050 proc_macros: ["libserde_derive"],
Alice Wang94a06352023-10-16 07:19:10 +000051 shared_libs: [
52 "libcrypto",
53 ],
54 static_libs: [
55 "libopen_dice_cbor",
56 ],
57 whole_static_libs: [
58 "libopen_dice_android",
59 ],
60 visibility: [
Shikha Panwarc8ba73c2024-01-03 18:34:38 +000061 "//hardware/interfaces/security/secretkeeper/aidl/vts",
Alice Wang94a06352023-10-16 07:19:10 +000062 "//packages/modules/Virtualization:__subpackages__",
Hasini Gunasinghe19234c42023-12-13 14:47:47 +000063 "//system/authgraph/tests:__subpackages__",
Shikha Panwar0ebd67e2023-12-22 23:58:31 +000064 "//system/secretkeeper/client:__subpackages__",
Alice Wang94a06352023-10-16 07:19:10 +000065 ],
66 apex_available: [
67 "//apex_available:platform",
68 "com.android.virt",
69 ],
70}
71
72rust_defaults {
73 name: "libdiced_open_dice_test_defaults",
74 crate_name: "diced_open_dice_test",
Alan Stokesd7aea452024-03-14 14:20:04 +000075 srcs: ["tests/api_test.rs"],
Alice Wang94a06352023-10-16 07:19:10 +000076 test_suites: ["general-tests"],
77}
78
79rust_test {
80 name: "libdiced_open_dice.integration_test",
81 defaults: ["libdiced_open_dice_test_defaults"],
82 rustlibs: [
83 "libdiced_open_dice",
84 ],
85}
86
87rust_test {
88 name: "libdiced_open_dice_nostd.integration_test",
89 defaults: ["libdiced_open_dice_test_defaults"],
90 rustlibs: [
91 "libdiced_open_dice_nostd",
92 ],
93}
94
95rust_defaults {
96 name: "libopen_dice_bindgen_nostd.rust_defaults",
97 bindgen_flags: [
98 "--use-core",
99 "--ctypes-prefix=core::ffi",
100 "--raw-line=#![no_std]",
101 ],
102 no_stdlibs: true,
103 prefer_rlib: true,
104 stdlibs: [
105 "libcore.rust_sysroot",
106 "libcompiler_builtins.rust_sysroot",
107 ],
108 target: {
109 musl: {
110 enabled: false,
111 },
112 glibc: {
113 enabled: false,
114 },
115 darwin: {
116 enabled: false,
117 },
118 },
119}
120
121rust_defaults {
122 name: "libopen_dice.rust_defaults",
123 host_supported: true,
124 vendor_available: true,
125 apex_available: [
126 "//apex_available:platform",
127 "com.android.compos",
128 "com.android.virt",
129 ],
130}
131
132rust_defaults {
133 name: "libopen_dice_cbor_bindgen.rust_defaults",
134 wrapper_src: "bindgen/dice.h",
135 crate_name: "open_dice_cbor_bindgen",
136 source_stem: "bindings",
137 bindgen_flags: [
138 "--rustified-enum DiceConfigType",
139 "--rustified-enum DiceMode",
140 "--rustified-enum DiceResult",
141
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",
151 "--allowlist-function=DiceVerify",
152 "--allowlist-function=DiceGenerateCertificate",
153
154 // We also need some constants in addition to the functions.
155 "--allowlist-var=DICE_CDI_SIZE",
156 "--allowlist-var=DICE_HASH_SIZE",
157 "--allowlist-var=DICE_HIDDEN_SIZE",
158 "--allowlist-var=DICE_INLINE_CONFIG_SIZE",
159 "--allowlist-var=DICE_PRIVATE_KEY_SEED_SIZE",
160 "--allowlist-var=DICE_ID_SIZE",
161 "--allowlist-var=DICE_PUBLIC_KEY_SIZE",
162 "--allowlist-var=DICE_PRIVATE_KEY_SIZE",
163 "--allowlist-var=DICE_SIGNATURE_SIZE",
164 ],
165}
166
167rust_bindgen {
168 name: "libopen_dice_cbor_bindgen",
169 defaults: [
170 "libopen_dice.rust_defaults",
171 "libopen_dice_cbor_bindgen.rust_defaults",
172 ],
173 whole_static_libs: ["libopen_dice_cbor"],
174}
175
176rust_bindgen {
177 name: "libopen_dice_cbor_bindgen_nostd",
178 defaults: [
179 "libopen_dice_cbor_bindgen.rust_defaults",
180 "libopen_dice_bindgen_nostd.rust_defaults",
181 ],
182 whole_static_libs: ["libopen_dice_cbor_baremetal"],
183}
184
185rust_defaults {
186 name: "libopen_dice_android_bindgen.rust_defaults",
187 wrapper_src: "bindgen/android.h",
188 crate_name: "open_dice_android_bindgen",
189 source_stem: "bindings",
190 bindgen_flags: [
191 // By generating only essential functions, we can make bindings concise and
192 // optimize compilation time.
193 "--allowlist-function=DiceAndroidFormatConfigDescriptor",
194 "--allowlist-function=DiceAndroidMainFlow",
195 "--allowlist-function=DiceAndroidHandoverMainFlow",
196 "--allowlist-function=DiceAndroidHandoverParse",
197
198 // We also need some constants in addition to the functions.
199 "--allowlist-var=DICE_ANDROID_CONFIG_.*",
200
201 // Prevent DiceInputValues from being generated a second time and
202 // import it instead from open_dice_cbor_bindgen.
203 "--blocklist-type=DiceInputValues_",
204 "--blocklist-type=DiceInputValues",
205 "--raw-line",
206 "pub use open_dice_cbor_bindgen::DiceInputValues;",
207
208 // Prevent DiceResult from being generated a second time and
209 // import it instead from open_dice_cbor_bindgen.
210 "--blocklist-type=DiceResult",
211 "--raw-line",
212 "pub use open_dice_cbor_bindgen::DiceResult;",
213 ],
214
215}
216
217rust_bindgen {
218 name: "libopen_dice_android_bindgen",
219 defaults: [
220 "libopen_dice.rust_defaults",
221 "libopen_dice_android_bindgen.rust_defaults",
222 ],
223 rustlibs: [
224 "libopen_dice_cbor_bindgen",
225 ],
226 whole_static_libs: ["libopen_dice_android"],
227}
228
229rust_bindgen {
230 name: "libopen_dice_android_bindgen_nostd",
231 defaults: [
232 "libopen_dice_android_bindgen.rust_defaults",
233 "libopen_dice_bindgen_nostd.rust_defaults",
234 ],
235 rustlibs: [
236 "libopen_dice_cbor_bindgen_nostd",
237 ],
238 whole_static_libs: ["libopen_dice_android_baremetal"],
239}
240
241rust_test {
242 name: "libopen_dice_cbor_bindgen_test",
243 srcs: [
244 ":libopen_dice_cbor_bindgen",
245 ],
246 crate_name: "open_dice_cbor_bindgen_test",
247 test_suites: ["general-tests"],
248 auto_gen_config: true,
249 clippy_lints: "none",
250 lints: "none",
251}
252
253rust_test {
254 name: "libopen_dice_android_bindgen_test",
255 srcs: [
256 ":libopen_dice_android_bindgen",
257 ],
258 crate_name: "open_dice_android_bindgen_test",
259 rustlibs: [
260 "libopen_dice_cbor_bindgen",
261 ],
262 test_suites: ["general-tests"],
263 auto_gen_config: true,
264 clippy_lints: "none",
265 lints: "none",
266}