Loading openssl/src/bn/mod.rs +5 −5 Original line number Diff line number Diff line use libc::{c_int, c_ulong, c_void}; use std::ffi::{CString, c_str_to_bytes}; use std::ffi::{CStr, CString}; use std::cmp::Ordering; use std::{fmt, ptr}; Loading Loading @@ -88,7 +88,7 @@ impl BigNum { pub fn from_dec_str(s: &str) -> Result<BigNum, SslError> { BigNum::new().and_then(|v| unsafe { let c_str = CString::from_slice(s.as_bytes()); let c_str = CString::new(s.as_bytes()).unwrap(); try_ssl!(ffi::BN_dec2bn(v.raw_ptr(), c_str.as_ptr())); Ok(v) }) Loading @@ -96,7 +96,7 @@ impl BigNum { pub fn from_hex_str(s: &str) -> Result<BigNum, SslError> { BigNum::new().and_then(|v| unsafe { let c_str = CString::from_slice(s.as_bytes()); let c_str = CString::new(s.as_bytes()).unwrap(); try_ssl!(ffi::BN_hex2bn(v.raw_ptr(), c_str.as_ptr())); Ok(v) }) Loading Loading @@ -421,7 +421,7 @@ impl BigNum { unsafe { let buf = ffi::BN_bn2dec(self.raw()); assert!(!buf.is_null()); let str = String::from_utf8(c_str_to_bytes(&buf).to_vec()).unwrap(); let str = String::from_utf8(CStr::from_ptr(buf).to_bytes().to_vec()).unwrap(); ffi::CRYPTO_free(buf as *mut c_void); str } Loading @@ -431,7 +431,7 @@ impl BigNum { unsafe { let buf = ffi::BN_bn2hex(self.raw()); assert!(!buf.is_null()); let str = String::from_utf8(c_str_to_bytes(&buf).to_vec()).unwrap(); let str = String::from_utf8(CStr::from_ptr(buf).to_bytes().to_vec()).unwrap(); ffi::CRYPTO_free(buf as *mut c_void); str } Loading openssl/src/crypto/hmac.rs +3 −3 Original line number Diff line number Diff line Loading @@ -253,7 +253,7 @@ mod tests { ]; let mut h = HMAC::new(MD5, &*tests[0].0); for i in 0..100us { for i in 0..100usize { let test = &tests[i % 2]; test_hmac_recycle(&mut h, test); } Loading Loading @@ -351,7 +351,7 @@ mod tests { ]; let mut h = HMAC::new(SHA1, &*tests[0].0); for i in 0..100us { for i in 0..100usize { let test = &tests[i % 2]; test_hmac_recycle(&mut h, test); } Loading Loading @@ -382,7 +382,7 @@ mod tests { // recycle test let mut h = HMAC::new(ty, &*tests[5].0); for i in 0..100us { for i in 0..100usize { let test = &tests[4 + i % 2]; let tup = (test.0.clone(), test.1.clone(), results[4 + i % 2].clone()); test_hmac_recycle(&mut h, &tup); Loading openssl/src/lib.rs +1 −1 Original line number Diff line number Diff line #![feature(unsafe_destructor, core, old_io, std_misc, libc, hash, old_path)] #![feature(unsafe_destructor, core, old_io, std_misc, libc, old_path)] #![crate_name="openssl"] #![crate_type="rlib"] #![crate_type="dylib"] Loading openssl/src/ssl/error.rs +4 −4 Original line number Diff line number Diff line Loading @@ -4,7 +4,7 @@ pub use self::OpensslError::*; use libc::c_ulong; use std::error; use std::fmt; use std::ffi::c_str_to_bytes; use std::ffi::CStr; use std::old_io::IoError; use ffi; Loading Loading @@ -75,21 +75,21 @@ pub enum OpensslError { fn get_lib(err: c_ulong) -> String { unsafe { let bytes = c_str_to_bytes(&ffi::ERR_lib_error_string(err)).to_vec(); let bytes = CStr::from_ptr(ffi::ERR_lib_error_string(err)).to_bytes().to_vec(); String::from_utf8(bytes).unwrap() } } fn get_func(err: c_ulong) -> String { unsafe { let bytes = c_str_to_bytes(&ffi::ERR_func_error_string(err)).to_vec(); let bytes = CStr::from_ptr(ffi::ERR_func_error_string(err)).to_bytes().to_vec(); String::from_utf8(bytes).unwrap() } } fn get_reason(err: c_ulong) -> String { unsafe { let bytes = c_str_to_bytes(&ffi::ERR_reason_error_string(err)).to_vec(); let bytes = CStr::from_ptr(ffi::ERR_reason_error_string(err)).to_bytes().to_vec(); String::from_utf8(bytes).unwrap() } } Loading openssl/src/ssl/mod.rs +7 −7 Original line number Diff line number Diff line use libc::{c_int, c_void, c_long}; use std::ffi::{CString, c_str_to_bytes}; use std::ffi::{CStr, CString}; use std::old_io::{IoResult, IoError, EndOfFile, OtherIoError, Stream, Reader, Writer}; use std::mem; use std::fmt; Loading Loading @@ -247,7 +247,7 @@ impl SslContext { pub fn set_CA_file(&mut self, file: &Path) -> Option<SslError> { wrap_ssl_result( unsafe { let file = CString::from_slice(file.as_vec()); let file = CString::new(file.as_vec()).unwrap(); ffi::SSL_CTX_load_verify_locations(*self.ctx, file.as_ptr(), ptr::null()) }) } Loading @@ -257,7 +257,7 @@ impl SslContext { file_type: X509FileType) -> Option<SslError> { wrap_ssl_result( unsafe { let file = CString::from_slice(file.as_vec()); let file = CString::new(file.as_vec()).unwrap(); ffi::SSL_CTX_use_certificate_file(*self.ctx, file.as_ptr(), file_type as c_int) }) } Loading @@ -267,7 +267,7 @@ impl SslContext { file_type: X509FileType) -> Option<SslError> { wrap_ssl_result( unsafe { let file = CString::from_slice(file.as_vec()); let file = CString::new(file.as_vec()).unwrap(); ffi::SSL_CTX_use_PrivateKey_file(*self.ctx, file.as_ptr(), file_type as c_int) }) } Loading @@ -275,7 +275,7 @@ impl SslContext { pub fn set_cipher_list(&mut self, cipher_list: &str) -> Option<SslError> { wrap_ssl_result( unsafe { let cipher_list = CString::from_slice(cipher_list.as_bytes()); let cipher_list = CString::new(cipher_list.as_bytes()).unwrap(); ffi::SSL_CTX_set_cipher_list(*self.ctx, cipher_list.as_ptr()) }) } Loading Loading @@ -378,7 +378,7 @@ impl Ssl { // #define SSL_set_tlsext_host_name(s,name) \ // SSL_ctrl(s,SSL_CTRL_SET_TLSEXT_HOSTNAME,TLSEXT_NAMETYPE_host_name,(char *)name) let hostname = CString::from_slice(hostname.as_bytes()); let hostname = CString::new(hostname.as_bytes()).unwrap(); ffi::SSL_ctrl(*self.ssl, ffi::SSL_CTRL_SET_TLSEXT_HOSTNAME, ffi::TLSEXT_NAMETYPE_host_name, hostname.as_ptr() as *mut c_void) Loading Loading @@ -542,7 +542,7 @@ impl<S: Stream> SslStream<S> { let meth = unsafe { ffi::SSL_COMP_get_name(ptr) }; let s = unsafe { String::from_utf8(c_str_to_bytes(&meth).to_vec()).unwrap() String::from_utf8(CStr::from_ptr(meth).to_bytes().to_vec()).unwrap() }; Some(s) Loading Loading
openssl/src/bn/mod.rs +5 −5 Original line number Diff line number Diff line use libc::{c_int, c_ulong, c_void}; use std::ffi::{CString, c_str_to_bytes}; use std::ffi::{CStr, CString}; use std::cmp::Ordering; use std::{fmt, ptr}; Loading Loading @@ -88,7 +88,7 @@ impl BigNum { pub fn from_dec_str(s: &str) -> Result<BigNum, SslError> { BigNum::new().and_then(|v| unsafe { let c_str = CString::from_slice(s.as_bytes()); let c_str = CString::new(s.as_bytes()).unwrap(); try_ssl!(ffi::BN_dec2bn(v.raw_ptr(), c_str.as_ptr())); Ok(v) }) Loading @@ -96,7 +96,7 @@ impl BigNum { pub fn from_hex_str(s: &str) -> Result<BigNum, SslError> { BigNum::new().and_then(|v| unsafe { let c_str = CString::from_slice(s.as_bytes()); let c_str = CString::new(s.as_bytes()).unwrap(); try_ssl!(ffi::BN_hex2bn(v.raw_ptr(), c_str.as_ptr())); Ok(v) }) Loading Loading @@ -421,7 +421,7 @@ impl BigNum { unsafe { let buf = ffi::BN_bn2dec(self.raw()); assert!(!buf.is_null()); let str = String::from_utf8(c_str_to_bytes(&buf).to_vec()).unwrap(); let str = String::from_utf8(CStr::from_ptr(buf).to_bytes().to_vec()).unwrap(); ffi::CRYPTO_free(buf as *mut c_void); str } Loading @@ -431,7 +431,7 @@ impl BigNum { unsafe { let buf = ffi::BN_bn2hex(self.raw()); assert!(!buf.is_null()); let str = String::from_utf8(c_str_to_bytes(&buf).to_vec()).unwrap(); let str = String::from_utf8(CStr::from_ptr(buf).to_bytes().to_vec()).unwrap(); ffi::CRYPTO_free(buf as *mut c_void); str } Loading
openssl/src/crypto/hmac.rs +3 −3 Original line number Diff line number Diff line Loading @@ -253,7 +253,7 @@ mod tests { ]; let mut h = HMAC::new(MD5, &*tests[0].0); for i in 0..100us { for i in 0..100usize { let test = &tests[i % 2]; test_hmac_recycle(&mut h, test); } Loading Loading @@ -351,7 +351,7 @@ mod tests { ]; let mut h = HMAC::new(SHA1, &*tests[0].0); for i in 0..100us { for i in 0..100usize { let test = &tests[i % 2]; test_hmac_recycle(&mut h, test); } Loading Loading @@ -382,7 +382,7 @@ mod tests { // recycle test let mut h = HMAC::new(ty, &*tests[5].0); for i in 0..100us { for i in 0..100usize { let test = &tests[4 + i % 2]; let tup = (test.0.clone(), test.1.clone(), results[4 + i % 2].clone()); test_hmac_recycle(&mut h, &tup); Loading
openssl/src/lib.rs +1 −1 Original line number Diff line number Diff line #![feature(unsafe_destructor, core, old_io, std_misc, libc, hash, old_path)] #![feature(unsafe_destructor, core, old_io, std_misc, libc, old_path)] #![crate_name="openssl"] #![crate_type="rlib"] #![crate_type="dylib"] Loading
openssl/src/ssl/error.rs +4 −4 Original line number Diff line number Diff line Loading @@ -4,7 +4,7 @@ pub use self::OpensslError::*; use libc::c_ulong; use std::error; use std::fmt; use std::ffi::c_str_to_bytes; use std::ffi::CStr; use std::old_io::IoError; use ffi; Loading Loading @@ -75,21 +75,21 @@ pub enum OpensslError { fn get_lib(err: c_ulong) -> String { unsafe { let bytes = c_str_to_bytes(&ffi::ERR_lib_error_string(err)).to_vec(); let bytes = CStr::from_ptr(ffi::ERR_lib_error_string(err)).to_bytes().to_vec(); String::from_utf8(bytes).unwrap() } } fn get_func(err: c_ulong) -> String { unsafe { let bytes = c_str_to_bytes(&ffi::ERR_func_error_string(err)).to_vec(); let bytes = CStr::from_ptr(ffi::ERR_func_error_string(err)).to_bytes().to_vec(); String::from_utf8(bytes).unwrap() } } fn get_reason(err: c_ulong) -> String { unsafe { let bytes = c_str_to_bytes(&ffi::ERR_reason_error_string(err)).to_vec(); let bytes = CStr::from_ptr(ffi::ERR_reason_error_string(err)).to_bytes().to_vec(); String::from_utf8(bytes).unwrap() } } Loading
openssl/src/ssl/mod.rs +7 −7 Original line number Diff line number Diff line use libc::{c_int, c_void, c_long}; use std::ffi::{CString, c_str_to_bytes}; use std::ffi::{CStr, CString}; use std::old_io::{IoResult, IoError, EndOfFile, OtherIoError, Stream, Reader, Writer}; use std::mem; use std::fmt; Loading Loading @@ -247,7 +247,7 @@ impl SslContext { pub fn set_CA_file(&mut self, file: &Path) -> Option<SslError> { wrap_ssl_result( unsafe { let file = CString::from_slice(file.as_vec()); let file = CString::new(file.as_vec()).unwrap(); ffi::SSL_CTX_load_verify_locations(*self.ctx, file.as_ptr(), ptr::null()) }) } Loading @@ -257,7 +257,7 @@ impl SslContext { file_type: X509FileType) -> Option<SslError> { wrap_ssl_result( unsafe { let file = CString::from_slice(file.as_vec()); let file = CString::new(file.as_vec()).unwrap(); ffi::SSL_CTX_use_certificate_file(*self.ctx, file.as_ptr(), file_type as c_int) }) } Loading @@ -267,7 +267,7 @@ impl SslContext { file_type: X509FileType) -> Option<SslError> { wrap_ssl_result( unsafe { let file = CString::from_slice(file.as_vec()); let file = CString::new(file.as_vec()).unwrap(); ffi::SSL_CTX_use_PrivateKey_file(*self.ctx, file.as_ptr(), file_type as c_int) }) } Loading @@ -275,7 +275,7 @@ impl SslContext { pub fn set_cipher_list(&mut self, cipher_list: &str) -> Option<SslError> { wrap_ssl_result( unsafe { let cipher_list = CString::from_slice(cipher_list.as_bytes()); let cipher_list = CString::new(cipher_list.as_bytes()).unwrap(); ffi::SSL_CTX_set_cipher_list(*self.ctx, cipher_list.as_ptr()) }) } Loading Loading @@ -378,7 +378,7 @@ impl Ssl { // #define SSL_set_tlsext_host_name(s,name) \ // SSL_ctrl(s,SSL_CTRL_SET_TLSEXT_HOSTNAME,TLSEXT_NAMETYPE_host_name,(char *)name) let hostname = CString::from_slice(hostname.as_bytes()); let hostname = CString::new(hostname.as_bytes()).unwrap(); ffi::SSL_ctrl(*self.ssl, ffi::SSL_CTRL_SET_TLSEXT_HOSTNAME, ffi::TLSEXT_NAMETYPE_host_name, hostname.as_ptr() as *mut c_void) Loading Loading @@ -542,7 +542,7 @@ impl<S: Stream> SslStream<S> { let meth = unsafe { ffi::SSL_COMP_get_name(ptr) }; let s = unsafe { String::from_utf8(c_str_to_bytes(&meth).to_vec()).unwrap() String::from_utf8(CStr::from_ptr(meth).to_bytes().to_vec()).unwrap() }; Some(s) Loading