1
0
Fork 0
mirror of https://github.com/dani-garcia/vaultwarden.git synced 2025-08-24 11:43:19 +00:00

Implement KDF iterations change (Fixes #195)

This commit is contained in:
Daniel García 2018-09-19 17:30:14 +02:00
commit ebb66c374e
No known key found for this signature in database
GPG key ID: FC8A7D14C3CD543A
6 changed files with 69 additions and 22 deletions

View file

@ -35,17 +35,20 @@ pub struct User {
pub equivalent_domains: String,
pub excluded_globals: String,
pub client_kdf_type: i32,
pub client_kdf_iter: i32,
}
/// Local methods
impl User {
pub const CLIENT_KDF_TYPE_DEFAULT: i32 = 0; // PBKDF2: 0
pub const CLIENT_KDF_ITER_DEFAULT: i32 = 5_000;
pub fn new(mail: String) -> Self {
let now = Utc::now().naive_utc();
let email = mail.to_lowercase();
let iterations = CONFIG.password_iterations;
let salt = crypto::get_random_64();
Self {
uuid: Uuid::new_v4().to_string(),
created_at: now,
@ -55,8 +58,8 @@ impl User {
key: String::new(),
password_hash: Vec::new(),
salt,
password_iterations: iterations,
salt: crypto::get_random_64(),
password_iterations: CONFIG.password_iterations,
security_stamp: Uuid::new_v4().to_string(),
@ -69,6 +72,9 @@ impl User {
equivalent_domains: "[]".to_string(),
excluded_globals: "[]".to_string(),
client_kdf_type: Self::CLIENT_KDF_TYPE_DEFAULT,
client_kdf_iter: Self::CLIENT_KDF_ITER_DEFAULT,
}
}