Skip to content

Commit

Permalink
Yet Another Attempt to LibreSSL 3.5.x
Browse files Browse the repository at this point in the history
  • Loading branch information
alex committed May 2, 2022
1 parent c30d4fd commit ea03bc0
Show file tree
Hide file tree
Showing 12 changed files with 43 additions and 25 deletions.
10 changes: 10 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,11 @@ jobs:
library:
name: libressl
version: 3.4.2
- target: x86_64-unknown-linux-gnu
bindgen: true
library:
name: libressl
version: 3.5.2
- target: x86_64-unknown-linux-gnu
bindgen: false
library:
Expand All @@ -189,6 +194,11 @@ jobs:
library:
name: libressl
version: 3.4.2
- target: x86_64-unknown-linux-gnu
bindgen: false
library:
name: libressl
version: 3.5.2
name: ${{ matrix.target }}-${{ matrix.library.name }}-${{ matrix.library.version }}-${{ matrix.bindgen }}
runs-on: ubuntu-latest
env:
Expand Down
3 changes: 3 additions & 0 deletions openssl-sys/build/cfgs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,9 @@ pub fn get(openssl_version: Option<u64>, libressl_version: Option<u64>) -> Vec<&
if libressl_version >= 0x3_03_02_00_0 {
cfgs.push("libressl332");
}
if libressl_version >= 0x3_05_00_00_0 {
cfgs.push("libressl350");
}
} else {
let openssl_version = openssl_version.unwrap();

Expand Down
3 changes: 2 additions & 1 deletion openssl-sys/build/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -267,6 +267,7 @@ See rust-openssl README for more information:
(3, 3, _) => ('3', '3', 'x'),
(3, 4, 0) => ('3', '4', '0'),
(3, 4, _) => ('3', '4', 'x'),
(3, 5, _) => ('3', '5', 'x'),
_ => version_error(),
};

Expand Down Expand Up @@ -309,7 +310,7 @@ fn version_error() -> ! {
"
This crate is only compatible with OpenSSL (version 1.0.1 through 1.1.1, or 3.0.0), or LibreSSL 2.5
through 3.4.1, but a different version of OpenSSL was found. The build is now aborting
through 3.5, but a different version of OpenSSL was found. The build is now aborting
due to this version mismatch.
"
Expand Down
4 changes: 2 additions & 2 deletions openssl-sys/src/handwritten/bn.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ extern "C" {
pub fn BN_mul(r: *mut BIGNUM, a: *const BIGNUM, b: *const BIGNUM, ctx: *mut BN_CTX) -> c_int;
pub fn BN_sqr(r: *mut BIGNUM, a: *const BIGNUM, ctx: *mut BN_CTX) -> c_int;
pub fn BN_set_negative(bn: *mut BIGNUM, n: c_int);
#[cfg(ossl110)]
#[cfg(any(ossl110, libressl350))]
pub fn BN_is_negative(b: *const ::BIGNUM) -> c_int;

pub fn BN_div(
Expand Down Expand Up @@ -138,7 +138,7 @@ extern "C" {
}

cfg_if! {
if #[cfg(ossl110)] {
if #[cfg(any(ossl110, libressl350))] {
extern "C" {
pub fn BN_get_rfc2409_prime_768(bn: *mut BIGNUM) -> *mut BIGNUM;
pub fn BN_get_rfc2409_prime_1024(bn: *mut BIGNUM) -> *mut BIGNUM;
Expand Down
2 changes: 1 addition & 1 deletion openssl-sys/src/handwritten/hmac.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use libc::*;
use *;

cfg_if! {
if #[cfg(ossl110)] {
if #[cfg(any(ossl110, libressl350))] {
extern "C" {
pub fn HMAC_CTX_new() -> *mut HMAC_CTX;
pub fn HMAC_CTX_free(ctx: *mut HMAC_CTX);
Expand Down
4 changes: 2 additions & 2 deletions openssl-sys/src/handwritten/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ cfg_if! {
}
}
cfg_if! {
if #[cfg(ossl110)] {
if #[cfg(any(ossl110, libressl350))] {
pub enum BIGNUM {}
} else {
#[repr(C)]
Expand Down Expand Up @@ -1019,7 +1019,7 @@ cfg_if! {
pub enum COMP_CTX {}

cfg_if! {
if #[cfg(ossl110)] {
if #[cfg(any(ossl110, libressl350))] {
pub enum COMP_METHOD {}
} else {
#[repr(C)]
Expand Down
28 changes: 14 additions & 14 deletions openssl-sys/src/handwritten/x509.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ stack!(stack_st_X509_EXTENSION);
stack!(stack_st_X509_ATTRIBUTE);

cfg_if! {
if #[cfg(ossl110)] {
if #[cfg(any(ossl110, libressl350))] {
pub enum X509_REQ_INFO {}
} else {
#[repr(C)]
Expand All @@ -33,7 +33,7 @@ cfg_if! {
}

cfg_if! {
if #[cfg(ossl110)] {
if #[cfg(any(ossl110, libressl350))] {
pub enum X509_CRL {}
} else {
#[repr(C)]
Expand All @@ -60,7 +60,7 @@ cfg_if! {
stack!(stack_st_X509_CRL);

cfg_if! {
if #[cfg(ossl110)] {
if #[cfg(any(ossl110, libressl350))] {
pub enum X509_CRL_INFO {}
} else {
#[repr(C)]
Expand All @@ -78,7 +78,7 @@ cfg_if! {
}

cfg_if! {
if #[cfg(ossl110)] {
if #[cfg(any(ossl110, libressl350))] {
pub enum X509_REVOKED {}
} else {
#[repr(C)]
Expand All @@ -96,7 +96,7 @@ cfg_if! {
stack!(stack_st_X509_REVOKED);

cfg_if! {
if #[cfg(ossl110)] {
if #[cfg(any(ossl110, libressl350))] {
pub enum X509_REQ {}
} else {
#[repr(C)]
Expand All @@ -110,7 +110,7 @@ cfg_if! {
}

cfg_if! {
if #[cfg(ossl110)] {
if #[cfg(any(ossl110, libressl350))] {
pub enum X509_CINF {}
} else {
#[repr(C)]
Expand Down Expand Up @@ -185,12 +185,12 @@ extern "C" {

const_ptr_api! {
extern "C" {
#[cfg(ossl102)]
#[cfg(any(ossl102, libressl350))]
pub fn X509_ALGOR_get0(
paobj: *mut #[const_ptr_if(ossl110)] ASN1_OBJECT,
paobj: *mut #[const_ptr_if(any(ossl110, libressl350))] ASN1_OBJECT,
pptype: *mut c_int,
ppval: *mut #[const_ptr_if(ossl110)] c_void,
alg: #[const_ptr_if(ossl110)] X509_ALGOR,
ppval: *mut #[const_ptr_if(any(ossl110, libressl350))] c_void,
alg: #[const_ptr_if(any(ossl110, libressl350))] X509_ALGOR,
);
}
}
Expand Down Expand Up @@ -317,7 +317,7 @@ const_ptr_api! {
}
}
cfg_if! {
if #[cfg(ossl110)] {
if #[cfg(any(ossl110, libressl350))] {
extern "C" {
pub fn X509_set1_notBefore(x: *mut ::X509, tm: *const ::ASN1_TIME) -> c_int;
pub fn X509_set1_notAfter(x: *mut ::X509, tm: *const ::ASN1_TIME) -> c_int;
Expand All @@ -330,10 +330,10 @@ cfg_if! {
}
}
extern "C" {
#[cfg(ossl110)]
#[cfg(any(ossl110, libressl350))]
pub fn X509_REQ_get_version(req: *const X509_REQ) -> c_long;
pub fn X509_REQ_set_version(req: *mut X509_REQ, version: c_long) -> c_int;
#[cfg(ossl110)]
#[cfg(any(ossl110, libressl350))]
pub fn X509_REQ_get_subject_name(req: *const X509_REQ) -> *mut X509_NAME;
}
const_ptr_api! {
Expand Down Expand Up @@ -606,7 +606,7 @@ extern "C" {
}

cfg_if! {
if #[cfg(ossl110)] {
if #[cfg(any(ossl110, libressl350))] {
extern "C" {
pub fn X509_OBJECT_free(a: *mut X509_OBJECT);
}
Expand Down
2 changes: 1 addition & 1 deletion openssl-sys/src/handwritten/x509_vfy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ extern "C" {
pub fn X509_STORE_CTX_set_error(ctx: *mut X509_STORE_CTX, error: c_int);
}
cfg_if! {
if #[cfg(ossl110)] {
if #[cfg(any(ossl110, libressl350))] {
const_ptr_api! {
extern "C" {
pub fn X509_STORE_CTX_get0_chain(ctx: #[const_ptr_if(ossl300)] X509_STORE_CTX) -> *mut stack_st_X509;
Expand Down
2 changes: 1 addition & 1 deletion openssl-sys/src/x509.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ pub const X509_FILETYPE_DEFAULT: c_int = 3;
pub const ASN1_R_HEADER_TOO_LONG: c_int = 123;

cfg_if! {
if #[cfg(not(ossl110))] {
if #[cfg(not(any(ossl110, libressl350)))] {
pub const X509_LU_FAIL: c_int = 0;
pub const X509_LU_X509: c_int = 1;
pub const X509_LU_CRL: c_int = 2;
Expand Down
4 changes: 4 additions & 0 deletions openssl/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -81,5 +81,9 @@ fn main() {
if version >= 0x3_04_00_00_0 {
println!("cargo:rustc-cfg=libressl340");
}

if version >= 0x3_05_00_00_0 {
println!("cargo:rustc-cfg=libressl350");
}
}
}
2 changes: 1 addition & 1 deletion openssl/src/bn.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ use crate::{cvt, cvt_n, cvt_p};
use openssl_macros::corresponds;

cfg_if! {
if #[cfg(ossl110)] {
if #[cfg(any(ossl110, libressl350))] {
use ffi::{
BN_get_rfc2409_prime_1024, BN_get_rfc2409_prime_768, BN_get_rfc3526_prime_1536,
BN_get_rfc3526_prime_2048, BN_get_rfc3526_prime_3072, BN_get_rfc3526_prime_4096,
Expand Down
4 changes: 2 additions & 2 deletions openssl/src/x509/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1534,7 +1534,7 @@ cfg_if! {
}

cfg_if! {
if #[cfg(ossl110)] {
if #[cfg(any(ossl110, libressl350))] {
use ffi::{
X509_ALGOR_get0, ASN1_STRING_get0_data, X509_STORE_CTX_get0_chain, X509_set1_notAfter,
X509_set1_notBefore, X509_REQ_get_version, X509_REQ_get_subject_name,
Expand Down Expand Up @@ -1589,7 +1589,7 @@ cfg_if! {
}

cfg_if! {
if #[cfg(ossl110)] {
if #[cfg(any(ossl110, libressl350))] {
use ffi::X509_OBJECT_free;
} else {
#[allow(bad_style)]
Expand Down

0 comments on commit ea03bc0

Please sign in to comment.