Add password module for hashing on the client side.

Hashing a password on the client side is useful so that you can set a
user's password without ever sending it in plain text to the
server. This avoids leaking passwords in the log or elsewhere.
This commit is contained in:
Jeff Davis
2021-01-07 18:25:53 -08:00
parent f6fedb8fd8
commit e4e48a06b7
4 changed files with 125 additions and 1 deletions

View File

@@ -32,7 +32,7 @@ fn normalize(pass: &[u8]) -> Vec<u8> {
}
}
fn hi(str: &[u8], salt: &[u8], i: u32) -> [u8; 32] {
pub(crate) fn hi(str: &[u8], salt: &[u8], i: u32) -> [u8; 32] {
let mut hmac = Hmac::<Sha256>::new_varkey(str).expect("HMAC is able to accept all key sizes");
hmac.update(salt);
hmac.update(&[0, 0, 0, 1]);