pub struct Balloon<'key, D: Digest + FixedOutputReset>{
pub digest: PhantomData<D>,
pub algorithm: Algorithm,
pub params: Params,
pub secret: Option<&'key [u8]>,
}Expand description
Balloon context.
This is the primary type of this crate’s API, and contains the following:
- Default set of
Paramsto be used - (Optional) Secret key a.k.a. “pepper” to be used
Fields§
§digest: PhantomData<D>Storing which hash function is used
algorithm: AlgorithmAlgorithm to use
params: ParamsAlgorithm parameters
secret: Option<&'key [u8]>Key array
Implementations§
Source§impl<'key, D: Digest + FixedOutputReset> Balloon<'key, D>
impl<'key, D: Digest + FixedOutputReset> Balloon<'key, D>
Sourcepub fn new(
algorithm: Algorithm,
params: Params,
secret: Option<&'key [u8]>,
) -> Self
pub fn new( algorithm: Algorithm, params: Params, secret: Option<&'key [u8]>, ) -> Self
Create a new Balloon context.
Sourcepub fn hash(
&self,
pwd: &[u8],
salt: &[u8],
) -> Result<GenericArray<u8, D::OutputSize>>
Available on crate feature alloc only.
pub fn hash( &self, pwd: &[u8], salt: &[u8], ) -> Result<GenericArray<u8, D::OutputSize>>
alloc only.Hash a password and associated parameters.
Sourcepub fn hash_into(
&self,
pwd: &[u8],
salt: &[u8],
output: &mut [u8],
) -> Result<()>
Available on crate feature alloc only.
pub fn hash_into( &self, pwd: &[u8], salt: &[u8], output: &mut [u8], ) -> Result<()>
alloc only.Hash a password and associated parameters.
The output has to have the same size as the hash output size: D::OutputSize.
Sourcepub fn hash_with_memory(
&self,
pwd: &[u8],
salt: &[u8],
memory_blocks: &mut [GenericArray<u8, D::OutputSize>],
) -> Result<GenericArray<u8, D::OutputSize>>
pub fn hash_with_memory( &self, pwd: &[u8], salt: &[u8], memory_blocks: &mut [GenericArray<u8, D::OutputSize>], ) -> Result<GenericArray<u8, D::OutputSize>>
Hash a password and associated parameters.
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 useBalloon::hashto have it allocated for them. no_stdusers on “heapless” targets can use an array of theGenericArraytype to stack allocate this buffer. It needs a minimum size ofs_costors_cost * p_costwith theparallelcrate feature enabled.
Sourcepub fn hash_into_with_memory(
&self,
pwd: &[u8],
salt: &[u8],
memory_blocks: &mut [GenericArray<u8, D::OutputSize>],
output: &mut [u8],
) -> Result<()>
pub fn hash_into_with_memory( &self, pwd: &[u8], salt: &[u8], memory_blocks: &mut [GenericArray<u8, D::OutputSize>], output: &mut [u8], ) -> Result<()>
Hash a password and associated parameters into the provided output buffer.
The output has to have the same size as the hash output size: D::OutputSize.
See Balloon::hash_with_memory for more details.
Trait Implementations§
Source§impl<D: Digest + FixedOutputReset> PasswordHasher for Balloon<'_, D>
Available on crate features alloc and password-hash only.
impl<D: Digest + FixedOutputReset> PasswordHasher for Balloon<'_, D>
Available on crate features
alloc and password-hash only.Source§fn hash_password<'a>(
&self,
password: &[u8],
salt: impl Into<Salt<'a>>,
) -> Result<PasswordHash<'a>>
fn hash_password<'a>( &self, password: &[u8], salt: impl Into<Salt<'a>>, ) -> Result<PasswordHash<'a>>
Simple API for computing a
PasswordHash from a password and
salt value. Read moreSource§fn hash_password_customized<'a>(
&self,
password: &[u8],
alg_id: Option<Ident<'a>>,
version: Option<Decimal>,
params: Params,
salt: impl Into<Salt<'a>>,
) -> Result<PasswordHash<'a>>
fn hash_password_customized<'a>( &self, password: &[u8], alg_id: Option<Ident<'a>>, version: Option<Decimal>, params: Params, salt: impl Into<Salt<'a>>, ) -> Result<PasswordHash<'a>>
Compute a
PasswordHash from the provided password using an
explicit set of customized algorithm parameters as opposed to the
defaults. Read moreAuto Trait Implementations§
impl<'key, D> Freeze for Balloon<'key, D>
impl<'key, D> RefUnwindSafe for Balloon<'key, D>where
D: RefUnwindSafe,
impl<'key, D> Send for Balloon<'key, D>where
D: Send,
impl<'key, D> Sync for Balloon<'key, D>where
D: Sync,
impl<'key, D> Unpin for Balloon<'key, D>where
D: Unpin,
impl<'key, D> UnsafeUnpin for Balloon<'key, D>
impl<'key, D> UnwindSafe for Balloon<'key, D>where
D: UnwindSafe,
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> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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 moreSource§impl<T> PasswordVerifier for Twhere
T: PasswordHasher,
impl<T> PasswordVerifier for Twhere
T: PasswordHasher,
Source§fn verify_password(
&self,
password: &[u8],
hash: &PasswordHash<'_>,
) -> Result<(), Error>
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.