Commit 8c40c2ef authored by Steven Fackler's avatar Steven Fackler
Browse files

Update for * -> *const change

parent bfd8fa2d
Loading
Loading
Loading
Loading
+22 −22
Original line number Diff line number Diff line
@@ -14,12 +14,12 @@ pub enum HashType {
#[allow(dead_code)]
#[allow(non_camel_case_types)]
pub struct EVP_MD_CTX {
    digest: *EVP_MD,
    engine: *libc::c_void,
    digest: *mut EVP_MD,
    engine: *mut libc::c_void,
    flags: libc::c_ulong,
    md_data: *libc::c_void,
    pctx: *EVP_PKEY_CTX,
    update: *libc::c_void
    md_data: *mut libc::c_void,
    pctx: *mut EVP_PKEY_CTX,
    update: *mut libc::c_void
}

#[allow(non_camel_case_types)]
@@ -30,22 +30,22 @@ pub struct EVP_PKEY_CTX;

#[link(name = "crypto")]
extern {
    fn EVP_MD_CTX_create() -> *EVP_MD_CTX;
    fn EVP_MD_CTX_destroy(ctx: *EVP_MD_CTX);
    fn EVP_MD_CTX_create() -> *mut EVP_MD_CTX;
    fn EVP_MD_CTX_destroy(ctx: *mut EVP_MD_CTX);

    fn EVP_md5() -> *EVP_MD;
    fn EVP_sha1() -> *EVP_MD;
    fn EVP_sha224() -> *EVP_MD;
    fn EVP_sha256() -> *EVP_MD;
    fn EVP_sha384() -> *EVP_MD;
    fn EVP_sha512() -> *EVP_MD;
    fn EVP_md5() -> *const EVP_MD;
    fn EVP_sha1() -> *const EVP_MD;
    fn EVP_sha224() -> *const EVP_MD;
    fn EVP_sha256() -> *const EVP_MD;
    fn EVP_sha384() -> *const EVP_MD;
    fn EVP_sha512() -> *const EVP_MD;

    fn EVP_DigestInit(ctx: *EVP_MD_CTX, typ: *EVP_MD);
    fn EVP_DigestUpdate(ctx: *EVP_MD_CTX, data: *u8, n: c_uint);
    fn EVP_DigestFinal(ctx: *EVP_MD_CTX, res: *mut u8, n: *u32);
    fn EVP_DigestInit(ctx: *mut EVP_MD_CTX, typ: *const EVP_MD);
    fn EVP_DigestUpdate(ctx: *mut EVP_MD_CTX, data: *const u8, n: c_uint);
    fn EVP_DigestFinal(ctx: *mut EVP_MD_CTX, res: *mut u8, n: *mut u32);
}

pub fn evpmd(t: HashType) -> (*EVP_MD, uint) {
pub fn evpmd(t: HashType) -> (*const EVP_MD, uint) {
    unsafe {
        match t {
            MD5 => (EVP_md5(), 16u),
@@ -60,8 +60,8 @@ pub fn evpmd(t: HashType) -> (*EVP_MD, uint) {

#[allow(dead_code)]
pub struct Hasher {
    evp: *EVP_MD,
    ctx: *EVP_MD_CTX,
    evp: *const EVP_MD,
    ctx: *mut EVP_MD_CTX,
    len: uint,
}

@@ -90,7 +90,7 @@ impl Hasher {
    pub fn final(&self) -> Vec<u8> {
        unsafe {
            let mut res = Vec::from_elem(self.len, 0u8);
            EVP_DigestFinal(self.ctx, res.as_mut_ptr(), ptr::null());
            EVP_DigestFinal(self.ctx, res.as_mut_ptr(), ptr::mut_null());
            res
        }
    }
+4 −4
Original line number Diff line number Diff line
@@ -20,7 +20,7 @@ use crypto::hash;
#[allow(dead_code)]
#[allow(non_camel_case_types)]
pub struct HMAC_CTX {
    md: *hash::EVP_MD,
    md: *mut hash::EVP_MD,
    md_ctx: hash::EVP_MD_CTX,
    i_ctx: hash::EVP_MD_CTX,
    o_ctx: hash::EVP_MD_CTX,
@@ -31,8 +31,8 @@ pub struct HMAC_CTX {
#[link(name = "crypto")]
extern {
    fn HMAC_CTX_init(ctx: *mut HMAC_CTX);
    fn HMAC_Init_ex(ctx: *mut HMAC_CTX, key: *u8, keylen: c_int, md: *hash::EVP_MD, imple: *ENGINE);
    fn HMAC_Update(ctx: *mut HMAC_CTX, input: *u8, len: c_uint);
    fn HMAC_Init_ex(ctx: *mut HMAC_CTX, key: *const u8, keylen: c_int, md: *const hash::EVP_MD, imple: *const ENGINE);
    fn HMAC_Update(ctx: *mut HMAC_CTX, input: *const u8, len: c_uint);
    fn HMAC_Final(ctx: *mut HMAC_CTX, output: *mut u8, len: *mut c_uint);
}

@@ -55,7 +55,7 @@ pub fn HMAC(ht: hash::HashType, key: &[u8]) -> HMAC {
        HMAC_Init_ex(&mut ctx,
                     key.as_ptr(),
                     key.len() as c_int,
                     evp, 0 as *_);
                     evp, 0 as *const _);

        HMAC { ctx: ctx, len: mdlen }
    }
+2 −2
Original line number Diff line number Diff line
@@ -2,8 +2,8 @@ use libc::c_int;

#[link(name = "crypto")]
extern {
    fn PKCS5_PBKDF2_HMAC_SHA1(pass: *u8, passlen: c_int,
                              salt: *u8, saltlen: c_int,
    fn PKCS5_PBKDF2_HMAC_SHA1(pass: *const u8, passlen: c_int,
                              salt: *const u8, saltlen: c_int,
                              iter: c_int, keylen: c_int,
                              out: *mut u8) -> c_int;
}
+22 −22
Original line number Diff line number Diff line
@@ -5,34 +5,34 @@ use std::ptr;
use crypto::hash::{HashType, MD5, SHA1, SHA224, SHA256, SHA384, SHA512};

#[allow(non_camel_case_types)]
pub type EVP_PKEY = *libc::c_void;
pub type EVP_PKEY = *mut libc::c_void;

#[allow(non_camel_case_types)]
pub type RSA = *libc::c_void;
pub type RSA = *mut libc::c_void;

#[link(name = "crypto")]
extern {
    fn EVP_PKEY_new() -> *EVP_PKEY;
    fn EVP_PKEY_free(k: *EVP_PKEY);
    fn EVP_PKEY_assign(pkey: *EVP_PKEY, typ: c_int, key: *c_char) -> c_int;
    fn EVP_PKEY_get1_RSA(k: *EVP_PKEY) -> *RSA;
    fn EVP_PKEY_new() -> *mut EVP_PKEY;
    fn EVP_PKEY_free(k: *mut EVP_PKEY);
    fn EVP_PKEY_assign(pkey: *mut EVP_PKEY, typ: c_int, key: *const c_char) -> c_int;
    fn EVP_PKEY_get1_RSA(k: *mut EVP_PKEY) -> *mut RSA;

    fn i2d_PublicKey(k: *EVP_PKEY, buf: **mut u8) -> c_int;
    fn d2i_PublicKey(t: c_int, k: **EVP_PKEY, buf: **u8, len: c_uint) -> *EVP_PKEY;
    fn i2d_PrivateKey(k: *EVP_PKEY, buf: **mut u8) -> c_int;
    fn d2i_PrivateKey(t: c_int, k: **EVP_PKEY, buf: **u8, len: c_uint) -> *EVP_PKEY;
    fn i2d_PublicKey(k: *mut EVP_PKEY, buf: *const *mut u8) -> c_int;
    fn d2i_PublicKey(t: c_int, k: *const *mut EVP_PKEY, buf: *const *const u8, len: c_uint) -> *mut EVP_PKEY;
    fn i2d_PrivateKey(k: *mut EVP_PKEY, buf: *const *mut u8) -> c_int;
    fn d2i_PrivateKey(t: c_int, k: *const *mut EVP_PKEY, buf: *const *const u8, len: c_uint) -> *mut EVP_PKEY;

    fn RSA_generate_key(modsz: c_uint, e: c_uint, cb: *u8, cbarg: *u8) -> *RSA;
    fn RSA_size(k: *RSA) -> c_uint;
    fn RSA_generate_key(modsz: c_uint, e: c_uint, cb: *const u8, cbarg: *const u8) -> *mut RSA;
    fn RSA_size(k: *mut RSA) -> c_uint;

    fn RSA_public_encrypt(flen: c_uint, from: *u8, to: *mut u8, k: *RSA,
    fn RSA_public_encrypt(flen: c_uint, from: *const u8, to: *mut u8, k: *mut RSA,
                          pad: c_int) -> c_int;
    fn RSA_private_decrypt(flen: c_uint, from: *u8, to: *mut u8, k: *RSA,
    fn RSA_private_decrypt(flen: c_uint, from: *const u8, to: *mut u8, k: *mut RSA,
                           pad: c_int) -> c_int;
    fn RSA_sign(t: c_int, m: *u8, mlen: c_uint, sig: *mut u8, siglen: *mut c_uint,
                k: *RSA) -> c_int;
    fn RSA_verify(t: c_int, m: *u8, mlen: c_uint, sig: *u8, siglen: c_uint,
                  k: *RSA) -> c_int;
    fn RSA_sign(t: c_int, m: *const u8, mlen: c_uint, sig: *mut u8, siglen: *mut c_uint,
                k: *mut RSA) -> c_int;
    fn RSA_verify(t: c_int, m: *const u8, mlen: c_uint, sig: *const u8, siglen: c_uint,
                  k: *mut RSA) -> c_int;
}

enum Parts {
@@ -74,7 +74,7 @@ fn openssl_hash_nid(hash: HashType) -> c_int {
}

pub struct PKey {
    evp: *EVP_PKEY,
    evp: *mut EVP_PKEY,
    parts: Parts,
}

@@ -89,7 +89,7 @@ impl PKey {
        }
    }

    fn _tostr(&self, f: unsafe extern "C" fn(*EVP_PKEY, **mut u8) -> c_int) -> Vec<u8> {
    fn _tostr(&self, f: unsafe extern "C" fn(*mut EVP_PKEY, *const *mut u8) -> c_int) -> Vec<u8> {
        unsafe {
            let len = f(self.evp, ptr::null());
            if len < 0 as c_int { return vec!(); }
@@ -102,9 +102,9 @@ impl PKey {
        }
    }

    fn _fromstr(&mut self, s: &[u8], f: unsafe extern "C" fn(c_int, **EVP_PKEY, **u8, c_uint) -> *EVP_PKEY) {
    fn _fromstr(&mut self, s: &[u8], f: unsafe extern "C" fn(c_int, *const *mut EVP_PKEY, *const *const u8, c_uint) -> *mut EVP_PKEY) {
        unsafe {
            let evp = ptr::null();
            let evp = ptr::mut_null();
            f(6 as c_int, &evp, &s.as_ptr(), s.len() as c_uint);
            self.evp = evp;
        }
+4 −4
Original line number Diff line number Diff line
@@ -2,10 +2,10 @@ use libc::{c_int, c_uint};
use libc;

#[allow(non_camel_case_types)]
pub type EVP_CIPHER_CTX = *libc::c_void;
pub type EVP_CIPHER_CTX = *mut libc::c_void;

#[allow(non_camel_case_types)]
pub type EVP_CIPHER = *libc::c_void;
pub type EVP_CIPHER = *mut libc::c_void;

#[link(name = "crypto")]
extern {
@@ -26,9 +26,9 @@ extern {
    fn EVP_rc4() -> EVP_CIPHER;

    fn EVP_CipherInit(ctx: EVP_CIPHER_CTX, evp: EVP_CIPHER,
                      key: *u8, iv: *u8, mode: c_int);
                      key: *const u8, iv: *const u8, mode: c_int);
    fn EVP_CipherUpdate(ctx: EVP_CIPHER_CTX, outbuf: *mut u8,
                        outlen: &mut c_uint, inbuf: *u8, inlen: c_int);
                        outlen: &mut c_uint, inbuf: *const u8, inlen: c_int);
    fn EVP_CipherFinal(ctx: EVP_CIPHER_CTX, res: *mut u8, len: &mut c_int);
}

Loading