Merge pull request #57 from vhbit/mut-cleanup
Clean up of mut/const types in `ffi` and also `mut_null` -> `null_mut`
This commit is contained in:
commit
73885dad02
|
|
@ -165,8 +165,8 @@ impl BigNum {
|
||||||
pub fn checked_generate_prime(bits: i32, safe: bool, add: Option<&BigNum>, rem: Option<&BigNum>) -> Result<BigNum, SslError> {
|
pub fn checked_generate_prime(bits: i32, safe: bool, add: Option<&BigNum>, rem: Option<&BigNum>) -> Result<BigNum, SslError> {
|
||||||
unsafe {
|
unsafe {
|
||||||
with_bn_in_ctx!(r, ctx, {
|
with_bn_in_ctx!(r, ctx, {
|
||||||
let add_arg = add.map(|a| a.raw()).unwrap_or(ptr::mut_null());
|
let add_arg = add.map(|a| a.raw()).unwrap_or(ptr::null_mut());
|
||||||
let rem_arg = rem.map(|r| r.raw()).unwrap_or(ptr::mut_null());
|
let rem_arg = rem.map(|r| r.raw()).unwrap_or(ptr::null_mut());
|
||||||
|
|
||||||
ffi::BN_generate_prime_ex(r.raw(), bits as c_int, safe as c_int, add_arg, rem_arg, ptr::null()) == 1
|
ffi::BN_generate_prime_ex(r.raw(), bits as c_int, safe as c_int, add_arg, rem_arg, ptr::null()) == 1
|
||||||
})
|
})
|
||||||
|
|
@ -281,13 +281,13 @@ impl BigNum {
|
||||||
|
|
||||||
pub fn checked_div(&self, a: &BigNum) -> Result<BigNum, SslError> {
|
pub fn checked_div(&self, a: &BigNum) -> Result<BigNum, SslError> {
|
||||||
unsafe {
|
unsafe {
|
||||||
with_bn_in_ctx!(r, ctx, { ffi::BN_div(r.raw(), ptr::mut_null(), self.raw(), a.raw(), ctx) == 1 })
|
with_bn_in_ctx!(r, ctx, { ffi::BN_div(r.raw(), ptr::null_mut(), self.raw(), a.raw(), ctx) == 1 })
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn checked_mod(&self, a: &BigNum) -> Result<BigNum, SslError> {
|
pub fn checked_mod(&self, a: &BigNum) -> Result<BigNum, SslError> {
|
||||||
unsafe {
|
unsafe {
|
||||||
with_bn_in_ctx!(r, ctx, { ffi::BN_div(ptr::mut_null(), r.raw(), self.raw(), a.raw(), ctx) == 1 })
|
with_bn_in_ctx!(r, ctx, { ffi::BN_div(ptr::null_mut(), r.raw(), self.raw(), a.raw(), ctx) == 1 })
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -22,7 +22,7 @@ pub enum Type {
|
||||||
RC4_128,
|
RC4_128,
|
||||||
}
|
}
|
||||||
|
|
||||||
fn evpc(t: Type) -> (ffi::EVP_CIPHER, uint, uint) {
|
fn evpc(t: Type) -> (*const ffi::EVP_CIPHER, uint, uint) {
|
||||||
unsafe {
|
unsafe {
|
||||||
match t {
|
match t {
|
||||||
AES_128_ECB => (ffi::EVP_aes_128_ecb(), 16u, 16u),
|
AES_128_ECB => (ffi::EVP_aes_128_ecb(), 16u, 16u),
|
||||||
|
|
@ -42,8 +42,8 @@ fn evpc(t: Type) -> (ffi::EVP_CIPHER, uint, uint) {
|
||||||
|
|
||||||
/// Represents a symmetric cipher context.
|
/// Represents a symmetric cipher context.
|
||||||
pub struct Crypter {
|
pub struct Crypter {
|
||||||
evp: ffi::EVP_CIPHER,
|
evp: *const ffi::EVP_CIPHER,
|
||||||
ctx: ffi::EVP_CIPHER_CTX,
|
ctx: *mut ffi::EVP_CIPHER_CTX,
|
||||||
keylen: uint,
|
keylen: uint,
|
||||||
blocksize: uint
|
blocksize: uint
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -7,16 +7,16 @@ pub type ASN1_STRING = c_void;
|
||||||
pub type ASN1_TIME = c_void;
|
pub type ASN1_TIME = c_void;
|
||||||
pub type BIO = c_void;
|
pub type BIO = c_void;
|
||||||
pub type BIO_METHOD = c_void;
|
pub type BIO_METHOD = c_void;
|
||||||
pub type BN_CTX = *mut c_void;
|
pub type BN_CTX = c_void;
|
||||||
pub type COMP_METHOD = c_void;
|
pub type COMP_METHOD = c_void;
|
||||||
pub type CRYPTO_EX_DATA = c_void;
|
pub type CRYPTO_EX_DATA = c_void;
|
||||||
pub type ENGINE = c_void;
|
pub type ENGINE = c_void;
|
||||||
pub type EVP_CIPHER = *mut c_void;
|
pub type EVP_CIPHER = c_void;
|
||||||
pub type EVP_CIPHER_CTX = *mut c_void;
|
pub type EVP_CIPHER_CTX = c_void;
|
||||||
pub type EVP_MD = c_void;
|
pub type EVP_MD = c_void;
|
||||||
pub type EVP_PKEY = *mut c_void;
|
pub type EVP_PKEY = c_void;
|
||||||
pub type EVP_PKEY_CTX = c_void;
|
pub type EVP_PKEY_CTX = c_void;
|
||||||
pub type RSA = *mut c_void;
|
pub type RSA = c_void;
|
||||||
pub type SSL = c_void;
|
pub type SSL = c_void;
|
||||||
pub type SSL_CTX = c_void;
|
pub type SSL_CTX = c_void;
|
||||||
pub type SSL_METHOD = c_void;
|
pub type SSL_METHOD = c_void;
|
||||||
|
|
@ -276,25 +276,25 @@ extern "C" {
|
||||||
pub fn EVP_sha384() -> *const EVP_MD;
|
pub fn EVP_sha384() -> *const EVP_MD;
|
||||||
pub fn EVP_sha512() -> *const EVP_MD;
|
pub fn EVP_sha512() -> *const EVP_MD;
|
||||||
|
|
||||||
pub fn EVP_aes_128_cbc() -> EVP_CIPHER;
|
pub fn EVP_aes_128_cbc() -> *const EVP_CIPHER;
|
||||||
pub fn EVP_aes_128_ecb() -> EVP_CIPHER;
|
pub fn EVP_aes_128_ecb() -> *const EVP_CIPHER;
|
||||||
// fn EVP_aes_128_ctr() -> EVP_CIPHER;
|
// fn EVP_aes_128_ctr() -> EVP_CIPHER;
|
||||||
// fn EVP_aes_128_gcm() -> EVP_CIPHER;
|
// fn EVP_aes_128_gcm() -> EVP_CIPHER;
|
||||||
pub fn EVP_aes_256_cbc() -> EVP_CIPHER;
|
pub fn EVP_aes_256_cbc() -> *const EVP_CIPHER;
|
||||||
pub fn EVP_aes_256_ecb() -> EVP_CIPHER;
|
pub fn EVP_aes_256_ecb() -> *const EVP_CIPHER;
|
||||||
// fn EVP_aes_256_ctr() -> EVP_CIPHER;
|
// fn EVP_aes_256_ctr() -> EVP_CIPHER;
|
||||||
// fn EVP_aes_256_gcm() -> EVP_CIPHER;
|
// fn EVP_aes_256_gcm() -> EVP_CIPHER;
|
||||||
pub fn EVP_rc4() -> EVP_CIPHER;
|
pub fn EVP_rc4() -> *const EVP_CIPHER;
|
||||||
|
|
||||||
pub fn EVP_CIPHER_CTX_new() -> EVP_CIPHER_CTX;
|
pub fn EVP_CIPHER_CTX_new() -> *mut EVP_CIPHER_CTX;
|
||||||
pub fn EVP_CIPHER_CTX_set_padding(ctx: EVP_CIPHER_CTX, padding: c_int);
|
pub fn EVP_CIPHER_CTX_set_padding(ctx: *mut EVP_CIPHER_CTX, padding: c_int);
|
||||||
pub fn EVP_CIPHER_CTX_free(ctx: EVP_CIPHER_CTX);
|
pub fn EVP_CIPHER_CTX_free(ctx: *mut EVP_CIPHER_CTX);
|
||||||
|
|
||||||
pub fn EVP_CipherInit(ctx: EVP_CIPHER_CTX, evp: EVP_CIPHER,
|
pub fn EVP_CipherInit(ctx: *mut EVP_CIPHER_CTX, evp: *const EVP_CIPHER,
|
||||||
key: *const u8, iv: *const u8, mode: c_int);
|
key: *const u8, iv: *const u8, mode: c_int);
|
||||||
pub fn EVP_CipherUpdate(ctx: EVP_CIPHER_CTX, outbuf: *mut u8,
|
pub fn EVP_CipherUpdate(ctx: *mut EVP_CIPHER_CTX, outbuf: *mut u8,
|
||||||
outlen: &mut c_uint, inbuf: *const u8, inlen: c_int);
|
outlen: &mut c_uint, inbuf: *const u8, inlen: c_int);
|
||||||
pub fn EVP_CipherFinal(ctx: EVP_CIPHER_CTX, res: *mut u8, len: &mut c_int);
|
pub fn EVP_CipherFinal(ctx: *mut EVP_CIPHER_CTX, res: *mut u8, len: &mut c_int);
|
||||||
|
|
||||||
pub fn EVP_DigestInit(ctx: *mut EVP_MD_CTX, typ: *const EVP_MD);
|
pub fn EVP_DigestInit(ctx: *mut EVP_MD_CTX, typ: *const EVP_MD);
|
||||||
pub fn EVP_DigestUpdate(ctx: *mut EVP_MD_CTX, data: *const u8, n: c_uint);
|
pub fn EVP_DigestUpdate(ctx: *mut EVP_MD_CTX, data: *const u8, n: c_uint);
|
||||||
|
|
|
||||||
|
|
@ -242,7 +242,7 @@ impl Ssl {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn wrap_bio<'a>(&'a self, bio: *mut ffi::BIO) -> MemBioRef<'a> {
|
fn wrap_bio<'a>(&'a self, bio: *mut ffi::BIO) -> MemBioRef<'a> {
|
||||||
assert!(bio != ptr::mut_null());
|
assert!(bio != ptr::null_mut());
|
||||||
MemBioRef {
|
MemBioRef {
|
||||||
ssl: self,
|
ssl: self,
|
||||||
bio: MemBio::borrowed(bio)
|
bio: MemBio::borrowed(bio)
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue