Skip to main content

ScramClient

Struct ScramClient 

Source
pub struct ScramClient { /* private fields */ }
Expand description

A SCRAM-SHA-256 exchange in progress.

Implementations§

Source§

impl ScramClient

Source

pub fn new(password: &str) -> Result<Self, Error>

Starts a new exchange. password is the cleartext password.

The startup message already carries the username, so it is not repeated in the SCRAM message (matching other PostgreSQL clients).

Source

pub fn with_max_iterations( password: &str, max_iterations: u32, ) -> Result<Self, Error>

Like ScramClient::new, but caps the server-supplied PBKDF2 iteration count at max_iterations instead of the default.

§Errors

Returns Error::Auth when the password cannot be SASLprep’d (it contains a prohibited control character).

Source

pub fn client_first_message(&self) -> String

The full initial response: GS2 header n,, followed by the client-first-message-bare.

Source

pub fn parse_server_first_message(&mut self, data: &[u8]) -> Result<(), Error>

Parses the server-first-message and derives the salted password.

§Errors

Returns Error::Auth when the message is malformed, when the server nonce does not extend the client nonce, when the iteration count is outside 1..=MAX_SCRAM_ITERATIONS, or when the salt is oversized.

Source

pub fn build_client_final_message(&self) -> Result<Vec<u8>, Error>

Builds the client-final-message.

§Errors

Returns Error::Auth when called before parse_server_first_message.

Source

pub fn parse_server_final_message(&self, data: &[u8]) -> Result<(), Error>

Verifies the server-final-message (v=) against the expected signature.

§Errors

Returns Error::Auth when the server rejects the exchange (e=), when the signature is missing or malformed, or when it does not match the expected value (a proxy that does not know the password).

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.