blob: b76a764effdb23b789700bc668d8803b8a3f50a7 [file] [log] [blame]
Alice Wang0b9e1102023-02-02 09:57:06 +00001package {
Alice Wang988df592023-02-16 12:05:42 +00002 default_visibility: [":__subpackages__"],
Alice Wang0b9e1102023-02-02 09:57:06 +00003 default_applicable_licenses: ["Android-Apache-2.0"],
4}
5
6rust_defaults {
7 name: "libdiced_open_dice_defaults",
8 crate_name: "diced_open_dice",
9 srcs: ["src/lib.rs"],
10 static_libs: [
11 "libopen_dice_cbor",
12 ],
13 vendor_available: true,
14 apex_available: [
15 "//apex_available:platform",
16 "com.android.virt",
17 ],
18}
19
20rust_library_rlib {
21 name: "libdiced_open_dice_nostd",
22 defaults: ["libdiced_open_dice_defaults"],
23 rustlibs: [
Alice Wang9c40eca2023-02-03 13:10:24 +000024 "libopen_dice_bcc_bindgen_nostd",
Alice Wang0b9e1102023-02-02 09:57:06 +000025 "libopen_dice_cbor_bindgen_nostd",
Alice Wangf4bd1c62023-02-08 08:38:44 +000026 "libzeroize_nostd",
Alice Wang0b9e1102023-02-02 09:57:06 +000027 ],
Alice Wang988df592023-02-16 12:05:42 +000028 whole_static_libs: [
Alice Wang24954b42023-02-06 10:03:45 +000029 "libopen_dice_cbor",
30 "libcrypto_baremetal",
31 ],
Alice Wang988df592023-02-16 12:05:42 +000032 visibility: [
33 "//packages/modules/Virtualization:__subpackages__",
34 ],
Alice Wang0b9e1102023-02-02 09:57:06 +000035}
36
Alice Wang856d6562023-02-03 13:51:08 +000037rust_library {
Alice Wang0b9e1102023-02-02 09:57:06 +000038 name: "libdiced_open_dice",
39 defaults: ["libdiced_open_dice_defaults"],
40 rustlibs: [
Alice Wang9c40eca2023-02-03 13:10:24 +000041 "libopen_dice_bcc_bindgen",
Alice Wang0b9e1102023-02-02 09:57:06 +000042 "libopen_dice_cbor_bindgen",
Alice Wang856d6562023-02-03 13:51:08 +000043 // For ZVec
44 "libkeystore2_crypto_rust",
Alice Wangf4bd1c62023-02-08 08:38:44 +000045 "libzeroize",
Alice Wang0b9e1102023-02-02 09:57:06 +000046 ],
47 features: [
48 "std",
49 ],
Alice Wang9c40eca2023-02-03 13:10:24 +000050 whole_static_libs: [
51 "libopen_dice_bcc",
52 ],
Alice Wang988df592023-02-16 12:05:42 +000053 visibility: [
54 "//system/security/diced:__subpackages__",
55 "//packages/modules/Virtualization:__subpackages__",
Alice Wang5e8db6a2023-02-17 17:13:18 +000056 "//hardware/interfaces/security/dice/aidl:__subpackages__",
Alice Wang988df592023-02-16 12:05:42 +000057 ],
Alice Wang24954b42023-02-06 10:03:45 +000058}
59
Alice Wangceb66422023-02-07 13:55:33 +000060rust_defaults {
61 name: "libdiced_open_dice_test_defaults",
62 crate_name: "diced_open_dice_test",
63 srcs: ["tests/*.rs"],
64 test_suites: ["general-tests"],
65}
66
67rust_test {
68 name: "libdiced_open_dice.integration_test",
69 defaults: ["libdiced_open_dice_test_defaults"],
70 rustlibs: [
71 "libdiced_open_dice",
72 ],
73}
74
75rust_test {
76 name: "libdiced_open_dice_nostd.integration_test",
77 defaults: ["libdiced_open_dice_test_defaults"],
78 rustlibs: [
79 "libdiced_open_dice_nostd",
80 ],
81}
Alice Wang988df592023-02-16 12:05:42 +000082
83rust_defaults {
84 name: "libopen_dice_bindgen_nostd.rust_defaults",
85 bindgen_flags: [
86 "--use-core",
87 "--ctypes-prefix=core::ffi",
88 "--raw-line=#![no_std]",
89 ],
90 no_stdlibs: true,
91 prefer_rlib: true,
92 stdlibs: [
93 "libcore.rust_sysroot",
94 "libcompiler_builtins.rust_sysroot",
95 ],
96 target: {
97 musl: {
98 enabled: false,
99 },
100 glibc: {
101 enabled: false,
102 },
103 darwin: {
104 enabled: false,
105 },
106 },
107}
108
109rust_defaults {
110 name: "libopen_dice.rust_defaults",
111 host_supported: true,
112 vendor_available: true,
113 apex_available: [
114 "//apex_available:platform",
115 "com.android.compos",
116 "com.android.virt",
117 ],
118}
119
120rust_defaults {
121 name: "libopen_dice_cbor_bindgen.rust_defaults",
122 defaults: ["libopen_dice.rust_defaults"],
123 wrapper_src: "bindgen/dice.h",
124 crate_name: "open_dice_cbor_bindgen",
125 source_stem: "bindings",
126 bindgen_flags: [
127 "--size_t-is-usize",
128 "--rustified-enum DiceConfigType",
129 "--rustified-enum DiceMode",
130 "--rustified-enum DiceResult",
131
132 // By generating only essential functions, we can make bindings concise and
133 // optimize compilation time.
134 "--allowlist-function=DiceDeriveCdiPrivateKeySeed",
135 "--allowlist-function=DiceDeriveCdiCertificateId",
136 "--allowlist-function=DiceMainFlow",
137 "--allowlist-function=DiceHash",
138 "--allowlist-function=DiceKdf",
139 "--allowlist-function=DiceKeypairFromSeed",
140 "--allowlist-function=DiceSign",
141 "--allowlist-function=DiceVerify",
142 "--allowlist-function=DiceGenerateCertificate",
143
144 // We also need some constants in addition to the functions.
145 "--allowlist-var=DICE_CDI_SIZE",
146 "--allowlist-var=DICE_HASH_SIZE",
147 "--allowlist-var=DICE_HIDDEN_SIZE",
148 "--allowlist-var=DICE_INLINE_CONFIG_SIZE",
149 "--allowlist-var=DICE_PRIVATE_KEY_SEED_SIZE",
150 "--allowlist-var=DICE_ID_SIZE",
151 "--allowlist-var=DICE_PUBLIC_KEY_SIZE",
152 "--allowlist-var=DICE_PRIVATE_KEY_SIZE",
153 "--allowlist-var=DICE_SIGNATURE_SIZE",
154 ],
155}
156
157rust_bindgen {
158 name: "libopen_dice_cbor_bindgen",
159 defaults: ["libopen_dice_cbor_bindgen.rust_defaults"],
160 whole_static_libs: ["libopen_dice_cbor"],
161 // TODO(b/267575445): Remove the visibility to open_dice_cbor once everything
162 // in open_dice_cbor is moved to open_dice
163 visibility: [
164 "//system/security/diced/open_dice_cbor",
165 ],
166}
167
168rust_bindgen {
169 name: "libopen_dice_cbor_bindgen_nostd",
170 defaults: [
171 "libopen_dice_cbor_bindgen.rust_defaults",
172 "libopen_dice_bindgen_nostd.rust_defaults",
173 ],
174 whole_static_libs: ["libopen_dice_cbor_baremetal"],
175}
176
177rust_defaults {
178 name: "libopen_dice_bcc_bindgen.rust_defaults",
179 defaults: ["libopen_dice.rust_defaults"],
180 wrapper_src: "bindgen/android/bcc.h",
181 crate_name: "open_dice_bcc_bindgen",
182 source_stem: "bindings",
183 bindgen_flags: [
184 "--size_t-is-usize",
185
186 // By generating only essential functions, we can make bindings concise and
187 // optimize compilation time.
188 "--allowlist-function=BccFormatConfigDescriptor",
189 "--allowlist-function=BccMainFlow",
190 "--allowlist-function=BccHandoverMainFlow",
191 "--allowlist-function=BccHandoverParse",
192
193 // We also need some constants in addition to the functions.
194 "--allowlist-var=BCC_INPUT_COMPONENT_NAME",
195 "--allowlist-var=BCC_INPUT_COMPONENT_VERSION",
196 "--allowlist-var=BCC_INPUT_RESETTABLE",
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_bcc_bindgen",
216 defaults: ["libopen_dice_bcc_bindgen.rust_defaults"],
217 rustlibs: [
218 "libopen_dice_cbor_bindgen",
219 ],
220 whole_static_libs: ["libopen_dice_bcc"],
221}
222
223rust_bindgen {
224 name: "libopen_dice_bcc_bindgen_nostd",
225 defaults: [
226 "libopen_dice_bcc_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_bcc_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_bcc_bindgen_test",
249 srcs: [
250 ":libopen_dice_bcc_bindgen",
251 ],
252 crate_name: "open_dice_bcc_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}