blob: 2505b426ee183aa1ce0dd13dcedb1ca0309d6b5b [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: [
128 "--size_t-is-usize",
129 "--rustified-enum DiceConfigType",
130 "--rustified-enum DiceMode",
131 "--rustified-enum DiceResult",
132
133 // By generating only essential functions, we can make bindings concise and
134 // optimize compilation time.
135 "--allowlist-function=DiceDeriveCdiPrivateKeySeed",
136 "--allowlist-function=DiceDeriveCdiCertificateId",
137 "--allowlist-function=DiceMainFlow",
138 "--allowlist-function=DiceHash",
139 "--allowlist-function=DiceKdf",
140 "--allowlist-function=DiceKeypairFromSeed",
141 "--allowlist-function=DiceSign",
142 "--allowlist-function=DiceVerify",
143 "--allowlist-function=DiceGenerateCertificate",
144
145 // We also need some constants in addition to the functions.
146 "--allowlist-var=DICE_CDI_SIZE",
147 "--allowlist-var=DICE_HASH_SIZE",
148 "--allowlist-var=DICE_HIDDEN_SIZE",
149 "--allowlist-var=DICE_INLINE_CONFIG_SIZE",
150 "--allowlist-var=DICE_PRIVATE_KEY_SEED_SIZE",
151 "--allowlist-var=DICE_ID_SIZE",
152 "--allowlist-var=DICE_PUBLIC_KEY_SIZE",
153 "--allowlist-var=DICE_PRIVATE_KEY_SIZE",
154 "--allowlist-var=DICE_SIGNATURE_SIZE",
155 ],
156}
157
158rust_bindgen {
159 name: "libopen_dice_cbor_bindgen",
160 defaults: ["libopen_dice_cbor_bindgen.rust_defaults"],
161 whole_static_libs: ["libopen_dice_cbor"],
Alice Wang988df592023-02-16 12:05:42 +0000162}
163
164rust_bindgen {
165 name: "libopen_dice_cbor_bindgen_nostd",
166 defaults: [
167 "libopen_dice_cbor_bindgen.rust_defaults",
168 "libopen_dice_bindgen_nostd.rust_defaults",
169 ],
170 whole_static_libs: ["libopen_dice_cbor_baremetal"],
171}
172
173rust_defaults {
174 name: "libopen_dice_bcc_bindgen.rust_defaults",
175 defaults: ["libopen_dice.rust_defaults"],
176 wrapper_src: "bindgen/android/bcc.h",
177 crate_name: "open_dice_bcc_bindgen",
178 source_stem: "bindings",
179 bindgen_flags: [
180 "--size_t-is-usize",
181
182 // By generating only essential functions, we can make bindings concise and
183 // optimize compilation time.
184 "--allowlist-function=BccFormatConfigDescriptor",
185 "--allowlist-function=BccMainFlow",
186 "--allowlist-function=BccHandoverMainFlow",
187 "--allowlist-function=BccHandoverParse",
188
189 // We also need some constants in addition to the functions.
190 "--allowlist-var=BCC_INPUT_COMPONENT_NAME",
191 "--allowlist-var=BCC_INPUT_COMPONENT_VERSION",
192 "--allowlist-var=BCC_INPUT_RESETTABLE",
193
194 // Prevent DiceInputValues from being generated a second time and
195 // import it instead from open_dice_cbor_bindgen.
196 "--blocklist-type=DiceInputValues_",
197 "--blocklist-type=DiceInputValues",
198 "--raw-line",
199 "pub use open_dice_cbor_bindgen::DiceInputValues;",
200
201 // Prevent DiceResult from being generated a second time and
202 // import it instead from open_dice_cbor_bindgen.
203 "--blocklist-type=DiceResult",
204 "--raw-line",
205 "pub use open_dice_cbor_bindgen::DiceResult;",
206 ],
207
208}
209
210rust_bindgen {
211 name: "libopen_dice_bcc_bindgen",
212 defaults: ["libopen_dice_bcc_bindgen.rust_defaults"],
213 rustlibs: [
214 "libopen_dice_cbor_bindgen",
215 ],
216 whole_static_libs: ["libopen_dice_bcc"],
217}
218
219rust_bindgen {
220 name: "libopen_dice_bcc_bindgen_nostd",
221 defaults: [
222 "libopen_dice_bcc_bindgen.rust_defaults",
223 "libopen_dice_bindgen_nostd.rust_defaults",
224 ],
225 rustlibs: [
226 "libopen_dice_cbor_bindgen_nostd",
227 ],
228 whole_static_libs: ["libopen_dice_bcc_baremetal"],
229}
230
231rust_test {
232 name: "libopen_dice_cbor_bindgen_test",
233 srcs: [
234 ":libopen_dice_cbor_bindgen",
235 ],
236 crate_name: "open_dice_cbor_bindgen_test",
237 test_suites: ["general-tests"],
238 auto_gen_config: true,
239 clippy_lints: "none",
240 lints: "none",
241}
242
243rust_test {
244 name: "libopen_dice_bcc_bindgen_test",
245 srcs: [
246 ":libopen_dice_bcc_bindgen",
247 ],
248 crate_name: "open_dice_bcc_bindgen_test",
249 rustlibs: [
250 "libopen_dice_cbor_bindgen",
251 ],
252 test_suites: ["general-tests"],
253 auto_gen_config: true,
254 clippy_lints: "none",
255 lints: "none",
256}