diff options
| author | Kevin Ballard <[email protected]> | 2013-05-29 23:42:07 -0700 |
|---|---|---|
| committer | Kevin Ballard <[email protected]> | 2013-05-29 23:42:07 -0700 |
| commit | 2eba04e579048bb33a7a99cb738d5d9118909026 (patch) | |
| tree | 624777ef967533e7fcb40575a55de4058a37ee68 | |
| parent | Update for current incoming (diff) | |
| download | rust-openssl-2eba04e579048bb33a7a99cb738d5d9118909026.tar.xz rust-openssl-2eba04e579048bb33a7a99cb738d5d9118909026.zip | |
Update for latest incoming (3a3bf8b)
| -rw-r--r-- | Makefile | 2 | ||||
| -rw-r--r-- | hash.rs | 4 | ||||
| -rw-r--r-- | hex.rs | 2 | ||||
| -rw-r--r-- | hmac.rs | 15 | ||||
| -rw-r--r-- | pkcs5.rs | 2 | ||||
| -rw-r--r-- | pkey.rs | 5 | ||||
| -rw-r--r-- | rand.rs | 3 | ||||
| -rw-r--r-- | symm.rs | 9 |
8 files changed, 26 insertions, 16 deletions
@@ -5,3 +5,5 @@ crypto: crypto.rc $(wildcard *.rs) clean: rm -f crypto libcrypto-*.so + rm libcrypto-*.dylib + rm -rf *.dSYM @@ -1,4 +1,5 @@ use std::libc::c_uint; +use std::{libc,vec,ptr}; pub enum HashType { MD5, @@ -108,6 +109,7 @@ mod tests { use super::*; use hex::FromHex; use hex::ToHex; + use std::vec; struct HashTest { input: ~[u8], @@ -125,7 +127,7 @@ mod tests { let calced = calced_raw.to_hex(); if calced != hashtest.expected_output { - io::println(fmt!("Test failed - %s != %s", calced, hashtest.expected_output)); + println(fmt!("Test failed - %s != %s", calced, hashtest.expected_output)); } assert!(calced == hashtest.expected_output); @@ -14,7 +14,7 @@ * limitations under the License. */ -extern mod std; +use std::{str,uint,vec}; pub trait ToHex { fn to_hex(&self) -> ~str; @@ -15,6 +15,7 @@ */ use hash::*; +use std::{libc,ptr,vec}; #[allow(non_camel_case_types)] pub struct HMAC_CTX { @@ -47,12 +48,12 @@ pub fn HMAC(ht: HashType, key: ~[u8]) -> HMAC { let (evp, mdlen) = evpmd(ht); let mut ctx : HMAC_CTX = HMAC_CTX { - mut md: ptr::null(), - mut md_ctx: ptr::null(), - mut i_ctx: ptr::null(), - mut o_ctx: ptr::null(), - mut key_length: 0, - mut key: [0u8, .. 128] + md: ptr::null(), + md_ctx: ptr::null(), + i_ctx: ptr::null(), + o_ctx: ptr::null(), + key_length: 0, + key: [0u8, .. 128] }; HMAC_CTX_init(&mut ctx, @@ -91,5 +92,5 @@ fn main() { h.update([00u8]); - io::println(fmt!("%?", h.final())) + println(fmt!("%?", h.final())) } @@ -1,4 +1,5 @@ use std::libc::c_int; +use std::{vec,str}; #[link_args = "-lcrypto"] #[abi = "cdecl"] @@ -43,6 +44,7 @@ pub fn pbkdf2_hmac_sha1(pass: &str, salt: &[u8], iter: uint, #[cfg(test)] mod tests { use super::*; + use std::str; // Test vectors from // http://tools.ietf.org/html/draft-josefsson-pbkdf2-test-vectors-06 @@ -1,4 +1,5 @@ use std::libc::{c_int, c_uint}; +use std::{libc,cast,ptr,vec}; use hash::{HashType, MD5, SHA1, SHA224, SHA256, SHA384, SHA512}; #[allow(non_camel_case_types)] @@ -99,7 +100,7 @@ pub fn PKey() -> PKey { ///Represents a public key, optionally with a private key attached. priv impl PKey { - priv fn _tostr(&self, f: extern "C" unsafe fn(*EVP_PKEY, &*mut u8) -> c_int) -> ~[u8] { + priv unsafe fn _tostr(&self, f: extern "C" unsafe fn(*EVP_PKEY, &*mut u8) -> c_int) -> ~[u8] { let buf = ptr::mut_null(); let len = f(self.evp, &buf); if len < 0 as c_int { return ~[]; } @@ -112,7 +113,7 @@ priv impl PKey { vec::slice(s, 0u, r as uint).to_owned() } - priv fn _fromstr( + priv unsafe fn _fromstr( &mut self, s: &[u8], f: extern "C" unsafe fn(c_int, &*EVP_PKEY, &*u8, c_uint) -> *EVP_PKEY @@ -1,4 +1,5 @@ use std::libc::c_int; +use std::vec; #[link_args = "-lcrypto"] #[abi = "cdecl"] @@ -28,6 +29,6 @@ mod tests { #[test] fn test_rand_bytes() { let bytes = rand_bytes(32u); - io::println(fmt!("%?", bytes)); + println(fmt!("%?", bytes)); } } @@ -1,4 +1,5 @@ use std::libc::{c_int, c_uint}; +use std::{libc,vec}; #[allow(non_camel_case_types)] type EVP_CIPHER_CTX = *libc::c_void; @@ -236,11 +237,11 @@ mod tests { let computed = cipher.update(pt.from_hex()) + cipher.final(); if computed != expected { - io::println(fmt!("Computed: %s", computed.to_hex())); - io::println(fmt!("Expected: %s", expected.to_hex())); + println(fmt!("Computed: %s", computed.to_hex())); + println(fmt!("Expected: %s", expected.to_hex())); if computed.len() != expected.len() { - io::println(fmt!("Lengths differ: %u in computed vs %u expected", - computed.len(), expected.len())); + println(fmt!("Lengths differ: %u in computed vs %u expected", + computed.len(), expected.len())); } fail!(~"test failure"); } |