diff options
author | Pete Bentley <prb@google.com> | 2022-10-04 22:10:35 +0000 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2022-10-04 22:10:35 +0000 |
commit | aa6b738d994f6e44a0ec25a3dc16c74c748dc951 (patch) | |
tree | 5e06709d4eb6fb449856a106fb53f3dd1aa83c39 | |
parent | 4bde7734dbdbc44d0ceb3c33a2630cb5fc37d138 (diff) | |
parent | 1364953c681d19461b5bf3f291cc336c1ec0f625 (diff) | |
download | boringssl-android13-qpr3-c-s12-release.tar.gz |
Merge changes from topics "prng_seeder_daemon", "tm-bssl-ffi" into tm-qpr-devandroid-13.0.0_r82android-13.0.0_r81android-13.0.0_r80android-13.0.0_r74android-13.0.0_r73android-13.0.0_r72android-13.0.0_r66android-13.0.0_r65android-13.0.0_r64android-13.0.0_r60android-13.0.0_r59android-13.0.0_r58android13-qpr3-c-s8-releaseandroid13-qpr3-c-s7-releaseandroid13-qpr3-c-s6-releaseandroid13-qpr3-c-s5-releaseandroid13-qpr3-c-s4-releaseandroid13-qpr3-c-s3-releaseandroid13-qpr3-c-s2-releaseandroid13-qpr3-c-s12-releaseandroid13-qpr3-c-s11-releaseandroid13-qpr3-c-s10-releaseandroid13-qpr3-c-s1-release
* changes:
Use genrule to pull in bindgen-erated source
Make crate vendor_available
Allow prng_seeder utility
Build Rust bindings
-rw-r--r-- | Android.bp | 91 | ||||
-rw-r--r-- | TEST_MAPPING | 7 | ||||
-rw-r--r-- | src/rust/wrapper.h | 1 |
3 files changed, 99 insertions, 0 deletions
@@ -566,3 +566,94 @@ cc_binary { "src/util/fipstools/test_fips.c", ], } + +// Rust bindings +rust_bindgen { + name: "libbssl_sys_raw", + source_stem: "bindings", + crate_name: "bssl_sys_raw", + host_supported: true, + wrapper_src: "src/rust/wrapper.h", + vendor_available: true, + bindgen_flags: [ + // Adapted from upstream the src/rust/CMakeLists.txt file at: + // https://boringssl.googlesource.com/boringssl/+/refs/heads/master/rust/CMakeLists.txt + "--no-derive-default", + "--enable-function-attribute-detection", + "--use-core", + "--size_t-is-usize", + "--default-macro-constant-type=signed", + "--rustified-enum=point_conversion_form_t", + // These are not BoringSSL symbols, they are from glibc + // and are not relevant to the build besides throwing warnings + // about their 'long double' (aka u128) not being FFI safe. + // We block those functions so that the build doesn't + // spam warnings. + // + // https://github.com/rust-lang/rust-bindgen/issues/1549 describes the current problem + // and other folks' solutions. + "--blocklist-function=strtold", + "--blocklist-function=qecvt", + "--blocklist-function=qecvt_r", + "--blocklist-function=qgcvt", + "--blocklist-function=qfcvt", + "--blocklist-function=qfcvt_r", + ], + shared_libs: [ + "libcrypto", + "libssl", + ], +} + +// Encapsulate the bindgen-generated layout tests as a test target. +rust_test { + name: "libbssl_sys_raw_test", + srcs: [ + ":libbssl_sys_raw", + ], + crate_name: "bssl_sys_raw_test", + test_suites: ["general-tests"], + auto_gen_config: true, + clippy_lints: "none", + lints: "none", +} + +// Rust's bindgen doesn't cope with macros, so this target includes C functions that +// do the same thing as macros defined in BoringSSL header files. +cc_library_static { + name: "libbssl_rust_support", + host_supported: true, + defaults: ["boringssl_flags"], + srcs: ["src/rust/rust_wrapper.c"], + shared_libs: [ + "libcrypto", + "libssl", + ], +} + +// Replace the upstream CMake placeholder with a re-export of all of the local bindgen output. +gensrcs { + name: "libbssl_sys_src", + srcs: ["src/rust/src/lib.rs"], + cmd: "sed 's@^.{INCLUDES}@pub use bssl_sys_raw::*;@' $(in) > $(out)", +} + +rust_library { + name: "libbssl_ffi", + host_supported: true, + crate_name: "bssl_ffi", + visibility: [ + "//external/rust/crates/openssl", + "//system/keymint/boringssl", + "//system/security/prng_seeder", + ], + // Use the modified source with placeholder replaced. + srcs: [":libbssl_sys_src"], + vendor_available: true, + // Since libbssl_sys_raw is not publically visible, we can't + // accidentally force a double-link by linking statically, so do so. + rlibs: ["libbssl_sys_raw"], + static_libs: [ + "libbssl_rust_support", + ], +} diff --git a/TEST_MAPPING b/TEST_MAPPING new file mode 100644 index 00000000..ce976386 --- /dev/null +++ b/TEST_MAPPING @@ -0,0 +1,7 @@ +{ + "presubmit": [ + { + "name": "libbssl_sys_raw_test" + } + ] +} diff --git a/src/rust/wrapper.h b/src/rust/wrapper.h index aa5aeedb..ff466423 100644 --- a/src/rust/wrapper.h +++ b/src/rust/wrapper.h @@ -18,6 +18,7 @@ #include "../include/openssl/conf.h" #include "../include/openssl/cpu.h" #include "../include/openssl/crypto.h" +#include "../include/openssl/ctrdrbg.h" #include "../include/openssl/curve25519.h" #include "../include/openssl/des.h" #include "../include/openssl/dh.h" |