Skip to content

Commit f620b1e

Browse files
authored
Merge pull request #2423 from justsmth/bindgen-feature-macros
Improve support for OPENSSL_NO_COMP and OPENSSL_NO_SRTP
2 parents c723b6b + 0e91ccc commit f620b1e

File tree

7 files changed

+15
-5
lines changed

7 files changed

+15
-5
lines changed

openssl-sys/build/expando.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,10 @@ RUST_CONF_OPENSSL_NO_SHA
111111
RUST_CONF_OPENSSL_NO_SRP
112112
#endif
113113

114+
#ifdef OPENSSL_NO_SRTP
115+
RUST_CONF_OPENSSL_NO_SRTP
116+
#endif
117+
114118
#ifdef OPENSSL_NO_SSL3_METHOD
115119
RUST_CONF_OPENSSL_NO_SSL3_METHOD
116120
#endif

openssl-sys/build/main.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ fn check_ssl_kind() {
120120
}
121121

122122
fn main() {
123-
println!("cargo:rustc-check-cfg=cfg(osslconf, values(\"OPENSSL_NO_OCB\", \"OPENSSL_NO_SM4\", \"OPENSSL_NO_SEED\", \"OPENSSL_NO_CHACHA\", \"OPENSSL_NO_CAST\", \"OPENSSL_NO_IDEA\", \"OPENSSL_NO_CAMELLIA\", \"OPENSSL_NO_RC4\", \"OPENSSL_NO_BF\", \"OPENSSL_NO_PSK\", \"OPENSSL_NO_DEPRECATED_3_0\", \"OPENSSL_NO_SCRYPT\", \"OPENSSL_NO_SM3\", \"OPENSSL_NO_RMD160\", \"OPENSSL_NO_EC2M\", \"OPENSSL_NO_OCSP\", \"OPENSSL_NO_CMS\", \"OPENSSL_NO_COMP\", \"OPENSSL_NO_SOCK\", \"OPENSSL_NO_STDIO\", \"OPENSSL_NO_EC\", \"OPENSSL_NO_SSL3_METHOD\", \"OPENSSL_NO_KRB5\", \"OPENSSL_NO_TLSEXT\", \"OPENSSL_NO_SRP\", \"OPENSSL_NO_RFC3779\", \"OPENSSL_NO_SHA\", \"OPENSSL_NO_NEXTPROTONEG\", \"OPENSSL_NO_ENGINE\", \"OPENSSL_NO_BUF_FREELISTS\", \"OPENSSL_NO_RC2\"))");
123+
println!("cargo:rustc-check-cfg=cfg(osslconf, values(\"OPENSSL_NO_OCB\", \"OPENSSL_NO_SM4\", \"OPENSSL_NO_SEED\", \"OPENSSL_NO_CHACHA\", \"OPENSSL_NO_CAST\", \"OPENSSL_NO_IDEA\", \"OPENSSL_NO_CAMELLIA\", \"OPENSSL_NO_RC4\", \"OPENSSL_NO_BF\", \"OPENSSL_NO_PSK\", \"OPENSSL_NO_DEPRECATED_3_0\", \"OPENSSL_NO_SCRYPT\", \"OPENSSL_NO_SM3\", \"OPENSSL_NO_RMD160\", \"OPENSSL_NO_EC2M\", \"OPENSSL_NO_OCSP\", \"OPENSSL_NO_CMS\", \"OPENSSL_NO_COMP\", \"OPENSSL_NO_SOCK\", \"OPENSSL_NO_STDIO\", \"OPENSSL_NO_EC\", \"OPENSSL_NO_SSL3_METHOD\", \"OPENSSL_NO_KRB5\", \"OPENSSL_NO_TLSEXT\", \"OPENSSL_NO_SRP\", \"OPENSSL_NO_SRTP\", \"OPENSSL_NO_RFC3779\", \"OPENSSL_NO_SHA\", \"OPENSSL_NO_NEXTPROTONEG\", \"OPENSSL_NO_ENGINE\", \"OPENSSL_NO_BUF_FREELISTS\", \"OPENSSL_NO_RC2\"))");
124124

125125
println!("cargo:rustc-check-cfg=cfg(openssl)");
126126
println!("cargo:rustc-check-cfg=cfg(libressl)");

openssl-sys/build/run_bindgen.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ const INCLUDES: &str = "
4545
#include <openssl/cms.h>
4646
#endif
4747
48-
#if !(defined(OPENSSL_IS_BORINGSSL) || defined(OPENSSL_IS_AWSLC))
48+
#if !defined(OPENSSL_NO_COMP) && !(defined(OPENSSL_IS_BORINGSSL) || defined(OPENSSL_IS_AWSLC))
4949
#include <openssl/comp.h>
5050
#endif
5151

openssl-sys/src/handwritten/types.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1072,9 +1072,9 @@ cfg_if! {
10721072
pub enum COMP_CTX {}
10731073

10741074
cfg_if! {
1075-
if #[cfg(any(ossl110, libressl350))] {
1075+
if #[cfg(all(any(ossl110, libressl350), not(osslconf = "OPENSSL_NO_COMP")))] {
10761076
pub enum COMP_METHOD {}
1077-
} else {
1077+
} else if #[cfg(not(osslconf = "OPENSSL_NO_COMP"))] {
10781078
#[repr(C)]
10791079
pub struct COMP_METHOD {
10801080
pub type_: c_int,

openssl-sys/src/tls1.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,7 @@ pub unsafe fn SSL_CTX_set_tlsext_status_cb(
109109
)
110110
}
111111

112+
#[cfg(not(osslconf = "OPENSSL_NO_SRTP"))]
112113
pub unsafe fn SSL_CTX_set_tlsext_status_arg(ctx: *mut SSL_CTX, arg: *mut c_void) -> c_long {
113114
SSL_CTX_ctrl(ctx, SSL_CTRL_SET_TLSEXT_STATUS_REQ_CB_ARG, 0, arg)
114115
}

openssl/build.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
use std::env;
88

99
fn main() {
10-
println!("cargo:rustc-check-cfg=cfg(osslconf, values(\"OPENSSL_NO_OCB\", \"OPENSSL_NO_SM4\", \"OPENSSL_NO_SEED\", \"OPENSSL_NO_CHACHA\", \"OPENSSL_NO_CAST\", \"OPENSSL_NO_IDEA\", \"OPENSSL_NO_CAMELLIA\", \"OPENSSL_NO_RC4\", \"OPENSSL_NO_BF\", \"OPENSSL_NO_PSK\", \"OPENSSL_NO_DEPRECATED_3_0\", \"OPENSSL_NO_SCRYPT\", \"OPENSSL_NO_SM3\", \"OPENSSL_NO_RMD160\", \"OPENSSL_NO_EC2M\", \"OPENSSL_NO_OCSP\", \"OPENSSL_NO_CMS\", \"OPENSSL_NO_EC\", \"OPENSSL_NO_ARGON2\", \"OPENSSL_NO_RC2\"))");
10+
println!("cargo:rustc-check-cfg=cfg(osslconf, values(\"OPENSSL_NO_OCB\", \"OPENSSL_NO_SM4\", \"OPENSSL_NO_SEED\", \"OPENSSL_NO_CHACHA\", \"OPENSSL_NO_CAST\", \"OPENSSL_NO_IDEA\", \"OPENSSL_NO_CAMELLIA\", \"OPENSSL_NO_RC4\", \"OPENSSL_NO_BF\", \"OPENSSL_NO_PSK\", \"OPENSSL_NO_DEPRECATED_3_0\", \"OPENSSL_NO_SCRYPT\", \"OPENSSL_NO_SM3\", \"OPENSSL_NO_RMD160\", \"OPENSSL_NO_EC2M\", \"OPENSSL_NO_OCSP\", \"OPENSSL_NO_SRTP\", \"OPENSSL_NO_CMS\", \"OPENSSL_NO_EC\", \"OPENSSL_NO_ARGON2\", \"OPENSSL_NO_RC2\"))");
1111

1212
println!("cargo:rustc-check-cfg=cfg(libressl)");
1313
println!("cargo:rustc-check-cfg=cfg(boringssl)");

openssl/src/ssl/mod.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@ use crate::nid::Nid;
7272
use crate::pkey::{HasPrivate, PKeyRef, Params, Private};
7373
#[cfg(ossl300)]
7474
use crate::pkey::{PKey, Public};
75+
#[cfg(not(osslconf = "OPENSSL_NO_SRTP"))]
7576
use crate::srtp::{SrtpProtectionProfile, SrtpProtectionProfileRef};
7677
use crate::ssl::bio::BioMethod;
7778
use crate::ssl::callbacks::*;
@@ -1269,6 +1270,7 @@ impl SslContextBuilder {
12691270
}
12701271

12711272
/// Enables the DTLS extension "use_srtp" as defined in RFC5764.
1273+
#[cfg(not(osslconf = "OPENSSL_NO_SRTP"))]
12721274
#[corresponds(SSL_CTX_set_tlsext_use_srtp)]
12731275
pub fn set_tlsext_use_srtp(&mut self, protocols: &str) -> Result<(), ErrorStack> {
12741276
unsafe {
@@ -2675,6 +2677,7 @@ impl SslRef {
26752677
}
26762678

26772679
/// Enables the DTLS extension "use_srtp" as defined in RFC5764.
2680+
#[cfg(not(osslconf = "OPENSSL_NO_SRTP"))]
26782681
#[corresponds(SSL_set_tlsext_use_srtp)]
26792682
pub fn set_tlsext_use_srtp(&mut self, protocols: &str) -> Result<(), ErrorStack> {
26802683
unsafe {
@@ -2693,6 +2696,7 @@ impl SslRef {
26932696
/// Gets all SRTP profiles that are enabled for handshake via set_tlsext_use_srtp
26942697
///
26952698
/// DTLS extension "use_srtp" as defined in RFC5764 has to be enabled.
2699+
#[cfg(not(osslconf = "OPENSSL_NO_SRTP"))]
26962700
#[corresponds(SSL_get_srtp_profiles)]
26972701
pub fn srtp_profiles(&self) -> Option<&StackRef<SrtpProtectionProfile>> {
26982702
unsafe {
@@ -2705,6 +2709,7 @@ impl SslRef {
27052709
/// Gets the SRTP profile selected by handshake.
27062710
///
27072711
/// DTLS extension "use_srtp" as defined in RFC5764 has to be enabled.
2712+
#[cfg(not(osslconf = "OPENSSL_NO_SRTP"))]
27082713
#[corresponds(SSL_get_selected_srtp_profile)]
27092714
pub fn selected_srtp_profile(&self) -> Option<&SrtpProtectionProfileRef> {
27102715
unsafe {

0 commit comments

Comments
 (0)