pub struct Scram { /* private fields */ }Expand description
SCRAM client state machine. Create with Scram::client_first, feed
the server-first into client_final, and feed the server-final into
verify_server.
Implementations§
Source§impl Scram
impl Scram
Sourcepub fn client_first(nonce: impl Into<String>) -> (Self, ScramMessage)
pub fn client_first(nonce: impl Into<String>) -> (Self, ScramMessage)
Build the SASL initial response for SCRAM-SHA-256.
The returned bytes are the payload of a PasswordMessage
(tag p). nonce must be a unique random string per session —
the caller provides it so the function is testable.
Sourcepub fn client_final(
&mut self,
server_first: &[u8],
password: &str,
) -> BackendResult<ScramMessage>
pub fn client_final( &mut self, server_first: &[u8], password: &str, ) -> BackendResult<ScramMessage>
Consume the server-first message and produce the client-final.
server_first is the raw bytes the server sent (the payload of
an AuthenticationSASLContinue frame, minus the 4-byte type
code which the caller strips).
Sourcepub fn verify_server(&self, server_final: &[u8]) -> BackendResult<()>
pub fn verify_server(&self, server_final: &[u8]) -> BackendResult<()>
Verify the server-final message’s v=<server-signature> tag.
Returns Ok(()) only if the signature matches what we expect
from the derived server_key.
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> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more