Commit 4900d3fe authored by Brian Chin's avatar Brian Chin
Browse files

Fixed constant names from openssl/rsa.h

Fixed PKeyCtxRef method that didn't need to be mutable.

Added non-mutable accessors for PKeyCtxRef for Signer and Verifier.
parent 302ee77d
Loading
Loading
Loading
Loading
+6 −6
Original line number Diff line number Diff line
@@ -153,6 +153,10 @@ pub const EVP_PKEY_EC: c_int = NID_X9_62_id_ecPublicKey;

pub const EVP_PKEY_ALG_CTRL: c_int = 0x1000;

pub const EVP_PKEY_CTRL_RSA_PADDING: c_int = EVP_PKEY_ALG_CTRL + 1;

pub const EVP_PKEY_CTRL_GET_RSA_PADDING: c_int = EVP_PKEY_ALG_CTRL + 6;

pub const EVP_CTRL_GCM_SET_IVLEN: c_int = 0x9;
pub const EVP_CTRL_GCM_GET_TAG: c_int = 0x10;
pub const EVP_CTRL_GCM_SET_TAG: c_int = 0x11;
@@ -1123,10 +1127,6 @@ pub const RSA_NO_PADDING: c_int = 3;
pub const RSA_PKCS1_OAEP_PADDING: c_int = 4;
pub const RSA_X931_PADDING: c_int = 5;

pub const RSA_PKEY_CTRL_RSA_PADDING: c_int = EVP_PKEY_ALG_CTRL + 1;

pub const RSA_PKEY_CTRL_GET_RSA_PADDING: c_int = EVP_PKEY_ALG_CTRL + 6;

pub const SSL_CTRL_SET_TMP_DH: c_int = 3;
pub const SSL_CTRL_SET_TMP_ECDH: c_int = 4;
pub const SSL_CTRL_EXTRA_CHAIN_CERT: c_int = 14;
@@ -1312,11 +1312,11 @@ pub unsafe fn BIO_set_retry_write(b: *mut BIO) {

// EVP_PKEY_CTX_ctrl macros
pub unsafe fn EVP_PKEY_CTX_set_rsa_padding(ctx: *mut EVP_PKEY_CTX, pad: c_int) -> c_int {
    EVP_PKEY_CTX_ctrl(ctx, EVP_PKEY_RSA, -1, RSA_PKEY_CTRL_RSA_PADDING, pad, ptr::null_mut())
    EVP_PKEY_CTX_ctrl(ctx, EVP_PKEY_RSA, -1, EVP_PKEY_CTRL_RSA_PADDING, pad, ptr::null_mut())
}

pub unsafe fn EVP_PKEY_CTX_get_rsa_padding(ctx: *mut EVP_PKEY_CTX, ppad: *mut c_int) -> c_int {
    EVP_PKEY_CTX_ctrl(ctx, EVP_PKEY_RSA, -1, RSA_PKEY_CTRL_GET_RSA_PADDING, 0, ppad as *mut c_void)
    EVP_PKEY_CTX_ctrl(ctx, EVP_PKEY_RSA, -1, EVP_PKEY_CTRL_GET_RSA_PADDING, 0, ppad as *mut c_void)
}

pub unsafe fn SSL_CTX_set_mode(ctx: *mut SSL_CTX, op: c_long) -> c_long {
+1 −1
Original line number Diff line number Diff line
@@ -161,7 +161,7 @@ impl PKeyCtxRef {
        Ok(())
    }

    pub fn rsa_padding(&mut self) -> Result<Padding, ErrorStack> {
    pub fn rsa_padding(&self) -> Result<Padding, ErrorStack> {
        let mut pad: c_int = 0;
        unsafe {
            try!(cvt(ffi::EVP_PKEY_CTX_get_rsa_padding(self.as_ptr(), &mut pad)));
+8 −0
Original line number Diff line number Diff line
@@ -119,6 +119,10 @@ impl<'a> Signer<'a> {
        }
    }

    pub fn pkey_ctx(&self) -> &PKeyCtxRef {
        unsafe { ::types::OpenSslTypeRef::from_ptr(self.pkey_ctx) }
    }

    pub fn pkey_ctx_mut(&mut self) -> &mut PKeyCtxRef {
        unsafe { ::types::OpenSslTypeRef::from_ptr_mut(self.pkey_ctx) }
    }
@@ -195,6 +199,10 @@ impl<'a> Verifier<'a> {
        }
    }

    pub fn pkey_ctx(&self) -> &PKeyCtxRef {
        unsafe { ::types::OpenSslTypeRef::from_ptr(self.pkey_ctx) }
    }

    pub fn pkey_ctx_mut(&mut self) -> &mut PKeyCtxRef {
        unsafe { ::types::OpenSslTypeRef::from_ptr_mut(self.pkey_ctx) }
    }