Struct bonsaidb::local::argon2::Argon2

pub struct Argon2<'key> { /* private fields */ }
Expand description

Argon2 context.

This is the primary type of this crate’s API, and contains the following:

  • Argon2 Algorithm variant to be used
  • Argon2 Version to be used
  • Default set of Params to be used
  • (Optional) Secret key a.k.a. “pepper” to be used

Implementations§

§

impl<'key> Argon2<'key>

pub fn new( algorithm: Algorithm, version: Version, params: Params ) -> Argon2<'key>

Create a new Argon2 context.

pub fn new_with_secret( secret: &'key [u8], algorithm: Algorithm, version: Version, params: Params ) -> Result<Argon2<'key>, Error>

Create a new Argon2 context.

pub fn hash_password_into( &self, pwd: &[u8], salt: &[u8], out: &mut [u8] ) -> Result<(), Error>

Hash a password and associated parameters into the provided output buffer.

pub fn hash_password_into_with_memory( &self, pwd: &[u8], salt: &[u8], out: &mut [u8], memory_blocks: impl AsMut<[Block]> ) -> Result<(), Error>

Hash a password and associated parameters into the provided output buffer.

This method takes an explicit memory_blocks parameter which allows the caller to provide the backing storage for the algorithm’s state:

  • Users with the alloc feature enabled can use Argon2::hash_password_into to have it allocated for them.
  • no_std users on “heapless” targets can use an array of the Block type to stack allocate this buffer.

pub fn fill_memory( &self, pwd: &[u8], salt: &[u8], memory_blocks: impl AsMut<[Block]> ) -> Result<(), Error>

Use a password and associated parameters only to fill the given memory blocks.

This method omits the calculation of a hash and can be used when only the filled memory is required. It is not necessary to call this method before calling any of the hashing functions.

pub const fn params(&self) -> &Params

Get default configured Params.

Trait Implementations§

§

impl<'key> Clone for Argon2<'key>

§

fn clone(&self) -> Argon2<'key>

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
§

impl Debug for Argon2<'_>

§

fn fmt(&self, fmt: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more
§

impl Default for Argon2<'_>

§

fn default() -> Argon2<'_>

Returns the “default value” for a type. Read more
§

impl<'key> From<&Params> for Argon2<'key>

§

fn from(params: &Params) -> Argon2<'key>

Converts to this type from the input type.
§

impl<'key> From<Params> for Argon2<'key>

§

fn from(params: Params) -> Argon2<'key>

Converts to this type from the input type.
§

impl PasswordHasher for Argon2<'_>

§

type Params = Params

Algorithm-specific parameters.
§

fn hash_password<'a>( &self, password: &[u8], salt: impl Into<Salt<'a>> ) -> Result<PasswordHash<'a>, Error>

Simple API for computing a PasswordHash from a password and salt value. Read more
§

fn hash_password_customized<'a>( &self, password: &[u8], alg_id: Option<Ident<'a>>, version: Option<u32>, params: Params, salt: impl Into<Salt<'a>> ) -> Result<PasswordHash<'a>, Error>

Compute a PasswordHash from the provided password using an explicit set of customized algorithm parameters as opposed to the defaults. Read more

Auto Trait Implementations§

§

impl<'key> RefUnwindSafe for Argon2<'key>

§

impl<'key> Send for Argon2<'key>

§

impl<'key> Sync for Argon2<'key>

§

impl<'key> Unpin for Argon2<'key>

§

impl<'key> UnwindSafe for Argon2<'key>

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
§

impl<'a, T, E> AsTaggedExplicit<'a, E> for T
where T: 'a,

§

fn explicit(self, class: Class, tag: u32) -> TaggedParser<'a, Explicit, Self, E>

§

impl<'a, T, E> AsTaggedImplicit<'a, E> for T
where T: 'a,

§

fn implicit( self, class: Class, constructed: bool, tag: u32 ) -> TaggedParser<'a, Implicit, Self, E>

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.

§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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.

§

impl<T> PasswordVerifier for T
where T: PasswordHasher,

§

fn verify_password( &self, password: &[u8], hash: &PasswordHash<'_> ) -> Result<(), Error>

Compute this password hashing function against the provided password using the parameters from the provided password hash and see if the computed output matches.
source§

impl<T> Same for T

§

type Output = T

Should always be Self
source§

impl<T> ToOwned for T
where T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

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

§

type Error = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

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

§

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.
§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V

§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more