Skip to main content

Scram

Struct Scram 

Source
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

Source

pub const MECHANISM: &'static str = "SCRAM-SHA-256"

Source

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.

Source

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.

Source

pub fn client_first(&self) -> String

The client-first message, including the GS2 header (no channel binding).

Source

pub fn client_final(&mut self, server_first: &str) -> Result<String>

Answer the server’s challenge with the client proof.

Source

pub fn verify(&self, server_final: &str) -> Result<()>

Check the server’s signature. An exchange that skips this is not mutually authenticated.

Auto Trait Implementations§

§

impl Freeze for Scram

§

impl RefUnwindSafe for Scram

§

impl Send for Scram

§

impl Sync for Scram

§

impl Unpin for Scram

§

impl UnsafeUnpin for Scram

§

impl UnwindSafe for Scram

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> Same for T

Source§

type Output = T

Should always be Self
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.