blob: 40acf086fe312b5b1abed56e75f1ae94d7e0ec90 [file] [log] [blame]
Dan Willemsen21986fb2016-07-14 15:23:56 -07001// Note that some host libraries have the same module name as the target
2// libraries. This is currently needed to build, for example, adb. But it's
3// probably something that should be changed.
4
Paul Duffincb6fdd22019-06-04 13:24:44 +01005package {
6 default_visibility: ["//visibility:private"],
Bob Badourb313bb52021-02-12 15:33:59 -08007 default_applicable_licenses: ["external_boringssl_license"],
8}
9
10// Added automatically by a large-scale-change that took the approach of
11// 'apply every license found to every target'. While this makes sure we respect
12// every license restriction, it may not be entirely correct.
13//
14// e.g. GPL in an MIT project might only apply to the contrib/ directory.
15//
16// Please consider splitting the single license below into multiple licenses,
17// taking care not to lose any license_kind information, and overriding the
18// default license using the 'licenses: [...]' property on targets as needed.
19//
20// For unused files, consider creating a 'fileGroup' with "//visibility:private"
21// to attach the license to, and including a comment whether the files may be
22// used in the current project.
23// See: http://go/android-license-faq
24license {
25 name: "external_boringssl_license",
26 visibility: [":__subpackages__"],
27 license_kinds: [
28 "SPDX-license-identifier-Apache-2.0",
29 "SPDX-license-identifier-BSD",
30 "SPDX-license-identifier-ISC",
31 "SPDX-license-identifier-MIT",
32 "SPDX-license-identifier-OpenSSL",
33 "legacy_unencumbered",
34 ],
35 license_text: [
36 "NOTICE",
37 ],
Paul Duffincb6fdd22019-06-04 13:24:44 +010038}
39
Dan Willemsen21986fb2016-07-14 15:23:56 -070040// Pull in the autogenerated sources modules
41build = ["sources.bp"]
42
43// Used by libcrypto, libssl, bssl tool, and native tests
44cc_defaults {
45 name: "boringssl_flags",
Steven Morelandf593be82017-04-14 04:51:23 -070046 vendor_available: true,
Justin Yun56083292020-11-11 15:43:11 +090047 product_available: true,
Dan Willemsen21986fb2016-07-14 15:23:56 -070048
49 cflags: [
50 "-fvisibility=hidden",
51 "-DBORINGSSL_SHARED_LIBRARY",
David Benjaminfc8a7862018-06-25 19:02:46 -040052 "-DBORINGSSL_ANDROID_SYSTEM",
Dan Willemsen21986fb2016-07-14 15:23:56 -070053 "-DOPENSSL_SMALL",
Chih-Hung Hsieh9146d992017-09-27 10:26:03 -070054 "-Werror",
Dan Willemsen21986fb2016-07-14 15:23:56 -070055 "-Wno-unused-parameter",
56 ],
57
58 cppflags: [
59 "-Wall",
60 "-Werror",
61 ],
62
David Benjamineee229f2022-01-28 13:36:41 -050063 c_std: "gnu11",
David Benjaminfc8a7862018-06-25 19:02:46 -040064
65 // Build BoringSSL and its tests against the same STL.
66 sdk_version: "9",
67 target: {
68 android: {
69 stl: "libc++_static",
70 },
71 },
Dan Willemsen21986fb2016-07-14 15:23:56 -070072}
73
74// Used by libcrypto + libssl
75cc_defaults {
76 name: "boringssl_defaults",
77
78 local_include_dirs: ["src/include"],
79 export_include_dirs: ["src/include"],
David Benjaminfc8a7862018-06-25 19:02:46 -040080 cflags: ["-DBORINGSSL_IMPLEMENTATION"],
Dan Willemsen21986fb2016-07-14 15:23:56 -070081}
82
83//// libcrypto
Dan Willemsen21986fb2016-07-14 15:23:56 -070084cc_defaults {
85 name: "libcrypto_defaults",
86 host_supported: true,
Yifan Hongca6b4e82020-10-21 18:11:12 -070087 ramdisk_available: true,
88 vendor_ramdisk_available: true,
Dan Willemsen21986fb2016-07-14 15:23:56 -070089
90 // Windows and Macs both have problems with assembly files
91 target: {
92 windows: {
93 enabled: true,
94 cflags: ["-DOPENSSL_NO_ASM"],
95 host_ldlibs: ["-lws2_32"],
96 },
97 darwin: {
98 cflags: ["-DOPENSSL_NO_ASM"],
99 },
Kenny Root7b550be2016-09-20 15:25:24 -0700100 host: {
Dan Willemsen21986fb2016-07-14 15:23:56 -0700101 host_ldlibs: ["-lpthread"],
102 },
Pete Bentley1e9e5852020-06-30 16:45:33 +0100103 android: {
104 // On FIPS builds (i.e. Android only) prevent other libraries
105 // from pre-empting symbols in libcrypto which could affect FIPS
106 // compliance and cause integrity checks to fail. See b/160231064.
107 ldflags: ["-Wl,-Bsymbolic"],
108 },
Dan Willemsen21986fb2016-07-14 15:23:56 -0700109 },
110
111 local_include_dirs: ["src/crypto"],
Pete Bentleye6a478a2019-08-19 22:20:24 +0100112}
113
114cc_object {
115 name: "bcm_object",
116 device_supported: true,
117 recovery_available: true,
118 native_bridge_supported: true,
119 defaults: [
120 "libcrypto_bcm_sources",
121 "libcrypto_defaults",
122 "boringssl_defaults",
123 "boringssl_flags",
124 ],
Peter Collingbourne22f5f872019-09-27 15:32:38 -0700125 sanitize: {
126 address: false,
Tobias Thierer6204b542019-10-18 21:55:05 +0100127 hwaddress: false,
Mitch Phillipsf5a60782019-12-10 08:47:30 -0800128 fuzzer: false,
Peter Collingbourne22f5f872019-09-27 15:32:38 -0700129 },
Pete Bentleye6a478a2019-08-19 22:20:24 +0100130 target: {
131 android: {
132 cflags: [
133 "-DBORINGSSL_FIPS",
134 "-fPIC",
Pete Bentley1d07cf82019-10-18 12:49:31 +0100135 // -fno[data|text]-sections required to ensure a
136 // single text and data section for FIPS integrity check
137 "-fno-data-sections",
138 "-fno-function-sections",
Pete Bentleye6a478a2019-08-19 22:20:24 +0100139 ],
140 linker_script: "src/crypto/fipsmodule/fips_shared.lds",
141 },
Peter Collingbourne0560ada2019-11-22 13:50:29 -0800142 // Temporary hack to let BoringSSL build with a new compiler.
143 // This doesn't enable HWASAN unconditionally, it just causes
144 // BoringSSL's asm code to unconditionally use a HWASAN-compatible
145 // global variable reference so that the non-HWASANified (because of
146 // sanitize: { hwaddress: false } above) code in the BCM can
147 // successfully link against the HWASANified code in the rest of
148 // BoringSSL in HWASAN builds.
149 android_arm64: {
150 asflags: [
151 "-fsanitize=hwaddress",
152 ],
153 },
Pete Bentleye6a478a2019-08-19 22:20:24 +0100154 },
Jiyong Park0dcd4e82020-03-09 15:23:05 +0900155 apex_available: [
156 "//apex_available:platform",
157 "com.android.adbd",
Martin Stjernholm98b03622020-10-12 15:10:40 +0100158 "com.android.art",
Jiyong Park0dcd4e82020-03-09 15:23:05 +0900159 "com.android.art.debug",
Jiyong Park0dcd4e82020-03-09 15:23:05 +0900160 "com.android.art.testing",
Etienne Ruffieux49791bd2021-12-15 16:21:34 +0000161 "com.android.bluetooth",
Alan Stokes53cbde72021-07-06 17:46:00 +0100162 "com.android.compos",
Jiyong Park0dcd4e82020-03-09 15:23:05 +0900163 "com.android.conscrypt",
Jiyong Park0dcd4e82020-03-09 15:23:05 +0900164 "com.android.resolv",
Jiyong Park16f7c572021-01-05 14:41:56 +0900165 "com.android.virt",
Jiyong Park0dcd4e82020-03-09 15:23:05 +0900166 ],
Jooyung Han856ad1d2020-04-16 18:48:25 +0900167 min_sdk_version: "29",
Pete Bentleye6a478a2019-08-19 22:20:24 +0100168}
169
170bootstrap_go_package {
171 name: "bssl_ar",
172 pkgPath: "boringssl.googlesource.com/boringssl/util/ar",
173 srcs: [
174 "src/util/ar/ar.go",
175 ],
176 testSrcs: [
177 "src/util/ar/ar_test.go",
178 ],
179}
180
181bootstrap_go_package {
182 name: "bssl_fipscommon",
183 pkgPath: "boringssl.googlesource.com/boringssl/util/fipstools/fipscommon",
184 srcs: [
185 "src/util/fipstools/fipscommon/const.go",
186 ],
187}
188
189blueprint_go_binary {
190 name: "bssl_inject_hash",
191 srcs: [
192 "src/util/fipstools/inject_hash/inject_hash.go",
193 ],
194 deps: [
195 "bssl_ar",
196 "bssl_fipscommon",
197 ],
Dan Willemsen21986fb2016-07-14 15:23:56 -0700198}
199
200// Target and host library
201cc_library {
202 name: "libcrypto",
Paul Duffincb6fdd22019-06-04 13:24:44 +0100203 visibility: ["//visibility:public"],
Vijay Venkatraman3caad952017-05-16 12:00:57 -0700204 vendor_available: true,
Justin Yun56083292020-11-11 15:43:11 +0900205 product_available: true,
dimitry09dd3be2019-05-09 16:42:01 +0200206 native_bridge_supported: true,
Justin Yun47949c52017-07-24 15:19:43 +0900207 vndk: {
208 enabled: true,
209 },
Jooyung Hanb6b07c32019-01-18 15:31:20 +0900210 double_loadable: true,
Jiyong Parkc3463952018-04-27 21:44:32 +0900211 recovery_available: true,
Paul Duffinf6a61fd2019-06-25 12:06:25 +0100212 defaults: [
213 "libcrypto_sources",
214 "libcrypto_defaults",
215 "boringssl_defaults",
216 "boringssl_flags",
217 ],
Dan Willemsen2b2c24b2016-07-21 11:03:36 -0700218 unique_host_soname: true,
Pete Bentleye6a478a2019-08-19 22:20:24 +0100219 srcs: [
220 ":bcm_object",
221 ],
222 target: {
223 android: {
224 cflags: [
225 "-DBORINGSSL_FIPS",
226 ],
Pete Bentleye0c3f632020-05-06 19:52:29 +0100227 sanitize: {
228 // Disable address sanitizing otherwise libcrypto will not report
229 // itself as being in FIPS mode, which causes boringssl_self_test
230 // to fail.
231 address: false,
232 },
Pete Bentleye6a478a2019-08-19 22:20:24 +0100233 inject_bssl_hash: true,
Colin Cross4b979db2019-09-18 11:20:16 -0700234 static: {
235 // Disable the static version of libcrypto, as it causes
236 // problems for FIPS certification. Use libcrypto_static for
237 // modules that need static libcrypto but do not need FIPS self
238 // testing, or use dynamic libcrypto.
239 enabled: false,
240 },
Pete Bentleye6a478a2019-08-19 22:20:24 +0100241 },
242 },
Joshua Duong26b57e22020-02-10 16:04:44 -0800243 apex_available: [
244 "//apex_available:platform",
245 "com.android.adbd",
Martin Stjernholm98b03622020-10-12 15:10:40 +0100246 "com.android.art",
Jiyong Park0dcd4e82020-03-09 15:23:05 +0900247 "com.android.art.debug",
Jiyong Park0dcd4e82020-03-09 15:23:05 +0900248 "com.android.art.testing",
Etienne Ruffieux49791bd2021-12-15 16:21:34 +0000249 "com.android.bluetooth",
Alan Stokes53cbde72021-07-06 17:46:00 +0100250 "com.android.compos",
Jiyong Park0dcd4e82020-03-09 15:23:05 +0900251 "com.android.conscrypt",
Jiyong Park0dcd4e82020-03-09 15:23:05 +0900252 "com.android.resolv",
Jiyong Park16f7c572021-01-05 14:41:56 +0900253 "com.android.virt",
Joshua Duong26b57e22020-02-10 16:04:44 -0800254 ],
Jooyung Han856ad1d2020-04-16 18:48:25 +0900255 min_sdk_version: "29",
Dan Willemsen21986fb2016-07-14 15:23:56 -0700256}
257
258// Static library
Colin Cross4b979db2019-09-18 11:20:16 -0700259// This version of libcrypto will not have FIPS self tests enabled, so its
260// usage is protected through visibility to ensure it doesn't end up used
261// somewhere that needs the FIPS version.
Dan Willemsen21986fb2016-07-14 15:23:56 -0700262cc_library_static {
263 name: "libcrypto_static",
Colin Cross4b979db2019-09-18 11:20:16 -0700264 visibility: [
Paul Duffinebdc4062020-01-22 14:29:01 +0000265 "//art/build/sdk",
Colin Cross4b979db2019-09-18 11:20:16 -0700266 "//bootable/recovery/updater",
267 "//external/conscrypt",
268 "//external/python/cpython2",
Luke Huangf695bbb2021-04-23 15:38:04 +0800269 "//external/rust/crates/quiche",
Elliott Hughes77319d02020-05-14 15:51:34 -0700270 // Strictly, only the *static* toybox for legacy devices should have
271 // access to libcrypto_static, but we can't express that.
272 "//external/toybox",
Colin Cross4b979db2019-09-18 11:20:16 -0700273 "//hardware/interfaces/confirmationui/1.0/vts/functional",
274 "//hardware/interfaces/drm/1.0/vts/functional",
275 "//hardware/interfaces/drm/1.2/vts/functional",
Robert Shih6526b5c2020-01-21 11:03:32 -0800276 "//hardware/interfaces/drm/1.3/vts/functional",
Colin Cross4b979db2019-09-18 11:20:16 -0700277 "//hardware/interfaces/keymaster/3.0/vts/functional",
278 "//hardware/interfaces/keymaster/4.0/vts/functional",
Shawn Willden1ff77d02020-01-16 23:52:56 -0700279 "//hardware/interfaces/keymaster/4.1/vts/functional",
Josh Gaoe49f0ff2021-04-14 15:41:00 -0700280 "//packages/modules/adb",
Luke Huang16a30fc2019-11-22 11:44:50 +0800281 "//packages/modules/DnsResolver/tests:__subpackages__",
Baligh Uddinf58f8702020-11-24 05:58:10 +0000282 "//packages/modules/NeuralNetworks:__subpackages__",
Colin Cross4b979db2019-09-18 11:20:16 -0700283 "//system/core/init",
284 "//system/core/fs_mgr/liblp",
285 "//system/core/fs_mgr/liblp/vts_core",
286 "//system/core/fs_mgr/libsnapshot",
287 "//system/libvintf/test",
288 "//system/security/keystore/tests",
289 "//test/vts-testcase/security/avb",
290 ],
Przemyslaw Szczepaniakdab438a2020-02-05 17:33:41 +0000291 apex_available: [
292 "//apex_available:platform",
293 "com.android.neuralnetworks",
Przemyslaw Szczepaniakdab438a2020-02-05 17:33:41 +0000294 ],
Paul Duffinf6a61fd2019-06-25 12:06:25 +0100295 defaults: [
Pete Bentley47637342019-08-19 12:22:49 +0100296 "libcrypto_bcm_sources",
Paul Duffinf6a61fd2019-06-25 12:06:25 +0100297 "libcrypto_sources",
298 "libcrypto_defaults",
299 "boringssl_defaults",
300 "boringssl_flags",
301 ],
Dan Willemsen21986fb2016-07-14 15:23:56 -0700302}
303
Yifan Honga11a41e2021-09-28 17:18:45 -0700304// Common defaults for lib*_fuzz_unsafe. These are unsafe and deterministic
305// libraries for testing and fuzzing only. See src/FUZZING.md.
306cc_defaults {
307 name: "boringssl_fuzz_unsafe_defaults",
308 host_supported: true,
309 cflags: [
310 "-DBORINGSSL_UNSAFE_DETERMINISTIC_MODE",
311 "-DBORINGSSL_UNSAFE_FUZZER_MODE",
312 ],
313 visibility: [
314 "//frameworks/native/libs/binder/tests:__subpackages__",
315 ],
316}
317
318// Unsafe and deterministic version of libcrypto. For testing and fuzzing only.
319// See src/FUZZING.md.
320cc_test_library {
321 name: "libcrypto_fuzz_unsafe",
322 ramdisk_available: false,
323 vendor_ramdisk_available: false,
324 defaults: [
325 "libcrypto_bcm_sources",
326 "libcrypto_sources",
327 "libcrypto_defaults",
328 "boringssl_defaults",
329 "boringssl_flags",
330 "boringssl_fuzz_unsafe_defaults",
331 ],
332}
333
Dan Willemsen21986fb2016-07-14 15:23:56 -0700334//// libssl
335
336// Target static library
Dan Willemsen21986fb2016-07-14 15:23:56 -0700337
338// Static and Shared library
339cc_library {
340 name: "libssl",
Paul Duffincb6fdd22019-06-04 13:24:44 +0100341 visibility: ["//visibility:public"],
Dan Willemsenea55e182018-10-23 13:41:19 -0700342 recovery_available: true,
Justin Yun47949c52017-07-24 15:19:43 +0900343 vendor_available: true,
Justin Yun56083292020-11-11 15:43:11 +0900344 product_available: true,
dimitry09dd3be2019-05-09 16:42:01 +0200345 native_bridge_supported: true,
Justin Yun47949c52017-07-24 15:19:43 +0900346 vndk: {
347 enabled: true,
348 },
Dan Willemsen21986fb2016-07-14 15:23:56 -0700349 host_supported: true,
Paul Duffinf6a61fd2019-06-25 12:06:25 +0100350 defaults: [
351 "libssl_sources",
352 "boringssl_defaults",
353 "boringssl_flags",
354 ],
Joshua Duong81ce7a52019-10-31 12:44:47 -0700355 target: {
356 windows: {
357 enabled: true,
358 },
359 },
Dan Willemsen2b2c24b2016-07-21 11:03:36 -0700360 unique_host_soname: true,
Dan Willemsen21986fb2016-07-14 15:23:56 -0700361
Dan Willemsen2b2c24b2016-07-21 11:03:36 -0700362 shared_libs: ["libcrypto"],
Joshua Duong26b57e22020-02-10 16:04:44 -0800363
364 apex_available: [
365 "//apex_available:platform",
Roopa Sattiraju517dcb02021-12-22 14:04:18 -0800366 "com.android.bluetooth",
Joshua Duong26b57e22020-02-10 16:04:44 -0800367 "com.android.adbd",
Jiyong Park0dcd4e82020-03-09 15:23:05 +0900368 "com.android.conscrypt",
369 "com.android.resolv",
Joshua Duong26b57e22020-02-10 16:04:44 -0800370 ],
Jooyung Han856ad1d2020-04-16 18:48:25 +0900371 min_sdk_version: "29",
Dan Willemsen21986fb2016-07-14 15:23:56 -0700372}
373
Yifan Honga11a41e2021-09-28 17:18:45 -0700374// Unsafe and deterministic version of libssl. For testing and fuzzing only.
375// See src/FUZZING.md.
376cc_test_library {
377 name: "libssl_fuzz_unsafe",
378 host_supported: true,
379 defaults: [
380 "libssl_sources",
381 "boringssl_defaults",
382 "boringssl_flags",
383 "boringssl_fuzz_unsafe_defaults",
384 ],
385 static_libs: [
386 "libcrypto_fuzz_unsafe",
387 ],
388}
389
Dan Willemsen21986fb2016-07-14 15:23:56 -0700390// Tool
391cc_binary {
392 name: "bssl",
393 host_supported: true,
Paul Duffinf6a61fd2019-06-25 12:06:25 +0100394 defaults: [
395 "bssl_sources",
396 "boringssl_flags",
397 ],
Dan Willemsen21986fb2016-07-14 15:23:56 -0700398
Dan Willemsen2b2c24b2016-07-21 11:03:36 -0700399 shared_libs: [
400 "libcrypto",
401 "libssl",
402 ],
Dan Willemsen21986fb2016-07-14 15:23:56 -0700403 target: {
Dan Willemsen21986fb2016-07-14 15:23:56 -0700404 darwin: {
405 enabled: false,
406 },
Pete Bentleyd7165532020-05-14 12:01:03 +0100407 android: {
408 compile_multilib: "both",
409 },
410 },
411 multilib: {
412 lib32: {
413 suffix: "32",
414 },
Dan Willemsen21986fb2016-07-14 15:23:56 -0700415 },
416}
Dan Willemsen2458a412016-07-15 09:28:31 -0700417
Pete Bentley390f5872020-12-10 11:19:10 +0000418// Used for ACVP testing for FIPS certification.
419// Not installed on devices by default.
420cc_binary {
421 name: "acvp_modulewrapper",
Pete Bentley390f5872020-12-10 11:19:10 +0000422 srcs: [
Stephen Craned4573992021-02-25 10:52:24 -0800423 "src/util/fipstools/acvp/modulewrapper/main.cc",
Pete Bentley390f5872020-12-10 11:19:10 +0000424 ],
425 target: {
Pete Bentley7f684a42021-07-21 13:52:17 +0100426 android_x86: {
427 enabled: false,
428 },
429 android_x86_64: {
430 enabled: false,
Pete Bentley390f5872020-12-10 11:19:10 +0000431 },
432 },
433 stem: "modulewrapper",
Pete Bentley7f684a42021-07-21 13:52:17 +0100434 compile_multilib: "both",
Pete Bentley390f5872020-12-10 11:19:10 +0000435 multilib: {
436 lib32: {
437 suffix: "32",
438 },
439 },
440
Stephen Craned4573992021-02-25 10:52:24 -0800441 static_libs: [
442 "libacvp_modulewrapper",
443 ],
444 shared_libs: [
445 "libcrypto",
446 ],
447
448 defaults: [
449 "boringssl_flags",
450 ],
451}
452
453// ACVP wrapper implementation shared between Android and Trusty
454cc_library_static {
455 name: "libacvp_modulewrapper",
456 host_supported: true,
457 vendor_available: true,
458 srcs: [
459 "src/util/fipstools/acvp/modulewrapper/modulewrapper.cc",
460 ],
461 target: {
462 android: {
463 compile_multilib: "both",
464 },
465 },
466 export_include_dirs: ["src/util/fipstools/acvp/modulewrapper/"],
Pete Bentley390f5872020-12-10 11:19:10 +0000467 shared_libs: [
468 "libcrypto",
469 ],
470
471 defaults: [
472 "boringssl_flags",
473 ],
Stephen Crane859a48d2021-03-10 18:01:35 -0800474
475 visibility: ["//system/core/trusty/utils/acvp"],
Pete Bentley390f5872020-12-10 11:19:10 +0000476}
477
Dan Willemsen2458a412016-07-15 09:28:31 -0700478// Test support library
479cc_library_static {
480 name: "boringssl_test_support",
481 host_supported: true,
Paul Duffinf6a61fd2019-06-25 12:06:25 +0100482 defaults: [
483 "boringssl_test_support_sources",
484 "boringssl_flags",
485 ],
Dan Willemsen2458a412016-07-15 09:28:31 -0700486
Dan Willemsen2b2c24b2016-07-21 11:03:36 -0700487 shared_libs: [
488 "libcrypto",
489 "libssl",
490 ],
Dan Willemsen2458a412016-07-15 09:28:31 -0700491}
492
493// Tests
494cc_test {
Paul Duffinf6a61fd2019-06-25 12:06:25 +0100495 name: "boringssl_crypto_test",
Pete Bentleyfe406ed2021-06-29 13:22:21 +0100496 test_config: "NativeTests.xml",
497 host_supported: false,
498 per_testcase_directory: true,
499 compile_multilib: "both",
500 multilib: {
501 lib32: {
502 suffix: "32",
503 },
504 lib64: {
505 suffix: "64",
506 },
507 },
Paul Duffinf6a61fd2019-06-25 12:06:25 +0100508 defaults: [
509 "boringssl_crypto_test_sources",
510 "boringssl_flags",
511 ],
512 whole_static_libs: ["boringssl_test_support"],
Pete Bentley00087b42022-04-11 12:43:46 +0100513 // Statically link the library to test to ensure we always pick up the
514 // correct version regardless of device linker configuration.
515 static_libs: ["libcrypto_static"],
Pete Bentleyfe406ed2021-06-29 13:22:21 +0100516 target: {
517 android: {
518 test_suites: ["mts-conscrypt"],
519 },
520 },
David Benjaminf31229b2017-01-25 14:08:15 -0500521}
522
523cc_test {
Paul Duffinf6a61fd2019-06-25 12:06:25 +0100524 name: "boringssl_ssl_test",
Pete Bentleyfe406ed2021-06-29 13:22:21 +0100525 test_config: "NativeTests.xml",
526 host_supported: false,
527 per_testcase_directory: true,
528 compile_multilib: "both",
529 multilib: {
530 lib32: {
531 suffix: "32",
532 },
533 lib64: {
534 suffix: "64",
535 },
536 },
Paul Duffinf6a61fd2019-06-25 12:06:25 +0100537 defaults: [
538 "boringssl_ssl_test_sources",
539 "boringssl_flags",
540 ],
541 whole_static_libs: ["boringssl_test_support"],
Pete Bentley00087b42022-04-11 12:43:46 +0100542 // Statically link the libraries to test to ensure we always pick up the
543 // correct version regardless of device linker configuration.
544 static_libs: [
545 "libcrypto_static",
Paul Duffinf6a61fd2019-06-25 12:06:25 +0100546 "libssl",
547 ],
Pete Bentleyfe406ed2021-06-29 13:22:21 +0100548 target: {
549 android: {
550 test_suites: ["mts-conscrypt"],
551 },
552 },
David Benjaminf31229b2017-01-25 14:08:15 -0500553}
Adam Langleyb6f75152019-10-18 12:20:11 -0700554
555// Utility binary for CMVP on-site testing.
556cc_binary {
Tobias Thierer6204b542019-10-18 21:55:05 +0100557 name: "test_fips",
558 host_supported: false,
559 defaults: [
560 "boringssl_flags",
561 ],
562 shared_libs: [
563 "libcrypto",
564 ],
565 srcs: [
Pete Bentley83b8e972022-02-28 19:23:25 +0000566 "src/util/fipstools/test_fips.c",
Tobias Thierer6204b542019-10-18 21:55:05 +0100567 ],
Adam Langleyb6f75152019-10-18 12:20:11 -0700568}
Matthew Maurer5e4a5b32022-04-27 14:18:37 -0700569
570// Rust bindings
571rust_bindgen {
572 name: "libbssl_sys_raw",
573 source_stem: "bindings",
574 crate_name: "bssl_sys_raw",
575 host_supported: true,
576 wrapper_src: "src/rust/wrapper.h",
David Drysdale4f45dac2022-05-09 13:07:42 +0100577 vendor_available: true,
Matthew Maurer5e4a5b32022-04-27 14:18:37 -0700578 bindgen_flags: [
David Drysdalec022f1c2022-02-02 17:04:17 +0000579 // Adapted from upstream the src/rust/CMakeLists.txt file at:
580 // https://boringssl.googlesource.com/boringssl/+/refs/heads/master/rust/CMakeLists.txt
Matthew Maurer5e4a5b32022-04-27 14:18:37 -0700581 "--no-derive-default",
582 "--enable-function-attribute-detection",
583 "--use-core",
584 "--size_t-is-usize",
585 "--default-macro-constant-type=signed",
586 "--rustified-enum=point_conversion_form_t",
587 // These are not BoringSSL symbols, they are from glibc
588 // and are not relevant to the build besides throwing warnings
589 // about their 'long double' (aka u128) not being FFI safe.
590 // We block those functions so that the build doesn't
591 // spam warnings.
592 //
593 // https://github.com/rust-lang/rust-bindgen/issues/1549 describes the current problem
594 // and other folks' solutions.
595 "--blocklist-function=strtold",
596 "--blocklist-function=qecvt",
597 "--blocklist-function=qecvt_r",
598 "--blocklist-function=qgcvt",
599 "--blocklist-function=qfcvt",
600 "--blocklist-function=qfcvt_r",
601 ],
602 shared_libs: [
603 "libcrypto",
604 "libssl",
605 ],
606}
607
David Drysdalec022f1c2022-02-02 17:04:17 +0000608// Encapsulate the bindgen-generated layout tests as a test target.
609rust_test {
610 name: "libbssl_sys_raw_test",
611 srcs: [
612 ":libbssl_sys_raw",
613 ],
614 crate_name: "bssl_sys_raw_test",
615 test_suites: ["general-tests"],
616 auto_gen_config: true,
617 clippy_lints: "none",
618 lints: "none",
619}
620
621// Rust's bindgen doesn't cope with macros, so this target includes C functions that
622// do the same thing as macros defined in BoringSSL header files.
Matthew Maurer5e4a5b32022-04-27 14:18:37 -0700623cc_library_static {
624 name: "libbssl_rust_support",
625 host_supported: true,
626 defaults: ["boringssl_flags"],
627 srcs: ["src/rust/rust_wrapper.c"],
628 shared_libs: [
629 "libcrypto",
630 "libssl",
631 ],
632}
633
David Drysdalec022f1c2022-02-02 17:04:17 +0000634// Replace the upstream CMake placeholder with a re-export of all of the local bindgen output.
635gensrcs {
636 name: "libbssl_sys_src",
637 srcs: ["src/rust/src/lib.rs"],
638 cmd: "sed 's@^.{INCLUDES}@pub use bssl_sys_raw::*;@' $(in) > $(out)",
639}
640
Matthew Maurer5e4a5b32022-04-27 14:18:37 -0700641rust_library {
642 name: "libbssl_ffi",
643 host_supported: true,
644 crate_name: "bssl_ffi",
Paul Crowleyedd35e72022-05-16 21:46:39 +0000645 visibility: [
646 "//external/rust/crates/openssl",
647 "//system/keymint/boringssl",
648 "//system/security/prng_seeder",
649 ],
650 // Use the modified source with placeholder replaced.
651 srcs: [":libbssl_sys_src"],
652 vendor_available: true,
Matthew Maurer5e4a5b32022-04-27 14:18:37 -0700653 // Since libbssl_sys_raw is not publically visible, we can't
654 // accidentally force a double-link by linking statically, so do so.
655 rlibs: ["libbssl_sys_raw"],
656 static_libs: [
657 "libbssl_rust_support",
658 ],
659}