Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove old codes that belows supported Rust version. #1966

Merged
merged 5 commits into from Jun 19, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/workflows/ci.yml
Expand Up @@ -59,6 +59,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
# Remember to also update `--rust-target` in `openssl-sys/build/run_bindgen.rs`
- uses: sfackler/actions/rustup@master
with:
version: 1.56.0
Expand Down
1 change: 1 addition & 0 deletions openssl-sys/build/cfgs.rs
@@ -1,3 +1,4 @@
#[allow(clippy::unusual_byte_groupings)]
pub fn get(openssl_version: Option<u64>, libressl_version: Option<u64>) -> Vec<&'static str> {
let mut cfgs = vec![];

Expand Down
33 changes: 8 additions & 25 deletions openssl-sys/build/main.rs
@@ -1,9 +1,3 @@
#![allow(
clippy::inconsistent_digit_grouping,
clippy::uninlined_format_args,
clippy::unusual_byte_groupings
)]

#[cfg(feature = "bindgen")]
extern crate bindgen;
extern crate cc;
Expand Down Expand Up @@ -131,7 +125,6 @@ fn main() {
}
}

#[allow(clippy::let_and_return)]
fn postprocess(include_dirs: &[PathBuf]) -> Version {
let version = validate_headers(include_dirs);

Expand All @@ -146,7 +139,7 @@ fn postprocess(include_dirs: &[PathBuf]) -> Version {

/// Validates the header files found in `include_dir` and then returns the
/// version string of OpenSSL.
#[allow(clippy::manual_strip)] // we need to support pre-1.45.0
#[allow(clippy::unusual_byte_groupings)]
fn validate_headers(include_dirs: &[PathBuf]) -> Version {
// This `*-sys` crate only works with OpenSSL 1.0.1, 1.0.2, 1.1.0, 1.1.1 and 3.0.0.
// To correctly expose the right API from this crate, take a look at
Expand All @@ -162,9 +155,7 @@ fn validate_headers(include_dirs: &[PathBuf]) -> Version {
// account for compile differences and such.
println!("cargo:rerun-if-changed=build/expando.c");
let mut gcc = cc::Build::new();
for include_dir in include_dirs {
gcc.include(include_dir);
}
gcc.includes(include_dirs);
let expanded = match gcc.file("build/expando.c").try_expand() {
Ok(expanded) => expanded,
Err(e) => {
Expand Down Expand Up @@ -210,17 +201,14 @@ See rust-openssl documentation for more information:
let libressl_prefix = "RUST_VERSION_LIBRESSL_";
let boringsl_prefix = "RUST_OPENSSL_IS_BORINGSSL";
let conf_prefix = "RUST_CONF_";
if line.starts_with(openssl_prefix) {
let version = &line[openssl_prefix.len()..];
if let Some(version) = line.strip_prefix(openssl_prefix) {
openssl_version = Some(parse_version(version));
} else if line.starts_with(new_openssl_prefix) {
let version = &line[new_openssl_prefix.len()..];
} else if let Some(version) = line.strip_prefix(new_openssl_prefix) {
openssl_version = Some(parse_new_version(version));
} else if line.starts_with(libressl_prefix) {
let version = &line[libressl_prefix.len()..];
} else if let Some(version) = line.strip_prefix(libressl_prefix) {
libressl_version = Some(parse_version(version));
} else if line.starts_with(conf_prefix) {
enabled.push(&line[conf_prefix.len()..]);
} else if let Some(conf) = line.strip_prefix(conf_prefix) {
enabled.push(conf);
} else if line.starts_with(boringsl_prefix) {
is_boringssl = true;
}
Expand Down Expand Up @@ -336,18 +324,13 @@ due to this version mismatch.
}

// parses a string that looks like "0x100020cfL"
#[allow(deprecated)] // trim_right_matches is now trim_end_matches
#[allow(clippy::match_like_matches_macro)] // matches macro requires rust 1.42.0
fn parse_version(version: &str) -> u64 {
// cut off the 0x prefix
assert!(version.starts_with("0x"));
let version = &version[2..];

// and the type specifier suffix
let version = version.trim_right_matches(|c: char| match c {
'0'..='9' | 'a'..='f' | 'A'..='F' => false,
_ => true,
});
let version = version.trim_end_matches(|c: char| !c.is_ascii_hexdigit());

u64::from_str_radix(version, 16).unwrap()
}
Expand Down
2 changes: 1 addition & 1 deletion openssl-sys/build/run_bindgen.rs
Expand Up @@ -167,7 +167,7 @@ pub fn run_boringssl(include_dirs: &[PathBuf]) {
bindgen_cmd
.arg("-o")
.arg(out_dir.join("bindgen.rs"))
.arg("--rust-target=1.47")
.arg("--rust-target=1.56")
.arg("--ctypes-prefix=::libc")
.arg("--raw-line=use libc::*;")
.arg("--no-derive-default")
Expand Down
4 changes: 0 additions & 4 deletions openssl-sys/src/lib.rs
@@ -1,13 +1,9 @@
#![allow(
clippy::missing_safety_doc,
clippy::unreadable_literal,
clippy::uninlined_format_args,
clippy::upper_case_acronyms,
dead_code,
non_camel_case_types,
non_snake_case,
non_upper_case_globals,
overflowing_literals,
unused_imports
)]
#![cfg_attr(feature = "unstable_boringssl", allow(ambiguous_glob_reexports))]
Expand Down
4 changes: 2 additions & 2 deletions openssl/src/ssl/mod.rs
Expand Up @@ -599,7 +599,7 @@ impl AlpnError {
/// Terminate the handshake with a fatal alert.
///
/// Requires OpenSSL 1.1.0 or newer.
#[cfg(any(ossl110))]
#[cfg(ossl110)]
pub const ALERT_FATAL: AlpnError = AlpnError(ffi::SSL_TLSEXT_ERR_ALERT_FATAL);

/// Do not select a protocol, but continue the handshake.
Expand Down Expand Up @@ -2413,7 +2413,7 @@ impl SslRef {
///
/// Requires OpenSSL 1.0.1 or 1.0.2.
#[corresponds(SSL_set_tmp_ecdh_callback)]
#[cfg(any(all(ossl101, not(ossl110))))]
#[cfg(all(ossl101, not(ossl110)))]
#[deprecated(note = "this function leaks memory and does not exist on newer OpenSSL versions")]
pub fn set_tmp_ecdh_callback<F>(&mut self, callback: F)
where
Expand Down
2 changes: 1 addition & 1 deletion openssl/src/ssl/test/mod.rs
Expand Up @@ -467,7 +467,7 @@ fn test_alpn_server_advertise_multiple() {
}

#[test]
#[cfg(any(ossl110))]
#[cfg(ossl110)]
fn test_alpn_server_select_none_fatal() {
let mut server = Server::builder();
server.ctx().set_alpn_select_callback(|_, client| {
Expand Down
4 changes: 2 additions & 2 deletions openssl/src/symm.rs
Expand Up @@ -1478,7 +1478,7 @@ mod tests {
}

#[test]
#[cfg(any(ossl110))]
#[cfg(ossl110)]
fn test_chacha20() {
let key = "0000000000000000000000000000000000000000000000000000000000000000";
let iv = "00000000000000000000000000000000";
Expand All @@ -1493,7 +1493,7 @@ mod tests {
}

#[test]
#[cfg(any(ossl110))]
#[cfg(ossl110)]
fn test_chacha20_poly1305() {
let key = "808182838485868788898a8b8c8d8e8f909192939495969798999a9b9c9d9e9f";
let iv = "070000004041424344454647";
Expand Down