blob: 4241c47e5643a56cf7357a05c81df112fb76f319 [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 Wang87fbc4b2024-11-05 13:09:58 +000022 features: [
23 "multialg",
24 ],
Alice Wang94a06352023-10-16 07:19:10 +000025 whole_static_libs: [
Alice Wang94a06352023-10-16 07:19:10 +000026 "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: [
Alice Wangb1ed0842024-11-05 09:45:37 +000039 "libcoset",
Alice Wang94a06352023-10-16 07:19:10 +000040 "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: [
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",
Alice Wang14ca76a2024-11-05 12:41:57 +0000138 "--rustified-enum DicePrincipal",
Alice Wang94a06352023-10-16 07:19:10 +0000139
140 // By generating only essential functions, we can make bindings concise and
141 // optimize compilation time.
142 "--allowlist-function=DiceDeriveCdiPrivateKeySeed",
143 "--allowlist-function=DiceDeriveCdiCertificateId",
144 "--allowlist-function=DiceMainFlow",
145 "--allowlist-function=DiceHash",
146 "--allowlist-function=DiceKdf",
147 "--allowlist-function=DiceKeypairFromSeed",
148 "--allowlist-function=DiceSign",
149 "--allowlist-function=DiceVerify",
150 "--allowlist-function=DiceGenerateCertificate",
151
152 // We also need some constants in addition to the functions.
153 "--allowlist-var=DICE_CDI_SIZE",
154 "--allowlist-var=DICE_HASH_SIZE",
155 "--allowlist-var=DICE_HIDDEN_SIZE",
156 "--allowlist-var=DICE_INLINE_CONFIG_SIZE",
157 "--allowlist-var=DICE_PRIVATE_KEY_SEED_SIZE",
158 "--allowlist-var=DICE_ID_SIZE",
Alice Wang94a06352023-10-16 07:19:10 +0000159 "--allowlist-var=DICE_PRIVATE_KEY_SIZE",
Alice Wang94a06352023-10-16 07:19:10 +0000160 ],
161}
162
163rust_bindgen {
164 name: "libopen_dice_cbor_bindgen",
165 defaults: [
166 "libopen_dice.rust_defaults",
167 "libopen_dice_cbor_bindgen.rust_defaults",
168 ],
169 whole_static_libs: ["libopen_dice_cbor"],
170}
171
172rust_bindgen {
173 name: "libopen_dice_cbor_bindgen_nostd",
174 defaults: [
175 "libopen_dice_cbor_bindgen.rust_defaults",
176 "libopen_dice_bindgen_nostd.rust_defaults",
177 ],
Alice Wang87fbc4b2024-11-05 13:09:58 +0000178 bindgen_flags: [
179 "--rustified-enum DiceKeyAlgorithm",
180 "--allowlist-type=DiceContext",
181 ],
182 whole_static_libs: ["libopen_dice_cbor_baremetal_multialg"],
Alice Wang94a06352023-10-16 07:19:10 +0000183}
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 ],
Alice Wang87fbc4b2024-11-05 13:09:58 +0000238 whole_static_libs: ["libopen_dice_android_baremetal_multialg"],
Alice Wang94a06352023-10-16 07:19:10 +0000239}
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}