aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKatharina Fey <kookie@spacekookie.de>2017-12-15 01:26:27 +0100
committerKatharina Fey <kookie@spacekookie.de>2017-12-15 01:26:27 +0100
commitbb84351e65787d5ca5e3c687950adbabd801ba77 (patch)
treea0590fc1fcad2f5240a6e845e23e01f8575f9999
parent7a2d7474da81f0bddbb895537de4661bdec09c0f (diff)
Refactoring the crypto/security module
Diffstat (limited to '')
-rw-r--r--src/security/aes.rs14
-rw-r--r--src/security/encoding.rs (renamed from src/crypto/encoding.rs)0
-rw-r--r--src/security/engine.rs (renamed from src/crypto/engine.rs)12
-rw-r--r--src/security/hash.rs (renamed from src/crypto/hash.rs)2
-rw-r--r--src/security/mod.rs (renamed from src/crypto/mod.rs)5
-rw-r--r--src/security/random.rs (renamed from src/crypto/random.rs)0
6 files changed, 25 insertions, 8 deletions
diff --git a/src/security/aes.rs b/src/security/aes.rs
new file mode 100644
index 0000000..4b82175
--- /dev/null
+++ b/src/security/aes.rs
@@ -0,0 +1,14 @@
+//! Wrapper AES encryption, decryption functions
+//!
+//!
+
+
+use aesni::{Aes128, BlockCipher};
+use generic_array::GenericArray;
+use std::str::from_utf8_unchecked;
+
+use record::{Record, Header, Payload, Version};
+
+pub struct AES {
+ aes: Aes128,
+} \ No newline at end of file
diff --git a/src/crypto/encoding.rs b/src/security/encoding.rs
index f0cd054..f0cd054 100644
--- a/src/crypto/encoding.rs
+++ b/src/security/encoding.rs
diff --git a/src/crypto/engine.rs b/src/security/engine.rs
index e083a94..5a93b65 100644
--- a/src/crypto/engine.rs
+++ b/src/security/engine.rs
@@ -7,7 +7,7 @@ use super::encoding;
use super::random;
use super::hash;
-use aesni::{Aes128, BlockCipher};
+use aesni::{Aes256, BlockCipher};
use generic_array::GenericArray;
use std::str::from_utf8_unchecked;
@@ -15,7 +15,7 @@ use std::str::from_utf8_unchecked;
///
pub struct CryptoEngine {
encrypted_key: Option<String>,
- aes: Aes128,
+ aes: Aes256,
}
@@ -31,7 +31,7 @@ impl CryptoEngine {
let k = hash::blake2_16(password, "");
let tmp = CryptoEngine {
encrypted_key: None,
- aes: Aes128::new_varkey(&k).unwrap(),
+ aes: Aes256::new_varkey(&k).unwrap(),
};
/* Encrypt and encode the secret key */
@@ -42,7 +42,7 @@ impl CryptoEngine {
/* Then actually create an engine and return it */
let me = CryptoEngine {
encrypted_key: Some(encoded),
- aes: Aes128::new_varkey(&secret_key).unwrap(),
+ aes: Aes256::new_varkey(&secret_key).unwrap(),
};
return me;
@@ -55,7 +55,7 @@ impl CryptoEngine {
let k = hash::blake2_16(password, "");
let tmp = CryptoEngine {
encrypted_key: Some(String::from(encrypted_key)),
- aes: Aes128::new_varkey(&k).unwrap(),
+ aes: Aes256::new_varkey(&k).unwrap(),
};
/* Decode and decrypt key */
@@ -65,7 +65,7 @@ impl CryptoEngine {
/* Then initialise a new crypto engine with the newly decrypted key */
let me = CryptoEngine {
encrypted_key: Some(String::from(encrypted_key)),
- aes: Aes128::new_varkey(&decrypted.as_bytes()).unwrap(),
+ aes: Aes256::new_varkey(&decrypted.as_bytes()).unwrap(),
};
return me;
diff --git a/src/crypto/hash.rs b/src/security/hash.rs
index a54ec50..7b0db9a 100644
--- a/src/crypto/hash.rs
+++ b/src/security/hash.rs
@@ -5,7 +5,7 @@ use blake2::Blake2s;
use blake2::digest::{Input, VariableOutput};
/* To make sure I don't typo all over this */
-const BLAKE_16_LENGTH: usize = 16;
+const BLAKE_16_LENGTH: usize = 32;
pub fn blake2_16(data: &str, salt: &str) -> [u8; BLAKE_16_LENGTH] {
diff --git a/src/crypto/mod.rs b/src/security/mod.rs
index 423d33a..21736a3 100644
--- a/src/crypto/mod.rs
+++ b/src/security/mod.rs
@@ -3,9 +3,12 @@
//! A crypto engine is attached to a vault and provides easy to use
//! and high-level encryption and decryption functions.
+// mod aes;
+
pub mod hash;
pub mod random;
pub mod engine;
pub mod encoding;
-const DEFAULT_KEYLENGTH: usize = 16;
+
+const DEFAULT_KEYLENGTH: usize = 32;
diff --git a/src/crypto/random.rs b/src/security/random.rs
index bc96032..bc96032 100644
--- a/src/crypto/random.rs
+++ b/src/security/random.rs