Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 10 additions & 6 deletions sqlx-postgres/src/connection/sasl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -86,13 +86,17 @@ pub(crate) async fn authenticate(
}
};

// Normalize(password):
let password = options.password.as_deref().unwrap_or_default();
let password = match saslprep(password) {
Ok(v) => v,
// The behavior is similar to what was observed when using SASLprep for username.
// TODO: Remove panic when we have proper support for configuration errors
Err(_) => panic!("Failed to saslprep password"),
};

// SaltedPassword := Hi(Normalize(password), salt, i)
let salted_password = hi(
options.password.as_deref().unwrap_or_default(),
&cont.salt,
cont.iterations,
)
.await?;
let salted_password = hi(&password, &cont.salt, cont.iterations).await?;

// ClientKey := HMAC(SaltedPassword, "Client Key")
let mut mac = Hmac::<Sha256>::new_from_slice(&salted_password).map_err(Error::protocol)?;
Expand Down
Loading