diff --git a/openssl/src/crypto/mod.rs b/openssl/src/crypto/mod.rs deleted file mode 100644 index 0db23bcc..00000000 --- a/openssl/src/crypto/mod.rs +++ /dev/null @@ -1,28 +0,0 @@ -// Copyright 2011 Google Inc. -// 2013 Jack Lloyd -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// - -mod util; -pub mod dsa; -pub mod hash; -pub mod memcmp; -pub mod pkcs12; -pub mod pkcs5; -pub mod pkey; -pub mod rand; -pub mod rsa; -pub mod sign; -pub mod symm; - diff --git a/openssl/src/crypto/dsa.rs b/openssl/src/dsa.rs similarity index 98% rename from openssl/src/crypto/dsa.rs rename to openssl/src/dsa.rs index f5b0f4e4..fc005574 100644 --- a/openssl/src/crypto/dsa.rs +++ b/openssl/src/dsa.rs @@ -7,7 +7,7 @@ use libc::{c_int, c_char, c_void}; use {cvt, cvt_p}; use bn::BigNumRef; use bio::{MemBio, MemBioSlice}; -use crypto::util::{CallbackState, invoke_passwd_cb}; +use util::{CallbackState, invoke_passwd_cb}; /// Builder for upfront DSA parameter generation pub struct DSAParams(*mut ffi::DSA); @@ -248,7 +248,7 @@ mod test { #[test] pub fn test_password() { let mut password_queried = false; - let key = include_bytes!("../../test/dsa-encrypted.pem"); + let key = include_bytes!("../test/dsa-encrypted.pem"); DSA::private_key_from_pem_cb(key, |password| { password_queried = true; password[0] = b'm' as c_char; diff --git a/openssl/src/crypto/hash.rs b/openssl/src/hash.rs similarity index 100% rename from openssl/src/crypto/hash.rs rename to openssl/src/hash.rs diff --git a/openssl/src/lib.rs b/openssl/src/lib.rs index 10f450dd..9ed02207 100644 --- a/openssl/src/lib.rs +++ b/openssl/src/lib.rs @@ -22,17 +22,27 @@ use error::ErrorStack; mod macros; -pub mod asn1; mod bio; +mod opaque; +mod util; +pub mod asn1; pub mod bn; -pub mod crypto; pub mod dh; +pub mod dsa; pub mod error; +pub mod hash; +pub mod memcmp; pub mod nid; +pub mod pkcs12; +pub mod pkcs5; +pub mod pkey; +pub mod rand; +pub mod rsa; +pub mod sign; pub mod ssl; +pub mod symm; pub mod version; pub mod x509; -mod opaque; pub fn cvt_p(r: *mut T) -> Result<*mut T, ErrorStack> { if r.is_null() { diff --git a/openssl/src/crypto/memcmp.rs b/openssl/src/memcmp.rs similarity index 100% rename from openssl/src/crypto/memcmp.rs rename to openssl/src/memcmp.rs diff --git a/openssl/src/crypto/pkcs12.rs b/openssl/src/pkcs12.rs similarity index 96% rename from openssl/src/crypto/pkcs12.rs rename to openssl/src/pkcs12.rs index 846b7baf..f143ec49 100644 --- a/openssl/src/crypto/pkcs12.rs +++ b/openssl/src/pkcs12.rs @@ -7,7 +7,7 @@ use std::ptr; use std::ffi::CString; use {cvt, cvt_p}; -use crypto::pkey::PKey; +use pkey::PKey; use error::ErrorStack; use x509::X509; @@ -98,14 +98,14 @@ mod compat { #[cfg(test)] mod test { - use crypto::hash::MessageDigest; + use hash::MessageDigest; use serialize::hex::ToHex; use super::*; #[test] fn parse() { - let der = include_bytes!("../../test/identity.p12"); + let der = include_bytes!("../test/identity.p12"); let pkcs12 = Pkcs12::from_der(der).unwrap(); let parsed = pkcs12.parse("mypass").unwrap(); diff --git a/openssl/src/crypto/pkcs5.rs b/openssl/src/pkcs5.rs similarity index 98% rename from openssl/src/crypto/pkcs5.rs rename to openssl/src/pkcs5.rs index 8bcb9b31..b0c899e5 100644 --- a/openssl/src/crypto/pkcs5.rs +++ b/openssl/src/pkcs5.rs @@ -3,8 +3,8 @@ use std::ptr; use ffi; use cvt; -use crypto::hash::MessageDigest; -use crypto::symm::Cipher; +use hash::MessageDigest; +use symm::Cipher; use error::ErrorStack; #[derive(Clone, Eq, PartialEq, Hash, Debug)] @@ -98,8 +98,8 @@ pub fn pbkdf2_hmac(pass: &[u8], #[cfg(test)] mod tests { - use crypto::hash::MessageDigest; - use crypto::symm::Cipher; + use hash::MessageDigest; + use symm::Cipher; // Test vectors from // https://git.lysator.liu.se/nettle/nettle/blob/nettle_3.1.1_release_20150424/testsuite/pbkdf2-test.c diff --git a/openssl/src/crypto/pkey.rs b/openssl/src/pkey.rs similarity index 96% rename from openssl/src/crypto/pkey.rs rename to openssl/src/pkey.rs index 1d062cfa..d91acb36 100644 --- a/openssl/src/crypto/pkey.rs +++ b/openssl/src/pkey.rs @@ -5,10 +5,10 @@ use ffi; use {cvt, cvt_p}; use bio::{MemBio, MemBioSlice}; -use crypto::dsa::DSA; -use crypto::rsa::RSA; +use dsa::DSA; +use rsa::RSA; use error::ErrorStack; -use crypto::util::{CallbackState, invoke_passwd_cb}; +use util::{CallbackState, invoke_passwd_cb}; pub struct PKey(*mut ffi::EVP_PKEY); @@ -167,19 +167,19 @@ impl Drop for PKey { mod tests { #[test] fn test_private_key_from_pem() { - let key = include_bytes!("../../test/key.pem"); + let key = include_bytes!("../test/key.pem"); super::PKey::private_key_from_pem(key).unwrap(); } #[test] fn test_public_key_from_pem() { - let key = include_bytes!("../../test/key.pem.pub"); + let key = include_bytes!("../test/key.pem.pub"); super::PKey::public_key_from_pem(key).unwrap(); } #[test] fn test_pem() { - let key = include_bytes!("../../test/key.pem"); + let key = include_bytes!("../test/key.pem"); let key = super::PKey::private_key_from_pem(key).unwrap(); let priv_key = key.private_key_to_pem().unwrap(); diff --git a/openssl/src/crypto/rand.rs b/openssl/src/rand.rs similarity index 100% rename from openssl/src/crypto/rand.rs rename to openssl/src/rand.rs diff --git a/openssl/src/crypto/rsa.rs b/openssl/src/rsa.rs similarity index 98% rename from openssl/src/crypto/rsa.rs rename to openssl/src/rsa.rs index 1b9e0e76..b8702f97 100644 --- a/openssl/src/crypto/rsa.rs +++ b/openssl/src/rsa.rs @@ -8,7 +8,7 @@ use {cvt, cvt_p, cvt_n}; use bn::{BigNum, BigNumRef}; use bio::{MemBio, MemBioSlice}; use error::ErrorStack; -use crypto::util::{CallbackState, invoke_passwd_cb}; +use util::{CallbackState, invoke_passwd_cb}; /// Type of encryption padding to use. #[derive(Copy, Clone)] @@ -421,7 +421,7 @@ mod test { #[test] pub fn test_password() { let mut password_queried = false; - let key = include_bytes!("../../test/rsa-encrypted.pem"); + let key = include_bytes!("../test/rsa-encrypted.pem"); RSA::private_key_from_pem_cb(key, |password| { password_queried = true; password[0] = b'm' as c_char; @@ -438,7 +438,7 @@ mod test { #[test] pub fn test_public_encrypt_private_decrypt_with_padding() { - let key = include_bytes!("../../test/rsa.pem.pub"); + let key = include_bytes!("../test/rsa.pem.pub"); let public_key = RSA::public_key_from_pem(key).unwrap(); let mut result = vec![0; public_key.size()]; @@ -446,7 +446,7 @@ mod test { let len = public_key.public_encrypt(original_data, &mut result, Padding::pkcs1()).unwrap(); assert_eq!(len, 256); - let pkey = include_bytes!("../../test/rsa.pem"); + let pkey = include_bytes!("../test/rsa.pem"); let private_key = RSA::private_key_from_pem(pkey).unwrap(); let mut dec_result = vec![0; private_key.size()]; let len = private_key.private_decrypt(&result, &mut dec_result, Padding::pkcs1()).unwrap(); diff --git a/openssl/src/crypto/sign.rs b/openssl/src/sign.rs similarity index 95% rename from openssl/src/crypto/sign.rs rename to openssl/src/sign.rs index 41009149..8fb27427 100644 --- a/openssl/src/crypto/sign.rs +++ b/openssl/src/sign.rs @@ -60,8 +60,8 @@ use std::marker::PhantomData; use std::ptr; use {cvt, cvt_p}; -use crypto::hash::MessageDigest; -use crypto::pkey::PKey; +use hash::MessageDigest; +use pkey::PKey; use error::ErrorStack; #[cfg(ossl110)] @@ -208,11 +208,11 @@ mod test { use serialize::hex::FromHex; use std::iter; - use crypto::hash::MessageDigest; - use crypto::sign::{Signer, Verifier}; - use crypto::rsa::RSA; - use crypto::dsa::DSA; - use crypto::pkey::PKey; + use hash::MessageDigest; + use sign::{Signer, Verifier}; + use rsa::RSA; + use dsa::DSA; + use pkey::PKey; static INPUT: &'static [u8] = &[101, 121, 74, 104, 98, 71, 99, 105, 79, 105, 74, 83, 85, 122, 73, 49, 78, 105, 74, 57, @@ -240,7 +240,7 @@ mod test { #[test] fn rsa_sign() { - let key = include_bytes!("../../test/rsa.pem"); + let key = include_bytes!("../test/rsa.pem"); let private_key = RSA::private_key_from_pem(key).unwrap(); let pkey = PKey::from_rsa(private_key).unwrap(); @@ -253,7 +253,7 @@ mod test { #[test] fn rsa_verify_ok() { - let key = include_bytes!("../../test/rsa.pem"); + let key = include_bytes!("../test/rsa.pem"); let private_key = RSA::private_key_from_pem(key).unwrap(); let pkey = PKey::from_rsa(private_key).unwrap(); @@ -264,7 +264,7 @@ mod test { #[test] fn rsa_verify_invalid() { - let key = include_bytes!("../../test/rsa.pem"); + let key = include_bytes!("../test/rsa.pem"); let private_key = RSA::private_key_from_pem(key).unwrap(); let pkey = PKey::from_rsa(private_key).unwrap(); @@ -279,12 +279,12 @@ mod test { let input: Vec = (0..25).cycle().take(1024).collect(); let private_key = { - let key = include_bytes!("../../test/dsa.pem"); + let key = include_bytes!("../test/dsa.pem"); PKey::from_dsa(DSA::private_key_from_pem(key).unwrap()).unwrap() }; let public_key = { - let key = include_bytes!("../../test/dsa.pem.pub"); + let key = include_bytes!("../test/dsa.pem.pub"); PKey::from_dsa(DSA::public_key_from_pem(key).unwrap()).unwrap() }; @@ -302,12 +302,12 @@ mod test { let input: Vec = (0..25).cycle().take(1024).collect(); let private_key = { - let key = include_bytes!("../../test/dsa.pem"); + let key = include_bytes!("../test/dsa.pem"); PKey::from_dsa(DSA::private_key_from_pem(key).unwrap()).unwrap() }; let public_key = { - let key = include_bytes!("../../test/dsa.pem.pub"); + let key = include_bytes!("../test/dsa.pem.pub"); PKey::from_dsa(DSA::public_key_from_pem(key).unwrap()).unwrap() }; diff --git a/openssl/src/ssl/mod.rs b/openssl/src/ssl/mod.rs index 963f252c..6e5a2c09 100644 --- a/openssl/src/ssl/mod.rs +++ b/openssl/src/ssl/mod.rs @@ -24,7 +24,7 @@ use dh::DH; use x509::{X509StoreContextRef, X509FileType, X509, X509Ref, X509VerifyError}; #[cfg(any(all(feature = "v102", ossl102), all(feature = "v110", ossl110)))] use x509::verify::X509VerifyParamRef; -use crypto::pkey::PKey; +use pkey::PKey; use error::ErrorStack; use opaque::Opaque; diff --git a/openssl/src/ssl/tests/mod.rs b/openssl/src/ssl/tests/mod.rs index fada2a8e..45c5b215 100644 --- a/openssl/src/ssl/tests/mod.rs +++ b/openssl/src/ssl/tests/mod.rs @@ -14,7 +14,7 @@ use std::time::Duration; use tempdir::TempDir; -use crypto::hash::MessageDigest; +use hash::MessageDigest; use ssl; use ssl::SSL_VERIFY_PEER; use ssl::{SslMethod, HandshakeError}; @@ -25,7 +25,7 @@ use x509::X509FileType; use x509::X509; #[cfg(any(all(feature = "v102", ossl102), all(feature = "v110", ossl110)))] use x509::verify::X509_CHECK_FLAG_NO_PARTIAL_WILDCARDS; -use crypto::pkey::PKey; +use pkey::PKey; use std::net::UdpSocket; @@ -167,7 +167,7 @@ macro_rules! run_test( use ssl::SslMethod; use ssl::{SslContext, Ssl, SslStream}; use ssl::SSL_VERIFY_PEER; - use crypto::hash::MessageDigest; + use hash::MessageDigest; use x509::X509StoreContextRef; use serialize::hex::FromHex; use super::Server; @@ -774,7 +774,7 @@ mod dtlsv1 { use std::net::TcpStream; use std::thread; - use crypto::hash::MessageDigest; + use hash::MessageDigest; use ssl::SslMethod; use ssl::{SslContext, SslStream}; use ssl::SSL_VERIFY_PEER; diff --git a/openssl/src/crypto/symm.rs b/openssl/src/symm.rs similarity index 100% rename from openssl/src/crypto/symm.rs rename to openssl/src/symm.rs diff --git a/openssl/src/crypto/util.rs b/openssl/src/util.rs similarity index 100% rename from openssl/src/crypto/util.rs rename to openssl/src/util.rs diff --git a/openssl/src/x509/mod.rs b/openssl/src/x509/mod.rs index db5ef1df..dfd61cac 100644 --- a/openssl/src/x509/mod.rs +++ b/openssl/src/x509/mod.rs @@ -15,9 +15,9 @@ use {cvt, cvt_p}; use asn1::Asn1Time; use asn1::Asn1TimeRef; use bio::{MemBio, MemBioSlice}; -use crypto::hash::MessageDigest; -use crypto::pkey::PKey; -use crypto::rand::rand_bytes; +use hash::MessageDigest; +use pkey::PKey; +use rand::rand_bytes; use error::ErrorStack; use ffi; use nid::Nid; diff --git a/openssl/src/x509/tests.rs b/openssl/src/x509/tests.rs index afb06408..a5eb04e7 100644 --- a/openssl/src/x509/tests.rs +++ b/openssl/src/x509/tests.rs @@ -1,8 +1,8 @@ use serialize::hex::FromHex; -use crypto::hash::MessageDigest; -use crypto::pkey::PKey; -use crypto::rsa::RSA; +use hash::MessageDigest; +use pkey::PKey; +use rsa::RSA; use x509::{X509, X509Generator}; use x509::extension::Extension::{KeyUsage, ExtKeyUsage, SubjectAltName, OtherNid, OtherStr}; use x509::extension::AltNameOption as SAN;