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