Revert^2 "Update to work with new BoringSSL" am: 2a93b21a43
Original change: https://android-review.googlesource.com/c/platform/external/rust/crates/openssl/+/2470948
Change-Id: I254a0112c1cb3ee266d908140140447ec58e5152
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
diff --git a/patches/bssl-update.diff b/patches/bssl-update.diff
new file mode 100644
index 0000000..2eea3ce
--- /dev/null
+++ b/patches/bssl-update.diff
@@ -0,0 +1,60 @@
+diff --git a/src/bio.rs b/src/bio.rs
+index 6a72552..0324218 100644
+--- a/src/bio.rs
++++ b/src/bio.rs
+@@ -4,7 +4,7 @@ use std::marker::PhantomData;
+ use std::ptr;
+ use std::slice;
+
+-use crate::cvt_p;
++use crate::{cvt_p, SignedLenType};
+ use crate::error::ErrorStack;
+
+ pub struct MemBioSlice<'a>(*mut ffi::BIO, PhantomData<&'a [u8]>);
+@@ -25,7 +25,7 @@ impl<'a> MemBioSlice<'a> {
+ let bio = unsafe {
+ cvt_p(BIO_new_mem_buf(
+ buf.as_ptr() as *const _,
+- buf.len() as c_int,
++ buf.len() as SignedLenType,
+ ))?
+ };
+
+@@ -78,7 +78,7 @@ cfg_if! {
+ use ffi::BIO_new_mem_buf;
+ } else {
+ #[allow(bad_style)]
+- unsafe fn BIO_new_mem_buf(buf: *const ::libc::c_void, len: ::libc::c_int) -> *mut ffi::BIO {
++ unsafe fn BIO_new_mem_buf(buf: *const ::libc::c_void, len: SignedLenType) -> *mut ffi::BIO {
+ ffi::BIO_new_mem_buf(buf as *mut _, len)
+ }
+ }
+diff --git a/src/dh.rs b/src/dh.rs
+index 12170b9..e781543 100644
+--- a/src/dh.rs
++++ b/src/dh.rs
+@@ -239,7 +239,7 @@ where
+ }
+
+ cfg_if! {
+- if #[cfg(any(ossl110, libressl270))] {
++ if #[cfg(any(ossl110, libressl270, boringssl))] {
+ use ffi::{DH_set0_pqg, DH_get0_pqg, DH_get0_key, DH_set0_key};
+ } else {
+ #[allow(bad_style)]
+diff --git a/src/lib.rs b/src/lib.rs
+index f149bfd..e8d07d8 100644
+--- a/src/lib.rs
++++ b/src/lib.rs
+@@ -196,6 +196,11 @@ type LenType = libc::size_t;
+ #[cfg(not(boringssl))]
+ type LenType = libc::c_int;
+
++#[cfg(boringssl)]
++type SignedLenType = libc::ssize_t;
++#[cfg(not(boringssl))]
++type SignedLenType = libc::c_int;
++
+ #[inline]
+ fn cvt_p<T>(r: *mut T) -> Result<*mut T, ErrorStack> {
+ if r.is_null() {
diff --git a/src/bio.rs b/src/bio.rs
index 6a72552..0324218 100644
--- a/src/bio.rs
+++ b/src/bio.rs
@@ -4,7 +4,7 @@
use std::ptr;
use std::slice;
-use crate::cvt_p;
+use crate::{cvt_p, SignedLenType};
use crate::error::ErrorStack;
pub struct MemBioSlice<'a>(*mut ffi::BIO, PhantomData<&'a [u8]>);
@@ -25,7 +25,7 @@
let bio = unsafe {
cvt_p(BIO_new_mem_buf(
buf.as_ptr() as *const _,
- buf.len() as c_int,
+ buf.len() as SignedLenType,
))?
};
@@ -78,7 +78,7 @@
use ffi::BIO_new_mem_buf;
} else {
#[allow(bad_style)]
- unsafe fn BIO_new_mem_buf(buf: *const ::libc::c_void, len: ::libc::c_int) -> *mut ffi::BIO {
+ unsafe fn BIO_new_mem_buf(buf: *const ::libc::c_void, len: SignedLenType) -> *mut ffi::BIO {
ffi::BIO_new_mem_buf(buf as *mut _, len)
}
}
diff --git a/src/dh.rs b/src/dh.rs
index 12170b9..e781543 100644
--- a/src/dh.rs
+++ b/src/dh.rs
@@ -239,7 +239,7 @@
}
cfg_if! {
- if #[cfg(any(ossl110, libressl270))] {
+ if #[cfg(any(ossl110, libressl270, boringssl))] {
use ffi::{DH_set0_pqg, DH_get0_pqg, DH_get0_key, DH_set0_key};
} else {
#[allow(bad_style)]
diff --git a/src/lib.rs b/src/lib.rs
index f149bfd..e8d07d8 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -196,6 +196,11 @@
#[cfg(not(boringssl))]
type LenType = libc::c_int;
+#[cfg(boringssl)]
+type SignedLenType = libc::ssize_t;
+#[cfg(not(boringssl))]
+type SignedLenType = libc::c_int;
+
#[inline]
fn cvt_p<T>(r: *mut T) -> Result<*mut T, ErrorStack> {
if r.is_null() {