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