Commit cc0698ad authored by James Mayclin's avatar James Mayclin
Browse files

use c_long return value

parent 8ae4cdee
Loading
Loading
Loading
Loading
+4 −4
Original line number Diff line number Diff line
@@ -512,12 +512,12 @@ cfg_if! {
}
cfg_if! {
    if #[cfg(ossl300)] {
        pub unsafe fn SSL_get_peer_tmp_key(ssl: *mut SSL, key: *mut *mut EVP_PKEY) -> c_int {
            SSL_ctrl(ssl, SSL_CTRL_GET_PEER_TMP_KEY, 0, key as *mut c_void) as c_int
        pub unsafe fn SSL_get_peer_tmp_key(ssl: *mut SSL, key: *mut *mut EVP_PKEY) -> c_long {
            SSL_ctrl(ssl, SSL_CTRL_GET_PEER_TMP_KEY, 0, key as *mut c_void)
        }

        pub unsafe fn SSL_get_tmp_key(ssl: *mut SSL, key: *mut *mut EVP_PKEY) -> c_int {
            SSL_ctrl(ssl, SSL_CTRL_GET_TMP_KEY, 0, key as *mut c_void) as c_int
        pub unsafe fn SSL_get_tmp_key(ssl: *mut SSL, key: *mut *mut EVP_PKEY) -> c_long {
            SSL_ctrl(ssl, SSL_CTRL_GET_TMP_KEY, 0, key as *mut c_void)
        }
    }
}
+10 −1
Original line number Diff line number Diff line
@@ -124,7 +124,7 @@
#[doc(inline)]
pub use ffi::init;

use libc::c_int;
use libc::{c_int, c_long};

use crate::error::ErrorStack;

@@ -212,6 +212,15 @@ fn cvt(r: c_int) -> Result<c_int, ErrorStack> {
    }
}

#[inline]
fn cvt_long(r: c_long) -> Result<c_long, ErrorStack> {
    if r <= 0 {
        Err(ErrorStack::get())
    } else {
        Ok(r)
    }
}

#[inline]
fn cvt_n(r: c_int) -> Result<c_int, ErrorStack> {
    if r < 0 {
+3 −3
Original line number Diff line number Diff line
@@ -78,7 +78,7 @@ use crate::x509::store::{X509Store, X509StoreBuilderRef, X509StoreRef};
#[cfg(any(ossl102, libressl261))]
use crate::x509::verify::X509VerifyParamRef;
use crate::x509::{X509Name, X509Ref, X509StoreContextRef, X509VerifyResult, X509};
use crate::{cvt, cvt_n, cvt_p, init};
use crate::{cvt, cvt_long, cvt_n, cvt_p, init};
use bitflags::bitflags;
use cfg_if::cfg_if;
use foreign_types::{ForeignType, ForeignTypeRef, Opaque};
@@ -3455,7 +3455,7 @@ impl SslRef {
    pub fn peer_tmp_key(&self) -> Result<PKey<Public>, ErrorStack> {
        unsafe {
            let mut key = ptr::null_mut();
            match cvt(ffi::SSL_get_peer_tmp_key(self.as_ptr(), &mut key)) {
            match cvt_long(ffi::SSL_get_peer_tmp_key(self.as_ptr(), &mut key)) {
                Ok(_) => Ok(PKey::<Public>::from_ptr(key)),
                Err(e) => Err(e),
            }
@@ -3471,7 +3471,7 @@ impl SslRef {
    pub fn tmp_key(&self) -> Result<PKey<Public>, ErrorStack> {
        unsafe {
            let mut key = ptr::null_mut();
            match cvt(ffi::SSL_get_tmp_key(self.as_ptr(), &mut key)) {
            match cvt_long(ffi::SSL_get_tmp_key(self.as_ptr(), &mut key)) {
                Ok(_) => Ok(PKey::<Public>::from_ptr(key)),
                Err(e) => Err(e),
            }
+2 −2
Original line number Diff line number Diff line
@@ -326,7 +326,7 @@ fn state() {
// return P-384 keys, and the peer and local keys are different.
#[test]
#[cfg(ossl300)]
fn peer_temp_key_p384() {
fn peer_tmp_key_p384() {
    let mut server = Server::builder();
    server.ctx().set_groups_list("P-384").unwrap();
    let server = server.build();
@@ -350,7 +350,7 @@ fn peer_temp_key_p384() {
// temp key sent in the initial key share.
#[test]
#[cfg(ossl300)]
fn peer_temp_key_rsa() {
fn peer_tmp_key_rsa() {
    let mut server = Server::builder();
    server.ctx().set_cipher_list("RSA").unwrap();
    // RSA key exchange is not allowed in TLS 1.3, so force the connection