• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1// 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
5package {
6    default_visibility: ["//visibility:private"],
7    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    ],
38}
39
40// Pull in the autogenerated sources modules
41build = ["sources.bp"]
42
43// Used by libcrypto, libssl, bssl tool, and native tests
44cc_defaults {
45    // This contains the common options between boringssl_flags and
46    // boringssl_flags_baremetal. Nothing else should include this target
47    // directly.
48    name: "boringssl_flags_common",
49
50    cflags: [
51        "-fvisibility=hidden",
52        "-DBORINGSSL_SHARED_LIBRARY",
53        "-DOPENSSL_SMALL",
54        "-Werror",
55        "-Wno-unused-parameter",
56    ],
57
58    cppflags: [
59        "-Wall",
60        "-Werror",
61    ],
62
63    // Build BoringSSL and its tests against the same STL.
64    stl: "libc++_static",
65}
66
67cc_defaults {
68    name: "boringssl_flags",
69    vendor_available: true,
70    product_available: true,
71    cflags: ["-DBORINGSSL_ANDROID_SYSTEM"],
72    defaults: ["boringssl_flags_common"],
73    sdk_version: "9",
74}
75
76cc_defaults {
77    name: "boringssl_flags_baremetal",
78    cflags: [
79        "-DBORINGSSL_NO_STATIC_INITIALIZER",
80        "-DANDROID_BAREMETAL",
81    ],
82    defaults: ["boringssl_flags_common"],
83    apex_available: [
84        "com.android.virt",
85    ],
86}
87
88// Used by libcrypto + libssl
89cc_defaults {
90    name: "boringssl_defaults",
91
92    local_include_dirs: ["src/include"],
93    export_include_dirs: ["src/include"],
94    cflags: ["-DBORINGSSL_IMPLEMENTATION"],
95
96    cmake_snapshot_supported: true,
97}
98
99//// libcrypto, but not libcrypto_baremetal. libcrypto_baremetal is a single
100//// target, so there is no need for a libcrypto_defaults_baremetal.
101cc_defaults {
102    name: "libcrypto_defaults",
103    host_supported: true,
104    ramdisk_available: true,
105    vendor_ramdisk_available: true,
106
107    target: {
108        windows: {
109            enabled: true,
110            host_ldlibs: ["-lws2_32"],
111        },
112        host: {
113            host_ldlibs: ["-lpthread"],
114        },
115        android: {
116            // On FIPS builds (i.e. Android only) prevent other libraries
117            // from pre-empting symbols in libcrypto which could affect FIPS
118            // compliance and cause integrity checks to fail. See b/160231064.
119            ldflags: ["-Wl,-Bsymbolic"],
120        },
121    },
122
123    stl: "none",
124}
125
126// Boring Crypto Module object file.
127// Common settings between bcm_object and bcm_object_for_testing.
128cc_defaults {
129    name: "bcm_object_defaults",
130    device_supported: true,
131    defaults: [
132        "libcrypto_bcm_sources",
133        "libcrypto_defaults",
134        "boringssl_defaults",
135        "boringssl_flags",
136    ],
137    sanitize: {
138        address: false,
139        hwaddress: false,
140        memtag_stack: false,
141        memtag_globals: false,
142        fuzzer: false,
143    },
144    target: {
145        android: {
146            cflags: [
147                "-DBORINGSSL_FIPS",
148                "-fPIC",
149                // -fno[data|text]-sections required to ensure a
150                // single text and data section for FIPS integrity check
151                "-fno-data-sections",
152                "-fno-function-sections",
153            ],
154            linker_script: "src/crypto/fipsmodule/fips_shared.lds",
155        },
156        // Temporary hack to let BoringSSL build with a new compiler.
157        // This doesn't enable HWASAN unconditionally, it just causes
158        // BoringSSL's asm code to unconditionally use a HWASAN-compatible
159        // global variable reference so that the non-HWASANified (because of
160        // sanitize: { hwaddress: false } above) code in the BCM can
161        // successfully link against the HWASANified code in the rest of
162        // BoringSSL in HWASAN builds.
163        android_arm64: {
164            asflags: [
165                "-fsanitize=hwaddress",
166            ],
167        },
168    },
169    min_sdk_version: "29",
170}
171
172cc_object {
173    name: "bcm_object",
174    recovery_available: true,
175    native_bridge_supported: true,
176    defaults: [
177        "bcm_object_defaults",
178    ],
179    apex_available: [
180        "//apex_available:platform",
181        "com.android.adbd",
182        "com.android.adservices",
183        "com.android.btservices",
184        "com.android.compos",
185        "com.android.conscrypt",
186        "com.android.extservices",
187        "com.android.ondevicepersonalization",
188        "com.android.resolv",
189        "com.android.virt",
190    ],
191}
192
193// Version of bcm_object built with BORINGSSL_FIPS_BREAK_TESTS defined.
194// Only for use with the FIPS break-tests.sh script.
195cc_object {
196    name: "bcm_object_for_testing",
197    visibility: [
198        "//external/boringssl",
199    ],
200    defaults: [
201        "bcm_object_defaults",
202    ],
203    target: {
204        android: {
205            cflags: ["-DBORINGSSL_FIPS_BREAK_TESTS"],
206        },
207    },
208}
209
210bootstrap_go_package {
211    name: "bssl_ar",
212    pkgPath: "boringssl.googlesource.com/boringssl/util/ar",
213    srcs: [
214        "src/util/ar/ar.go",
215    ],
216    testSrcs: [
217        "src/util/ar/ar_test.go",
218    ],
219}
220
221bootstrap_go_package {
222    name: "bssl_fipscommon",
223    pkgPath: "boringssl.googlesource.com/boringssl/util/fipstools/fipscommon",
224    srcs: [
225        "src/util/fipstools/fipscommon/const.go",
226    ],
227}
228
229blueprint_go_binary {
230    name: "bssl_inject_hash",
231    srcs: [
232        "src/util/fipstools/inject_hash/inject_hash.go",
233    ],
234    deps: [
235        "bssl_ar",
236        "bssl_fipscommon",
237    ],
238}
239
240// Target and host library.
241// Any changes here must also be reflected in libcrypto_for_test below.
242cc_library {
243    name: "libcrypto",
244    visibility: ["//visibility:public"],
245    vendor_available: true,
246    product_available: true,
247    native_bridge_supported: true,
248    double_loadable: true,
249    recovery_available: true,
250    defaults: [
251        "libcrypto_sources",
252        "libcrypto_defaults",
253        "boringssl_defaults",
254        "boringssl_flags",
255    ],
256    unique_host_soname: true,
257    srcs: [
258        ":bcm_object",
259    ],
260    target: {
261        android: {
262            cflags: [
263                "-DBORINGSSL_FIPS",
264            ],
265            sanitize: {
266                // Disable address sanitizing otherwise libcrypto will not report
267                // itself as being in FIPS mode, which causes boringssl_self_test
268                // to fail.
269                address: false,
270            },
271            inject_bssl_hash: true,
272            static: {
273                // Disable the static version of libcrypto, as it causes
274                // problems for FIPS certification.  Use libcrypto_static for
275                // modules that need static libcrypto but do not need FIPS self
276                // testing, or use dynamic libcrypto.
277                enabled: false,
278            },
279        },
280    },
281    apex_available: [
282        "//apex_available:platform",
283        "com.android.adbd",
284        "com.android.adservices",
285        "com.android.btservices",
286        "com.android.compos",
287        "com.android.conscrypt",
288        "com.android.extservices",
289        "com.android.resolv",
290        "com.android.ondevicepersonalization",
291        "com.android.virt",
292    ],
293    min_sdk_version: "29",
294    afdo: true,
295}
296
297// Version of libcrypto build with BORINGSSL_FIPS_BREAK_TESTS defined
298// Only for use with the FIPS break-tests.sh script.
299// Must be kept in sync with libcrypto.
300cc_library {
301    name: "libcrypto_for_testing",
302    visibility: [
303        "//external/boringssl",
304    ],
305    defaults: [
306        "libcrypto_sources",
307        "libcrypto_defaults",
308        "boringssl_defaults",
309        "boringssl_flags",
310    ],
311    unique_host_soname: true,
312    srcs: [
313        ":bcm_object_for_testing",
314    ],
315    target: {
316        android: {
317            cflags: [
318                "-DBORINGSSL_FIPS",
319                "-DBORINGSSL_FIPS_BREAK_TESTS",
320            ],
321            sanitize: {
322                // Disable address sanitizing otherwise libcrypto will not report
323                // itself as being in FIPS mode, which causes boringssl_self_test
324                // to fail.
325                address: false,
326            },
327            inject_bssl_hash: true,
328            static: {
329                // Disable the static version of libcrypto, as it causes
330                // problems for FIPS certification.  Use libcrypto_static for
331                // modules that need static libcrypto but do not need FIPS self
332                // testing, or use dynamic libcrypto.
333                enabled: false,
334            },
335        },
336    },
337    min_sdk_version: "29",
338}
339
340// Static library
341// This version of libcrypto will not have FIPS self tests enabled, so its
342// usage is protected through visibility to ensure it doesn't end up used
343// somewhere that needs the FIPS version.
344cc_library_static {
345    name: "libcrypto_static",
346    visibility: [
347        "//bootable/recovery/updater",
348        "//bootable/deprecated-ota/updater",
349        "//external/conscrypt",
350        "//external/python/cpython2",
351        "//external/rust/crates/quiche",
352        // Strictly, only the *static* toybox for legacy devices should have
353        // access to libcrypto_static, but we can't express that.
354        "//external/toybox",
355        "//hardware/interfaces/confirmationui/1.0/vts/functional",
356        "//hardware/interfaces/drm/1.0/vts/functional",
357        "//hardware/interfaces/drm/1.2/vts/functional",
358        "//hardware/interfaces/drm/1.3/vts/functional",
359        "//hardware/interfaces/keymaster/3.0/vts/functional",
360        "//hardware/interfaces/keymaster/4.0/vts/functional",
361        "//hardware/interfaces/keymaster/4.1/vts/functional",
362        "//packages/modules/adb",
363        "//packages/modules/AdServices:__subpackages__",
364        "//packages/modules/DnsResolver/tests:__subpackages__",
365        "//packages/modules/NeuralNetworks:__subpackages__",
366        "//system/core/init",
367        "//system/core/fs_mgr/liblp",
368        "//system/core/fs_mgr/liblp/vts_core",
369        "//system/core/fs_mgr/libsnapshot",
370        "//system/libvintf/test",
371        "//system/security/keystore/tests",
372        "//system/security/provisioner",
373        "//test/vts-testcase/security/avb",
374        "//vendor:__subpackages__",
375    ],
376    min_sdk_version: "29",
377    apex_available: [
378        "//apex_available:platform",
379        "com.android.adservices",
380        "com.android.extservices",
381        "com.android.neuralnetworks",
382    ],
383    defaults: [
384        "libcrypto_bcm_sources",
385        "libcrypto_sources",
386        "libcrypto_defaults",
387        "boringssl_defaults",
388        "boringssl_flags",
389    ],
390}
391
392// Static library for use in bare-metal environments
393cc_library_static {
394    name: "libcrypto_baremetal",
395    defaults: [
396        "libcrypto_bcm_sources",
397        "libcrypto_sources",
398        "boringssl_defaults",
399        "boringssl_flags_baremetal",
400    ],
401    visibility: [
402        "//external/avb:__subpackages__",
403        "//external/open-dice",
404        "//packages/modules/Virtualization:__subpackages__",
405        "//system/security/diced/open_dice",
406    ],
407}
408
409// For static linking into the ART module to provide limited functionality:
410// bignums and SHA1 for ELF checksums.
411cc_library_static {
412    name: "libcrypto_for_art",
413    defaults: [
414        "libcrypto_defaults",
415        "boringssl_defaults",
416    ],
417    srcs: [
418        "src/crypto/cpu_*.c",
419        "src/crypto/crypto.c",
420        "src/crypto/err/err.c",
421        "src/crypto/fipsmodule/bn/*.c",
422        "src/crypto/fipsmodule/bn/asm/*.c",
423        "src/crypto/fipsmodule/rand/*.c",
424        "src/crypto/fipsmodule/sha/sha1.c",
425        "src/crypto/mem.c",
426        "src/crypto/stack/stack.c",
427        "src/crypto/thread_pthread.c",
428        "src/gen/crypto/err_data.c",
429    ],
430    target: {
431        linux: {
432            srcs: [
433                "src/gen/bcm/*-linux.S",
434            ],
435        },
436    },
437    visibility: [
438        "//art:__subpackages__",
439        "//libcore:__subpackages__",
440    ],
441    apex_available: [
442        "com.android.art",
443        "com.android.art.debug",
444        "com.android.art.testing",
445    ],
446    min_sdk_version: "29",
447}
448
449// Common defaults for lib*_fuzz_unsafe. These are unsafe and deterministic
450// libraries for testing and fuzzing only. See src/FUZZING.md.
451cc_defaults {
452    name: "boringssl_fuzz_unsafe_defaults",
453    host_supported: true,
454    cflags: [
455        "-DBORINGSSL_UNSAFE_DETERMINISTIC_MODE",
456        "-DBORINGSSL_UNSAFE_FUZZER_MODE",
457    ],
458    visibility: [
459        "//frameworks/native/libs/binder/tests:__subpackages__",
460    ],
461}
462
463// Unsafe and deterministic version of libcrypto. For testing and fuzzing only.
464// See src/FUZZING.md.
465cc_test_library {
466    name: "libcrypto_fuzz_unsafe",
467    ramdisk_available: false,
468    vendor_ramdisk_available: false,
469    defaults: [
470        "libcrypto_bcm_sources",
471        "libcrypto_sources",
472        "libcrypto_defaults",
473        "boringssl_defaults",
474        "boringssl_flags",
475        "boringssl_fuzz_unsafe_defaults",
476    ],
477}
478
479//// libssl
480
481// Target static library
482
483// Static and Shared library
484cc_library {
485    name: "libssl",
486    visibility: ["//visibility:public"],
487    recovery_available: true,
488    vendor_available: true,
489    product_available: true,
490    native_bridge_supported: true,
491    host_supported: true,
492    defaults: [
493        "libssl_sources",
494        "boringssl_defaults",
495        "boringssl_flags",
496    ],
497    target: {
498        windows: {
499            enabled: true,
500        },
501    },
502    unique_host_soname: true,
503
504    shared_libs: ["libcrypto"],
505
506    apex_available: [
507        "//apex_available:platform",
508        "com.android.btservices",
509        "com.android.adbd",
510        "com.android.conscrypt",
511        "com.android.resolv",
512        "com.android.virt",
513    ],
514    min_sdk_version: "29",
515}
516
517cc_library_static {
518    name: "libssl_baremetal",
519    defaults: [
520        "libssl_sources",
521        "boringssl_defaults",
522        "boringssl_flags_baremetal",
523    ],
524    static_libs: ["libcrypto_baremetal"],
525}
526
527cc_library_host_static {
528    name: "libssl_static",
529    defaults: [
530        "libssl_sources",
531        "boringssl_defaults",
532        "boringssl_flags",
533    ],
534    static_libs: ["libcrypto_static"],
535}
536
537// Unsafe and deterministic version of libssl. For testing and fuzzing only.
538// See src/FUZZING.md.
539cc_test_library {
540    name: "libssl_fuzz_unsafe",
541    host_supported: true,
542    defaults: [
543        "libssl_sources",
544        "boringssl_defaults",
545        "boringssl_flags",
546        "boringssl_fuzz_unsafe_defaults",
547    ],
548    static_libs: [
549        "libcrypto_fuzz_unsafe",
550    ],
551}
552
553// Tool
554cc_binary {
555    name: "bssl",
556    host_supported: true,
557    defaults: [
558        "bssl_sources",
559        "boringssl_flags",
560    ],
561
562    shared_libs: [
563        "libcrypto",
564        "libssl",
565    ],
566    target: {
567        darwin: {
568            enabled: false,
569        },
570        android: {
571            compile_multilib: "both",
572        },
573    },
574    multilib: {
575        lib32: {
576            suffix: "32",
577        },
578    },
579}
580
581// Used for ACVP testing for FIPS certification.
582// Not installed on devices by default.
583cc_binary {
584    name: "acvp_modulewrapper",
585    srcs: [
586        "src/util/fipstools/acvp/modulewrapper/main.cc",
587    ],
588    target: {
589        android_x86: {
590            enabled: false,
591        },
592        android_x86_64: {
593            enabled: false,
594        },
595    },
596    stem: "modulewrapper",
597    compile_multilib: "both",
598    multilib: {
599        lib32: {
600            suffix: "32",
601        },
602    },
603
604    static_libs: [
605        "libacvp_modulewrapper",
606    ],
607    shared_libs: [
608        "libcrypto",
609    ],
610
611    defaults: [
612        "boringssl_flags",
613    ],
614}
615
616// ACVP wrapper implementation shared between Android and Trusty
617cc_library_static {
618    name: "libacvp_modulewrapper",
619    host_supported: true,
620    vendor_available: true,
621    srcs: [
622        "src/util/fipstools/acvp/modulewrapper/modulewrapper.cc",
623    ],
624    target: {
625        android: {
626            compile_multilib: "both",
627        },
628    },
629    export_include_dirs: ["src/util/fipstools/acvp/modulewrapper/"],
630    shared_libs: [
631        "libcrypto",
632    ],
633
634    defaults: [
635        "boringssl_flags",
636    ],
637
638    visibility: ["//system/core/trusty/utils/acvp"],
639}
640
641// Test support library
642cc_test_library {
643    name: "boringssl_test_support",
644    host_supported: true,
645    defaults: [
646        "boringssl_test_support_sources",
647        "boringssl_flags",
648    ],
649
650    shared_libs: [
651        "libcrypto",
652    ],
653}
654
655// Tests
656cc_test {
657    name: "boringssl_crypto_test",
658    test_config: "CryptoNativeTests.xml",
659    host_supported: false,
660    vendor_available: false,
661    product_available: false,
662    per_testcase_directory: true,
663    compile_multilib: "both",
664    multilib: {
665        lib32: {
666            suffix: "32",
667        },
668        lib64: {
669            suffix: "64",
670        },
671    },
672    defaults: [
673        "boringssl_crypto_test_sources",
674        "boringssl_flags",
675    ],
676    whole_static_libs: ["boringssl_test_support"],
677    // Statically link the library to test to ensure we always pick up the
678    // correct version regardless of device linker configuration.
679    static_libs: [
680        "libcrypto_static",
681        "libgmock_ndk",
682    ],
683    target: {
684        android: {
685            test_suites: ["mts-conscrypt"],
686        },
687    },
688}
689
690cc_test {
691    name: "boringssl_ssl_test",
692    test_config: "SslNativeTests.xml",
693    host_supported: false,
694    vendor_available: false,
695    product_available: false,
696    per_testcase_directory: true,
697    compile_multilib: "both",
698    multilib: {
699        lib32: {
700            suffix: "32",
701        },
702        lib64: {
703            suffix: "64",
704        },
705    },
706    defaults: [
707        "boringssl_ssl_test_sources",
708        "boringssl_flags",
709    ],
710    whole_static_libs: ["boringssl_test_support"],
711    // Statically link the libraries to test to ensure we always pick up the
712    // correct version regardless of device linker configuration.
713    static_libs: [
714        "libcrypto_static",
715        "libgmock_ndk",
716        "libssl",
717    ],
718    target: {
719        android: {
720            test_suites: ["mts-conscrypt"],
721        },
722    },
723}
724
725// Utility binary for CMVP on-site testing.
726cc_binary {
727    name: "test_fips",
728    host_supported: false,
729    compile_multilib: "both",
730    multilib: {
731        lib32: {
732            suffix: "32",
733        },
734        lib64: {
735            suffix: "",
736        },
737    },
738    defaults: [
739        "boringssl_flags",
740    ],
741    shared_libs: [
742        "libcrypto",
743    ],
744    srcs: [
745        "src/util/fipstools/test_fips.c",
746    ],
747    required: [
748        "adb",
749        "libcrypto_for_testing",
750    ],
751}
752
753libbssl_sys_raw_flags = [
754    // Adapted from upstream the src/rust/CMakeLists.txt file at:
755    // https://boringssl.googlesource.com/boringssl/+/refs/heads/master/rust/CMakeLists.txt
756    "--no-derive-default",
757    "--enable-function-attribute-detection",
758    "--use-core",
759    "--default-macro-constant-type=signed",
760    "--rustified-enum=point_conversion_form_t",
761    // These regexes use [[:punct:]] instead of / to handle Windows file paths.
762    // Ideally we would write [/\\], but escaping rules are complex, and often
763    // ill-defined, in some build systems, so align on [[:punct:]].
764    "--allowlist-file=.*[[:punct:]]include[[:punct:]]openssl[[:punct:]].*\\.h",
765    "--allowlist-file=.*[[:punct:]]rust_wrapper\\.h",
766]
767
768// Rust bindings
769rust_bindgen {
770    name: "libbssl_sys_raw",
771    source_stem: "bssl_sys_bindings",
772    crate_name: "bssl_sys_raw",
773    host_supported: true,
774    wrapper_src: "src/rust/bssl-sys/wrapper.h",
775    vendor_available: true,
776    product_available: true,
777    bindgen_flags: libbssl_sys_raw_flags,
778    shared_libs: [
779        "libcrypto",
780        "libssl",
781    ],
782    apex_available: [
783        "//apex_available:platform",
784        "com.android.virt",
785    ],
786}
787
788rust_bindgen {
789    name: "libbssl_sys_raw_nostd",
790    source_stem: "bssl_sys_bindings",
791    crate_name: "bssl_sys_raw",
792    wrapper_src: "src/rust/bssl-sys/wrapper.h",
793    bindgen_flags: [
794        "--ctypes-prefix=core::ffi",
795    ] + libbssl_sys_raw_flags,
796    header_libs: [
797        "libcrypto_baremetal",
798        "libssl_baremetal",
799    ],
800    apex_available: [
801        "com.android.virt",
802    ],
803}
804
805// Encapsulate the bindgen-generated layout tests as a test target.
806rust_test {
807    name: "libbssl_sys_raw_test",
808    srcs: [
809        ":libbssl_sys_raw",
810    ],
811    crate_name: "bssl_sys_raw_test",
812    test_suites: ["general-tests"],
813    auto_gen_config: true,
814    clippy_lints: "none",
815    lints: "none",
816}
817
818// Rust's bindgen doesn't cope with macros, so this target includes C functions that
819// do the same thing as macros defined in BoringSSL header files.
820cc_library_static {
821    name: "libbssl_rust_support",
822    host_supported: true,
823    defaults: ["boringssl_flags"],
824    srcs: ["src/rust/bssl-sys/rust_wrapper.c"],
825    shared_libs: [
826        "libcrypto",
827        "libssl",
828    ],
829    apex_available: [
830        "//apex_available:platform",
831        "com.android.virt",
832    ],
833}
834
835cc_library_static {
836    name: "libbssl_rust_support_baremetal",
837    defaults: ["boringssl_flags_baremetal"],
838    srcs: ["src/rust/bssl-sys/rust_wrapper.c"],
839    static_libs: [
840        "libcrypto_baremetal",
841        "libssl_baremetal",
842    ],
843}
844
845cc_library_host_static {
846    name: "libbssl_rust_support_static",
847    defaults: ["boringssl_flags"],
848    srcs: ["src/rust/bssl-sys/rust_wrapper.c"],
849    whole_static_libs: [
850        "libcrypto_static",
851        "libssl_static",
852    ],
853}
854
855rust_defaults {
856    name: "libbssl_sys_defaults",
857    host_supported: true,
858    crate_name: "bssl_sys",
859    visibility: [
860        "//external/rust/crates/openssl",
861        "//system/keymint/boringssl",
862        "//system/security/prng_seeder",
863    ],
864    srcs: [
865        "src/rust/bssl-sys/src/lib.rs",
866        ":libbssl_sys_raw",
867    ],
868    shared_libs: [
869        "libcrypto",
870        "libssl",
871    ],
872    vendor_available: true,
873    product_available: true,
874}
875
876rust_library {
877    name: "libbssl_sys",
878    defaults: ["libbssl_sys_defaults"],
879    whole_static_libs: [
880        "libbssl_rust_support",
881    ],
882    apex_available: [
883        "//apex_available:platform",
884        "com.android.virt",
885    ],
886    cfgs: ["unsupported_inline_wrappers"],
887}
888
889rust_library_host_rlib {
890    name: "libbssl_sys_static",
891    defaults: ["libbssl_sys_defaults"],
892    whole_static_libs: [
893        "libbssl_rust_support_static",
894    ],
895    cfgs: ["unsupported_inline_wrappers"],
896}
897
898genrule {
899    name: "libbssl_sys_src_nostd",
900    srcs: ["src/rust/bssl-sys/src/lib.rs"],
901    out: ["lib.rs"],
902    cmd: "(echo '#![no_std]' && cat $(in)) > $(out)",
903}
904
905rust_library_rlib {
906    name: "libbssl_sys_nostd",
907    crate_name: "bssl_sys",
908    visibility: [
909        "//packages/modules/Virtualization:__subpackages__",
910    ],
911    srcs: [
912        ":libbssl_sys_src_nostd",
913        ":libbssl_sys_raw_nostd",
914    ],
915    prefer_rlib: true,
916    no_stdlibs: true,
917    stdlibs: [
918        "libcompiler_builtins.rust_sysroot",
919        "libcore.rust_sysroot",
920    ],
921    whole_static_libs: [
922        "libbssl_rust_support_baremetal",
923    ],
924    cfgs: ["unsupported_inline_wrappers"],
925}
926
927// High-level Rust crate `bssl-crypto`
928
929rust_defaults {
930    name: "libbssl_crypto_defaults",
931    crate_name: "bssl_crypto",
932    visibility: ["//visibility:public"],
933    srcs: ["src/rust/bssl-crypto/src/lib.rs"],
934    rustlibs: ["libbssl_sys"],
935}
936
937rust_library {
938    name: "libbssl_crypto",
939    defaults: ["libbssl_crypto_defaults"],
940    host_supported: true,
941    apex_available: [
942        "//apex_available:platform",
943        "com.android.virt",
944    ],
945    vendor_available: true,
946    product_available: true,
947}
948
949rust_test {
950    name: "libbssl_crypto_test",
951    defaults: ["libbssl_crypto_defaults"],
952    crate_name: "bssl_crypto_test",
953    test_suites: ["general-tests"],
954    auto_gen_config: true,
955}
956