pub struct Scram { /* private fields */ }Expand description
A SCRAM-SHA-256 exchange in progress.
SCRAM proves both sides know the password without either sending it, and the server’s final message is verified rather than trusted — skipping that check would leave the client open to a server impersonating the real one.
Implementations§
Source§impl Scram
impl Scram
pub const MECHANISM: &'static str = "SCRAM-SHA-256"
Sourcepub fn new(password: &str, nonce: String) -> Self
pub fn new(password: &str, nonce: String) -> Self
Start an exchange.
The username field is left empty, which is what PostgreSQL requires: the role was already sent in the startup packet, and a server that read a different name here would be authenticating the wrong account.
Sourcepub fn with_username(password: &str, username: &str, nonce: String) -> Self
pub fn with_username(password: &str, username: &str, nonce: String) -> Self
Start an exchange that carries a username in the SCRAM message itself.
PostgreSQL never uses this; it exists so the implementation can be checked against the RFC 7677 test vectors, which do include one.
Sourcepub fn client_first(&self) -> String
pub fn client_first(&self) -> String
The client-first message, including the GS2 header (no channel binding).
Sourcepub fn client_final(&mut self, server_first: &str) -> Result<String>
pub fn client_final(&mut self, server_first: &str) -> Result<String>
Answer the server’s challenge with the client proof.