blob: 37745e4cf0a857782d81bb2dd29e0a640fd32bc3 [file] [log] [blame]
Andrew Scull9573bec2021-07-15 19:05:19 +00001package {
2 default_applicable_licenses: ["external_open_dice_license"],
3}
4
5license {
6 name: "external_open_dice_license",
7 visibility: [":__subpackages__"],
8 license_kinds: ["SPDX-license-identifier-Apache-2.0"],
9 license_text: ["LICENSE"],
10}
11
12cc_library_headers {
13 name: "libopen_dice_headers",
14 host_supported: true,
Janis Danisevskis785b0b42021-11-09 14:41:24 -080015 vendor_available: true,
Andrew Scull9573bec2021-07-15 19:05:19 +000016 export_include_dirs: ["include"],
17}
18
Andrew Scullf0b06902021-08-10 21:17:01 +000019cc_library_headers {
20 name: "libopen_dice_boringssl_ed25519_headers",
21 host_supported: true,
Janis Danisevskis785b0b42021-11-09 14:41:24 -080022 vendor_available: true,
Andrew Scullf0b06902021-08-10 21:17:01 +000023 export_include_dirs: ["include/dice/config/boringssl_ed25519"],
24}
25
Andrew Scull9573bec2021-07-15 19:05:19 +000026cc_library_static {
27 name: "libopen_dice_cbor",
28 host_supported: true,
Janis Danisevskis785b0b42021-11-09 14:41:24 -080029 vendor_available: true,
Andrew Scull9573bec2021-07-15 19:05:19 +000030 srcs: [
Hasini Gunasinghe0620de42022-04-06 05:01:36 +000031 "src/boringssl_hash_kdf_ops.c",
32 "src/boringssl_ed25519_ops.c",
Andrew Scull9573bec2021-07-15 19:05:19 +000033 "src/cbor_cert_op.c",
34 "src/cbor_writer.c",
Andrew Scullf0b06902021-08-10 21:17:01 +000035 "src/clear_memory.c",
Andrew Scull9573bec2021-07-15 19:05:19 +000036 "src/dice.c",
37 "src/utils.c",
38 ],
Andrew Scullf0b06902021-08-10 21:17:01 +000039 header_libs: [
40 "libopen_dice_boringssl_ed25519_headers",
41 "libopen_dice_headers",
42 ],
43 export_header_lib_headers: [
44 "libopen_dice_boringssl_ed25519_headers",
45 "libopen_dice_headers",
46 ],
Andrew Scull9573bec2021-07-15 19:05:19 +000047 shared_libs: ["libcrypto"],
48}
49
Andrew Scullecd29a62021-11-04 17:27:44 +000050cc_library_static {
51 name: "libopen_dice_bcc",
52 host_supported: true,
Janis Danisevskis785b0b42021-11-09 14:41:24 -080053 vendor_available: true,
Andrew Scullecd29a62021-11-04 17:27:44 +000054 srcs: [
55 "src/cbor_reader.c",
56 "src/android/bcc.c",
57 ],
58 static_libs: ["libopen_dice_cbor"],
59 export_static_lib_headers: ["libopen_dice_cbor"],
60 shared_libs: ["libcrypto"],
61}
62
Andrew Scull9573bec2021-07-15 19:05:19 +000063cc_test {
64 name: "libopen_dice_test",
65 host_supported: true,
66 cflags: ["-DDICE_USE_GTEST"],
67 srcs: [
Andrew Scullf0b06902021-08-10 21:17:01 +000068 "src/clear_memory.c",
Andrew Scull9573bec2021-07-15 19:05:19 +000069 "src/dice_test.cc",
70 "src/dice.c",
71 "src/utils.c",
72 ],
Andrew Scullf0b06902021-08-10 21:17:01 +000073 header_libs: [
74 "libopen_dice_boringssl_ed25519_headers",
75 "libopen_dice_headers",
76 ],
Andrew Scull9573bec2021-07-15 19:05:19 +000077 shared_libs: ["libcrypto"],
78}
79
80cc_test {
81 name: "libopen_dice_cbor_writer_test",
82 host_supported: true,
83 cflags: ["-DDICE_USE_GTEST"],
84 srcs: ["src/cbor_writer_test.cc"],
85 static_libs: ["libopen_dice_cbor"],
86}
87
Andrew Scullecd29a62021-11-04 17:27:44 +000088cc_test {
89 name: "libopen_dice_cbor_reader_test",
90 host_supported: true,
91 cflags: ["-DDICE_USE_GTEST"],
92 srcs: ["src/cbor_reader_test.cc"],
93 static_libs: ["libopen_dice_bcc"],
94}
95
96cc_test {
97 name: "libopen_dice_bcc_test",
98 host_supported: true,
99 cflags: ["-DDICE_USE_GTEST"],
100 srcs: ["src/android/bcc_test.cc"],
101 static_libs: [
102 "libopen_dice_bcc",
103 "libopen_dice_cbor",
104 ],
105 shared_libs: ["libcrypto"],
106}
107
Andrew Scull9573bec2021-07-15 19:05:19 +0000108// TODO: cbor_cert_op_test after resolving COSE dependency
109
110cc_fuzz {
111 name: "libopen_dice_cbor_writer_fuzzer",
112 host_supported: true,
113 srcs: ["src/cbor_writer_fuzzer.cc"],
114 static_libs: ["libopen_dice_cbor"],
115}
116
117cc_fuzz {
Andrew Scullecd29a62021-11-04 17:27:44 +0000118 name: "libopen_dice_cbor_reader_fuzzer",
119 host_supported: true,
120 srcs: ["src/cbor_reader_fuzzer.cc"],
121 static_libs: ["libopen_dice_bcc"],
122}
123
124cc_fuzz {
Andrew Scull9573bec2021-07-15 19:05:19 +0000125 name: "libopen_dice_cbor_fuzzer",
126 host_supported: true,
Andrew Scullf0b06902021-08-10 21:17:01 +0000127 srcs: ["src/fuzzer.cc"],
Andrew Scull9573bec2021-07-15 19:05:19 +0000128 static_libs: ["libopen_dice_cbor"],
129 shared_libs: ["libcrypto"],
130}
Andrew Scullecd29a62021-11-04 17:27:44 +0000131
132cc_fuzz {
133 name: "libopen_dice_bcc_fuzzer",
134 host_supported: true,
135 srcs: ["src/android/bcc_fuzzer.cc"],
136 static_libs: [
137 "libopen_dice_bcc",
138 "libopen_dice_cbor",
139 ],
140 shared_libs: ["libcrypto"],
141}
Janis Danisevskis3d32ed52021-10-11 14:20:30 -0700142
143rust_bindgen {
144 name: "libopen_dice_cbor_bindgen",
145 wrapper_src: "rust/dice.h",
146 crate_name: "open_dice_cbor_bindgen",
147 source_stem: "bindings",
148 header_libs: [
149 "libopen_dice_boringssl_ed25519_headers",
150 "libopen_dice_headers",
151 ],
152
153 // Generate bindings only for the symbols that are actually exported (see exported.map.txt).
154 // This makes the generated bindings much more concise and improves compilation
155 // time.
156 bindgen_flags: [
Janis Danisevskis5669e7b2021-12-13 21:03:05 -0800157 "--size_t-is-usize",
158
Janis Danisevskis3d32ed52021-10-11 14:20:30 -0700159 "--allowlist-function=DiceDeriveCdiPrivateKeySeed",
160 "--allowlist-function=DiceDeriveCdiCertificateId",
161 "--allowlist-function=DiceMainFlow",
162 "--allowlist-function=DiceHash",
163 "--allowlist-function=DiceKdf",
164 "--allowlist-function=DiceKeypairFromSeed",
165 "--allowlist-function=DiceSign",
166 "--allowlist-function=DiceVerify",
167 "--allowlist-function=DiceGenerateCertificate",
168
169 // We also need some constants in addition to the functions.
170 "--allowlist-var=DICE_CDI_SIZE",
171 "--allowlist-var=DICE_HASH_SIZE",
172 "--allowlist-var=DICE_HIDDEN_SIZE",
173 "--allowlist-var=DICE_INLINE_CONFIG_SIZE",
174 "--allowlist-var=DICE_PRIVATE_KEY_SEED_SIZE",
175 "--allowlist-var=DICE_ID_SIZE",
176 "--allowlist-var=DICE_PUBLIC_KEY_SIZE",
177 "--allowlist-var=DICE_PRIVATE_KEY_SIZE",
178 "--allowlist-var=DICE_SIGNATURE_SIZE",
179 ],
180
181 // This is mainly to run layout tests for generated bindings on the host.
182 host_supported: true,
Janis Danisevskis785b0b42021-11-09 14:41:24 -0800183 vendor_available: true,
Janis Danisevskis3d32ed52021-10-11 14:20:30 -0700184}
185
186rust_bindgen {
187 name: "libopen_dice_bcc_bindgen",
188 wrapper_src: "rust/android/bcc.h",
189 crate_name: "open_dice_bcc_bindgen",
190 source_stem: "bindings",
191 header_libs: [
192 "libopen_dice_headers",
193 ],
194
195 // Generate bindings only for the symbols that are actually exported (see exported.map.txt).
196 // This makes the generated bindings much more concise and improves compilation
197 // time.
198 bindgen_flags: [
Janis Danisevskis5669e7b2021-12-13 21:03:05 -0800199 "--size_t-is-usize",
200
Janis Danisevskis3d32ed52021-10-11 14:20:30 -0700201 "--allowlist-function=BccFormatConfigDescriptor",
202 "--allowlist-function=BccMainFlow",
203 "--allowlist-function=BccHandoverMainFlow",
204
205 // We also need some constants in addition to the functions.
206 "--allowlist-var=BCC_INPUT_COMPONENT_NAME",
207 "--allowlist-var=BCC_INPUT_COMPONENT_VERSION",
208 "--allowlist-var=BCC_INPUT_RESETTABLE",
Janis Danisevskis5669e7b2021-12-13 21:03:05 -0800209
210 // Prevent DiceInputValues from being generated a second time and
211 // import it instead from open_dice_cbor_bindgen.
212 "--blocklist-type=DiceInputValues_",
213 "--blocklist-type=DiceInputValues",
Hasini Gunasinghe0620de42022-04-06 05:01:36 +0000214 "--raw-line",
215 "pub use open_dice_cbor_bindgen::DiceInputValues;",
Janis Danisevskis5669e7b2021-12-13 21:03:05 -0800216 ],
217
218 rustlibs: [
219 "libopen_dice_cbor_bindgen",
Janis Danisevskis3d32ed52021-10-11 14:20:30 -0700220 ],
221
222 // This is mainly to run layout tests for generated bindings on the host.
223 host_supported: true,
Janis Danisevskis785b0b42021-11-09 14:41:24 -0800224 vendor_available: true,
Janis Danisevskis3d32ed52021-10-11 14:20:30 -0700225}
Janis Danisevskisecade462021-11-12 10:09:22 -0800226
227rust_test {
228 name: "libopen_dice_cbor_bindgen_test",
229 srcs: [
230 ":libopen_dice_cbor_bindgen",
231 ],
232 crate_name: "open_dice_cbor_bindgen_test",
233 test_suites: ["general-tests"],
234 auto_gen_config: true,
235 clippy_lints: "none",
236 lints: "none",
237}
238
239rust_test {
240 name: "libopen_dice_bcc_bindgen_test",
241 srcs: [
242 ":libopen_dice_bcc_bindgen",
243 ],
244 crate_name: "open_dice_bcc_bindgen_test",
Janis Danisevskis5669e7b2021-12-13 21:03:05 -0800245
246 rustlibs: [
247 "libopen_dice_cbor_bindgen",
248 ],
249
Janis Danisevskisecade462021-11-12 10:09:22 -0800250 test_suites: ["general-tests"],
251 auto_gen_config: true,
252 clippy_lints: "none",
253 lints: "none",
254}