blob: 5151578ca394a15f821ba9e6c1bb0e4b9933ec3d [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__",
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: [
39 "libopen_dice_android_bindgen",
40 "libopen_dice_cbor_bindgen",
Nikita Ioffeab035a52024-03-14 00:33:50 +000041 "libserde",
Alice Wang94a06352023-10-16 07:19:10 +000042 "libzeroize",
43 ],
44 features: [
45 "alloc",
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",
78 ],
79}
80
81rust_test {
82 name: "libdiced_open_dice_nostd.integration_test",
83 defaults: ["libdiced_open_dice_test_defaults"],
84 rustlibs: [
85 "libdiced_open_dice_nostd",
86 ],
87}
88
89rust_defaults {
90 name: "libopen_dice_bindgen_nostd.rust_defaults",
91 bindgen_flags: [
92 "--use-core",
93 "--ctypes-prefix=core::ffi",
94 "--raw-line=#![no_std]",
95 ],
Ivan Lozano6561e342024-08-07 14:16:39 +000096 dylib: {
97 enabled: false,
98 },
Alice Wang94a06352023-10-16 07:19:10 +000099 no_stdlibs: true,
100 prefer_rlib: true,
101 stdlibs: [
102 "libcore.rust_sysroot",
103 "libcompiler_builtins.rust_sysroot",
104 ],
105 target: {
106 musl: {
107 enabled: false,
108 },
109 glibc: {
110 enabled: false,
111 },
112 darwin: {
113 enabled: false,
114 },
115 },
116}
117
118rust_defaults {
119 name: "libopen_dice.rust_defaults",
120 host_supported: true,
121 vendor_available: true,
122 apex_available: [
123 "//apex_available:platform",
124 "com.android.compos",
125 "com.android.virt",
126 ],
127}
128
129rust_defaults {
130 name: "libopen_dice_cbor_bindgen.rust_defaults",
131 wrapper_src: "bindgen/dice.h",
132 crate_name: "open_dice_cbor_bindgen",
133 source_stem: "bindings",
134 bindgen_flags: [
135 "--rustified-enum DiceConfigType",
136 "--rustified-enum DiceMode",
137 "--rustified-enum DiceResult",
138
139 // By generating only essential functions, we can make bindings concise and
140 // optimize compilation time.
141 "--allowlist-function=DiceDeriveCdiPrivateKeySeed",
142 "--allowlist-function=DiceDeriveCdiCertificateId",
143 "--allowlist-function=DiceMainFlow",
144 "--allowlist-function=DiceHash",
145 "--allowlist-function=DiceKdf",
146 "--allowlist-function=DiceKeypairFromSeed",
147 "--allowlist-function=DiceSign",
148 "--allowlist-function=DiceVerify",
149 "--allowlist-function=DiceGenerateCertificate",
150
151 // We also need some constants in addition to the functions.
152 "--allowlist-var=DICE_CDI_SIZE",
153 "--allowlist-var=DICE_HASH_SIZE",
154 "--allowlist-var=DICE_HIDDEN_SIZE",
155 "--allowlist-var=DICE_INLINE_CONFIG_SIZE",
156 "--allowlist-var=DICE_PRIVATE_KEY_SEED_SIZE",
157 "--allowlist-var=DICE_ID_SIZE",
158 "--allowlist-var=DICE_PUBLIC_KEY_SIZE",
159 "--allowlist-var=DICE_PRIVATE_KEY_SIZE",
160 "--allowlist-var=DICE_SIGNATURE_SIZE",
Alice Wangff381112024-05-22 12:14:39 +0000161 "--allowlist-var=DICE_COSE_KEY_ALG_VALUE",
Alice Wang94a06352023-10-16 07:19:10 +0000162 ],
163}
164
165rust_bindgen {
166 name: "libopen_dice_cbor_bindgen",
167 defaults: [
168 "libopen_dice.rust_defaults",
169 "libopen_dice_cbor_bindgen.rust_defaults",
170 ],
171 whole_static_libs: ["libopen_dice_cbor"],
172}
173
174rust_bindgen {
175 name: "libopen_dice_cbor_bindgen_nostd",
176 defaults: [
177 "libopen_dice_cbor_bindgen.rust_defaults",
178 "libopen_dice_bindgen_nostd.rust_defaults",
179 ],
180 whole_static_libs: ["libopen_dice_cbor_baremetal"],
181}
182
183rust_defaults {
184 name: "libopen_dice_android_bindgen.rust_defaults",
185 wrapper_src: "bindgen/android.h",
186 crate_name: "open_dice_android_bindgen",
187 source_stem: "bindings",
188 bindgen_flags: [
189 // By generating only essential functions, we can make bindings concise and
190 // optimize compilation time.
191 "--allowlist-function=DiceAndroidFormatConfigDescriptor",
192 "--allowlist-function=DiceAndroidMainFlow",
193 "--allowlist-function=DiceAndroidHandoverMainFlow",
194 "--allowlist-function=DiceAndroidHandoverParse",
195
196 // We also need some constants in addition to the functions.
197 "--allowlist-var=DICE_ANDROID_CONFIG_.*",
198
199 // Prevent DiceInputValues from being generated a second time and
200 // import it instead from open_dice_cbor_bindgen.
201 "--blocklist-type=DiceInputValues_",
202 "--blocklist-type=DiceInputValues",
203 "--raw-line",
204 "pub use open_dice_cbor_bindgen::DiceInputValues;",
205
206 // Prevent DiceResult from being generated a second time and
207 // import it instead from open_dice_cbor_bindgen.
208 "--blocklist-type=DiceResult",
209 "--raw-line",
210 "pub use open_dice_cbor_bindgen::DiceResult;",
211 ],
212
213}
214
215rust_bindgen {
216 name: "libopen_dice_android_bindgen",
217 defaults: [
218 "libopen_dice.rust_defaults",
219 "libopen_dice_android_bindgen.rust_defaults",
220 ],
221 rustlibs: [
222 "libopen_dice_cbor_bindgen",
223 ],
224 whole_static_libs: ["libopen_dice_android"],
225}
226
227rust_bindgen {
228 name: "libopen_dice_android_bindgen_nostd",
229 defaults: [
230 "libopen_dice_android_bindgen.rust_defaults",
231 "libopen_dice_bindgen_nostd.rust_defaults",
232 ],
233 rustlibs: [
234 "libopen_dice_cbor_bindgen_nostd",
235 ],
236 whole_static_libs: ["libopen_dice_android_baremetal"],
237}
238
239rust_test {
240 name: "libopen_dice_cbor_bindgen_test",
241 srcs: [
242 ":libopen_dice_cbor_bindgen",
243 ],
244 crate_name: "open_dice_cbor_bindgen_test",
245 test_suites: ["general-tests"],
246 auto_gen_config: true,
247 clippy_lints: "none",
248 lints: "none",
249}
250
251rust_test {
252 name: "libopen_dice_android_bindgen_test",
253 srcs: [
254 ":libopen_dice_android_bindgen",
255 ],
256 crate_name: "open_dice_android_bindgen_test",
257 rustlibs: [
258 "libopen_dice_cbor_bindgen",
259 ],
260 test_suites: ["general-tests"],
261 auto_gen_config: true,
262 clippy_lints: "none",
263 lints: "none",
264}