Loading openssl/src/crypto.rsdeleted 100644 → 0 +0 −6 Original line number Diff line number Diff line #![doc(hidden)] #![deprecated(since = "0.9.20")] use string::OpensslString; #[deprecated(note = "renamed to OpensslString", since = "0.9.7")] pub type CryptoString = OpensslString; openssl/src/dsa.rs +1 −24 Original line number Diff line number Diff line Loading @@ -7,15 +7,13 @@ use ffi; use foreign_types::ForeignTypeRef; use libc::{c_char, c_int, c_void}; use libc::c_int; use std::fmt; use std::ptr; use {cvt, cvt_p}; use bio::MemBioSlice; use bn::BigNumRef; use error::ErrorStack; use util::{invoke_passwd_cb_old, CallbackState}; foreign_type_and_impl_send_sync! { type CType = ffi::DSA; Loading Loading @@ -158,27 +156,6 @@ impl Dsa { private_key_from_der!(Dsa, ffi::d2i_DSAPrivateKey); public_key_from_pem!(Dsa, ffi::PEM_read_bio_DSA_PUBKEY); public_key_from_der!(Dsa, ffi::d2i_DSAPublicKey); #[deprecated(since = "0.9.2", note = "use private_key_from_pem_callback")] pub fn private_key_from_pem_cb<F>(buf: &[u8], pass_cb: F) -> Result<Dsa, ErrorStack> where F: FnOnce(&mut [c_char]) -> usize, { ffi::init(); let mut cb = CallbackState::new(pass_cb); let mem_bio = MemBioSlice::new(buf)?; unsafe { let cb_ptr = &mut cb as *mut _ as *mut c_void; let dsa = cvt_p(ffi::PEM_read_bio_DSAPrivateKey( mem_bio.as_ptr(), ptr::null_mut(), Some(invoke_passwd_cb_old::<F>), cb_ptr, ))?; Ok(Dsa(dsa)) } } } impl fmt::Debug for Dsa { Loading openssl/src/ec.rs +0 −5 Original line number Diff line number Diff line Loading @@ -639,11 +639,6 @@ impl EcKey { Ok(builder.build()) } #[deprecated(since = "0.9.2", note = "use from_curve_name")] pub fn new_by_curve_name(nid: Nid) -> Result<EcKey, ErrorStack> { EcKey::from_curve_name(nid) } private_key_from_pem!(EcKey, ffi::PEM_read_bio_ECPrivateKey); private_key_from_der!(EcKey, ffi::d2i_ECPrivateKey); } Loading openssl/src/ec_key.rsdeleted 100644 → 0 +0 −4 Original line number Diff line number Diff line #![doc(hidden)] #![deprecated(since = "0.9.2", note = "renamed to `ec`")] pub use ec::{EcKey, EcKeyRef}; openssl/src/hash.rs +34 −49 Original line number Diff line number Diff line Loading @@ -5,7 +5,7 @@ use std::fmt; use ffi; #[cfg(ossl110)] use ffi::{EVP_MD_CTX_new, EVP_MD_CTX_free}; use ffi::{EVP_MD_CTX_free, EVP_MD_CTX_new}; #[cfg(any(ossl101, ossl102))] use ffi::{EVP_MD_CTX_create as EVP_MD_CTX_new, EVP_MD_CTX_destroy as EVP_MD_CTX_free}; Loading Loading @@ -70,7 +70,7 @@ use self::State::*; /// let data = b"\x42\xF4\x97\xE0"; /// let spec = b"\x7c\x43\x0f\x17\x8a\xef\xdf\x14\x87\xfe\xe7\x14\x4e\x96\x41\xe2"; /// let res = hash(MessageDigest::md5(), data).unwrap(); /// assert_eq!(res, spec); /// assert_eq!(&*res, spec); /// ``` /// /// Supply the input in chunks: Loading @@ -84,7 +84,7 @@ use self::State::*; /// h.update(data[0]).unwrap(); /// h.update(data[1]).unwrap(); /// let res = h.finish().unwrap(); /// assert_eq!(res, spec); /// assert_eq!(&*res, spec); /// ``` /// /// # Warning Loading Loading @@ -120,7 +120,7 @@ impl Hasher { match self.state { Reset => return Ok(()), Updated => { self.finish2()?; self.finish()?; } Finalized => (), } Loading @@ -147,15 +147,8 @@ impl Hasher { Ok(()) } #[deprecated(note = "use finish2 instead", since = "0.9.11")] pub fn finish(&mut self) -> Result<Vec<u8>, ErrorStack> { self.finish2().map(|b| b.to_vec()) } /// Returns the hash of the data written and resets the hasher. /// /// Unlike `finish`, this method does not allocate. pub fn finish2(&mut self) -> Result<DigestBytes, ErrorStack> { pub fn finish(&mut self) -> Result<DigestBytes, ErrorStack> { if self.state == Finalized { self.init()?; } Loading Loading @@ -210,7 +203,7 @@ impl Drop for Hasher { fn drop(&mut self) { unsafe { if self.state != Finalized { drop(self.finish2()); drop(self.finish()); } EVP_MD_CTX_free(self.ctx); } Loading Loading @@ -263,18 +256,11 @@ impl fmt::Debug for DigestBytes { } } #[deprecated(note = "use hash2 instead", since = "0.9.11")] pub fn hash(t: MessageDigest, data: &[u8]) -> Result<Vec<u8>, ErrorStack> { hash2(t, data).map(|b| b.to_vec()) } /// Computes the hash of the `data` with the hash `t`. /// /// Unlike `hash`, this function does not allocate the return value. pub fn hash2(t: MessageDigest, data: &[u8]) -> Result<DigestBytes, ErrorStack> { pub fn hash(t: MessageDigest, data: &[u8]) -> Result<DigestBytes, ErrorStack> { let mut h = Hasher::new(t)?; h.update(data)?; h.finish2() h.finish() } #[cfg(test)] Loading @@ -285,20 +271,19 @@ mod tests { use super::*; fn hash_test(hashtype: MessageDigest, hashtest: &(&str, &str)) { let res = hash2(hashtype, &Vec::from_hex(hashtest.0).unwrap()).unwrap(); let res = hash(hashtype, &Vec::from_hex(hashtest.0).unwrap()).unwrap(); assert_eq!(res.to_hex(), hashtest.1); } fn hash_recycle_test(h: &mut Hasher, hashtest: &(&str, &str)) { let _ = h.write_all(&Vec::from_hex(hashtest.0).unwrap()).unwrap(); let res = h.finish2().unwrap(); let res = h.finish().unwrap(); assert_eq!(res.to_hex(), hashtest.1); } // Test vectors from http://www.nsrl.nist.gov/testdata/ #[allow(non_upper_case_globals)] const md5_tests: [(&'static str, &'static str); 13] = [ const md5_tests: [(&'static str, &'static str); 13] = [ ("", "d41d8cd98f00b204e9800998ecf8427e"), ("7F", "83acb6e67e50e31db6ed341dd2de1595"), ("EC9C", "0b07f0d4ca797d8ac58874f887cb0b68"), Loading Loading @@ -337,9 +322,9 @@ mod tests { let mut h = Hasher::new(MessageDigest::md5()).unwrap(); h.write_all(&Vec::from_hex(md5_tests[6].0).unwrap()) .unwrap(); h.finish2().unwrap(); let res = h.finish2().unwrap(); let null = hash2(MessageDigest::md5(), &[]).unwrap(); h.finish().unwrap(); let res = h.finish().unwrap(); let null = hash(MessageDigest::md5(), &[]).unwrap(); assert_eq!(&*res, &*null); } Loading @@ -358,18 +343,18 @@ mod tests { println!("Clone an updated hasher"); let mut h2 = h1.clone(); h2.write_all(&inp[p..]).unwrap(); let res = h2.finish2().unwrap(); let res = h2.finish().unwrap(); assert_eq!(res.to_hex(), md5_tests[i].1); } h1.write_all(&inp[p..]).unwrap(); let res = h1.finish2().unwrap(); let res = h1.finish().unwrap(); assert_eq!(res.to_hex(), md5_tests[i].1); println!("Clone a finished hasher"); let mut h3 = h1.clone(); h3.write_all(&Vec::from_hex(md5_tests[i + 1].0).unwrap()) .unwrap(); let res = h3.finish2().unwrap(); let res = h3.finish().unwrap(); assert_eq!(res.to_hex(), md5_tests[i + 1].1); } Loading Loading
openssl/src/crypto.rsdeleted 100644 → 0 +0 −6 Original line number Diff line number Diff line #![doc(hidden)] #![deprecated(since = "0.9.20")] use string::OpensslString; #[deprecated(note = "renamed to OpensslString", since = "0.9.7")] pub type CryptoString = OpensslString;
openssl/src/dsa.rs +1 −24 Original line number Diff line number Diff line Loading @@ -7,15 +7,13 @@ use ffi; use foreign_types::ForeignTypeRef; use libc::{c_char, c_int, c_void}; use libc::c_int; use std::fmt; use std::ptr; use {cvt, cvt_p}; use bio::MemBioSlice; use bn::BigNumRef; use error::ErrorStack; use util::{invoke_passwd_cb_old, CallbackState}; foreign_type_and_impl_send_sync! { type CType = ffi::DSA; Loading Loading @@ -158,27 +156,6 @@ impl Dsa { private_key_from_der!(Dsa, ffi::d2i_DSAPrivateKey); public_key_from_pem!(Dsa, ffi::PEM_read_bio_DSA_PUBKEY); public_key_from_der!(Dsa, ffi::d2i_DSAPublicKey); #[deprecated(since = "0.9.2", note = "use private_key_from_pem_callback")] pub fn private_key_from_pem_cb<F>(buf: &[u8], pass_cb: F) -> Result<Dsa, ErrorStack> where F: FnOnce(&mut [c_char]) -> usize, { ffi::init(); let mut cb = CallbackState::new(pass_cb); let mem_bio = MemBioSlice::new(buf)?; unsafe { let cb_ptr = &mut cb as *mut _ as *mut c_void; let dsa = cvt_p(ffi::PEM_read_bio_DSAPrivateKey( mem_bio.as_ptr(), ptr::null_mut(), Some(invoke_passwd_cb_old::<F>), cb_ptr, ))?; Ok(Dsa(dsa)) } } } impl fmt::Debug for Dsa { Loading
openssl/src/ec.rs +0 −5 Original line number Diff line number Diff line Loading @@ -639,11 +639,6 @@ impl EcKey { Ok(builder.build()) } #[deprecated(since = "0.9.2", note = "use from_curve_name")] pub fn new_by_curve_name(nid: Nid) -> Result<EcKey, ErrorStack> { EcKey::from_curve_name(nid) } private_key_from_pem!(EcKey, ffi::PEM_read_bio_ECPrivateKey); private_key_from_der!(EcKey, ffi::d2i_ECPrivateKey); } Loading
openssl/src/ec_key.rsdeleted 100644 → 0 +0 −4 Original line number Diff line number Diff line #![doc(hidden)] #![deprecated(since = "0.9.2", note = "renamed to `ec`")] pub use ec::{EcKey, EcKeyRef};
openssl/src/hash.rs +34 −49 Original line number Diff line number Diff line Loading @@ -5,7 +5,7 @@ use std::fmt; use ffi; #[cfg(ossl110)] use ffi::{EVP_MD_CTX_new, EVP_MD_CTX_free}; use ffi::{EVP_MD_CTX_free, EVP_MD_CTX_new}; #[cfg(any(ossl101, ossl102))] use ffi::{EVP_MD_CTX_create as EVP_MD_CTX_new, EVP_MD_CTX_destroy as EVP_MD_CTX_free}; Loading Loading @@ -70,7 +70,7 @@ use self::State::*; /// let data = b"\x42\xF4\x97\xE0"; /// let spec = b"\x7c\x43\x0f\x17\x8a\xef\xdf\x14\x87\xfe\xe7\x14\x4e\x96\x41\xe2"; /// let res = hash(MessageDigest::md5(), data).unwrap(); /// assert_eq!(res, spec); /// assert_eq!(&*res, spec); /// ``` /// /// Supply the input in chunks: Loading @@ -84,7 +84,7 @@ use self::State::*; /// h.update(data[0]).unwrap(); /// h.update(data[1]).unwrap(); /// let res = h.finish().unwrap(); /// assert_eq!(res, spec); /// assert_eq!(&*res, spec); /// ``` /// /// # Warning Loading Loading @@ -120,7 +120,7 @@ impl Hasher { match self.state { Reset => return Ok(()), Updated => { self.finish2()?; self.finish()?; } Finalized => (), } Loading @@ -147,15 +147,8 @@ impl Hasher { Ok(()) } #[deprecated(note = "use finish2 instead", since = "0.9.11")] pub fn finish(&mut self) -> Result<Vec<u8>, ErrorStack> { self.finish2().map(|b| b.to_vec()) } /// Returns the hash of the data written and resets the hasher. /// /// Unlike `finish`, this method does not allocate. pub fn finish2(&mut self) -> Result<DigestBytes, ErrorStack> { pub fn finish(&mut self) -> Result<DigestBytes, ErrorStack> { if self.state == Finalized { self.init()?; } Loading Loading @@ -210,7 +203,7 @@ impl Drop for Hasher { fn drop(&mut self) { unsafe { if self.state != Finalized { drop(self.finish2()); drop(self.finish()); } EVP_MD_CTX_free(self.ctx); } Loading Loading @@ -263,18 +256,11 @@ impl fmt::Debug for DigestBytes { } } #[deprecated(note = "use hash2 instead", since = "0.9.11")] pub fn hash(t: MessageDigest, data: &[u8]) -> Result<Vec<u8>, ErrorStack> { hash2(t, data).map(|b| b.to_vec()) } /// Computes the hash of the `data` with the hash `t`. /// /// Unlike `hash`, this function does not allocate the return value. pub fn hash2(t: MessageDigest, data: &[u8]) -> Result<DigestBytes, ErrorStack> { pub fn hash(t: MessageDigest, data: &[u8]) -> Result<DigestBytes, ErrorStack> { let mut h = Hasher::new(t)?; h.update(data)?; h.finish2() h.finish() } #[cfg(test)] Loading @@ -285,20 +271,19 @@ mod tests { use super::*; fn hash_test(hashtype: MessageDigest, hashtest: &(&str, &str)) { let res = hash2(hashtype, &Vec::from_hex(hashtest.0).unwrap()).unwrap(); let res = hash(hashtype, &Vec::from_hex(hashtest.0).unwrap()).unwrap(); assert_eq!(res.to_hex(), hashtest.1); } fn hash_recycle_test(h: &mut Hasher, hashtest: &(&str, &str)) { let _ = h.write_all(&Vec::from_hex(hashtest.0).unwrap()).unwrap(); let res = h.finish2().unwrap(); let res = h.finish().unwrap(); assert_eq!(res.to_hex(), hashtest.1); } // Test vectors from http://www.nsrl.nist.gov/testdata/ #[allow(non_upper_case_globals)] const md5_tests: [(&'static str, &'static str); 13] = [ const md5_tests: [(&'static str, &'static str); 13] = [ ("", "d41d8cd98f00b204e9800998ecf8427e"), ("7F", "83acb6e67e50e31db6ed341dd2de1595"), ("EC9C", "0b07f0d4ca797d8ac58874f887cb0b68"), Loading Loading @@ -337,9 +322,9 @@ mod tests { let mut h = Hasher::new(MessageDigest::md5()).unwrap(); h.write_all(&Vec::from_hex(md5_tests[6].0).unwrap()) .unwrap(); h.finish2().unwrap(); let res = h.finish2().unwrap(); let null = hash2(MessageDigest::md5(), &[]).unwrap(); h.finish().unwrap(); let res = h.finish().unwrap(); let null = hash(MessageDigest::md5(), &[]).unwrap(); assert_eq!(&*res, &*null); } Loading @@ -358,18 +343,18 @@ mod tests { println!("Clone an updated hasher"); let mut h2 = h1.clone(); h2.write_all(&inp[p..]).unwrap(); let res = h2.finish2().unwrap(); let res = h2.finish().unwrap(); assert_eq!(res.to_hex(), md5_tests[i].1); } h1.write_all(&inp[p..]).unwrap(); let res = h1.finish2().unwrap(); let res = h1.finish().unwrap(); assert_eq!(res.to_hex(), md5_tests[i].1); println!("Clone a finished hasher"); let mut h3 = h1.clone(); h3.write_all(&Vec::from_hex(md5_tests[i + 1].0).unwrap()) .unwrap(); let res = h3.finish2().unwrap(); let res = h3.finish().unwrap(); assert_eq!(res.to_hex(), md5_tests[i + 1].1); } Loading