Switch to argon2: WIP

This commit is contained in:
Jeremy Soller
2016-10-24 12:22:13 -06:00
parent a05b8f4d25
commit e0fe388ccf
5 changed files with 25 additions and 60 deletions
+1 -1
View File
@@ -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() {
+1 -1
View File
@@ -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() {
+3 -9
View File
@@ -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