/// Computes the salted password according to the SCRAM RFC and the MongoDB specific password
/// hashing algorithm.
Computes the salted password according to the SCRAM RFC and the MongoDB specific password
hashing algorithm.
Computes the salted password according to the SCRAM RFC and the MongoDB specific password hashing algorithm .
fn compute_salted_password(
        &self,
        username: &str,
        password: &str,
        i: u32,
        salt: &[u8],
    ) -> Result<Vec<u8>> {
        let normalized_password = match self {
            ScramVersion::Sha1 => {
                let mut md5 = Md5::new();
                md5.update(format!("{}:mongo:{}", username, password));
                Cow::Owned(hex::encode(md5.finalize()))
            }
            ScramVersion::Sha256 => match stringprep::saslprep(password) {
                Ok(p) => p,
                Err(_) => {
                    return Err(Error::authentication_error(
                        "SCRAM-SHA-256",
                        "saslprep failure",
                    ))
                }
            },
        };
        Ok(self.h_i(normalized_password.as_ref(), salt, i))
    }
fn compute_salted_password ( & self , username : & str , password : & str , i : u32 , salt : & [ u8 ] , ) -> Result < Vec < u8 > > { let normalized_password = match self { ScramVersion :: Sha1 => { let mut md5 = Md5 :: new ( ) ; md5 . update ( format ! ( " " username password ) ) ; Cow :: Owned ( hex :: encode ( md5 . finalize ( ) ) ) } ScramVersion :: Sha256 => match stringprep :: saslprep ( password ) { Ok ( p ) => p , Err ( _ ) => { return Err ( Error :: authentication_error ( " " , " " , ) ) } } , } ; Ok ( self . h_i ( normalized_password . as_ref ( ) , salt , i ) ) }
Computes the salted password according to the SCRAM RFC and the MongoDB specific password
hashing algorithm.
Computes the salted password according to the SCRAM RFC and the MongoDB specific password hashing algorithm .
&self
username
&str
password
&str
i
u32
salt
&[u8]