diff --git a/.gitignore b/.gitignore index 9aef65b4..27a84a97 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,4 @@ /.rust/ /doc/ +/rust-openssl +/rust-openssl.dSYM/ diff --git a/LICENSE b/LICENSE new file mode 100644 index 00000000..665f599e --- /dev/null +++ b/LICENSE @@ -0,0 +1,15 @@ +Copyright 2011 Google Inc. + 2013 Jack Lloyd + 2013 Steven Fackler + +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. diff --git a/Makefile b/Makefile index 51070f9d..789ece8a 100644 --- a/Makefile +++ b/Makefile @@ -3,11 +3,11 @@ RUSTC ?= rustc RUST_FLAGS ?= -Z debug-info -O all: - $(RUSTPKG) $(RUST_FLAGS) install crypto + $(RUSTPKG) $(RUST_FLAGS) install test: - $(RUSTC) $(RUST_FLAGS) --test src/crypto/lib.rs - ./src/crypto/crypto + $(RUSTC) $(RUST_FLAGS) --test lib.rs + ./rust-openssl clean: rm -rf bin/ lib/ build/ src/crypto/lib diff --git a/crypto/hash.rs b/crypto/hash.rs index bb75d0ef..9967ee1f 100644 --- a/crypto/hash.rs +++ b/crypto/hash.rs @@ -105,8 +105,8 @@ pub fn hash(t: HashType, data: &[u8]) -> ~[u8] { #[cfg(test)] mod tests { - use hex::FromHex; - use hex::ToHex; + use crypto::hex::FromHex; + use crypto::hex::ToHex; struct HashTest { input: ~[u8], diff --git a/crypto/hmac.rs b/crypto/hmac.rs index 5cac7f50..d7a76e08 100644 --- a/crypto/hmac.rs +++ b/crypto/hmac.rs @@ -17,7 +17,7 @@ use std::libc::{c_uchar, c_int, c_uint}; use std::ptr; use std::vec; -use hash; +use crypto::hash; #[allow(non_camel_case_types)] pub struct HMAC_CTX { diff --git a/crypto/lib.rs b/crypto/mod.rs similarity index 96% rename from crypto/lib.rs rename to crypto/mod.rs index f1038450..30fb08b0 100644 --- a/crypto/lib.rs +++ b/crypto/mod.rs @@ -15,8 +15,6 @@ * limitations under the License. */ -#[crate_id = "crypto#0.3"]; - pub mod hash; pub mod hex; pub mod hmac; diff --git a/crypto/pkey.rs b/crypto/pkey.rs index b8206d4e..8a2b06c1 100644 --- a/crypto/pkey.rs +++ b/crypto/pkey.rs @@ -3,7 +3,7 @@ use std::libc::{c_char, c_int, c_uint}; use std::libc; use std::ptr; use std::vec; -use hash::{HashType, MD5, SHA1, SHA224, SHA256, SHA384, SHA512}; +use crypto::hash::{HashType, MD5, SHA1, SHA224, SHA256, SHA384, SHA512}; #[allow(non_camel_case_types)] pub type EVP_PKEY = *libc::c_void; @@ -336,7 +336,7 @@ impl Drop for PKey { #[cfg(test)] mod tests { - use hash::{MD5, SHA1}; + use crypto::hash::{MD5, SHA1}; #[test] fn test_gen_pub() { diff --git a/crypto/symm.rs b/crypto/symm.rs index d3c54d27..365a716a 100644 --- a/crypto/symm.rs +++ b/crypto/symm.rs @@ -194,7 +194,7 @@ pub fn decrypt(t: Type, key: &[u8], iv: ~[u8], data: &[u8]) -> ~[u8] { #[cfg(test)] mod tests { - use hex::FromHex; + use crypto::hex::FromHex; // Test vectors from FIPS-197: // http://csrc.nist.gov/publications/fips/fips197/fips-197.pdf @@ -223,7 +223,7 @@ mod tests { } fn cipher_test(ciphertype: super::Type, pt: ~str, ct: ~str, key: ~str, iv: ~str) { - use hex::ToHex; + use crypto::hex::ToHex; let cipher = super::Crypter::new(ciphertype); cipher.init(super::Encrypt, key.from_hex(), iv.from_hex()); diff --git a/lib.rs b/lib.rs new file mode 100644 index 00000000..79c12407 --- /dev/null +++ b/lib.rs @@ -0,0 +1,6 @@ +#[feature(struct_variant, macro_rules)]; +#[crate_id="github.com/sfackler/rust-openssl"]; +#[doc(html_root_url="http://sfackler.github.io/rust-openssl/doc")]; + +pub mod ssl; +pub mod crypto; diff --git a/ssl/lib.rs b/ssl/mod.rs similarity index 98% rename from ssl/lib.rs rename to ssl/mod.rs index 8725080c..777e5dae 100644 --- a/ssl/lib.rs +++ b/ssl/mod.rs @@ -1,7 +1,3 @@ -#[feature(struct_variant, macro_rules)]; -#[crate_id="github.com/sfackler/rust-ssl"]; -#[doc(html_root_url="http://sfackler.github.io/rust-ssl/doc/")]; - use std::cast; use std::libc::{c_int, c_void, c_char}; use std::ptr; @@ -12,11 +8,12 @@ use std::unstable::mutex::Mutex; use std::io::{Stream, Reader, Writer, Decorator}; use std::vec; -use self::error::{SslError, SslSessionClosed, StreamEof}; +use ssl::error::{SslError, SslSessionClosed, StreamEof}; pub mod error; - mod ffi; +#[cfg(test)] +mod tests; static mut STARTED_INIT: AtomicBool = INIT_ATOMIC_BOOL; static mut FINISHED_INIT: AtomicBool = INIT_ATOMIC_BOOL; diff --git a/ssl/test.rs b/ssl/tests.rs similarity index 97% rename from ssl/test.rs rename to ssl/tests.rs index 2655fa98..266acc4c 100644 --- a/ssl/test.rs +++ b/ssl/tests.rs @@ -1,12 +1,8 @@ -#[feature(struct_variant, macro_rules)]; - use std::io::Writer; use std::io::net::tcp::TcpStream; use std::str; -use lib::{Sslv23, SslContext, SslStream, SslVerifyPeer, X509StoreContext}; - -mod lib; +use ssl::{Sslv23, SslContext, SslStream, SslVerifyPeer, X509StoreContext}; #[test] fn test_new_ctx() { diff --git a/ssl/test/cert.pem b/test/cert.pem similarity index 100% rename from ssl/test/cert.pem rename to test/cert.pem diff --git a/ssl/test/key.pem b/test/key.pem similarity index 100% rename from ssl/test/key.pem rename to test/key.pem