blob: 745b86eb5756c74e5b8a653717256749805e6f9d [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"],
Alice Wang0b9e1102023-02-02 09:57:06 +000010}
11
12rust_library_rlib {
13 name: "libdiced_open_dice_nostd",
14 defaults: ["libdiced_open_dice_defaults"],
15 rustlibs: [
Andrew Scull0275aa52023-08-18 18:03:11 +000016 "libopen_dice_android_bindgen_nostd",
Alice Wang0b9e1102023-02-02 09:57:06 +000017 "libopen_dice_cbor_bindgen_nostd",
Alice Wangf4bd1c62023-02-08 08:38:44 +000018 "libzeroize_nostd",
Alice Wang0b9e1102023-02-02 09:57:06 +000019 ],
Alice Wangdb748d22023-09-19 11:18:29 +000020 features: [
21 "alloc",
22 ],
Alice Wang988df592023-02-16 12:05:42 +000023 whole_static_libs: [
Alice Wang24954b42023-02-06 10:03:45 +000024 "libopen_dice_cbor",
25 "libcrypto_baremetal",
26 ],
Alice Wang988df592023-02-16 12:05:42 +000027 visibility: [
28 "//packages/modules/Virtualization:__subpackages__",
Alice Wangdb748d22023-09-19 11:18:29 +000029 "//system/security/diced/sample_inputs",
Alice Wang988df592023-02-16 12:05:42 +000030 ],
Alice Wang0b9e1102023-02-02 09:57:06 +000031}
32
Alice Wang856d6562023-02-03 13:51:08 +000033rust_library {
Alice Wang0b9e1102023-02-02 09:57:06 +000034 name: "libdiced_open_dice",
35 defaults: ["libdiced_open_dice_defaults"],
Pierre-Clément Tosida662b02023-07-27 17:03:53 +010036 vendor_available: true,
Alice Wang0b9e1102023-02-02 09:57:06 +000037 rustlibs: [
Andrew Scull0275aa52023-08-18 18:03:11 +000038 "libopen_dice_android_bindgen",
Alice Wang0b9e1102023-02-02 09:57:06 +000039 "libopen_dice_cbor_bindgen",
Alice Wangf4bd1c62023-02-08 08:38:44 +000040 "libzeroize",
Alice Wang0b9e1102023-02-02 09:57:06 +000041 ],
42 features: [
Alice Wangdb748d22023-09-19 11:18:29 +000043 "alloc",
Alice Wang0b9e1102023-02-02 09:57:06 +000044 "std",
45 ],
Alice Wang147f6042023-02-20 08:33:17 +000046 shared_libs: [
47 "libcrypto",
48 ],
Pierre-Clément Tosida662b02023-07-27 17:03:53 +010049 static_libs: [
50 "libopen_dice_cbor",
51 ],
Alice Wang9c40eca2023-02-03 13:10:24 +000052 whole_static_libs: [
Andrew Scull0275aa52023-08-18 18:03:11 +000053 "libopen_dice_android",
Alice Wang9c40eca2023-02-03 13:10:24 +000054 ],
Alice Wang988df592023-02-16 12:05:42 +000055 visibility: [
56 "//system/security/diced:__subpackages__",
57 "//packages/modules/Virtualization:__subpackages__",
Alice Wang5e8db6a2023-02-17 17:13:18 +000058 "//hardware/interfaces/security/dice/aidl:__subpackages__",
Alice Wang988df592023-02-16 12:05:42 +000059 ],
Pierre-Clément Tosida662b02023-07-27 17:03:53 +010060 apex_available: [
61 "//apex_available:platform",
62 "com.android.virt",
63 ],
Alice Wang24954b42023-02-06 10:03:45 +000064}
65
Alice Wangceb66422023-02-07 13:55:33 +000066rust_defaults {
67 name: "libdiced_open_dice_test_defaults",
68 crate_name: "diced_open_dice_test",
69 srcs: ["tests/*.rs"],
70 test_suites: ["general-tests"],
71}
72
73rust_test {
74 name: "libdiced_open_dice.integration_test",
75 defaults: ["libdiced_open_dice_test_defaults"],
76 rustlibs: [
77 "libdiced_open_dice",
78 ],
79}
80
81rust_test {
82 name: "libdiced_open_dice_nostd.integration_test",
83 defaults: ["libdiced_open_dice_test_defaults"],
84 rustlibs: [
85 "libdiced_open_dice_nostd",
86 ],
87}
Alice Wang988df592023-02-16 12:05:42 +000088
89rust_defaults {
90 name: "libopen_dice_bindgen_nostd.rust_defaults",
91 bindgen_flags: [
92 "--use-core",
93 "--ctypes-prefix=core::ffi",
94 "--raw-line=#![no_std]",
95 ],
96 no_stdlibs: true,
97 prefer_rlib: true,
98 stdlibs: [
99 "libcore.rust_sysroot",
100 "libcompiler_builtins.rust_sysroot",
101 ],
102 target: {
103 musl: {
104 enabled: false,
105 },
106 glibc: {
107 enabled: false,
108 },
109 darwin: {
110 enabled: false,
111 },
112 },
113}
114
115rust_defaults {
116 name: "libopen_dice.rust_defaults",
117 host_supported: true,
118 vendor_available: true,
119 apex_available: [
120 "//apex_available:platform",
121 "com.android.compos",
122 "com.android.virt",
123 ],
124}
125
126rust_defaults {
127 name: "libopen_dice_cbor_bindgen.rust_defaults",
Alice Wang988df592023-02-16 12:05:42 +0000128 wrapper_src: "bindgen/dice.h",
129 crate_name: "open_dice_cbor_bindgen",
130 source_stem: "bindings",
131 bindgen_flags: [
Alice Wang988df592023-02-16 12:05:42 +0000132 "--rustified-enum DiceConfigType",
133 "--rustified-enum DiceMode",
134 "--rustified-enum DiceResult",
135
136 // By generating only essential functions, we can make bindings concise and
137 // optimize compilation time.
138 "--allowlist-function=DiceDeriveCdiPrivateKeySeed",
139 "--allowlist-function=DiceDeriveCdiCertificateId",
140 "--allowlist-function=DiceMainFlow",
141 "--allowlist-function=DiceHash",
142 "--allowlist-function=DiceKdf",
143 "--allowlist-function=DiceKeypairFromSeed",
144 "--allowlist-function=DiceSign",
145 "--allowlist-function=DiceVerify",
146 "--allowlist-function=DiceGenerateCertificate",
147
148 // We also need some constants in addition to the functions.
149 "--allowlist-var=DICE_CDI_SIZE",
150 "--allowlist-var=DICE_HASH_SIZE",
151 "--allowlist-var=DICE_HIDDEN_SIZE",
152 "--allowlist-var=DICE_INLINE_CONFIG_SIZE",
153 "--allowlist-var=DICE_PRIVATE_KEY_SEED_SIZE",
154 "--allowlist-var=DICE_ID_SIZE",
155 "--allowlist-var=DICE_PUBLIC_KEY_SIZE",
156 "--allowlist-var=DICE_PRIVATE_KEY_SIZE",
157 "--allowlist-var=DICE_SIGNATURE_SIZE",
158 ],
159}
160
161rust_bindgen {
162 name: "libopen_dice_cbor_bindgen",
Pierre-Clément Tosida662b02023-07-27 17:03:53 +0100163 defaults: [
164 "libopen_dice.rust_defaults",
165 "libopen_dice_cbor_bindgen.rust_defaults",
166 ],
Alice Wang988df592023-02-16 12:05:42 +0000167 whole_static_libs: ["libopen_dice_cbor"],
Alice Wang988df592023-02-16 12:05:42 +0000168}
169
170rust_bindgen {
171 name: "libopen_dice_cbor_bindgen_nostd",
172 defaults: [
173 "libopen_dice_cbor_bindgen.rust_defaults",
174 "libopen_dice_bindgen_nostd.rust_defaults",
175 ],
176 whole_static_libs: ["libopen_dice_cbor_baremetal"],
177}
178
179rust_defaults {
Andrew Scull0275aa52023-08-18 18:03:11 +0000180 name: "libopen_dice_android_bindgen.rust_defaults",
181 wrapper_src: "bindgen/android.h",
182 crate_name: "open_dice_android_bindgen",
Alice Wang988df592023-02-16 12:05:42 +0000183 source_stem: "bindings",
184 bindgen_flags: [
Alice Wang988df592023-02-16 12:05:42 +0000185 // By generating only essential functions, we can make bindings concise and
186 // optimize compilation time.
Andrew Scull0275aa52023-08-18 18:03:11 +0000187 "--allowlist-function=DiceAndroidFormatConfigDescriptor",
188 "--allowlist-function=DiceAndroidMainFlow",
189 "--allowlist-function=DiceAndroidHandoverMainFlow",
190 "--allowlist-function=DiceAndroidHandoverParse",
Alice Wang988df592023-02-16 12:05:42 +0000191
192 // We also need some constants in addition to the functions.
Alan Stokes82b12392023-08-22 14:39:29 +0100193 "--allowlist-var=DICE_ANDROID_CONFIG_.*",
Alice Wang988df592023-02-16 12:05:42 +0000194
195 // Prevent DiceInputValues from being generated a second time and
196 // import it instead from open_dice_cbor_bindgen.
197 "--blocklist-type=DiceInputValues_",
198 "--blocklist-type=DiceInputValues",
199 "--raw-line",
200 "pub use open_dice_cbor_bindgen::DiceInputValues;",
201
202 // Prevent DiceResult from being generated a second time and
203 // import it instead from open_dice_cbor_bindgen.
204 "--blocklist-type=DiceResult",
205 "--raw-line",
206 "pub use open_dice_cbor_bindgen::DiceResult;",
207 ],
208
209}
210
211rust_bindgen {
Andrew Scull0275aa52023-08-18 18:03:11 +0000212 name: "libopen_dice_android_bindgen",
Pierre-Clément Tosida662b02023-07-27 17:03:53 +0100213 defaults: [
214 "libopen_dice.rust_defaults",
Andrew Scull0275aa52023-08-18 18:03:11 +0000215 "libopen_dice_android_bindgen.rust_defaults",
Pierre-Clément Tosida662b02023-07-27 17:03:53 +0100216 ],
Alice Wang988df592023-02-16 12:05:42 +0000217 rustlibs: [
218 "libopen_dice_cbor_bindgen",
219 ],
Andrew Scull0275aa52023-08-18 18:03:11 +0000220 whole_static_libs: ["libopen_dice_android"],
Alice Wang988df592023-02-16 12:05:42 +0000221}
222
223rust_bindgen {
Andrew Scull0275aa52023-08-18 18:03:11 +0000224 name: "libopen_dice_android_bindgen_nostd",
Alice Wang988df592023-02-16 12:05:42 +0000225 defaults: [
Andrew Scull0275aa52023-08-18 18:03:11 +0000226 "libopen_dice_android_bindgen.rust_defaults",
Alice Wang988df592023-02-16 12:05:42 +0000227 "libopen_dice_bindgen_nostd.rust_defaults",
228 ],
229 rustlibs: [
230 "libopen_dice_cbor_bindgen_nostd",
231 ],
Andrew Scull0275aa52023-08-18 18:03:11 +0000232 whole_static_libs: ["libopen_dice_android_baremetal"],
Alice Wang988df592023-02-16 12:05:42 +0000233}
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 {
Andrew Scull0275aa52023-08-18 18:03:11 +0000248 name: "libopen_dice_android_bindgen_test",
Alice Wang988df592023-02-16 12:05:42 +0000249 srcs: [
Andrew Scull0275aa52023-08-18 18:03:11 +0000250 ":libopen_dice_android_bindgen",
Alice Wang988df592023-02-16 12:05:42 +0000251 ],
Andrew Scull0275aa52023-08-18 18:03:11 +0000252 crate_name: "open_dice_android_bindgen_test",
Alice Wang988df592023-02-16 12:05:42 +0000253 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}