Skip to content

Commit 3b73dda

Browse files
committed
Add support for OpenSSL 1.1.1
1 parent 8cfe49f commit 3b73dda

File tree

22 files changed

+117
-63
lines changed

22 files changed

+117
-63
lines changed

.circleci/config.yml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,9 @@ macos_job: &MACOS_JOB
8989
cargo test --manifest-path=openssl/Cargo.toml --all-features
9090
- *SAVE_DEPS
9191

92+
openssl_111: &OPENSSL_111
93+
LIBRARY: openssl
94+
VERSION: 1.1.1
9295
openssl_110: &OPENSSL_110
9396
LIBRARY: openssl
9497
VERSION: 1.1.0g
@@ -124,6 +127,10 @@ base: &BASE
124127

125128
version: 2
126129
jobs:
130+
x86_64-openssl-1.1.1:
131+
<<: *JOB
132+
environment:
133+
<<: [*OPENSSL_111, *X86_64, *BASE]
127134
x86_64-openssl-1.1.0:
128135
<<: *JOB
129136
environment:
@@ -136,6 +143,10 @@ jobs:
136143
<<: *JOB
137144
environment:
138145
<<: [*OPENSSL_101, *X86_64, *BASE]
146+
i686-openssl-1.1.1:
147+
<<: *JOB
148+
environment:
149+
<<: [*OPENSSL_111, *I686, *BASE]
139150
i686-openssl-1.1.0:
140151
<<: *JOB
141152
environment:
@@ -148,6 +159,10 @@ jobs:
148159
<<: *JOB
149160
environment:
150161
<<: [*OPENSSL_101, *I686, *BASE]
162+
armhf-openssl-1.1.1:
163+
<<: *JOB
164+
environment:
165+
<<: [*OPENSSL_111, *ARMHF, *BASE]
151166
armhf-openssl-1.1.0:
152167
<<: *JOB
153168
environment:
@@ -174,12 +189,15 @@ workflows:
174189
version: 2
175190
tests:
176191
jobs:
192+
- x86_64-openssl-1.1.1
177193
- x86_64-openssl-1.1.0
178194
- x86_64-openssl-1.0.2
179195
- x86_64-openssl-1.0.1
196+
- i686-openssl-1.1.1
180197
- i686-openssl-1.1.0
181198
- i686-openssl-1.0.2
182199
- i686-openssl-1.0.1
200+
- armhf-openssl-1.1.1
183201
- armhf-openssl-1.1.0
184202
- armhf-openssl-1.0.2
185203
- armhf-openssl-1.0.1

openssl/build.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,11 @@ fn main() {
1212
}
1313
Ok(ref v) if v == "110" => {
1414
println!("cargo:rustc-cfg=ossl110");
15+
println!("cargo:rustc-cfg=ossl11x");
16+
}
17+
Ok(ref v) if v == "111" => {
18+
println!("cargo:rustc-cfg=ossl111");
19+
println!("cargo:rustc-cfg=ossl11x");
1520
}
1621
_ => panic!("Unable to detect OpenSSL version"),
1722
}

openssl/src/asn1.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -288,7 +288,7 @@ impl fmt::Display for Asn1ObjectRef {
288288
#[cfg(any(ossl101, ossl102))]
289289
use ffi::ASN1_STRING_data;
290290

291-
#[cfg(ossl110)]
291+
#[cfg(ossl11x)]
292292
#[allow(bad_style)]
293293
unsafe fn ASN1_STRING_data(s: *mut ffi::ASN1_STRING) -> *mut ::libc::c_uchar {
294294
ffi::ASN1_STRING_get0_data(s) as *mut _

openssl/src/bn.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ use ffi::{get_rfc2409_prime_768 as BN_get_rfc2409_prime_768,
4747
get_rfc3526_prime_6144 as BN_get_rfc3526_prime_6144,
4848
get_rfc3526_prime_8192 as BN_get_rfc3526_prime_8192};
4949

50-
#[cfg(ossl110)]
50+
#[cfg(ossl11x)]
5151
use ffi::{BN_get_rfc2409_prime_768, BN_get_rfc2409_prime_1024, BN_get_rfc3526_prime_1536,
5252
BN_get_rfc3526_prime_2048, BN_get_rfc3526_prime_3072, BN_get_rfc3526_prime_4096,
5353
BN_get_rfc3526_prime_6144, BN_get_rfc3526_prime_8192};
@@ -366,7 +366,7 @@ impl BigNumRef {
366366
unsafe { (*self.as_ptr()).neg == 1 }
367367
}
368368

369-
#[cfg(ossl110)]
369+
#[cfg(ossl11x)]
370370
fn _is_negative(&self) -> bool {
371371
unsafe { ffi::BN_is_negative(self.as_ptr()) == 1 }
372372
}

openssl/src/dh.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ impl Dh {
4040
from_der!(Dh, ffi::d2i_DHparams);
4141

4242
/// Requires the `v102` or `v110` features and OpenSSL 1.0.2 or OpenSSL 1.1.0.
43-
#[cfg(any(all(feature = "v102", ossl102), all(feature = "v110", ossl110)))]
43+
#[cfg(any(all(feature = "v102", ossl102), all(feature = "v110", ossl11x)))]
4444
pub fn get_1024_160() -> Result<Dh, ErrorStack> {
4545
unsafe {
4646
ffi::init();
@@ -49,7 +49,7 @@ impl Dh {
4949
}
5050

5151
/// Requires the `v102` or `v110` features and OpenSSL 1.0.2 or OpenSSL 1.1.0.
52-
#[cfg(any(all(feature = "v102", ossl102), all(feature = "v110", ossl110)))]
52+
#[cfg(any(all(feature = "v102", ossl102), all(feature = "v110", ossl11x)))]
5353
pub fn get_2048_224() -> Result<Dh, ErrorStack> {
5454
unsafe {
5555
ffi::init();
@@ -58,7 +58,7 @@ impl Dh {
5858
}
5959

6060
/// Requires the `v102` or `v110` features and OpenSSL 1.0.2 or OpenSSL 1.1.0.
61-
#[cfg(any(all(feature = "v102", ossl102), all(feature = "v110", ossl110)))]
61+
#[cfg(any(all(feature = "v102", ossl102), all(feature = "v110", ossl11x)))]
6262
pub fn get_2048_256() -> Result<Dh, ErrorStack> {
6363
unsafe {
6464
ffi::init();
@@ -67,7 +67,7 @@ impl Dh {
6767
}
6868
}
6969

70-
#[cfg(ossl110)]
70+
#[cfg(ossl11x)]
7171
mod compat {
7272
pub use ffi::DH_set0_pqg;
7373
}
@@ -98,7 +98,7 @@ mod tests {
9898
use ssl::{SslMethod, SslContext};
9999

100100
#[test]
101-
#[cfg(any(all(feature = "v102", ossl102), all(feature = "v110", ossl110)))]
101+
#[cfg(any(all(feature = "v102", ossl102), all(feature = "v110", ossl11x)))]
102102
fn test_dh_rfc5114() {
103103
let mut ctx = SslContext::builder(SslMethod::tls()).unwrap();
104104
let dh1 = Dh::get_1024_160().unwrap();

openssl/src/dsa.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,7 @@ impl fmt::Debug for Dsa {
189189
}
190190
}
191191

192-
#[cfg(ossl110)]
192+
#[cfg(ossl11x)]
193193
mod compat {
194194
use std::ptr;
195195
use ffi::{self, BIGNUM, DSA};

openssl/src/hash.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ use std::ops::{Deref, DerefMut};
44
use std::fmt;
55
use ffi;
66

7-
#[cfg(ossl110)]
7+
#[cfg(ossl11x)]
88
use ffi::{EVP_MD_CTX_new, EVP_MD_CTX_free};
99
#[cfg(any(ossl101, ossl102))]
1010
use ffi::{EVP_MD_CTX_create as EVP_MD_CTX_new, EVP_MD_CTX_destroy as EVP_MD_CTX_free};

openssl/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ pub mod symm;
6060
pub mod types;
6161
pub mod version;
6262
pub mod x509;
63-
#[cfg(any(ossl102, ossl110))]
63+
#[cfg(any(ossl102, ossl11x))]
6464
mod verify;
6565

6666
fn cvt_p<T>(r: *mut T) -> Result<*mut T, ErrorStack> {

openssl/src/pkcs5.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ pub fn pbkdf2_hmac(
108108
/// Derives a key from a password and salt using the scrypt algorithm.
109109
///
110110
/// Requires the `v110` feature and OpenSSL 1.1.0.
111-
#[cfg(all(feature = "v110", ossl110))]
111+
#[cfg(all(feature = "v110", ossl11x))]
112112
pub fn scrypt(
113113
pass: &[u8],
114114
salt: &[u8],
@@ -546,7 +546,7 @@ mod tests {
546546
}
547547

548548
#[test]
549-
#[cfg(all(feature = "v110", ossl110))]
549+
#[cfg(all(feature = "v110", ossl11x))]
550550
fn scrypt() {
551551
use hex::ToHex;
552552

openssl/src/rsa.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -362,7 +362,7 @@ impl fmt::Debug for Rsa {
362362
}
363363
}
364364

365-
#[cfg(ossl110)]
365+
#[cfg(ossl11x)]
366366
mod compat {
367367
use std::ptr;
368368

openssl/src/sign.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ use hash::MessageDigest;
7272
use pkey::{PKeyCtxRef, PKeyRef};
7373
use error::ErrorStack;
7474

75-
#[cfg(ossl110)]
75+
#[cfg(ossl11x)]
7676
use ffi::{EVP_MD_CTX_free, EVP_MD_CTX_new};
7777
#[cfg(any(ossl101, ossl102))]
7878
use ffi::{EVP_MD_CTX_create as EVP_MD_CTX_new, EVP_MD_CTX_destroy as EVP_MD_CTX_free};

openssl/src/ssl/bio.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,7 @@ unsafe extern "C" fn destroy<S>(bio: *mut BIO) -> c_int {
173173
1
174174
}
175175

176-
#[cfg(ossl110)]
176+
#[cfg(ossl11x)]
177177
#[allow(bad_style)]
178178
mod compat {
179179
use std::io::{Read, Write};

openssl/src/ssl/callbacks.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ use dh::Dh;
1212
#[cfg(any(all(feature = "v101", ossl101), all(feature = "v102", ossl102)))]
1313
use ec_key::EcKey;
1414
use ssl::{get_callback_idx, get_ssl_callback_idx, SslRef, SniError, NPN_PROTOS_IDX};
15-
#[cfg(any(all(feature = "v102", ossl102), all(feature = "v110", ossl110)))]
15+
#[cfg(any(all(feature = "v102", ossl102), all(feature = "v110", ossl11x)))]
1616
use ssl::ALPN_PROTOS_IDX;
1717
use x509::X509StoreContextRef;
1818

@@ -158,7 +158,7 @@ pub extern "C" fn raw_next_proto_select_cb(
158158
unsafe { select_proto_using(ssl, out, outlen, inbuf, inlen, *NPN_PROTOS_IDX) }
159159
}
160160

161-
#[cfg(any(all(feature = "v102", ossl102), all(feature = "v110", ossl110)))]
161+
#[cfg(any(all(feature = "v102", ossl102), all(feature = "v110", ossl11x)))]
162162
pub extern "C" fn raw_alpn_select_cb(
163163
ssl: *mut ffi::SSL,
164164
out: *mut *const c_uchar,

openssl/src/ssl/connector.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -367,7 +367,7 @@ fn setup_curves(ctx: &mut SslContextBuilder) -> Result<(), ErrorStack> {
367367
ctx._set_ecdh_auto(true)
368368
}
369369

370-
#[cfg(ossl110)]
370+
#[cfg(ossl11x)]
371371
fn setup_curves(_: &mut SslContextBuilder) -> Result<(), ErrorStack> {
372372
Ok(())
373373
}
@@ -390,7 +390,7 @@ impl SslAcceptor {
390390
}
391391
}
392392

393-
#[cfg(any(ossl102, ossl110))]
393+
#[cfg(any(ossl102, ossl11x))]
394394
fn setup_verify(ctx: &mut SslContextBuilder) {
395395
ctx.set_verify(SSL_VERIFY_PEER);
396396
}
@@ -409,7 +409,7 @@ fn setup_verify(ctx: &mut SslContextBuilder) {
409409
});
410410
}
411411

412-
#[cfg(any(ossl102, ossl110))]
412+
#[cfg(any(ossl102, ossl11x))]
413413
fn setup_verify_hostname(ssl: &mut Ssl, domain: &str) -> Result<(), ErrorStack> {
414414
let param = ssl._param_mut();
415415
param.set_hostflags(::verify::X509_CHECK_FLAG_NO_PARTIAL_WILDCARDS);

openssl/src/ssl/mod.rs

Lines changed: 27 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -99,9 +99,9 @@ use ec::EcKeyRef;
9999
use ec::EcKey;
100100
use x509::{X509, X509FileType, X509Name, X509Ref, X509StoreContextRef, X509VerifyError};
101101
use x509::store::{X509StoreBuilderRef, X509StoreRef};
102-
#[cfg(any(all(feature = "v102", ossl102), all(feature = "v110", ossl110)))]
102+
#[cfg(any(all(feature = "v102", ossl102), all(feature = "v110", ossl11x)))]
103103
use x509::store::X509Store;
104-
#[cfg(any(ossl102, ossl110))]
104+
#[cfg(any(ossl102, ossl11x))]
105105
use verify::X509VerifyParamRef;
106106
use pkey::PKeyRef;
107107
use error::ErrorStack;
@@ -211,15 +211,21 @@ bitflags! {
211211
/// Disables the use of TLSv1.2.
212212
const SSL_OP_NO_TLSV1_2 = ffi::SSL_OP_NO_TLSv1_2;
213213

214+
/// Disables the use of TLSv1.3.
215+
///
216+
/// Requires OpenSSL 1.1.1 or newer.
217+
#[cfg(ossl111)]
218+
const SSL_OP_NO_TLSV1_3 = ffi::SSL_OP_NO_TLSv1_3;
219+
214220
/// Disables the use of DTLSv1.0
215221
///
216222
/// Requires the `v102` or `v110` features and OpenSSL 1.0.2 or OpenSSL 1.1.0.
217-
#[cfg(any(all(feature = "v102", ossl102), all(feature = "v110", ossl110)))]
223+
#[cfg(any(all(feature = "v102", ossl102), all(feature = "v110", ossl11x)))]
218224
const SSL_OP_NO_DTLSV1 = ffi::SSL_OP_NO_DTLSv1;
219225

220226
/// Disables the use of DTLSv1.2.
221227
/// Requires the `v102` or `v110` features and OpenSSL 1.0.2 or OpenSSL 1.1.0.
222-
#[cfg(any(all(feature = "v102", ossl102), all(feature = "v110", ossl110)))]
228+
#[cfg(any(all(feature = "v102", ossl102), all(feature = "v110", ossl11x)))]
223229
const SSL_OP_NO_DTLSV1_2 = ffi::SSL_OP_NO_DTLSv1_2;
224230

225231
/// Disables the use of all (D)TLS protocol versions.
@@ -237,8 +243,15 @@ bitflags! {
237243
///
238244
/// let options = SSL_OP_NO_SSL_MASK & !SSL_OP_NO_TLSV1_2;
239245
/// ```
240-
#[cfg(any(all(feature = "v102", ossl102), all(feature = "v110", ossl110)))]
246+
#[cfg(any(all(feature = "v102", ossl102), all(feature = "v110", ossl11x)))]
241247
const SSL_OP_NO_SSL_MASK = ffi::SSL_OP_NO_SSL_MASK;
248+
249+
/// Enable TLSv1.3 Compatibility mode.
250+
///
251+
/// Requires OpenSSL 1.1.1 or newer. This is on by default in 1.1.1, but a future version
252+
/// may have this disabled by default.
253+
#[cfg(ossl111)]
254+
const SSL_OP_ENABLE_MIDDLEBOX_COMPAT = ffi::SSL_OP_ENABLE_MIDDLEBOX_COMPAT;
242255
}
243256
}
244257

@@ -398,7 +411,7 @@ lazy_static! {
398411
static ref NPN_PROTOS_IDX: c_int = get_new_idx::<Vec<u8>>();
399412
}
400413

401-
#[cfg(any(all(feature = "v102", ossl102), all(feature = "v110", ossl110)))]
414+
#[cfg(any(all(feature = "v102", ossl102), all(feature = "v110", ossl11x)))]
402415
lazy_static! {
403416
static ref ALPN_PROTOS_IDX: c_int = get_new_idx::<Vec<u8>>();
404417
}
@@ -578,7 +591,7 @@ impl SslContextBuilder {
578591
/// This corresponds to [`SSL_CTX_set0_verify_cert_store`].
579592
///
580593
/// [`SSL_CTX_set0_verify_cert_store`]: https://www.openssl.org/docs/man1.0.2/ssl/SSL_CTX_set0_verify_cert_store.html
581-
#[cfg(any(all(feature = "v102", ossl102), all(feature = "v110", ossl110)))]
594+
#[cfg(any(all(feature = "v102", ossl102), all(feature = "v110", ossl11x)))]
582595
pub fn set_verify_cert_store(&mut self, cert_store: X509Store) -> Result<(), ErrorStack> {
583596
unsafe {
584597
let ptr = cert_store.as_ptr();
@@ -970,7 +983,7 @@ impl SslContextBuilder {
970983
///
971984
/// Requires the `v102` or `v110` features and OpenSSL 1.0.2 or OpenSSL 1.1.0.
972985
// FIXME overhaul
973-
#[cfg(any(all(feature = "v102", ossl102), all(feature = "v110", ossl110)))]
986+
#[cfg(any(all(feature = "v102", ossl102), all(feature = "v110", ossl11x)))]
974987
pub fn set_alpn_protocols(&mut self, protocols: &[&[u8]]) -> Result<(), ErrorStack> {
975988
let protocols: Box<Vec<u8>> = Box::new(ssl_encode_byte_strings(protocols));
976989
unsafe {
@@ -1190,7 +1203,7 @@ impl SslContextRef {
11901203
/// This corresponds to [`SSL_CTX_get0_certificate`].
11911204
///
11921205
/// [`SSL_CTX_get0_certificate`]: https://www.openssl.org/docs/man1.1.0/ssl/ssl.html
1193-
#[cfg(any(all(feature = "v102", ossl102), all(feature = "v110", ossl110)))]
1206+
#[cfg(any(all(feature = "v102", ossl102), all(feature = "v110", ossl11x)))]
11941207
pub fn certificate(&self) -> Option<&X509Ref> {
11951208
unsafe {
11961209
let ptr = ffi::SSL_CTX_get0_certificate(self.as_ptr());
@@ -1209,7 +1222,7 @@ impl SslContextRef {
12091222
/// This corresponds to [`SSL_CTX_get0_privatekey`].
12101223
///
12111224
/// [`SSL_CTX_get0_privatekey`]: https://www.openssl.org/docs/man1.1.0/ssl/ssl.html
1212-
#[cfg(any(all(feature = "v102", ossl102), all(feature = "v110", ossl110)))]
1225+
#[cfg(any(all(feature = "v102", ossl102), all(feature = "v110", ossl11x)))]
12131226
pub fn private_key(&self) -> Option<&PKeyRef> {
12141227
unsafe {
12151228
let ptr = ffi::SSL_CTX_get0_privatekey(self.as_ptr());
@@ -1794,7 +1807,7 @@ impl SslRef {
17941807
/// This corresponds to [`SSL_get0_alpn_selected`].
17951808
///
17961809
/// [`SSL_get0_alpn_selected`]: https://www.openssl.org/docs/manmaster/man3/SSL_get0_next_proto_negotiated.html
1797-
#[cfg(any(all(feature = "v102", ossl102), all(feature = "v110", ossl110)))]
1810+
#[cfg(any(all(feature = "v102", ossl102), all(feature = "v110", ossl11x)))]
17981811
pub fn selected_alpn_protocol(&self) -> Option<&[u8]> {
17991812
unsafe {
18001813
let mut data: *const c_uchar = ptr::null();
@@ -1894,12 +1907,12 @@ impl SslRef {
18941907
/// This corresponds to [`SSL_get0_param`].
18951908
///
18961909
/// [`SSL_get0_param`]: https://www.openssl.org/docs/man1.0.2/ssl/SSL_get0_param.html
1897-
#[cfg(any(all(feature = "v102", ossl102), all(feature = "v110", ossl110)))]
1910+
#[cfg(any(all(feature = "v102", ossl102), all(feature = "v110", ossl11x)))]
18981911
pub fn param_mut(&mut self) -> &mut X509VerifyParamRef {
18991912
self._param_mut()
19001913
}
19011914

1902-
#[cfg(any(ossl102, ossl110))]
1915+
#[cfg(any(ossl102, ossl11x))]
19031916
fn _param_mut(&mut self) -> &mut X509VerifyParamRef {
19041917
unsafe { X509VerifyParamRef::from_ptr_mut(ffi::SSL_get0_param(self.as_ptr())) }
19051918
}
@@ -2437,7 +2450,7 @@ pub enum ShutdownResult {
24372450
Received,
24382451
}
24392452

2440-
#[cfg(ossl110)]
2453+
#[cfg(ossl11x)]
24412454
mod compat {
24422455
use std::ptr;
24432456

0 commit comments

Comments
 (0)