blob: 986f496243597953863de2cfc6d4a028e8ec2dc4 [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",
Gil Cukiermane431d962025-01-22 13:25:52 -080078 "libcoset",
Alice Wang94a06352023-10-16 07:19:10 +000079 ],
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",
Gil Cukiermane431d962025-01-22 13:25:52 -080087 "libcoset_nostd",
Alice Wang94a06352023-10-16 07:19:10 +000088 ],
89}
90
91rust_defaults {
92 name: "libopen_dice_bindgen_nostd.rust_defaults",
93 bindgen_flags: [
94 "--use-core",
95 "--ctypes-prefix=core::ffi",
96 "--raw-line=#![no_std]",
97 ],
Ivan Lozano6561e342024-08-07 14:16:39 +000098 dylib: {
99 enabled: false,
100 },
Alice Wang94a06352023-10-16 07:19:10 +0000101 no_stdlibs: true,
102 prefer_rlib: true,
103 stdlibs: [
104 "libcore.rust_sysroot",
105 "libcompiler_builtins.rust_sysroot",
106 ],
107 target: {
108 musl: {
109 enabled: false,
110 },
111 glibc: {
112 enabled: false,
113 },
114 darwin: {
115 enabled: false,
116 },
117 },
118}
119
120rust_defaults {
121 name: "libopen_dice.rust_defaults",
122 host_supported: true,
123 vendor_available: true,
124 apex_available: [
125 "//apex_available:platform",
126 "com.android.compos",
127 "com.android.virt",
128 ],
129}
130
131rust_defaults {
132 name: "libopen_dice_cbor_bindgen.rust_defaults",
Gil Cukiermanf96915b2024-12-13 16:32:12 -0500133 wrapper_src: "bindgen/dice/dice.h",
Alice Wang94a06352023-10-16 07:19:10 +0000134 crate_name: "open_dice_cbor_bindgen",
135 source_stem: "bindings",
136 bindgen_flags: [
137 "--rustified-enum DiceConfigType",
138 "--rustified-enum DiceMode",
139 "--rustified-enum DiceResult",
Alice Wang14ca76a2024-11-05 12:41:57 +0000140 "--rustified-enum DicePrincipal",
Alice Wang94a06352023-10-16 07:19:10 +0000141
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",
Gil Cukiermane431d962025-01-22 13:25:52 -0800151 "--allowlist-function=DiceCoseSignAndEncodeSign1",
Alice Wang94a06352023-10-16 07:19:10 +0000152 "--allowlist-function=DiceVerify",
153 "--allowlist-function=DiceGenerateCertificate",
154
155 // We also need some constants in addition to the functions.
156 "--allowlist-var=DICE_CDI_SIZE",
157 "--allowlist-var=DICE_HASH_SIZE",
158 "--allowlist-var=DICE_HIDDEN_SIZE",
159 "--allowlist-var=DICE_INLINE_CONFIG_SIZE",
160 "--allowlist-var=DICE_PRIVATE_KEY_SEED_SIZE",
161 "--allowlist-var=DICE_ID_SIZE",
Alice Wangce6cbd72024-11-22 11:19:05 +0000162 "--allowlist-var=DICE_PRIVATE_KEY_BUFFER_SIZE",
Alice Wang94a06352023-10-16 07:19:10 +0000163 ],
164}
165
166rust_bindgen {
167 name: "libopen_dice_cbor_bindgen",
168 defaults: [
169 "libopen_dice.rust_defaults",
170 "libopen_dice_cbor_bindgen.rust_defaults",
171 ],
172 whole_static_libs: ["libopen_dice_cbor"],
Ivan Lozano36f783f2025-01-28 21:41:57 +0000173 shared_libs: ["libcrypto"],
Alice Wang94a06352023-10-16 07:19:10 +0000174}
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 ],
Alice Wang87fbc4b2024-11-05 13:09:58 +0000182 bindgen_flags: [
183 "--rustified-enum DiceKeyAlgorithm",
184 "--allowlist-type=DiceContext",
185 ],
186 whole_static_libs: ["libopen_dice_cbor_baremetal_multialg"],
Alice Wang94a06352023-10-16 07:19:10 +0000187}
188
189rust_defaults {
190 name: "libopen_dice_android_bindgen.rust_defaults",
Gil Cukiermanf96915b2024-12-13 16:32:12 -0500191 wrapper_src: "bindgen/android/android.h",
Alice Wang94a06352023-10-16 07:19:10 +0000192 crate_name: "open_dice_android_bindgen",
193 source_stem: "bindings",
194 bindgen_flags: [
195 // By generating only essential functions, we can make bindings concise and
196 // optimize compilation time.
197 "--allowlist-function=DiceAndroidFormatConfigDescriptor",
198 "--allowlist-function=DiceAndroidMainFlow",
199 "--allowlist-function=DiceAndroidHandoverMainFlow",
200 "--allowlist-function=DiceAndroidHandoverParse",
201
202 // We also need some constants in addition to the functions.
203 "--allowlist-var=DICE_ANDROID_CONFIG_.*",
204
205 // Prevent DiceInputValues from being generated a second time and
206 // import it instead from open_dice_cbor_bindgen.
207 "--blocklist-type=DiceInputValues_",
208 "--blocklist-type=DiceInputValues",
209 "--raw-line",
210 "pub use open_dice_cbor_bindgen::DiceInputValues;",
211
212 // Prevent DiceResult from being generated a second time and
213 // import it instead from open_dice_cbor_bindgen.
214 "--blocklist-type=DiceResult",
215 "--raw-line",
216 "pub use open_dice_cbor_bindgen::DiceResult;",
217 ],
218
219}
220
221rust_bindgen {
222 name: "libopen_dice_android_bindgen",
223 defaults: [
224 "libopen_dice.rust_defaults",
225 "libopen_dice_android_bindgen.rust_defaults",
226 ],
227 rustlibs: [
228 "libopen_dice_cbor_bindgen",
229 ],
230 whole_static_libs: ["libopen_dice_android"],
231}
232
233rust_bindgen {
234 name: "libopen_dice_android_bindgen_nostd",
235 defaults: [
236 "libopen_dice_android_bindgen.rust_defaults",
237 "libopen_dice_bindgen_nostd.rust_defaults",
238 ],
239 rustlibs: [
240 "libopen_dice_cbor_bindgen_nostd",
241 ],
Alice Wang87fbc4b2024-11-05 13:09:58 +0000242 whole_static_libs: ["libopen_dice_android_baremetal_multialg"],
Alice Wang94a06352023-10-16 07:19:10 +0000243}
244
245rust_test {
246 name: "libopen_dice_cbor_bindgen_test",
247 srcs: [
248 ":libopen_dice_cbor_bindgen",
249 ],
250 crate_name: "open_dice_cbor_bindgen_test",
251 test_suites: ["general-tests"],
252 auto_gen_config: true,
253 clippy_lints: "none",
254 lints: "none",
255}
256
257rust_test {
258 name: "libopen_dice_android_bindgen_test",
259 srcs: [
260 ":libopen_dice_android_bindgen",
261 ],
262 crate_name: "open_dice_android_bindgen_test",
263 rustlibs: [
264 "libopen_dice_cbor_bindgen",
265 ],
266 test_suites: ["general-tests"],
267 auto_gen_config: true,
268 clippy_lints: "none",
269 lints: "none",
270}
Gil Cukiermanf96915b2024-12-13 16:32:12 -0500271
272dirgroup {
273 name: "trusty_dirgroup_packages_modules_virtualization_libs_open_dice",
274 visibility: ["//trusty/vendor/google/aosp/scripts"],
275 dirs: ["."],
276}