|
|
@ -91,10 +91,16 @@ impl Encoder { |
|
|
|
Err(e) => Err(io::Error::new(io::ErrorKind::InvalidData, e)) |
|
|
|
Err(e) => Err(io::Error::new(io::ErrorKind::InvalidData, e)) |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
pub fn test_encoded_passphrase(&self, test_passphrase_encoded: String) -> bool { |
|
|
|
|
|
|
|
self.passphrase == test_passphrase_encoded |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
pub fn get_encoded_test_passphrase(&self) -> String { |
|
|
|
pub fn get_encoded_test_passphrase(&self) -> String { |
|
|
|
// TODO: encode SALT const with passphrase
|
|
|
|
// TODO: encode SALT const with passphrase
|
|
|
|
self.passphrase.clone() |
|
|
|
self.passphrase.clone() |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
pub struct Storage { |
|
|
|
pub struct Storage { |
|
|
@ -131,6 +137,9 @@ impl Storage { |
|
|
|
"Bad storage db format: no passphrase in the beginnning" |
|
|
|
"Bad storage db format: no passphrase in the beginnning" |
|
|
|
)), |
|
|
|
)), |
|
|
|
}; |
|
|
|
}; |
|
|
|
|
|
|
|
if !encoder.test_encoded_passphrase(passtest) { |
|
|
|
|
|
|
|
return Err(io::Error::new(io::ErrorKind::InvalidData, "Wrong passphrase")); |
|
|
|
|
|
|
|
} |
|
|
|
for line in lines { |
|
|
|
for line in lines { |
|
|
|
match line { |
|
|
|
match line { |
|
|
|
Ok(line) => { |
|
|
|
Ok(line) => { |
|
|
@ -148,8 +157,8 @@ impl Storage { |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
Ok(Storage { |
|
|
|
Ok(Storage { |
|
|
|
items: items, |
|
|
|
items, |
|
|
|
encoder: encoder |
|
|
|
encoder |
|
|
|
}) |
|
|
|
}) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|