xref: /aosp_15_r20/external/open-dice/Android.bp (revision 60b67249c2e226f42f35cc6cfe66c6048e0bae6b)
1package {
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_defaults {
13    name: "libopen_dice.cc_defaults",
14    defaults_visibility: ["//visibility:private"],
15    host_supported: true,
16    vendor_available: true,
17    apex_available: [
18        "//apex_available:platform",
19        "com.android.compos",
20        "com.android.virt",
21    ],
22}
23
24cc_library_headers {
25    name: "libopen_dice_headers",
26    defaults: ["libopen_dice.cc_defaults"],
27    export_include_dirs: ["include"],
28}
29
30cc_library_headers {
31    name: "libopen_dice_boringssl_ed25519_headers",
32    defaults: ["libopen_dice.cc_defaults"],
33    export_include_dirs: ["include/dice/config/boringssl_ed25519"],
34}
35
36cc_library_headers {
37    name: "libopen_dice_boringssl_ecdsa_p384_headers",
38    defaults: ["libopen_dice.cc_defaults"],
39    export_include_dirs: ["include/dice/config/boringssl_ecdsa_p384"],
40}
41
42cc_library_headers {
43    name: "libopen_dice_boringssl_multialg_headers",
44    defaults: ["libopen_dice.cc_defaults"],
45    export_include_dirs: ["include/dice/config/boringssl_multialg"],
46}
47
48filegroup {
49    name: "libopen_dice_common_srcs",
50    srcs: [
51        "src/clear_memory.c",
52        "src/dice.c",
53        "src/utils.c",
54    ],
55}
56
57filegroup {
58    name: "libopen_dice_cbor_common_srcs",
59    srcs: [
60        "src/boringssl_hash_kdf_ops.c",
61        "src/cbor_cert_op.c",
62        "src/cbor_writer.c",
63    ],
64}
65
66filegroup {
67    name: "libopen_dice_cbor_ed25519_srcs",
68    srcs: [
69        "src/boringssl_ed25519_ops.c",
70    ],
71}
72
73filegroup {
74    name: "libopen_dice_cbor_p384_srcs",
75    srcs: [
76        "src/boringssl_ecdsa_utils.c",
77        "src/boringssl_p384_ops.c",
78    ],
79}
80
81filegroup {
82    name: "libopen_dice_cbor_multialg_srcs",
83    srcs: [
84        "src/boringssl_ecdsa_utils.c",
85        "src/boringssl_multialg_ops.c",
86    ],
87}
88
89cc_library {
90    name: "libopen_dice_cbor",
91    defaults: ["libopen_dice.cc_defaults"],
92    srcs: [
93        ":libopen_dice_cbor_common_srcs",
94        ":libopen_dice_cbor_ed25519_srcs",
95        ":libopen_dice_common_srcs",
96    ],
97    header_libs: [
98        "libopen_dice_boringssl_ed25519_headers",
99        "libopen_dice_headers",
100    ],
101    export_header_lib_headers: [
102        "libopen_dice_boringssl_ed25519_headers",
103        "libopen_dice_headers",
104    ],
105    shared_libs: ["libcrypto"],
106
107    // b/336916369: This library gets linked into a rust rlib.  Disable LTO
108    // until cross-language lto is supported.
109    lto: {
110        never: true,
111    },
112}
113
114cc_library_static {
115    name: "libopen_dice_cbor_p384",
116    defaults: ["libopen_dice.cc_defaults"],
117    srcs: [
118        ":libopen_dice_cbor_common_srcs",
119        ":libopen_dice_cbor_p384_srcs",
120        ":libopen_dice_common_srcs",
121    ],
122    header_libs: [
123        "libopen_dice_boringssl_ecdsa_p384_headers",
124        "libopen_dice_headers",
125    ],
126    export_header_lib_headers: [
127        "libopen_dice_boringssl_ecdsa_p384_headers",
128        "libopen_dice_headers",
129    ],
130    shared_libs: ["libcrypto"],
131}
132
133// Version of the library missing DiceClearMemory, for baremetal client code.
134cc_library_static {
135    name: "libopen_dice_cbor_baremetal_multialg",
136    defaults: ["cc_baremetal_defaults"],
137    srcs: [
138        ":libopen_dice_cbor_common_srcs",
139        ":libopen_dice_cbor_multialg_srcs",
140        ":libopen_dice_common_srcs",
141    ],
142    exclude_srcs: ["src/clear_memory.c"],
143    allow_undefined_symbols: true,
144    header_libs: [
145        "libopen_dice_boringssl_multialg_headers",
146        "libopen_dice_headers",
147    ],
148    export_header_lib_headers: [
149        "libopen_dice_boringssl_multialg_headers",
150        "libopen_dice_headers",
151    ],
152    static_libs: ["libcrypto_baremetal"],
153
154    // b/336916369: This library gets linked into a rust rlib.  Disable LTO
155    // until cross-language lto is supported.
156    lto: {
157        never: true,
158    },
159}
160
161// Basic, standalone implementation of DiceClearMemory, for tests.
162//
163// Attention has not been given to performance, clearing caches or other
164// potential side channels. This should only be used in contexts that are not
165// security sensitive, such as tests.
166cc_library_static {
167    name: "libopen_dice_clear_memory",
168    defaults: ["cc_baremetal_defaults"],
169    srcs: ["src/clear_memory.c"],
170    header_libs: ["libopen_dice_headers"],
171    visibility: [
172        "//packages/modules/Virtualization:__subpackages__",
173    ],
174}
175
176filegroup {
177    name: "libopen_dice_android_srcs",
178    srcs: [
179        "src/cbor_reader.c",
180        "src/android.c",
181    ],
182}
183
184cc_library {
185    name: "libopen_dice_android",
186    defaults: ["libopen_dice.cc_defaults"],
187    srcs: [":libopen_dice_android_srcs"],
188    export_shared_lib_headers: ["libopen_dice_cbor"],
189    shared_libs: [
190        "libcrypto",
191        "libopen_dice_cbor",
192    ],
193
194    // b/336916369: This library gets linked into a rust rlib.  Disable LTO
195    // until cross-language lto is supported.
196    lto: {
197        never: true,
198    },
199}
200
201cc_library_static {
202    name: "libopen_dice_android_baremetal_multialg",
203    defaults: ["cc_baremetal_defaults"],
204    srcs: [":libopen_dice_android_srcs"],
205    export_static_lib_headers: ["libopen_dice_cbor_baremetal_multialg"],
206    static_libs: [
207        "libcrypto_baremetal",
208        "libopen_dice_cbor_baremetal_multialg",
209    ],
210
211    // b/336916369: This library gets linked into a rust rlib.  Disable LTO
212    // until cross-language lto is supported.
213    lto: {
214        never: true,
215    },
216}
217
218cc_library_static {
219    name: "libopen_dice_android_p384",
220    defaults: ["libopen_dice.cc_defaults"],
221    srcs: [
222        "src/cbor_reader.c",
223        "src/android.c",
224    ],
225    static_libs: ["libopen_dice_cbor_p384"],
226    export_static_lib_headers: ["libopen_dice_cbor_p384"],
227    shared_libs: ["libcrypto"],
228}
229
230cc_test {
231    name: "libopen_dice_test",
232    host_supported: true,
233    cflags: ["-DDICE_USE_GTEST"],
234    srcs: [
235        ":libopen_dice_common_srcs",
236        "src/dice_test.cc",
237    ],
238    header_libs: [
239        "libopen_dice_boringssl_ed25519_headers",
240        "libopen_dice_headers",
241    ],
242    shared_libs: ["libcrypto"],
243}
244
245cc_test {
246    name: "libopen_dice_p384_test",
247    host_supported: true,
248    cflags: ["-DDICE_USE_GTEST"],
249    srcs: [
250        ":libopen_dice_common_srcs",
251        "src/dice_test.cc",
252    ],
253    header_libs: [
254        "libopen_dice_boringssl_ecdsa_p384_headers",
255        "libopen_dice_headers",
256    ],
257    shared_libs: ["libcrypto"],
258}
259
260cc_test {
261    name: "libopen_dice_cbor_writer_test",
262    host_supported: true,
263    cflags: ["-DDICE_USE_GTEST"],
264    srcs: ["src/cbor_writer_test.cc"],
265    static_libs: ["libopen_dice_cbor"],
266}
267
268cc_test {
269    name: "libopen_dice_cbor_writer_p384_test",
270    host_supported: true,
271    cflags: ["-DDICE_USE_GTEST"],
272    srcs: ["src/cbor_writer_test.cc"],
273    static_libs: ["libopen_dice_cbor_p384"],
274}
275
276cc_test {
277    name: "libopen_dice_cbor_reader_test",
278    host_supported: true,
279    cflags: ["-DDICE_USE_GTEST"],
280    srcs: ["src/cbor_reader_test.cc"],
281    static_libs: ["libopen_dice_android"],
282}
283
284cc_test {
285    name: "libopen_dice_cbor_reader_p384_test",
286    host_supported: true,
287    cflags: ["-DDICE_USE_GTEST"],
288    srcs: ["src/cbor_reader_test.cc"],
289    static_libs: ["libopen_dice_android_p384"],
290}
291
292cc_test {
293    name: "libopen_dice_android_test",
294    host_supported: true,
295    cflags: ["-DDICE_USE_GTEST"],
296    srcs: ["src/android_test.cc"],
297    static_libs: [
298        "libopen_dice_android",
299        "libopen_dice_cbor",
300    ],
301    shared_libs: ["libcrypto"],
302}
303
304// TODO: cbor_cert_op_test after resolving COSE dependency
305
306cc_fuzz {
307    name: "libopen_dice_cbor_writer_fuzzer",
308    host_supported: true,
309    srcs: ["src/cbor_writer_fuzzer.cc"],
310    static_libs: ["libopen_dice_cbor"],
311}
312
313cc_fuzz {
314    name: "libopen_dice_cbor_writer_p384_fuzzer",
315    host_supported: true,
316    srcs: ["src/cbor_writer_fuzzer.cc"],
317    static_libs: ["libopen_dice_cbor_p384"],
318}
319
320cc_fuzz {
321    name: "libopen_dice_cbor_reader_fuzzer",
322    host_supported: true,
323    srcs: ["src/cbor_reader_fuzzer.cc"],
324    static_libs: ["libopen_dice_android"],
325}
326
327cc_fuzz {
328    name: "libopen_dice_cbor_reader_p384_fuzzer",
329    host_supported: true,
330    srcs: ["src/cbor_reader_fuzzer.cc"],
331    static_libs: ["libopen_dice_android_p384"],
332}
333
334cc_fuzz {
335    name: "libopen_dice_cbor_fuzzer",
336    host_supported: true,
337    srcs: ["src/fuzzer.cc"],
338    static_libs: ["libopen_dice_cbor"],
339    shared_libs: ["libcrypto"],
340}
341
342cc_fuzz {
343    name: "libopen_dice_cbor_p384_fuzzer",
344    host_supported: true,
345    srcs: ["src/fuzzer.cc"],
346    static_libs: ["libopen_dice_cbor_p384"],
347    shared_libs: ["libcrypto"],
348}
349
350cc_fuzz {
351    name: "libopen_dice_android_fuzzer",
352    host_supported: true,
353    srcs: ["src/android_fuzzer.cc"],
354    static_libs: [
355        "libopen_dice_android",
356        "libopen_dice_cbor",
357    ],
358    shared_libs: ["libcrypto"],
359}
360
361cc_fuzz {
362    name: "libopen_dice_android_p384_fuzzer",
363    host_supported: true,
364    srcs: ["src/android_fuzzer.cc"],
365    static_libs: [
366        "libopen_dice_android_p384",
367        "libopen_dice_cbor_p384",
368    ],
369    shared_libs: ["libcrypto"],
370}
371
372dirgroup {
373    name: "trusty_dirgroup_external_open-dice",
374    dirs: ["."],
375    visibility: ["//trusty/vendor/google/aosp/scripts"],
376}
377