mirror of
https://github.com/rustdesk/hbb_common.git
synced 2026-05-25 17:19:15 +00:00
refact(password): check invalid with 01 when set salt
Signed-off-by: fufesou <linlong1266@gmail.com>
This commit is contained in:
@@ -218,9 +218,12 @@ pub(super) fn password_is_empty_or_not_hashed(permanent_password_storage: &str)
|
||||
if decode_permanent_password_h1_from_storage(permanent_password_storage).is_some() {
|
||||
return false;
|
||||
}
|
||||
let (_, decrypted, should_store) =
|
||||
if permanent_password_storage.starts_with(PERMANENT_PASSWORD_ENC_VERSION) {
|
||||
return false;
|
||||
}
|
||||
let (_, decrypted, looks_like_plaintext) =
|
||||
decrypt_str_or_original(permanent_password_storage, PASSWORD_ENC_VERSION);
|
||||
decrypted || should_store
|
||||
decrypted || looks_like_plaintext
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
@@ -424,4 +427,9 @@ mod tests {
|
||||
|
||||
assert!(!password_is_empty_or_not_hashed(&locked_storage));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_password_is_empty_or_not_hashed_treats_invalid_01_storage_as_hashed() {
|
||||
assert!(!password_is_empty_or_not_hashed("01not-a-valid-hash"));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user