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)",
]
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;
/// 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<Vec<u8>> {
- 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();
/// 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<Vec<u8>> {
- 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();