blob: 45cbb676e1e493a0b0a78ce303c32155407245f6 [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 Wangf4bd1c62023-02-08 08:38:44 +000043 "libzeroize",
Alice Wang0b9e1102023-02-02 09:57:06 +000044 ],
45 features: [
46 "std",
47 ],
Alice Wang147f6042023-02-20 08:33:17 +000048 shared_libs: [
49 "libcrypto",
50 ],
Alice Wang9c40eca2023-02-03 13:10:24 +000051 whole_static_libs: [
52 "libopen_dice_bcc",
53 ],
Alice Wang988df592023-02-16 12:05:42 +000054 visibility: [
55 "//system/security/diced:__subpackages__",
56 "//packages/modules/Virtualization:__subpackages__",
Alice Wang5e8db6a2023-02-17 17:13:18 +000057 "//hardware/interfaces/security/dice/aidl:__subpackages__",
Alice Wang988df592023-02-16 12:05:42 +000058 ],
Alice Wang24954b42023-02-06 10:03:45 +000059}
60
Alice Wangceb66422023-02-07 13:55:33 +000061rust_defaults {
62 name: "libdiced_open_dice_test_defaults",
63 crate_name: "diced_open_dice_test",
64 srcs: ["tests/*.rs"],
65 test_suites: ["general-tests"],
66}
67
68rust_test {
69 name: "libdiced_open_dice.integration_test",
70 defaults: ["libdiced_open_dice_test_defaults"],
71 rustlibs: [
72 "libdiced_open_dice",
73 ],
74}
75
76rust_test {
77 name: "libdiced_open_dice_nostd.integration_test",
78 defaults: ["libdiced_open_dice_test_defaults"],
79 rustlibs: [
80 "libdiced_open_dice_nostd",
81 ],
82}
Alice Wang988df592023-02-16 12:05:42 +000083
84rust_defaults {
85 name: "libopen_dice_bindgen_nostd.rust_defaults",
86 bindgen_flags: [
87 "--use-core",
88 "--ctypes-prefix=core::ffi",
89 "--raw-line=#![no_std]",
90 ],
91 no_stdlibs: true,
92 prefer_rlib: true,
93 stdlibs: [
94 "libcore.rust_sysroot",
95 "libcompiler_builtins.rust_sysroot",
96 ],
97 target: {
98 musl: {
99 enabled: false,
100 },
101 glibc: {
102 enabled: false,
103 },
104 darwin: {
105 enabled: false,
106 },
107 },
108}
109
110rust_defaults {
111 name: "libopen_dice.rust_defaults",
112 host_supported: true,
113 vendor_available: true,
114 apex_available: [
115 "//apex_available:platform",
116 "com.android.compos",
117 "com.android.virt",
118 ],
119}
120
121rust_defaults {
122 name: "libopen_dice_cbor_bindgen.rust_defaults",
123 defaults: ["libopen_dice.rust_defaults"],
124 wrapper_src: "bindgen/dice.h",
125 crate_name: "open_dice_cbor_bindgen",
126 source_stem: "bindings",
127 bindgen_flags: [
Alice Wang988df592023-02-16 12:05:42 +0000128 "--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"],
Alice Wang988df592023-02-16 12:05:42 +0000161}
162
163rust_bindgen {
164 name: "libopen_dice_cbor_bindgen_nostd",
165 defaults: [
166 "libopen_dice_cbor_bindgen.rust_defaults",
167 "libopen_dice_bindgen_nostd.rust_defaults",
168 ],
169 whole_static_libs: ["libopen_dice_cbor_baremetal"],
170}
171
172rust_defaults {
173 name: "libopen_dice_bcc_bindgen.rust_defaults",
174 defaults: ["libopen_dice.rust_defaults"],
175 wrapper_src: "bindgen/android/bcc.h",
176 crate_name: "open_dice_bcc_bindgen",
177 source_stem: "bindings",
178 bindgen_flags: [
Alice Wang988df592023-02-16 12:05:42 +0000179 // By generating only essential functions, we can make bindings concise and
180 // optimize compilation time.
181 "--allowlist-function=BccFormatConfigDescriptor",
182 "--allowlist-function=BccMainFlow",
183 "--allowlist-function=BccHandoverMainFlow",
184 "--allowlist-function=BccHandoverParse",
185
186 // We also need some constants in addition to the functions.
187 "--allowlist-var=BCC_INPUT_COMPONENT_NAME",
188 "--allowlist-var=BCC_INPUT_COMPONENT_VERSION",
189 "--allowlist-var=BCC_INPUT_RESETTABLE",
190
191 // Prevent DiceInputValues from being generated a second time and
192 // import it instead from open_dice_cbor_bindgen.
193 "--blocklist-type=DiceInputValues_",
194 "--blocklist-type=DiceInputValues",
195 "--raw-line",
196 "pub use open_dice_cbor_bindgen::DiceInputValues;",
197
198 // Prevent DiceResult from being generated a second time and
199 // import it instead from open_dice_cbor_bindgen.
200 "--blocklist-type=DiceResult",
201 "--raw-line",
202 "pub use open_dice_cbor_bindgen::DiceResult;",
203 ],
204
205}
206
207rust_bindgen {
208 name: "libopen_dice_bcc_bindgen",
209 defaults: ["libopen_dice_bcc_bindgen.rust_defaults"],
210 rustlibs: [
211 "libopen_dice_cbor_bindgen",
212 ],
213 whole_static_libs: ["libopen_dice_bcc"],
214}
215
216rust_bindgen {
217 name: "libopen_dice_bcc_bindgen_nostd",
218 defaults: [
219 "libopen_dice_bcc_bindgen.rust_defaults",
220 "libopen_dice_bindgen_nostd.rust_defaults",
221 ],
222 rustlibs: [
223 "libopen_dice_cbor_bindgen_nostd",
224 ],
225 whole_static_libs: ["libopen_dice_bcc_baremetal"],
226}
227
228rust_test {
229 name: "libopen_dice_cbor_bindgen_test",
230 srcs: [
231 ":libopen_dice_cbor_bindgen",
232 ],
233 crate_name: "open_dice_cbor_bindgen_test",
234 test_suites: ["general-tests"],
235 auto_gen_config: true,
236 clippy_lints: "none",
237 lints: "none",
238}
239
240rust_test {
241 name: "libopen_dice_bcc_bindgen_test",
242 srcs: [
243 ":libopen_dice_bcc_bindgen",
244 ],
245 crate_name: "open_dice_bcc_bindgen_test",
246 rustlibs: [
247 "libopen_dice_cbor_bindgen",
248 ],
249 test_suites: ["general-tests"],
250 auto_gen_config: true,
251 clippy_lints: "none",
252 lints: "none",
253}