blob: 79d0b9660a3052a2fdc06d1f53f09df67d323ffe [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__",
Hasini Gunasinghe19234c42023-12-13 14:47:47 +000030 "//system/authgraph/tests:__subpackages__",
Alice Wang94a06352023-10-16 07:19:10 +000031 ],
32}
33
34rust_library {
35 name: "libdiced_open_dice",
36 defaults: ["libdiced_open_dice_defaults"],
Hasini Gunasingheb39fc152023-12-14 11:13:51 +000037 host_supported: true,
Alice Wang94a06352023-10-16 07:19:10 +000038 vendor_available: true,
39 rustlibs: [
40 "libopen_dice_android_bindgen",
41 "libopen_dice_cbor_bindgen",
42 "libzeroize",
43 ],
44 features: [
45 "alloc",
46 "std",
47 ],
48 shared_libs: [
49 "libcrypto",
50 ],
51 static_libs: [
52 "libopen_dice_cbor",
53 ],
54 whole_static_libs: [
55 "libopen_dice_android",
56 ],
57 visibility: [
Shikha Panwarc8ba73c2024-01-03 18:34:38 +000058 "//hardware/interfaces/security/secretkeeper/aidl/vts",
Alice Wang94a06352023-10-16 07:19:10 +000059 "//packages/modules/Virtualization:__subpackages__",
Hasini Gunasinghe19234c42023-12-13 14:47:47 +000060 "//system/authgraph/tests:__subpackages__",
Shikha Panwar0ebd67e2023-12-22 23:58:31 +000061 "//system/secretkeeper/client:__subpackages__",
Alice Wang94a06352023-10-16 07:19:10 +000062 ],
63 apex_available: [
64 "//apex_available:platform",
65 "com.android.virt",
66 ],
67}
68
69rust_defaults {
70 name: "libdiced_open_dice_test_defaults",
71 crate_name: "diced_open_dice_test",
72 srcs: ["tests/*.rs"],
73 test_suites: ["general-tests"],
74}
75
76rust_test {
77 name: "libdiced_open_dice.integration_test",
78 defaults: ["libdiced_open_dice_test_defaults"],
79 rustlibs: [
80 "libdiced_open_dice",
81 ],
82}
83
84rust_test {
85 name: "libdiced_open_dice_nostd.integration_test",
86 defaults: ["libdiced_open_dice_test_defaults"],
87 rustlibs: [
88 "libdiced_open_dice_nostd",
89 ],
90}
91
92rust_defaults {
93 name: "libopen_dice_bindgen_nostd.rust_defaults",
94 bindgen_flags: [
95 "--use-core",
96 "--ctypes-prefix=core::ffi",
97 "--raw-line=#![no_std]",
98 ],
99 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",
161 ],
162}
163
164rust_bindgen {
165 name: "libopen_dice_cbor_bindgen",
166 defaults: [
167 "libopen_dice.rust_defaults",
168 "libopen_dice_cbor_bindgen.rust_defaults",
169 ],
170 whole_static_libs: ["libopen_dice_cbor"],
171}
172
173rust_bindgen {
174 name: "libopen_dice_cbor_bindgen_nostd",
175 defaults: [
176 "libopen_dice_cbor_bindgen.rust_defaults",
177 "libopen_dice_bindgen_nostd.rust_defaults",
178 ],
179 whole_static_libs: ["libopen_dice_cbor_baremetal"],
180}
181
182rust_defaults {
183 name: "libopen_dice_android_bindgen.rust_defaults",
184 wrapper_src: "bindgen/android.h",
185 crate_name: "open_dice_android_bindgen",
186 source_stem: "bindings",
187 bindgen_flags: [
188 // By generating only essential functions, we can make bindings concise and
189 // optimize compilation time.
190 "--allowlist-function=DiceAndroidFormatConfigDescriptor",
191 "--allowlist-function=DiceAndroidMainFlow",
192 "--allowlist-function=DiceAndroidHandoverMainFlow",
193 "--allowlist-function=DiceAndroidHandoverParse",
194
195 // We also need some constants in addition to the functions.
196 "--allowlist-var=DICE_ANDROID_CONFIG_.*",
197
198 // Prevent DiceInputValues from being generated a second time and
199 // import it instead from open_dice_cbor_bindgen.
200 "--blocklist-type=DiceInputValues_",
201 "--blocklist-type=DiceInputValues",
202 "--raw-line",
203 "pub use open_dice_cbor_bindgen::DiceInputValues;",
204
205 // Prevent DiceResult from being generated a second time and
206 // import it instead from open_dice_cbor_bindgen.
207 "--blocklist-type=DiceResult",
208 "--raw-line",
209 "pub use open_dice_cbor_bindgen::DiceResult;",
210 ],
211
212}
213
214rust_bindgen {
215 name: "libopen_dice_android_bindgen",
216 defaults: [
217 "libopen_dice.rust_defaults",
218 "libopen_dice_android_bindgen.rust_defaults",
219 ],
220 rustlibs: [
221 "libopen_dice_cbor_bindgen",
222 ],
223 whole_static_libs: ["libopen_dice_android"],
224}
225
226rust_bindgen {
227 name: "libopen_dice_android_bindgen_nostd",
228 defaults: [
229 "libopen_dice_android_bindgen.rust_defaults",
230 "libopen_dice_bindgen_nostd.rust_defaults",
231 ],
232 rustlibs: [
233 "libopen_dice_cbor_bindgen_nostd",
234 ],
235 whole_static_libs: ["libopen_dice_android_baremetal"],
236}
237
238rust_test {
239 name: "libopen_dice_cbor_bindgen_test",
240 srcs: [
241 ":libopen_dice_cbor_bindgen",
242 ],
243 crate_name: "open_dice_cbor_bindgen_test",
244 test_suites: ["general-tests"],
245 auto_gen_config: true,
246 clippy_lints: "none",
247 lints: "none",
248}
249
250rust_test {
251 name: "libopen_dice_android_bindgen_test",
252 srcs: [
253 ":libopen_dice_android_bindgen",
254 ],
255 crate_name: "open_dice_android_bindgen_test",
256 rustlibs: [
257 "libopen_dice_cbor_bindgen",
258 ],
259 test_suites: ["general-tests"],
260 auto_gen_config: true,
261 clippy_lints: "none",
262 lints: "none",
263}