pub struct Argon2<'key> {
pub(crate) algorithm: Algorithm,
pub(crate) version: Version,
pub(crate) params: Params,
pub(crate) secret: Option<&'key [u8]>,
pub(crate) cpu_feat_avx2: InitToken,
}Expand description
Fields§
§algorithm: AlgorithmAlgorithm to use
version: VersionVersion number
params: ParamsAlgorithm parameters
secret: Option<&'key [u8]>Key array
cpu_feat_avx2: InitTokenImplementations§
Source§impl<'key> Argon2<'key>
impl<'key> Argon2<'key>
Sourcepub fn new(algorithm: Algorithm, version: Version, params: Params) -> Self
pub fn new(algorithm: Algorithm, version: Version, params: Params) -> Self
Create a new Argon2 context.
Sourcepub fn new_with_secret(
secret: &'key [u8],
algorithm: Algorithm,
version: Version,
params: Params,
) -> Result<Self>
pub fn new_with_secret( secret: &'key [u8], algorithm: Algorithm, version: Version, params: Params, ) -> Result<Self>
Sourcepub fn hash_password_into(
&self,
pwd: &[u8],
salt: &[u8],
out: &mut [u8],
) -> Result<()>
pub fn hash_password_into( &self, pwd: &[u8], salt: &[u8], out: &mut [u8], ) -> Result<()>
Hash a password and associated parameters into the provided output buffer.
§Errors
- Returns
Error::PwdTooLongifpwdis longer thanMAX_PWD_LEN. - Returns
Error::SaltTooShortifsaltis shorter thanMIN_SALT_LEN. - Returns
Error::SaltTooLongifsaltis longer thanMAX_SALT_LEN. - Returns
Error::OutputTooShortifoutis too short. - Returns
Error::OutputTooLongifoutis too long.
Sourcepub fn hash_password_into_with_memory(
&self,
pwd: &[u8],
salt: &[u8],
out: &mut [u8],
memory_blocks: impl AsMut<[Block]>,
) -> Result<()>
pub fn hash_password_into_with_memory( &self, pwd: &[u8], salt: &[u8], out: &mut [u8], memory_blocks: impl AsMut<[Block]>, ) -> Result<()>
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
allocfeature enabled can useArgon2::hash_password_intoto have it allocated for them. no_stdusers on “heapless” targets can use an array of theBlocktype to stack allocate this buffer.
§Errors
- Returns
Error::PwdTooLongifpwdis longer thanMAX_PWD_LEN. - Returns
Error::SaltTooShortifsaltis shorter thanMIN_SALT_LEN. - Returns
Error::SaltTooLongifsaltis longer thanMAX_SALT_LEN. - Returns
Error::OutputTooShortifoutis too short. - Returns
Error::OutputTooLongifoutis too long.
Sourcepub fn fill_memory(
&self,
pwd: &[u8],
salt: &[u8],
memory_blocks: impl AsMut<[Block]>,
) -> Result<()>
pub fn fill_memory( &self, pwd: &[u8], salt: &[u8], memory_blocks: impl AsMut<[Block]>, ) -> Result<()>
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.
§Errors
- Returns
Error::PwdTooLongifpwdis longer thanMAX_PWD_LEN. - Returns
Error::SaltTooShortifsaltis shorter thanMIN_SALT_LEN. - Returns
Error::SaltTooLongifsaltis longer thanMAX_SALT_LEN.
pub(crate) fn fill_blocks( &self, memory_blocks: &mut [Block], initial_hash: Output<Blake2b512>, ) -> Result<()>
pub(crate) fn compress(&self, rhs: &Block, lhs: &Block) -> Block
pub(crate) fn finalize( &self, memory_blocks: &[Block], out: &mut [u8], ) -> Result<()>
pub(crate) fn update_address_block( &self, address_block: &mut Block, input_block: &mut Block, zero_block: &Block, )
Sourcepub(crate) fn initial_hash(
&self,
pwd: &[u8],
salt: &[u8],
out: &[u8],
) -> Output<Blake2b512>
pub(crate) fn initial_hash( &self, pwd: &[u8], salt: &[u8], out: &[u8], ) -> Output<Blake2b512>
Hashes all the inputs into blockhash[PREHASH_DIGEST_LEN].
pub(crate) const fn verify_inputs(pwd: &[u8], salt: &[u8]) -> Result<()>
Trait Implementations§
Source§impl CustomizedPasswordHasher<PasswordHash> for Argon2<'_>
Available on crate features alloc and password-hash only.
impl CustomizedPasswordHasher<PasswordHash> for Argon2<'_>
Available on crate features
alloc and password-hash only.Source§fn hash_password_customized(
&self,
password: &[u8],
salt: &[u8],
alg_id: Option<&str>,
version: Option<u32>,
params: Params,
) -> Result<PasswordHash>
fn hash_password_customized( &self, password: &[u8], salt: &[u8], alg_id: Option<&str>, version: Option<u32>, params: Params, ) -> Result<PasswordHash>
Compute a password hash from the provided password using an explicit set of customized
algorithm parameters as opposed to the defaults. Read more
Source§impl PasswordHasher<PasswordHash> for Argon2<'_>
Available on crate features alloc and password-hash only.
impl PasswordHasher<PasswordHash> for Argon2<'_>
Available on crate features
alloc and password-hash only.Source§fn hash_password_with_salt(
&self,
password: &[u8],
salt: &[u8],
) -> Result<PasswordHash>
fn hash_password_with_salt( &self, password: &[u8], salt: &[u8], ) -> Result<PasswordHash>
Compute the hash
H from the given password and salt, potentially using configuration
stored in &self for the parameters, or otherwise the recommended defaults. Read moreSource§impl PasswordVerifier<str> for Argon2<'_>
Available on crate features alloc and password-hash only.
impl PasswordVerifier<str> for Argon2<'_>
Available on crate features
alloc and password-hash only.Auto Trait Implementations§
impl<'key> Freeze for Argon2<'key>
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> UnsafeUnpin for Argon2<'key>
impl<'key> UnwindSafe for Argon2<'key>
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