blob: b3cb65154aa1079b054a901c43ab8db48a4ae571 [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 ],
22 features: [
23 "alloc",
24 ],
25 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: [
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 ],
Alice Wang94a06352023-10-16 07:19:10 +000054 visibility: [
Shikha Panwarc8ba73c2024-01-03 18:34:38 +000055 "//hardware/interfaces/security/secretkeeper/aidl/vts",
Alice Wang94a06352023-10-16 07:19:10 +000056 "//packages/modules/Virtualization:__subpackages__",
Hasini Gunasinghe19234c42023-12-13 14:47:47 +000057 "//system/authgraph/tests:__subpackages__",
Shikha Panwar0ebd67e2023-12-22 23:58:31 +000058 "//system/secretkeeper/client:__subpackages__",
Istvan Nador8f2ab792024-09-10 11:08:55 +000059 "//system/software_defined_vehicle:__subpackages__",
Alice Wang94a06352023-10-16 07:19:10 +000060 ],
61 apex_available: [
62 "//apex_available:platform",
63 "com.android.virt",
64 ],
65}
66
67rust_defaults {
68 name: "libdiced_open_dice_test_defaults",
69 crate_name: "diced_open_dice_test",
Alan Stokesd7aea452024-03-14 14:20:04 +000070 srcs: ["tests/api_test.rs"],
Alice Wang94a06352023-10-16 07:19:10 +000071 test_suites: ["general-tests"],
72}
73
74rust_test {
75 name: "libdiced_open_dice.integration_test",
76 defaults: ["libdiced_open_dice_test_defaults"],
77 rustlibs: [
78 "libdiced_open_dice",
79 ],
80}
81
82rust_test {
83 name: "libdiced_open_dice_nostd.integration_test",
84 defaults: ["libdiced_open_dice_test_defaults"],
85 rustlibs: [
86 "libdiced_open_dice_nostd",
87 ],
88}
89
90rust_defaults {
91 name: "libopen_dice_bindgen_nostd.rust_defaults",
92 bindgen_flags: [
93 "--use-core",
94 "--ctypes-prefix=core::ffi",
95 "--raw-line=#![no_std]",
96 ],
Ivan Lozano6561e342024-08-07 14:16:39 +000097 dylib: {
98 enabled: false,
99 },
Alice Wang94a06352023-10-16 07:19:10 +0000100 no_stdlibs: true,
101 prefer_rlib: true,
102 stdlibs: [
103 "libcore.rust_sysroot",
104 "libcompiler_builtins.rust_sysroot",
105 ],
106 target: {
107 musl: {
108 enabled: false,
109 },
110 glibc: {
111 enabled: false,
112 },
113 darwin: {
114 enabled: false,
115 },
116 },
117}
118
119rust_defaults {
120 name: "libopen_dice.rust_defaults",
121 host_supported: true,
122 vendor_available: true,
123 apex_available: [
124 "//apex_available:platform",
125 "com.android.compos",
126 "com.android.virt",
127 ],
128}
129
130rust_defaults {
131 name: "libopen_dice_cbor_bindgen.rust_defaults",
132 wrapper_src: "bindgen/dice.h",
133 crate_name: "open_dice_cbor_bindgen",
134 source_stem: "bindings",
135 bindgen_flags: [
136 "--rustified-enum DiceConfigType",
137 "--rustified-enum DiceMode",
138 "--rustified-enum DiceResult",
139
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",
159 "--allowlist-var=DICE_PUBLIC_KEY_SIZE",
160 "--allowlist-var=DICE_PRIVATE_KEY_SIZE",
161 "--allowlist-var=DICE_SIGNATURE_SIZE",
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}