Loading openssl-sys/src/ssl.rs +1 −0 Original line number Diff line number Diff line Loading @@ -1067,6 +1067,7 @@ extern "C" { pub fn SSL_stateless(s: *mut SSL) -> c_int; pub fn SSL_connect(ssl: *mut SSL) -> c_int; pub fn SSL_read(ssl: *mut SSL, buf: *mut c_void, num: c_int) -> c_int; pub fn SSL_peek(ssl: *mut SSL, buf: *mut c_void, num: c_int) -> c_int; #[cfg(ossl111)] pub fn SSL_read_early_data( s: *mut ::SSL, Loading openssl/src/ssl/mod.rs +25 −0 Original line number Diff line number Diff line Loading @@ -2460,6 +2460,11 @@ impl SslRef { unsafe { ffi::SSL_read(self.as_ptr(), buf.as_ptr() as *mut c_void, len) } } fn peek(&mut self, buf: &mut [u8]) -> c_int { let len = cmp::min(c_int::max_value() as usize, buf.len()) as c_int; unsafe { ffi::SSL_peek(self.as_ptr(), buf.as_ptr() as *mut c_void, len) } } fn write(&mut self, buf: &[u8]) -> c_int { let len = cmp::min(c_int::max_value() as usize, buf.len()) as c_int; unsafe { ffi::SSL_write(self.as_ptr(), buf.as_ptr() as *const c_void, len) } Loading Loading @@ -3704,6 +3709,26 @@ impl<S: Read + Write> SslStream<S> { } } /// It is particularly useful with a nonblocking socket, where the error value will identify if /// OpenSSL is waiting on read or write readiness. /// /// This corresponds to [`SSL_peek`]. /// /// [`SSL_peek`]: https://www.openssl.org/docs/manmaster/man3/SSL_peek.html pub fn ssl_peek(&mut self, buf: &mut [u8]) -> Result<usize, Error> { // See above for why we short-circuit on zero-length buffers if buf.is_empty() { return Ok(0); } let ret = self.ssl.peek(buf); if ret > 0 { Ok(ret as usize) } else { Err(self.make_error(ret)) } } /// Shuts down the session. /// /// The shutdown process consists of two steps. The first step sends a close notify message to Loading Loading
openssl-sys/src/ssl.rs +1 −0 Original line number Diff line number Diff line Loading @@ -1067,6 +1067,7 @@ extern "C" { pub fn SSL_stateless(s: *mut SSL) -> c_int; pub fn SSL_connect(ssl: *mut SSL) -> c_int; pub fn SSL_read(ssl: *mut SSL, buf: *mut c_void, num: c_int) -> c_int; pub fn SSL_peek(ssl: *mut SSL, buf: *mut c_void, num: c_int) -> c_int; #[cfg(ossl111)] pub fn SSL_read_early_data( s: *mut ::SSL, Loading
openssl/src/ssl/mod.rs +25 −0 Original line number Diff line number Diff line Loading @@ -2460,6 +2460,11 @@ impl SslRef { unsafe { ffi::SSL_read(self.as_ptr(), buf.as_ptr() as *mut c_void, len) } } fn peek(&mut self, buf: &mut [u8]) -> c_int { let len = cmp::min(c_int::max_value() as usize, buf.len()) as c_int; unsafe { ffi::SSL_peek(self.as_ptr(), buf.as_ptr() as *mut c_void, len) } } fn write(&mut self, buf: &[u8]) -> c_int { let len = cmp::min(c_int::max_value() as usize, buf.len()) as c_int; unsafe { ffi::SSL_write(self.as_ptr(), buf.as_ptr() as *const c_void, len) } Loading Loading @@ -3704,6 +3709,26 @@ impl<S: Read + Write> SslStream<S> { } } /// It is particularly useful with a nonblocking socket, where the error value will identify if /// OpenSSL is waiting on read or write readiness. /// /// This corresponds to [`SSL_peek`]. /// /// [`SSL_peek`]: https://www.openssl.org/docs/manmaster/man3/SSL_peek.html pub fn ssl_peek(&mut self, buf: &mut [u8]) -> Result<usize, Error> { // See above for why we short-circuit on zero-length buffers if buf.is_empty() { return Ok(0); } let ret = self.ssl.peek(buf); if ret > 0 { Ok(ret as usize) } else { Err(self.make_error(ret)) } } /// Shuts down the session. /// /// The shutdown process consists of two steps. The first step sends a close notify message to Loading