Argon2

Struct Argon2 

Source
pub struct Argon2<const S: usize>{ /* private fields */ }
Expand description

Argon2 password hashing implementation

This struct provides methods for password hashing using the Argon2 algorithm, which is designed to be resistant against various attacks including GPU cracking and side-channel attacks.

Implementations§

Source§

impl<const S: usize> Argon2<S>

Source

pub fn new_with_params(params: Params<S>) -> Self

Creates a new Argon2 instance with the specified parameters

Source

pub fn hash_password(&self, password: &[u8]) -> Result<Zeroizing<Vec<u8>>>

Hashes a password using the configured Argon2 parameters

§Arguments
  • password - The password to hash
§Returns
  • A Result containing the hashed password as a zeroizing byte vector

Trait Implementations§

Source§

impl<const S: usize> Clone for Argon2<S>

Source§

fn clone(&self) -> Argon2<S>

Returns a duplicate of the value. Read more
1.0.0 · Source§

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

Performs copy-assignment from source. Read more
Source§

impl<const S: usize> KeyDerivationFunction for Argon2<S>
where Salt<S>: Argon2Compatible + Clone + Zeroize + Send + Sync + 'static, Params<S>: Default + Clone + Zeroize + Send + Sync + 'static,

Source§

type Algorithm = Argon2Algorithm

The algorithm this KDF implements
Source§

type Salt = Salt<S>

Salt type with appropriate validation
Source§

fn new() -> Self

Creates a new instance of the KDF with default parameters
Source§

fn builder(&self) -> impl KdfOperation<'_, Self::Algorithm>
where Self: Sized,

Creates a builder for fluent API usage - FIXED: Elided lifetime
Source§

fn generate_salt<R: RngCore + CryptoRng>(rng: &mut R) -> Self::Salt

Generate a random salt with appropriate size
Source§

fn derive_key( &self, input: &[u8], salt_override: Option<&[u8]>, info_override: Option<&[u8]>, length_override: usize, ) -> Result<Vec<u8>>

Derives a key using the KDF parameters Read more
Source§

fn security_level() -> SecurityLevel

Returns the security level of the KDF in bits
Source§

impl<const S: usize> ParamProvider for Argon2<S>
where Salt<S>: Argon2Compatible, Params<S>: Default + Clone + Zeroize + Send + Sync + 'static,

Source§

type Params = Params<S>

The parameter type associated with this algorithm
Source§

fn with_params(params: Self::Params) -> Self

Creates a new instance with the specified parameters
Source§

fn params(&self) -> &Self::Params

Returns the current parameters
Source§

fn set_params(&mut self, params: Self::Params)

Updates the parameters
Source§

impl<const S: usize> PasswordHashFunction for Argon2<S>
where Salt<S>: Argon2Compatible + Clone + Zeroize + Send + Sync + 'static, Params<S>: Default + Clone + Zeroize + Send + Sync + 'static,

Source§

type Password = SecretBytes<32>

Password type with zeroizing
Source§

fn hash_password(&self, password: &Self::Password) -> Result<PasswordHash>

Hashes a password with the configured parameters
Source§

fn verify( &self, password: &Self::Password, stored_hash: &PasswordHash, ) -> Result<bool>

Verifies a password against a hash
Source§

fn benchmark(&self) -> Duration

Benchmarks the current parameters on this system
Source§

fn recommended_params(_target_duration: Duration) -> Self::Params

Recommends parameters based on a target duration

Auto Trait Implementations§

§

impl<const S: usize> Freeze for Argon2<S>

§

impl<const S: usize> RefUnwindSafe for Argon2<S>

§

impl<const S: usize> Send for Argon2<S>

§

impl<const S: usize> Sync for Argon2<S>

§

impl<const S: usize> Unpin for Argon2<S>

§

impl<const S: usize> UnwindSafe for Argon2<S>

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> ToOwned for T
where T: Clone,

Source§

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>,

Source§

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>,

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

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

Source§

fn vzip(self) -> V