From e0fe388ccfe8873cc6e42dc99556bccc191528fb Mon Sep 17 00:00:00 2001 From: Jeremy Soller Date: Mon, 24 Oct 2016 12:22:13 -0600 Subject: [PATCH] Switch to argon2: WIP --- Cargo.lock | 64 ++++++++++++++---------------------------------- Cargo.toml | 5 ++-- src/bin/getty.rs | 2 +- src/bin/login.rs | 2 +- src/lib.rs | 12 +++------ 5 files changed, 25 insertions(+), 60 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index c5d8dd21d9..9245b6f6d7 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2,24 +2,32 @@ name = "userutils" version = "0.1.0" dependencies = [ - "octavo 0.1.1 (git+https://github.com/libOctavo/octavo)", + "argon2rs 0.2.5 (git+https://github.com/redox-os/argon2rs.git)", "syscall 0.1.0", "termion 1.1.1 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] -name = "byteorder" -version = "0.5.3" -source = "registry+https://github.com/rust-lang/crates.io-index" +name = "argon2rs" +version = "0.2.5" +source = "git+https://github.com/redox-os/argon2rs.git#b0fff3d712673a85a71bd552a1aeffa6de22a20c" +dependencies = [ + "blake2-rfc 0.2.17 (registry+https://github.com/rust-lang/crates.io-index)", +] [[package]] -name = "generic-array" -version = "0.2.1" +name = "blake2-rfc" +version = "0.2.17" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "typenum 1.3.2 (registry+https://github.com/rust-lang/crates.io-index)", + "constant_time_eq 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "constant_time_eq" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" + [[package]] name = "libc" version = "0.2.17" @@ -31,34 +39,6 @@ version = "0.2.17" source = "registry+https://github.com/rust-lang/crates.io-index" replace = "libc 0.2.17 (git+https://github.com/redox-os/liblibc.git?branch=new_kernel)" -[[package]] -name = "octavo" -version = "0.1.1" -source = "git+https://github.com/libOctavo/octavo#d94d924616dca83b9c6cfc815062276c5908713a" -dependencies = [ - "octavo-digest 0.1.2 (git+https://github.com/libOctavo/octavo)", -] - -[[package]] -name = "octavo-digest" -version = "0.1.2" -source = "git+https://github.com/libOctavo/octavo#d94d924616dca83b9c6cfc815062276c5908713a" -dependencies = [ - "byteorder 0.5.3 (registry+https://github.com/rust-lang/crates.io-index)", - "generic-array 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", - "static-buffer 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", - "typenum 1.3.2 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "static-buffer" -version = "0.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "generic-array 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", - "typenum 1.3.2 (registry+https://github.com/rust-lang/crates.io-index)", -] - [[package]] name = "syscall" version = "0.1.0" @@ -71,18 +51,10 @@ dependencies = [ "libc 0.2.17 (registry+https://github.com/rust-lang/crates.io-index)", ] -[[package]] -name = "typenum" -version = "1.3.2" -source = "registry+https://github.com/rust-lang/crates.io-index" - [metadata] -"checksum byteorder 0.5.3 (registry+https://github.com/rust-lang/crates.io-index)" = "0fc10e8cc6b2580fda3f36eb6dc5316657f812a3df879a44a66fc9f0fdbc4855" -"checksum generic-array 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "3406a3975bc944fdd85b7964d53296a0ff11f4b6c4704fa4972c9a7c8ba27367" +"checksum argon2rs 0.2.5 (git+https://github.com/redox-os/argon2rs.git)" = "" +"checksum blake2-rfc 0.2.17 (registry+https://github.com/rust-lang/crates.io-index)" = "0c6a476f32fef3402f1161f89d0d39822809627754a126f8441ff2a9d45e2d59" +"checksum constant_time_eq 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "07dcb7959f0f6f1cf662f9a7ff389bcb919924d99ac41cf31f10d611d8721323" "checksum libc 0.2.17 (git+https://github.com/redox-os/liblibc.git?branch=new_kernel)" = "" "checksum libc 0.2.17 (registry+https://github.com/rust-lang/crates.io-index)" = "044d1360593a78f5c8e5e710beccdc24ab71d1f01bc19a29bcacdba22e8475d8" -"checksum octavo 0.1.1 (git+https://github.com/libOctavo/octavo)" = "" -"checksum octavo-digest 0.1.2 (git+https://github.com/libOctavo/octavo)" = "" -"checksum static-buffer 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "6da6a96247d4b372d3ed90dec2c129ab57c934359ac4c6adbaa5871cd0737437" "checksum termion 1.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "ce9884af069456867e19fd5648b8908d5c9378f586b2659aaa6f3a4088fdb867" -"checksum typenum 1.3.2 (registry+https://github.com/rust-lang/crates.io-index)" = "20f316d9057bedfb465699a77d63d37d3eeef53a63ec835d715abd3bd3a87b5e" diff --git a/Cargo.toml b/Cargo.toml index 908b57c29c..62867eb325 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -26,10 +26,9 @@ path = "src/bin/sudo.rs" syscall = { path = "../../syscall/" } termion = "*" -[dependencies.octavo] -git = "https://github.com/libOctavo/octavo" +[dependencies.argon2rs] +git = "https://github.com/redox-os/argon2rs.git" default-features = false -features = ["digest"] [replace] "libc:0.2.17" = { git = "https://github.com/redox-os/liblibc.git", branch = "new_kernel" } diff --git a/src/bin/getty.rs b/src/bin/getty.rs index 08a6b3763b..866c5e78fe 100644 --- a/src/bin/getty.rs +++ b/src/bin/getty.rs @@ -35,7 +35,7 @@ pub fn main() { let stdout = io::stdout(); let mut stdout = stdout.lock(); loop { - stdout.write(b"\x1Bc").unwrap(); + //stdout.write(b"\x1Bc").unwrap(); let _ = stdout.flush(); match Command::new("file:bin/login").spawn() { Ok(mut child) => match child.wait() { diff --git a/src/bin/login.rs b/src/bin/login.rs index fe4dd74c45..202f2be30c 100644 --- a/src/bin/login.rs +++ b/src/bin/login.rs @@ -28,7 +28,7 @@ pub fn main() { let user = (&mut stdin as &mut Read).read_line().unwrap().unwrap_or(String::new()); if ! user.is_empty() { let mut passwd_string = String::new(); - File::open("file:etc/passwd").unwrap().read_to_string(&mut passwd_string).unwrap(); + File::open("/etc/passwd").unwrap().read_to_string(&mut passwd_string).unwrap(); let mut passwd_option = None; for line in passwd_string.lines() { diff --git a/src/lib.rs b/src/lib.rs index f32df51111..c59780b7f2 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1,7 +1,4 @@ -extern crate octavo; - -use octavo::octavo_digest::Digest; -use octavo::octavo_digest::sha3::Sha512; +extern crate argon2rs; pub struct Passwd<'a> { pub user: &'a str, @@ -14,13 +11,10 @@ pub struct Passwd<'a> { } impl<'a> Passwd<'a> { + //TODO: SALT pub fn encode(password: &str) -> String { - let mut output = vec![0; Sha512::output_bytes()]; - let mut hash = Sha512::default(); - hash.update(&password.as_bytes()); - hash.result(&mut output); let mut encoded = String::new(); - for b in output.iter() { + for b in argon2rs::argon2i_simple(password, "saltsalt").iter() { encoded.push_str(&format!("{:X}", b)); } encoded