From: Ummon Date: Wed, 3 Dec 2014 20:51:03 +0000 (+0100) Subject: Update some enum scope issues regarding the OpenSSL lib. X-Git-Url: http://git.euphorik.ch/index.cgi?a=commitdiff_plain;h=1b5d7e2cc71922a5f2b3100fb8dbec65ffdc62e6;p=crypto_lab1.git Update some enum scope issues regarding the OpenSSL lib. --- diff --git a/lab1_rust/Cargo.lock b/lab1_rust/Cargo.lock index 2efcda0..9dcb782 100644 --- a/lab1_rust/Cargo.lock +++ b/lab1_rust/Cargo.lock @@ -2,21 +2,21 @@ name = "lab1_rust" version = "0.0.2" dependencies = [ - "openssl 0.2.1 (git+https://github.com/sfackler/rust-openssl.git)", + "openssl 0.2.2 (git+https://github.com/sfackler/rust-openssl.git)", ] [[package]] name = "openssl" -version = "0.2.1" -source = "git+https://github.com/sfackler/rust-openssl.git#c3603b0db00d044c8332d39dd9d49e3c76a2a978" +version = "0.2.2" +source = "git+https://github.com/sfackler/rust-openssl.git#2901c279ab154933385fda86c620f87d3392a36d" dependencies = [ - "openssl-sys 0.2.1 (git+https://github.com/sfackler/rust-openssl.git)", + "openssl-sys 0.2.2 (git+https://github.com/sfackler/rust-openssl.git)", ] [[package]] name = "openssl-sys" -version = "0.2.1" -source = "git+https://github.com/sfackler/rust-openssl.git#c3603b0db00d044c8332d39dd9d49e3c76a2a978" +version = "0.2.2" +source = "git+https://github.com/sfackler/rust-openssl.git#2901c279ab154933385fda86c620f87d3392a36d" dependencies = [ "pkg-config 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", ] diff --git a/lab1_rust/src/crypto.rs b/lab1_rust/src/crypto.rs index cc217a6..ad7e6fa 100644 --- a/lab1_rust/src/crypto.rs +++ b/lab1_rust/src/crypto.rs @@ -1,7 +1,7 @@ use std::rand::{ OsRng, Rng }; use std::io::IoResult; use std::slice::bytes::copy_memory; -use openssl::crypto::hash::SHA256; +use openssl::crypto::hash::HashType::SHA256; use openssl::crypto::hmac::HMAC; use openssl::crypto::symm; @@ -20,8 +20,8 @@ pub fn compute_mac(data: &[u8]) -> [u8, ..10] { /// Encrypt may fail if the provided data size isn't a multiple of 16, no padding will be automatically added. pub fn encrypt(plaindata: &[u8], iv: &[u8]) -> Option> { - let c = symm::Crypter::new(symm::AES_256_CBC); - c.init(symm::Encrypt, KEY_C, iv.to_vec()); + let c = symm::Crypter::new(symm::Type::AES_256_CBC); + c.init(symm::Mode::Encrypt, KEY_C, iv.to_vec()); c.pad(false); // Padding disabled! let r = c.update(plaindata); let rest = c.finalize(); @@ -34,8 +34,8 @@ pub fn encrypt(plaindata: &[u8], iv: &[u8]) -> Option> { /// Decrypt may fail if the provided data size isn't a multiple of 16, no padding will be automatically added. pub fn decrypt(cipherdata: &[u8], iv: &[u8]) -> Option> { - let c = symm::Crypter::new(symm::AES_256_CBC); - c.init(symm::Decrypt, KEY_C, iv.to_vec()); + let c = symm::Crypter::new(symm::Type::AES_256_CBC); + c.init(symm::Mode::Decrypt, KEY_C, iv.to_vec()); c.pad(false); // Padding disabled! let r = c.update(cipherdata); let rest = c.finalize();