diff options
| author | Steven Fackler <[email protected]> | 2017-01-13 19:38:12 -0800 |
|---|---|---|
| committer | Steven Fackler <[email protected]> | 2017-01-14 21:09:38 -0800 |
| commit | 920ab0d6fb60c17077f43d7f08ad3ff391201689 (patch) | |
| tree | 2ede3415426f622fe2aff78eaa70a3d64f35a403 /openssl/src/crypto.rs | |
| parent | Release v0.9.6 (diff) | |
| download | rust-openssl-920ab0d6fb60c17077f43d7f08ad3ff391201689.tar.xz rust-openssl-920ab0d6fb60c17077f43d7f08ad3ff391201689.zip | |
OCSP functionality
Diffstat (limited to 'openssl/src/crypto.rs')
| -rw-r--r-- | openssl/src/crypto.rs | 60 |
1 files changed, 3 insertions, 57 deletions
diff --git a/openssl/src/crypto.rs b/openssl/src/crypto.rs index ce83cbae..49029318 100644 --- a/openssl/src/crypto.rs +++ b/openssl/src/crypto.rs @@ -1,59 +1,5 @@ -use libc::{c_char, c_int, c_void}; -use std::fmt; -use std::ffi::CStr; -use std::slice; -use std::ops::Deref; -use std::str; +use string::OpensslString; -pub struct CryptoString(&'static str); +#[deprecated(note = "renamed to OpensslString", since = "0.9.7")] +pub type CryptoString = OpensslString; -impl Drop for CryptoString { - fn drop(&mut self) { - unsafe { - CRYPTO_free(self.0.as_ptr() as *mut c_void, - concat!(file!(), "\0").as_ptr() as *const c_char, - line!() as c_int); - } - } -} - -impl Deref for CryptoString { - type Target = str; - - fn deref(&self) -> &str { - self.0 - } -} - -impl CryptoString { - pub unsafe fn from_raw_parts(buf: *mut u8, len: usize) -> CryptoString { - let slice = slice::from_raw_parts(buf, len); - CryptoString(str::from_utf8_unchecked(slice)) - } - - pub unsafe fn from_null_terminated(buf: *mut c_char) -> CryptoString { - let slice = CStr::from_ptr(buf).to_bytes(); - CryptoString(str::from_utf8_unchecked(slice)) - } -} - -impl fmt::Display for CryptoString { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - fmt::Display::fmt(self.0, f) - } -} - -impl fmt::Debug for CryptoString { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - fmt::Debug::fmt(self.0, f) - } -} - -#[cfg(not(ossl110))] -#[allow(non_snake_case)] -unsafe fn CRYPTO_free(buf: *mut c_void, _: *const c_char, _: c_int) { - ::ffi::CRYPTO_free(buf); -} - -#[cfg(ossl110)] -use ffi::CRYPTO_free; |